internal RubyMethodBody(MethodDeclaration/*!*/ ast, MSA.SymbolDocumentInfo document, RubyEncoding/*!*/ encoding) { Assert.NotNull(ast, encoding); _ast = ast; _document = document; _encoding = encoding; }
internal RubyMethodBody(MethodDeclaration /*!*/ ast, MSA.SymbolDocumentInfo document, RubyEncoding /*!*/ encoding) { Assert.NotNull(ast, encoding); _ast = ast; _document = document; _encoding = encoding; }
protected override void Walk(MethodDefinition node) { if (IsInitializeComponentMethod(node)) { Type type = GetComponentType(); component = componentCreator.CreateComponent(type, componentName); IResourceReader reader = componentCreator.GetResourceReader(CultureInfo.InvariantCulture); if (reader != null) { reader.Dispose(); } WalkMethodStatements(node.Body.Statements); } }
public override void Exit(MethodDefinition/*!*/ node) { _outerName.RemoveAt(_outerName.Count - 1); _outerMethods.Pop(); }
public override bool Enter(MethodDefinition/*!*/ node) { var outerModule = _outerModules.Peek(); string targetName; bool isSelfSingleton = !outerModule.IsSingleton && IsSelfModuleReference(node.Target, out targetName) || outerModule.IsSingleton && node.Target == null; var entry = new MethodEntry(node, isSelfSingleton); // add to the outer method: if (_outerMethods.Count > 0) { var outerMethod = _outerMethods.Peek(); if (outerMethod != null) { outerMethod.AddNested(entry); } } // add to the outer module: // TODO: lookup target name... if (isSelfSingleton || node.Target == null) { outerModule.AddMethod(entry); } _outerName.Add(null); _outerMethods.Push(entry); return true; }
public MethodEntry(MethodDefinition/*!*/ definition, bool isSingleton) : base(definition.Name, definition) { _isSingleton = isSingleton; }
static bool IsInitializeComponentMethod(MethodDefinition node) { string name = node.Name.ToLowerInvariant(); return name == "initializecomponent" || name == "initializecomponents"; }
public virtual void Exit(MethodDefinition/*!*/ node) { }
public virtual bool Enter(MethodDefinition/*!*/ node) { return true; }
public MethodScopeNode(MethodDefinition method) { _method = method; }
SourceLocation GetParametersEndLocationBasedOnMethodNameEnd(MethodDefinition methodDef) { const int methodParenthesesLength = 2; const int spaceLength = 1; int methodDefinitionLength = methodDef.Name.Length + MethodDefinitionLength + methodParenthesesLength + spaceLength; SourceLocation methodStartLocation = methodDef.Location.Start; int index = methodStartLocation.Index + methodDefinitionLength; int column = methodStartLocation.Column + methodDefinitionLength; int line = methodStartLocation.Line; return new SourceLocation(index, line, column); }
SourceLocation GetParametersEndLocation(MethodDefinition methodDef) { SourceLocation parametersEndLocation = methodDef.Parameters.Location.End; if (parametersEndLocation.IsValid) { if (ParametersEndLocationNeedsCorrecting(parametersEndLocation)) { parametersEndLocation = CorrectParametersEndLocation(parametersEndLocation); } } else { return GetParametersEndLocationBasedOnMethodNameEnd(methodDef); } return parametersEndLocation; }
/// <summary> /// Gets the region of a method. This does not include the body. /// </summary> DomRegion GetMethodRegion(MethodDefinition methodDef) { SourceLocation parametersEndLocation = GetParametersEndLocation(methodDef); return CreateRegion(methodDef.Location.Start, parametersEndLocation); }
protected override void Walk(MethodDefinition methodDef) { IClass c = currentClass; if (currentClass == null) { // Walking a global method. CreateGlobalClass(); c = globalClass; } // Create method. string methodName = methodDef.Name; DomRegion region = GetMethodRegion(methodDef); DomRegion bodyRegion = GetMethodBodyRegion(methodDef.Body.Location, region); DefaultMethod method; if (methodName == "initialize") { method = new Constructor(ModifierEnum.Public, region, bodyRegion, c); } else { method = new DefaultMethod(methodName, new DefaultReturnType(c), ModifierEnum.Public, region, bodyRegion, c); } foreach (IParameter parameter in ConvertParameters(methodDef.Parameters)) { method.Parameters.Add(parameter); } c.Methods.Add(method); }
/// <summary> /// Gets the region of a method. This does not include the body. /// </summary> DomRegion GetMethodRegion(MethodDefinition methodDef) { SourceLocation parametersEndLocation = methodDef.Parameters.Location.End; if (ParametersEndLocationNeedsCorrecting(parametersEndLocation)) { parametersEndLocation = CorrectParametersEndLocation(parametersEndLocation); } return CreateRegion(methodDef.Location.Start, parametersEndLocation); }