public object VisitFieldDeclaration(FieldDeclaration fieldDeclaration, object data) { for (int i = 0; i < fieldDeclaration.Fields.Count; i++) { ConvertField(fieldDeclaration.GetTypeForField(i), fieldDeclaration.Fields[i], fieldDeclaration); } return null; }
public override object VisitFieldDeclaration(FieldDeclaration fieldDeclaration, object data) { base.VisitFieldDeclaration(fieldDeclaration, data); // visit methods foreach(var field in fieldDeclaration.Fields) Fields.Add(new AstValue<FieldDeclaration>(field.Name, fieldDeclaration, fieldDeclaration.StartLocation, fieldDeclaration.EndLocation)); return null; }
public override object TrackedVisitIdentifierExpression(IdentifierExpression identifierExpression, object data) { TypeDeclaration typeDeclaration = (TypeDeclaration) AstUtil.GetParentOfType(identifierExpression, typeof(TypeDeclaration)); if (typeDeclaration != null && typeDeclaration.Parent is TypeDeclaration && !IsInvocation(identifierExpression)) { IList parentFields = AstUtil.GetChildrenWithType(typeDeclaration.Parent, typeof(FieldDeclaration)); IList innerFields = AstUtil.GetChildrenWithType(typeDeclaration, typeof(FieldDeclaration)); FieldDeclaration field = new FieldDeclaration(null); field.Fields.Add(new VariableDeclaration(identifierExpression.Identifier)); if (!ContainsField(innerFields, field, false) && !IdentifierDeclaredInParameter(identifierExpression) && ContainsField(parentFields, field, false)) { string parentTypeName = ((TypeDeclaration) typeDeclaration.Parent).Name; AddInstanceField(typeDeclaration, parentTypeName); IdentifierExpression ins = new IdentifierExpression(parentTypeName); FieldReferenceExpression fieldReferenceExpression = new FieldReferenceExpression(ins, identifierExpression.Identifier); fieldReferenceExpression.Parent = identifierExpression.Parent; ReplaceCurrentNode(fieldReferenceExpression); } } return base.TrackedVisitIdentifierExpression(identifierExpression, data); }
public override object VisitLocalVariableDeclaration(LocalVariableDeclaration localVariableDeclaration, object data) { base.VisitLocalVariableDeclaration(localVariableDeclaration, data); if ((localVariableDeclaration.Modifier & Modifiers.Static) == Modifiers.Static) { INode parent = localVariableDeclaration.Parent; while (parent != null && !IsTypeLevel(parent)) { parent = parent.Parent; } if (parent != null) { INode type = parent.Parent; if (type != null) { int pos = type.Children.IndexOf(parent); if (pos >= 0) { FieldDeclaration field = new FieldDeclaration(null); field.TypeReference = localVariableDeclaration.TypeReference; field.Modifier = Modifiers.Static; field.Fields = localVariableDeclaration.Variables; new PrefixFieldsVisitor(field.Fields, "static_" + GetTypeLevelEntityName(parent) + "_").Run(parent); type.Children.Insert(pos + 1, field); RemoveCurrentNode(); } } } } return null; }
public override object VisitFieldDeclaration(FieldDeclaration fieldDeclaration, object data) { if (currentInfo != null) { currentInfo.AddField(fieldDeclaration); } return base.VisitFieldDeclaration(fieldDeclaration, data); }
public override object VisitFieldDeclaration(FieldDeclaration fieldDeclaration, object data) { if ((fieldDeclaration.Modifier & Modifiers.Const) == Modifiers.Const) { UnlockWith(fieldDeclaration); } return base.VisitFieldDeclaration(fieldDeclaration, data); }
public static FieldDeclaration add_Field(this TypeDeclaration typeDeclaration, FieldDeclaration fieldDeclaration) { if (typeDeclaration.notNull() && fieldDeclaration.notNull() && typeDeclaration.Children.notNull()) { //var insertPosition = typeDeclaration.Children.Count; var insertPosition = 0; // fields are OK to go at the top typeDeclaration.Children.Insert(insertPosition, fieldDeclaration); } return fieldDeclaration; }
public override object VisitTypeDeclaration(TypeDeclaration typeDeclaration, object data) { base.VisitTypeDeclaration(typeDeclaration, data); // visit methods typeDeclaration.Attributes.Clear(); typeDeclaration.BaseTypes.Clear(); // add constructor accepting the wrapped object and the field holding the object FieldDeclaration fd = new FieldDeclaration(null, // no attributes new TypeReference(typeDeclaration.Name), Modifiers.Private); fd.Fields.Add(new VariableDeclaration("wrappedObject")); typeDeclaration.AddChild(fd); typeDeclaration.Name += "Wrapper"; if (typeDeclaration.Type == ClassType.Interface) { typeDeclaration.Type = ClassType.Class; typeDeclaration.Name = typeDeclaration.Name.Substring(1); } ConstructorDeclaration cd = new ConstructorDeclaration(typeDeclaration.Name, Modifiers.Public, new List<ParameterDeclarationExpression>(), null); cd.Parameters.Add(new ParameterDeclarationExpression(fd.TypeReference, "wrappedObject")); // this.wrappedObject = wrappedObject; Expression fieldReference = new MemberReferenceExpression(new ThisReferenceExpression(), "wrappedObject"); Expression assignment = new AssignmentExpression(fieldReference, AssignmentOperatorType.Assign, new IdentifierExpression("wrappedObject")); cd.Body = new BlockStatement(); cd.Body.AddChild(new ExpressionStatement(assignment)); typeDeclaration.AddChild(cd); for (int i = 0; i < typeDeclaration.Children.Count; i++) { object child = typeDeclaration.Children[i]; if (child is MethodDeclaration) { MethodDeclaration method = (MethodDeclaration)child; if (method.Parameters.Count == 0 && (method.Name.StartsWith("Is") || method.Name.StartsWith("Get"))) { // replace the method with a property PropertyDeclaration prop = new PropertyDeclaration(method.Modifier, method.Attributes, method.Name, null); prop.TypeReference = method.TypeReference; prop.GetRegion = new PropertyGetRegion(method.Body, null); typeDeclaration.Children[i] = prop; } } } return null; }
public override object TrackedVisitFieldDeclaration(FieldDeclaration fieldDeclaration, object data) { if (AstUtil.ContainsModifier(fieldDeclaration, Modifiers.Transient)) { AttributeSection ats = CreateAttributeSection("System.NonSerializedAttribute", null); FieldDeclaration replacedField = fieldDeclaration; replacedField.Attributes.Add(ats); ReplaceCurrentNode(replacedField); } return base.TrackedVisitFieldDeclaration(fieldDeclaration, data); }
private bool HasSimilarName(FieldDeclaration fieldDeclaration, IList methods) { VariableDeclaration declaration = (VariableDeclaration) fieldDeclaration.Fields[0]; string variableName = declaration.Name; foreach (MethodDeclaration methodDeclaration in methods) { if (variableName == methodDeclaration.Name) return true; } return false; }
public void GenerateCode_Field_CreatesField() { CreateCodeGenerator(); var field = new FieldDeclaration(new List<AttributeSection>()); field.TypeReference = new TypeReference("MyClass"); field.Modifier = Modifiers.Public; field.Fields.Add(new VariableDeclaration("myField")); string code = codeGenerator.GenerateCode(field, String.Empty); string expectedCode = "public MyClass myField;\r\n"; Assert.AreEqual(expectedCode, code); }
public override object TrackedVisitFieldDeclaration(FieldDeclaration fieldDeclaration, object data) { if (AstUtil.ContainsModifier(fieldDeclaration, Modifiers.Static) && IsJavaPrimitiveType(fieldDeclaration.TypeReference)) { if (fieldDeclaration.TypeReference.RankSpecifier == null || fieldDeclaration.TypeReference.RankSpecifier.Length == 0) { VariableDeclaration field = (VariableDeclaration) fieldDeclaration.Fields[0]; if (field.Initializer != null && (field.Initializer is PrimitiveExpression)) AstUtil.ReplaceModifiers(fieldDeclaration, Modifiers.Static, Modifiers.Const); } } return base.TrackedVisitFieldDeclaration(fieldDeclaration, data); }
private void RenameFeildNameSimilarToMethods(FieldDeclaration fieldDeclaration, IList methods) { if (HasSimilarName(fieldDeclaration, methods)) { VariableDeclaration declaration = (VariableDeclaration) fieldDeclaration.Fields[0]; TypeDeclaration typeDeclaration = (TypeDeclaration) fieldDeclaration.Parent; string fullName = GetFullName(typeDeclaration); string key = fullName + "." + declaration.Name; string newName = declaration.Name + "_Field"; CodeBase.References.Add(key, newName); declaration.Name = newName; } }
public override object TrackedVisitFieldDeclaration(FieldDeclaration fieldDeclaration, object data) { VariableDeclaration field = (VariableDeclaration) fieldDeclaration.Fields[0]; TypeDeclaration typeDeclaration = (TypeDeclaration) fieldDeclaration.Parent; NodeTypeExistenceVisitor nodeTypeExistenceVisitor = new NodeTypeExistenceVisitor(typeof(ThisReferenceExpression)); NodeTypeExistenceVisitor indexerNodeExistenceVisitor = new NodeTypeExistenceVisitor(typeof(IndexerExpression)); field.Initializer.AcceptVisitor(nodeTypeExistenceVisitor, null); field.Initializer.AcceptVisitor(indexerNodeExistenceVisitor, null); if (field.Initializer != null && (field.Initializer is InvocationExpression || IsArrayCreation(fieldDeclaration) || nodeTypeExistenceVisitor.Contains || indexerNodeExistenceVisitor.Contains) && !AstUtil.ContainsModifier(fieldDeclaration, Modifiers.Static)) { IList constructors = AstUtil.GetChildrenWithType(typeDeclaration, typeof(ConstructorDeclaration)); IdentifierExpression left = new IdentifierExpression(field.Name); Expression right = field.Initializer; AssignmentExpression assignmentExpression = new AssignmentExpression(left, AssignmentOperatorType.Assign, right); ExpressionStatement ExpressionStatement = new ExpressionStatement(assignmentExpression); field.Initializer = null; ConstructorDeclaration constructorDeclaration = null; ExpressionStatement.Parent = constructorDeclaration; foreach (ConstructorDeclaration consDec in constructors) { if (!AstUtil.ContainsModifier(consDec, Modifiers.Static)) { if (consDec.Parameters.Count == 0) { constructorDeclaration = consDec; constructorDeclaration.Body.Children.Add(ExpressionStatement); constructorDeclaration.Parent = typeDeclaration; return base.TrackedVisitFieldDeclaration(fieldDeclaration, data); } else { consDec.ConstructorInitializer = new ConstructorInitializer(); consDec.ConstructorInitializer.ConstructorInitializerType = ConstructorInitializerType.This; } } } constructorDeclaration = GetConstructor(ExpressionStatement, typeDeclaration); constructorDeclaration.Parent = typeDeclaration; return base.TrackedVisitFieldDeclaration(fieldDeclaration, data); } return base.TrackedVisitFieldDeclaration(fieldDeclaration, data); }
private bool IsArrayCreation(FieldDeclaration fieldDeclaration) { VariableDeclaration field = (VariableDeclaration) fieldDeclaration.Fields[0]; if ((field.Initializer is ArrayCreateExpression) && (fieldDeclaration.TypeReference.RankSpecifier.Length > 0)) { ArrayCreateExpression arrayCreateExpression = (ArrayCreateExpression) field.Initializer; if (arrayCreateExpression.Arguments.Count > 0) { foreach (Expression argument in arrayCreateExpression.Arguments) { if (!(argument is PrimitiveExpression)) return true; } } } return false; }
public override object VisitFieldDeclaration(NRefactoryAST.FieldDeclaration fieldDeclaration, object data) { DomRegion region = GetRegion(fieldDeclaration.StartLocation, fieldDeclaration.EndLocation); DefaultClass c = GetCurrentClass(); ModifierEnum modifier = ConvertModifier(fieldDeclaration.Modifier, (c.ClassType == ClassType.Struct && this.IsVisualBasic) ? ModifierEnum.Public : ModifierEnum.Private); string doku = GetDocumentation(region.BeginLine, fieldDeclaration.Attributes); if (currentClass.Count > 0) { for (int i = 0; i < fieldDeclaration.Fields.Count; ++i) { NRefactoryAST.VariableDeclaration field = (NRefactoryAST.VariableDeclaration)fieldDeclaration.Fields[i]; IReturnType retType; if (c.ClassType == ClassType.Enum) { retType = c.DefaultReturnType; } else { retType = CreateReturnType(fieldDeclaration.GetTypeForField(i)); if (!field.FixedArrayInitialization.IsNull) { retType = new ArrayReturnType(cu.ProjectContent, retType, 1); } } DefaultField f = new DefaultField(retType, field.Name, modifier, region, c); ConvertAttributes(fieldDeclaration, f); f.Documentation = doku; if (c.ClassType == ClassType.Enum) { f.Modifiers = ModifierEnum.Const | ModifierEnum.Public; } c.Fields.Add(f); mapField(fieldDeclaration, f); } } return(null); }
public override object VisitFieldDeclaration(FieldDeclaration fieldsDeclaration, object data) { Contract.Requires(fieldsDeclaration != null); fieldsDeclaration.AcceptChildren(this, data); if (fieldsDeclaration.Attributes.Any(s => s.Attributes.Any(a => a.Name == "DataMember"))) { foreach (var fieldDeclaration in fieldsDeclaration.Fields) { var jsProperty = new JsProperty() { OfType = fieldsDeclaration.TypeReference.GenericTypes.Count == 0 ? fieldsDeclaration.TypeReference.Type : fieldsDeclaration.TypeReference.GenericTypes[0].Type, Name = fieldDeclaration.Name, IsArray = (fieldsDeclaration.TypeReference.GenericTypes.Count > 0 || fieldsDeclaration.TypeReference.IsArrayType) }; CurrentParent.Properties.Add(jsProperty); // I can't figure out what this part is for, but I'm preserving it anyway if (fieldsDeclaration.Attributes.Count > 0) { var jsAttributes = new List<JsAttribute>(); foreach (var attribute in fieldsDeclaration.Attributes) { var a = attribute.Attributes[0]; jsAttributes.Add(new JsAttribute() { Name = a.Name }); } jsProperty.Attributes = jsAttributes; } } } return null; }
void ConvertToAutomaticProperty(ITextEditor editor, IProperty property, IField fieldDef, Ast.PropertyDeclaration astProp) { CodeGenerator codeGen = property.DeclaringType.ProjectContent.Language.CodeGenerator; int fieldStartOffset = editor.Document.PositionToOffset(fieldDef.Region.BeginLine, fieldDef.Region.BeginColumn); int fieldEndOffset = editor.Document.PositionToOffset(fieldDef.Region.EndLine, fieldDef.Region.EndColumn); int startOffset = editor.Document.PositionToOffset(property.Region.BeginLine, property.Region.BeginColumn); int endOffset = editor.Document.PositionToOffset(property.BodyRegion.EndLine, property.BodyRegion.EndColumn); ITextAnchor startAnchor = editor.Document.CreateAnchor(startOffset); ITextAnchor endAnchor = editor.Document.CreateAnchor(endOffset); if (astProp.HasGetRegion) { astProp.GetRegion.Block = null; } if (!astProp.HasSetRegion) { astProp.SetRegion = new Ast.PropertySetRegion(null, null); astProp.SetRegion.Modifier = CodeGenerator.ConvertModifier(fieldDef.Modifiers, new ClassFinder(fieldDef)) & (Ast.Modifiers.Private | Ast.Modifiers.Internal | Ast.Modifiers.Protected | Ast.Modifiers.Public); } Ast.FieldDeclaration f = ParseMember <Ast.FieldDeclaration>(Path.GetExtension(editor.FileName), GetMemberText(fieldDef, editor)); astProp.Initializer = f.Fields.First().Initializer; if (astProp.HasSetRegion) { astProp.SetRegion.Block = null; } using (AsynchronousWaitDialog monitor = AsynchronousWaitDialog.ShowWaitDialog("${res:SharpDevelop.Refactoring.ConvertToAutomaticProperty}")) { var refs = RefactoringService.FindReferences(fieldDef, monitor); using (editor.Document.OpenUndoGroup()) { FindReferencesAndRenameHelper.RenameReferences(refs, property.Name); editor.Document.Remove(fieldStartOffset, fieldEndOffset - fieldStartOffset); editor.Document.Replace(startAnchor.Offset, endAnchor.Offset - startAnchor.Offset, codeGen.GenerateCode(astProp, "")); } } }
void ConvertField(TypeReference typeRef, VariableDeclaration variable, FieldDeclaration fieldDeclaration) { B.TypeMember m; if (currentType is B.EnumDefinition) { if (variable.Initializer.IsNull) { m = new B.EnumMember(GetLexicalInfo(fieldDeclaration)); } else { PrimitiveExpression p = variable.Initializer as PrimitiveExpression; if (p == null || !(p.Value is int)) { AddError(fieldDeclaration, "enum member initializer must be integer value"); return; } m = new B.EnumMember(GetLexicalInfo(fieldDeclaration), new B.IntegerLiteralExpression((int)p.Value)); } } else { m = new B.Field(GetLexicalInfo(fieldDeclaration), ConvertTypeReference(typeRef), ConvertExpression(variable.Initializer)); m.Modifiers = ConvertModifier(fieldDeclaration, B.TypeMemberModifiers.Private); } m.Name = variable.Name; ConvertAttributes(fieldDeclaration.Attributes, m.Attributes); if (currentType != null) currentType.Members.Add(m); }
private static bool FieldHasInitialValue(FieldDeclaration fieldDeclaration) { return !fieldDeclaration.Fields[0].Initializer.IsNull; }
public sealed override object VisitFieldDeclaration(FieldDeclaration fieldDeclaration, object data) { this.BeginVisit(fieldDeclaration); object result = this.TrackedVisitFieldDeclaration(fieldDeclaration, data); this.EndVisit(fieldDeclaration); return result; }
public virtual object TrackedVisitFieldDeclaration(FieldDeclaration fieldDeclaration, object data) { return base.VisitFieldDeclaration(fieldDeclaration, data); }
public virtual object VisitFieldDeclaration(FieldDeclaration fieldDeclaration, object data) { throw new global::System.NotImplementedException("FieldDeclaration"); }
void EnumMemberDecl( #line 743 "VBNET.ATG" out FieldDeclaration f) { #line 745 "VBNET.ATG" Expression expr = null;List<AttributeSection> attributes = new List<AttributeSection>(); AttributeSection section = null; VariableDeclaration varDecl = null; while (la.kind == 28) { AttributeSection( #line 749 "VBNET.ATG" out section); #line 749 "VBNET.ATG" attributes.Add(section); } Identifier(); #line 752 "VBNET.ATG" f = new FieldDeclaration(attributes); varDecl = new VariableDeclaration(t.val); f.Fields.Add(varDecl); f.StartLocation = varDecl.StartLocation = t.Location; if (la.kind == 10) { lexer.NextToken(); Expr( #line 757 "VBNET.ATG" out expr); #line 757 "VBNET.ATG" varDecl.Initializer = expr; } EndOfStmt(); }
void StructureMemberDecl( //#line 807 "VBNET.ATG" ModifierList m, List<AttributeSection> attributes) { //#line 809 "VBNET.ATG" TypeReference type = null; List<ParameterDeclarationExpression> p = new List<ParameterDeclarationExpression>(); Statement stmt = null; List<VariableDeclaration> variableDeclarators = new List<VariableDeclaration>(); List<TemplateDefinition> templates = new List<TemplateDefinition>(); switch (la.kind) { case 84: case 103: case 115: case 142: case 155: case 209: { NonModuleDeclaration( //#line 816 "VBNET.ATG" m, attributes); break; } case 210: { lexer.NextToken(); //#line 820 "VBNET.ATG" Location startPos = t.Location; if (StartOf(4)) { //#line 824 "VBNET.ATG" string name = String.Empty; MethodDeclaration methodDeclaration; List<string> handlesClause = null; List<InterfaceImplementation> implementsClause = null; Identifier(); //#line 830 "VBNET.ATG" name = t.val; m.Check(Modifiers.VBMethods); TypeParameterList( //#line 833 "VBNET.ATG" templates); if (la.kind == 37) { lexer.NextToken(); if (StartOf(6)) { FormalParameterList( //#line 834 "VBNET.ATG" p); } Expect(38); } if (la.kind == 134 || la.kind == 136) { if (la.kind == 136) { ImplementsClause( //#line 837 "VBNET.ATG" out implementsClause); } else { HandlesClause( //#line 839 "VBNET.ATG" out handlesClause); } } //#line 842 "VBNET.ATG" Location endLocation = t.EndLocation; if ( //#line 845 "VBNET.ATG" IsMustOverride(m)) { EndOfStmt(); //#line 848 "VBNET.ATG" methodDeclaration = new MethodDeclaration { Name = name, Modifier = m.Modifier, Parameters = p, Attributes = attributes, StartLocation = m.GetDeclarationLocation(startPos), EndLocation = endLocation, TypeReference = new TypeReference("System.Void", true), Templates = templates, HandlesClause = handlesClause, InterfaceImplementations = implementsClause }; AddChild(methodDeclaration); } else if (la.kind == 1) { lexer.NextToken(); //#line 861 "VBNET.ATG" methodDeclaration = new MethodDeclaration { Name = name, Modifier = m.Modifier, Parameters = p, Attributes = attributes, StartLocation = m.GetDeclarationLocation(startPos), EndLocation = endLocation, TypeReference = new TypeReference("System.Void", true), Templates = templates, HandlesClause = handlesClause, InterfaceImplementations = implementsClause }; AddChild(methodDeclaration); //#line 872 "VBNET.ATG" if (ParseMethodBodies) { Block( //#line 873 "VBNET.ATG" out stmt); Expect(113); Expect(210); //#line 875 "VBNET.ATG" } else { // don't parse method body lexer.SkipCurrentBlock(Tokens.Sub); stmt = new BlockStatement(); } //#line 881 "VBNET.ATG" methodDeclaration.Body = (BlockStatement)stmt; //#line 882 "VBNET.ATG" methodDeclaration.Body.EndLocation = t.EndLocation; EndOfStmt(); } else SynErr(256); } else if (la.kind == 162) { lexer.NextToken(); if (la.kind == 37) { lexer.NextToken(); if (StartOf(6)) { FormalParameterList( //#line 886 "VBNET.ATG" p); } Expect(38); } //#line 887 "VBNET.ATG" m.Check(Modifiers.Constructors); //#line 888 "VBNET.ATG" Location constructorEndLocation = t.EndLocation; Expect(1); //#line 891 "VBNET.ATG" if (ParseMethodBodies) { Block( //#line 892 "VBNET.ATG" out stmt); Expect(113); Expect(210); //#line 894 "VBNET.ATG" } else { // don't parse method body lexer.SkipCurrentBlock(Tokens.Sub); stmt = new BlockStatement(); } //#line 900 "VBNET.ATG" Location endLocation = t.EndLocation; EndOfStmt(); //#line 903 "VBNET.ATG" ConstructorDeclaration cd = new ConstructorDeclaration("New", m.Modifier, p, attributes); cd.StartLocation = m.GetDeclarationLocation(startPos); cd.EndLocation = constructorEndLocation; cd.Body = (BlockStatement)stmt; cd.Body.EndLocation = endLocation; AddChild(cd); } else SynErr(257); break; } case 127: { lexer.NextToken(); //#line 915 "VBNET.ATG" m.Check(Modifiers.VBMethods); string name = String.Empty; Location startPos = t.Location; MethodDeclaration methodDeclaration;List<string> handlesClause = null; List<InterfaceImplementation> implementsClause = null; AttributeSection returnTypeAttributeSection = null; Identifier(); //#line 922 "VBNET.ATG" name = t.val; TypeParameterList( //#line 923 "VBNET.ATG" templates); if (la.kind == 37) { lexer.NextToken(); if (StartOf(6)) { FormalParameterList( //#line 924 "VBNET.ATG" p); } Expect(38); } if (la.kind == 63) { lexer.NextToken(); while (la.kind == 40) { AttributeSection( //#line 926 "VBNET.ATG" out returnTypeAttributeSection); //#line 928 "VBNET.ATG" if (returnTypeAttributeSection != null) { returnTypeAttributeSection.AttributeTarget = "return"; attributes.Add(returnTypeAttributeSection); } } TypeName( //#line 934 "VBNET.ATG" out type); } //#line 936 "VBNET.ATG" if(type == null) { type = new TypeReference("System.Object", true); } if (la.kind == 134 || la.kind == 136) { if (la.kind == 136) { ImplementsClause( //#line 942 "VBNET.ATG" out implementsClause); } else { HandlesClause( //#line 944 "VBNET.ATG" out handlesClause); } } //#line 947 "VBNET.ATG" Location endLocation = t.EndLocation; if ( //#line 950 "VBNET.ATG" IsMustOverride(m)) { EndOfStmt(); //#line 953 "VBNET.ATG" methodDeclaration = new MethodDeclaration { Name = name, Modifier = m.Modifier, TypeReference = type, Parameters = p, Attributes = attributes, StartLocation = m.GetDeclarationLocation(startPos), EndLocation = endLocation, HandlesClause = handlesClause, Templates = templates, InterfaceImplementations = implementsClause }; AddChild(methodDeclaration); } else if (la.kind == 1) { lexer.NextToken(); //#line 968 "VBNET.ATG" methodDeclaration = new MethodDeclaration { Name = name, Modifier = m.Modifier, TypeReference = type, Parameters = p, Attributes = attributes, StartLocation = m.GetDeclarationLocation(startPos), EndLocation = endLocation, Templates = templates, HandlesClause = handlesClause, InterfaceImplementations = implementsClause }; AddChild(methodDeclaration); if (ParseMethodBodies) { Block( //#line 981 "VBNET.ATG" out stmt); Expect(113); Expect(127); //#line 983 "VBNET.ATG" } else { // don't parse method body lexer.SkipCurrentBlock(Tokens.Function); stmt = new BlockStatement(); } methodDeclaration.Body = (BlockStatement)stmt; methodDeclaration.Body.StartLocation = methodDeclaration.EndLocation; methodDeclaration.Body.EndLocation = t.EndLocation; EndOfStmt(); } else SynErr(258); break; } case 101: { lexer.NextToken(); //#line 997 "VBNET.ATG" m.Check(Modifiers.VBExternalMethods); Location startPos = t.Location; CharsetModifier charsetModifer = CharsetModifier.None; string library = String.Empty; string alias = null; string name = String.Empty; if (StartOf(15)) { Charset( //#line 1004 "VBNET.ATG" out charsetModifer); } if (la.kind == 210) { lexer.NextToken(); Identifier(); //#line 1007 "VBNET.ATG" name = t.val; Expect(149); Expect(3); //#line 1008 "VBNET.ATG" library = t.literalValue as string; if (la.kind == 59) { lexer.NextToken(); Expect(3); //#line 1009 "VBNET.ATG" alias = t.literalValue as string; } if (la.kind == 37) { lexer.NextToken(); if (StartOf(6)) { FormalParameterList( //#line 1010 "VBNET.ATG" p); } Expect(38); } EndOfStmt(); //#line 1013 "VBNET.ATG" DeclareDeclaration declareDeclaration = new DeclareDeclaration(name, m.Modifier, null, p, attributes, library, alias, charsetModifer); declareDeclaration.StartLocation = m.GetDeclarationLocation(startPos); declareDeclaration.EndLocation = t.EndLocation; AddChild(declareDeclaration); } else if (la.kind == 127) { lexer.NextToken(); Identifier(); //#line 1020 "VBNET.ATG" name = t.val; Expect(149); Expect(3); //#line 1021 "VBNET.ATG" library = t.literalValue as string; if (la.kind == 59) { lexer.NextToken(); Expect(3); //#line 1022 "VBNET.ATG" alias = t.literalValue as string; } if (la.kind == 37) { lexer.NextToken(); if (StartOf(6)) { FormalParameterList( //#line 1023 "VBNET.ATG" p); } Expect(38); } if (la.kind == 63) { lexer.NextToken(); TypeName( //#line 1024 "VBNET.ATG" out type); } EndOfStmt(); //#line 1027 "VBNET.ATG" DeclareDeclaration declareDeclaration = new DeclareDeclaration(name, m.Modifier, type, p, attributes, library, alias, charsetModifer); declareDeclaration.StartLocation = m.GetDeclarationLocation(startPos); declareDeclaration.EndLocation = t.EndLocation; AddChild(declareDeclaration); } else SynErr(259); break; } case 119: { lexer.NextToken(); //#line 1037 "VBNET.ATG" m.Check(Modifiers.VBEvents); Location startPos = t.Location; EventDeclaration eventDeclaration; string name = String.Empty; List<InterfaceImplementation> implementsClause = null; Identifier(); //#line 1043 "VBNET.ATG" name= t.val; if (la.kind == 63) { lexer.NextToken(); TypeName( //#line 1045 "VBNET.ATG" out type); } else if (StartOf(16)) { if (la.kind == 37) { lexer.NextToken(); if (StartOf(6)) { FormalParameterList( //#line 1047 "VBNET.ATG" p); } Expect(38); } } else SynErr(260); if (la.kind == 136) { ImplementsClause( //#line 1049 "VBNET.ATG" out implementsClause); } //#line 1051 "VBNET.ATG" eventDeclaration = new EventDeclaration { Name = name, TypeReference = type, Modifier = m.Modifier, Parameters = p, Attributes = attributes, InterfaceImplementations = implementsClause, StartLocation = m.GetDeclarationLocation(startPos), EndLocation = t.EndLocation }; AddChild(eventDeclaration); EndOfStmt(); break; } case 2: case 58: case 62: case 64: case 65: case 66: case 67: case 70: case 87: case 104: case 107: case 116: case 121: case 126: case 133: case 139: case 143: case 146: case 147: case 170: case 176: case 178: case 184: case 203: case 212: case 213: case 223: case 224: case 230: { //#line 1062 "VBNET.ATG" m.Check(Modifiers.Fields); FieldDeclaration fd = new FieldDeclaration(attributes, null, m.Modifier); IdentifierForFieldDeclaration(); //#line 1065 "VBNET.ATG" string name = t.val; //#line 1066 "VBNET.ATG" fd.StartLocation = m.GetDeclarationLocation(t.Location); VariableDeclaratorPartAfterIdentifier( //#line 1068 "VBNET.ATG" variableDeclarators, name); while (la.kind == 22) { lexer.NextToken(); VariableDeclarator( //#line 1069 "VBNET.ATG" variableDeclarators); } EndOfStmt(); //#line 1072 "VBNET.ATG" fd.EndLocation = t.EndLocation; fd.Fields = variableDeclarators; AddChild(fd); break; } case 88: { //#line 1077 "VBNET.ATG" m.Check(Modifiers.Fields); lexer.NextToken(); //#line 1078 "VBNET.ATG" m.Add(Modifiers.Const, t.Location); //#line 1080 "VBNET.ATG" FieldDeclaration fd = new FieldDeclaration(attributes, type, m.Modifier); fd.StartLocation = m.GetDeclarationLocation(t.Location); List<VariableDeclaration> constantDeclarators = new List<VariableDeclaration>(); ConstantDeclarator( //#line 1084 "VBNET.ATG" constantDeclarators); while (la.kind == 22) { lexer.NextToken(); ConstantDeclarator( //#line 1085 "VBNET.ATG" constantDeclarators); } //#line 1087 "VBNET.ATG" fd.Fields = constantDeclarators; fd.EndLocation = t.Location; EndOfStmt(); //#line 1092 "VBNET.ATG" fd.EndLocation = t.EndLocation; AddChild(fd); break; } case 186: { lexer.NextToken(); //#line 1098 "VBNET.ATG" m.Check(Modifiers.VBProperties); Location startPos = t.Location; List<InterfaceImplementation> implementsClause = null; AttributeSection returnTypeAttributeSection = null; Expression initializer = null; Identifier(); //#line 1104 "VBNET.ATG" string propertyName = t.val; if (la.kind == 37) { lexer.NextToken(); if (StartOf(6)) { FormalParameterList( //#line 1105 "VBNET.ATG" p); } Expect(38); } if (la.kind == 63) { lexer.NextToken(); while (la.kind == 40) { AttributeSection( //#line 1108 "VBNET.ATG" out returnTypeAttributeSection); //#line 1110 "VBNET.ATG" if (returnTypeAttributeSection != null) { returnTypeAttributeSection.AttributeTarget = "return"; attributes.Add(returnTypeAttributeSection); } } if ( //#line 1117 "VBNET.ATG" IsNewExpression()) { ObjectCreateExpression( //#line 1117 "VBNET.ATG" out initializer); //#line 1119 "VBNET.ATG" if (initializer is ObjectCreateExpression) { type = ((ObjectCreateExpression)initializer).CreateType.Clone(); } else { type = ((ArrayCreateExpression)initializer).CreateType.Clone(); } } else if (StartOf(8)) { TypeName( //#line 1126 "VBNET.ATG" out type); } else SynErr(261); } if (la.kind == 20) { lexer.NextToken(); Expr( //#line 1129 "VBNET.ATG" out initializer); } if (la.kind == 136) { ImplementsClause( //#line 1130 "VBNET.ATG" out implementsClause); } EndOfStmt(); if ( //#line 1134 "VBNET.ATG" IsMustOverride(m) || IsAutomaticProperty()) { //#line 1136 "VBNET.ATG" PropertyDeclaration pDecl = new PropertyDeclaration(propertyName, type, m.Modifier, attributes); pDecl.StartLocation = m.GetDeclarationLocation(startPos); pDecl.EndLocation = t.Location; pDecl.TypeReference = type; pDecl.InterfaceImplementations = implementsClause; pDecl.Parameters = p; if (initializer != null) pDecl.Initializer = initializer; AddChild(pDecl); } else if (StartOf(17)) { //#line 1148 "VBNET.ATG" PropertyDeclaration pDecl = new PropertyDeclaration(propertyName, type, m.Modifier, attributes); pDecl.StartLocation = m.GetDeclarationLocation(startPos); pDecl.EndLocation = t.Location; pDecl.BodyStart = t.Location; pDecl.TypeReference = type; pDecl.InterfaceImplementations = implementsClause; pDecl.Parameters = p; PropertyGetRegion getRegion; PropertySetRegion setRegion; AccessorDecls( //#line 1158 "VBNET.ATG" out getRegion, out setRegion); Expect(113); Expect(186); EndOfStmt(); //#line 1162 "VBNET.ATG" pDecl.GetRegion = getRegion; pDecl.SetRegion = setRegion; pDecl.BodyEnd = t.Location; // t = EndOfStmt; not "Property" AddChild(pDecl); } else SynErr(262); break; } case 98: { lexer.NextToken(); //#line 1169 "VBNET.ATG" Location startPos = t.Location; Expect(119); //#line 1171 "VBNET.ATG" m.Check(Modifiers.VBCustomEvents); EventAddRemoveRegion eventAccessorDeclaration; EventAddRegion addHandlerAccessorDeclaration = null; EventRemoveRegion removeHandlerAccessorDeclaration = null; EventRaiseRegion raiseEventAccessorDeclaration = null; List<InterfaceImplementation> implementsClause = null; Identifier(); //#line 1178 "VBNET.ATG" string customEventName = t.val; Expect(63); TypeName( //#line 1179 "VBNET.ATG" out type); if (la.kind == 136) { ImplementsClause( //#line 1180 "VBNET.ATG" out implementsClause); } EndOfStmt(); while (StartOf(18)) { EventAccessorDeclaration( //#line 1183 "VBNET.ATG" out eventAccessorDeclaration); //#line 1185 "VBNET.ATG" if(eventAccessorDeclaration is EventAddRegion) { addHandlerAccessorDeclaration = (EventAddRegion)eventAccessorDeclaration; } else if(eventAccessorDeclaration is EventRemoveRegion) { removeHandlerAccessorDeclaration = (EventRemoveRegion)eventAccessorDeclaration; } else if(eventAccessorDeclaration is EventRaiseRegion) { raiseEventAccessorDeclaration = (EventRaiseRegion)eventAccessorDeclaration; } } Expect(113); Expect(119); EndOfStmt(); //#line 1201 "VBNET.ATG" if(addHandlerAccessorDeclaration == null) { Error("Need to provide AddHandler accessor."); } if(removeHandlerAccessorDeclaration == null) { Error("Need to provide RemoveHandler accessor."); } if(raiseEventAccessorDeclaration == null) { Error("Need to provide RaiseEvent accessor."); } EventDeclaration decl = new EventDeclaration { TypeReference = type, Name = customEventName, Modifier = m.Modifier, Attributes = attributes, StartLocation = m.GetDeclarationLocation(startPos), EndLocation = t.EndLocation, AddRegion = addHandlerAccessorDeclaration, RemoveRegion = removeHandlerAccessorDeclaration, RaiseRegion = raiseEventAccessorDeclaration }; AddChild(decl); break; } case 161: case 172: case 232: { //#line 1227 "VBNET.ATG" ConversionType opConversionType = ConversionType.None; if (la.kind == 161 || la.kind == 232) { if (la.kind == 232) { lexer.NextToken(); //#line 1228 "VBNET.ATG" opConversionType = ConversionType.Implicit; } else { lexer.NextToken(); //#line 1229 "VBNET.ATG" opConversionType = ConversionType.Explicit; } } Expect(172); //#line 1232 "VBNET.ATG" m.Check(Modifiers.VBOperators); Location startPos = t.Location; TypeReference returnType = NullTypeReference.Instance; TypeReference operandType = NullTypeReference.Instance; OverloadableOperatorType operatorType; AttributeSection section; ParameterDeclarationExpression param; List<ParameterDeclarationExpression> parameters = new List<ParameterDeclarationExpression>(); OverloadableOperator( //#line 1241 "VBNET.ATG" out operatorType); Expect(37); FormalParameter( //#line 1243 "VBNET.ATG" out param); //#line 1244 "VBNET.ATG" if (param != null) parameters.Add(param); if (la.kind == 22) { lexer.NextToken(); FormalParameter( //#line 1246 "VBNET.ATG" out param); //#line 1247 "VBNET.ATG" if (param != null) parameters.Add(param); } Expect(38); //#line 1250 "VBNET.ATG" Location endPos = t.EndLocation; if (la.kind == 63) { lexer.NextToken(); while (la.kind == 40) { AttributeSection( //#line 1251 "VBNET.ATG" out section); //#line 1252 "VBNET.ATG" if (section != null) { section.AttributeTarget = "return"; attributes.Add(section); } } TypeName( //#line 1256 "VBNET.ATG" out returnType); //#line 1256 "VBNET.ATG" endPos = t.EndLocation; } Expect(1); Block( //#line 1258 "VBNET.ATG" out stmt); Expect(113); Expect(172); EndOfStmt(); //#line 1260 "VBNET.ATG" OperatorDeclaration operatorDeclaration = new OperatorDeclaration { Modifier = m.Modifier, Attributes = attributes, Parameters = parameters, TypeReference = returnType, OverloadableOperator = operatorType, ConversionType = opConversionType, Body = (BlockStatement)stmt, StartLocation = m.GetDeclarationLocation(startPos), EndLocation = endPos }; operatorDeclaration.Body.StartLocation = startPos; operatorDeclaration.Body.EndLocation = t.Location; AddChild(operatorDeclaration); break; } default: SynErr(263); break; } }
public override object VisitPropertyDeclaration(PropertyDeclaration propertyDeclaration, object data) { if (!IsClassType(ClassType.Interface) && (propertyDeclaration.Modifier & Modifiers.Visibility) == 0) propertyDeclaration.Modifier |= Modifiers.Private; base.VisitPropertyDeclaration(propertyDeclaration, data); ToVBNetRenameConflictingVariablesVisitor.RenameConflicting(propertyDeclaration); if (!IsClassType(ClassType.Interface) && (propertyDeclaration.Modifier & Modifiers.Abstract) == 0) { if (propertyDeclaration.HasGetRegion && propertyDeclaration.HasSetRegion) { if (propertyDeclaration.GetRegion.Block.IsNull && propertyDeclaration.SetRegion.Block.IsNull) { // automatically implemented property string fieldName = "m_" + propertyDeclaration.Name; Modifiers fieldModifier = propertyDeclaration.Modifier & ~(Modifiers.Visibility) | Modifiers.Private; FieldDeclaration newField = new FieldDeclaration(null, propertyDeclaration.TypeReference, fieldModifier); newField.Fields.Add(new VariableDeclaration(fieldName)); InsertAfterSibling(propertyDeclaration, newField); propertyDeclaration.GetRegion.Block = new BlockStatement(); propertyDeclaration.GetRegion.Block.Return(ExpressionBuilder.Identifier(fieldName)); propertyDeclaration.SetRegion.Block = new BlockStatement(); propertyDeclaration.SetRegion.Block.Assign(ExpressionBuilder.Identifier(fieldName), ExpressionBuilder.Identifier("Value")); } } } return null; }
public override object VisitFieldDeclaration(FieldDeclaration fieldDeclaration, object data) { if (this.CheckNode(fieldDeclaration)) { return null; } return base.VisitFieldDeclaration(fieldDeclaration, data); }
public void mapField(NRefactoryAST.FieldDeclaration fieldDeclaration, IField iField) { IFieldToFieldDeclaration.add(iField, fieldDeclaration); }
private void CreateFieldInitialization(FieldDeclaration field) { VariableDeclaration item = field.Fields[0]; string name = item.Name; item.Name = string.Concat("self._", item.Name); this.VisitVariableDeclaration(item, null); item.Name = name; }
public override object TrackedVisitFieldDeclaration(FieldDeclaration fieldDeclaration, object data) { return null; }
public override object TrackedVisitFieldDeclaration(FieldDeclaration fieldDeclaration, object data) { return base.TrackedVisitFieldDeclaration(fieldDeclaration, fieldDeclaration); }
void EnumMemberDecl( //#line 774 "VBNET.ATG" out FieldDeclaration f) { //#line 776 "VBNET.ATG" Expression expr = null;List<AttributeSection> attributes = new List<AttributeSection>(); AttributeSection section = null; VariableDeclaration varDecl = null; while (la.kind == 40) { AttributeSection( //#line 780 "VBNET.ATG" out section); //#line 780 "VBNET.ATG" attributes.Add(section); } Identifier(); //#line 783 "VBNET.ATG" f = new FieldDeclaration(attributes); varDecl = new VariableDeclaration(t.val); f.Fields.Add(varDecl); f.StartLocation = varDecl.StartLocation = t.Location; if (la.kind == 20) { lexer.NextToken(); Expr( //#line 788 "VBNET.ATG" out expr); //#line 788 "VBNET.ATG" varDecl.Initializer = expr; } //#line 789 "VBNET.ATG" f.EndLocation = varDecl.EndLocation = t.EndLocation; EndOfStmt(); }
void StructureMemberDecl( #line 775 "VBNET.ATG" ModifierList m, List<AttributeSection> attributes) { #line 777 "VBNET.ATG" TypeReference type = null; List<ParameterDeclarationExpression> p = new List<ParameterDeclarationExpression>(); Statement stmt = null; List<VariableDeclaration> variableDeclarators = new List<VariableDeclaration>(); List<TemplateDefinition> templates = new List<TemplateDefinition>(); switch (la.kind) { case 71: case 90: case 102: case 129: case 141: case 194: { NonModuleDeclaration( #line 784 "VBNET.ATG" m, attributes); break; } case 195: { lexer.NextToken(); #line 788 "VBNET.ATG" Location startPos = t.Location; if (StartOf(14)) { #line 792 "VBNET.ATG" string name = String.Empty; MethodDeclaration methodDeclaration; List<string> handlesClause = null; List<InterfaceImplementation> implementsClause = null; Identifier(); #line 798 "VBNET.ATG" name = t.val; m.Check(Modifiers.VBMethods); TypeParameterList( #line 801 "VBNET.ATG" templates); if (la.kind == 25) { lexer.NextToken(); if (StartOf(4)) { FormalParameterList( #line 802 "VBNET.ATG" p); } Expect(26); } if (la.kind == 121 || la.kind == 123) { if (la.kind == 123) { ImplementsClause( #line 805 "VBNET.ATG" out implementsClause); } else { HandlesClause( #line 807 "VBNET.ATG" out handlesClause); } } #line 810 "VBNET.ATG" Location endLocation = t.EndLocation; if ( #line 813 "VBNET.ATG" IsMustOverride(m)) { EndOfStmt(); #line 816 "VBNET.ATG" methodDeclaration = new MethodDeclaration { Name = name, Modifier = m.Modifier, Parameters = p, Attributes = attributes, StartLocation = m.GetDeclarationLocation(startPos), EndLocation = endLocation, TypeReference = new TypeReference("System.Void", true), Templates = templates, HandlesClause = handlesClause, InterfaceImplementations = implementsClause }; compilationUnit.AddChild(methodDeclaration); } else if (la.kind == 1) { lexer.NextToken(); #line 829 "VBNET.ATG" methodDeclaration = new MethodDeclaration { Name = name, Modifier = m.Modifier, Parameters = p, Attributes = attributes, StartLocation = m.GetDeclarationLocation(startPos), EndLocation = endLocation, TypeReference = new TypeReference("System.Void", true), Templates = templates, HandlesClause = handlesClause, InterfaceImplementations = implementsClause }; compilationUnit.AddChild(methodDeclaration); #line 840 "VBNET.ATG" if (ParseMethodBodies) { Block( #line 841 "VBNET.ATG" out stmt); Expect(100); Expect(195); #line 843 "VBNET.ATG" } else { // don't parse method body lexer.SkipCurrentBlock(Tokens.Sub); stmt = new BlockStatement(); } #line 849 "VBNET.ATG" methodDeclaration.Body = (BlockStatement)stmt; #line 850 "VBNET.ATG" methodDeclaration.Body.EndLocation = t.EndLocation; EndOfStmt(); } else SynErr(238); } else if (la.kind == 148) { lexer.NextToken(); if (la.kind == 25) { lexer.NextToken(); if (StartOf(4)) { FormalParameterList( #line 854 "VBNET.ATG" p); } Expect(26); } #line 855 "VBNET.ATG" m.Check(Modifiers.Constructors); #line 856 "VBNET.ATG" Location constructorEndLocation = t.EndLocation; Expect(1); #line 859 "VBNET.ATG" if (ParseMethodBodies) { Block( #line 860 "VBNET.ATG" out stmt); Expect(100); Expect(195); #line 862 "VBNET.ATG" } else { // don't parse method body lexer.SkipCurrentBlock(Tokens.Sub); stmt = new BlockStatement(); } #line 868 "VBNET.ATG" Location endLocation = t.EndLocation; EndOfStmt(); #line 871 "VBNET.ATG" ConstructorDeclaration cd = new ConstructorDeclaration("New", m.Modifier, p, attributes); cd.StartLocation = m.GetDeclarationLocation(startPos); cd.EndLocation = constructorEndLocation; cd.Body = (BlockStatement)stmt; cd.Body.EndLocation = endLocation; compilationUnit.AddChild(cd); } else SynErr(239); break; } case 114: { lexer.NextToken(); #line 883 "VBNET.ATG" m.Check(Modifiers.VBMethods); string name = String.Empty; Location startPos = t.Location; MethodDeclaration methodDeclaration;List<string> handlesClause = null; List<InterfaceImplementation> implementsClause = null; AttributeSection returnTypeAttributeSection = null; Identifier(); #line 890 "VBNET.ATG" name = t.val; TypeParameterList( #line 891 "VBNET.ATG" templates); if (la.kind == 25) { lexer.NextToken(); if (StartOf(4)) { FormalParameterList( #line 892 "VBNET.ATG" p); } Expect(26); } if (la.kind == 50) { lexer.NextToken(); while (la.kind == 28) { AttributeSection( #line 893 "VBNET.ATG" out returnTypeAttributeSection); } TypeName( #line 893 "VBNET.ATG" out type); } #line 895 "VBNET.ATG" if(type == null) { type = new TypeReference("System.Object", true); } if (la.kind == 121 || la.kind == 123) { if (la.kind == 123) { ImplementsClause( #line 901 "VBNET.ATG" out implementsClause); } else { HandlesClause( #line 903 "VBNET.ATG" out handlesClause); } } if ( #line 908 "VBNET.ATG" IsMustOverride(m)) { EndOfStmt(); #line 911 "VBNET.ATG" methodDeclaration = new MethodDeclaration { Name = name, Modifier = m.Modifier, TypeReference = type, Parameters = p, Attributes = attributes, StartLocation = m.GetDeclarationLocation(startPos), EndLocation = t.EndLocation, HandlesClause = handlesClause, Templates = templates, InterfaceImplementations = implementsClause }; if (returnTypeAttributeSection != null) { returnTypeAttributeSection.AttributeTarget = "return"; methodDeclaration.Attributes.Add(returnTypeAttributeSection); } compilationUnit.AddChild(methodDeclaration); } else if (la.kind == 1) { lexer.NextToken(); #line 929 "VBNET.ATG" methodDeclaration = new MethodDeclaration { Name = name, Modifier = m.Modifier, TypeReference = type, Parameters = p, Attributes = attributes, StartLocation = m.GetDeclarationLocation(startPos), EndLocation = t.EndLocation, Templates = templates, HandlesClause = handlesClause, InterfaceImplementations = implementsClause }; if (returnTypeAttributeSection != null) { returnTypeAttributeSection.AttributeTarget = "return"; methodDeclaration.Attributes.Add(returnTypeAttributeSection); } compilationUnit.AddChild(methodDeclaration); if (ParseMethodBodies) { Block( #line 946 "VBNET.ATG" out stmt); Expect(100); Expect(114); #line 948 "VBNET.ATG" } else { // don't parse method body lexer.SkipCurrentBlock(Tokens.Function); stmt = new BlockStatement(); } methodDeclaration.Body = (BlockStatement)stmt; methodDeclaration.Body.StartLocation = methodDeclaration.EndLocation; methodDeclaration.Body.EndLocation = t.EndLocation; EndOfStmt(); } else SynErr(240); break; } case 88: { lexer.NextToken(); #line 962 "VBNET.ATG" m.Check(Modifiers.VBExternalMethods); Location startPos = t.Location; CharsetModifier charsetModifer = CharsetModifier.None; string library = String.Empty; string alias = null; string name = String.Empty; if (StartOf(15)) { Charset( #line 969 "VBNET.ATG" out charsetModifer); } if (la.kind == 195) { lexer.NextToken(); Identifier(); #line 972 "VBNET.ATG" name = t.val; Expect(135); Expect(3); #line 973 "VBNET.ATG" library = t.literalValue as string; if (la.kind == 46) { lexer.NextToken(); Expect(3); #line 974 "VBNET.ATG" alias = t.literalValue as string; } if (la.kind == 25) { lexer.NextToken(); if (StartOf(4)) { FormalParameterList( #line 975 "VBNET.ATG" p); } Expect(26); } EndOfStmt(); #line 978 "VBNET.ATG" DeclareDeclaration declareDeclaration = new DeclareDeclaration(name, m.Modifier, null, p, attributes, library, alias, charsetModifer); declareDeclaration.StartLocation = m.GetDeclarationLocation(startPos); declareDeclaration.EndLocation = t.EndLocation; compilationUnit.AddChild(declareDeclaration); } else if (la.kind == 114) { lexer.NextToken(); Identifier(); #line 985 "VBNET.ATG" name = t.val; Expect(135); Expect(3); #line 986 "VBNET.ATG" library = t.literalValue as string; if (la.kind == 46) { lexer.NextToken(); Expect(3); #line 987 "VBNET.ATG" alias = t.literalValue as string; } if (la.kind == 25) { lexer.NextToken(); if (StartOf(4)) { FormalParameterList( #line 988 "VBNET.ATG" p); } Expect(26); } if (la.kind == 50) { lexer.NextToken(); TypeName( #line 989 "VBNET.ATG" out type); } EndOfStmt(); #line 992 "VBNET.ATG" DeclareDeclaration declareDeclaration = new DeclareDeclaration(name, m.Modifier, type, p, attributes, library, alias, charsetModifer); declareDeclaration.StartLocation = m.GetDeclarationLocation(startPos); declareDeclaration.EndLocation = t.EndLocation; compilationUnit.AddChild(declareDeclaration); } else SynErr(241); break; } case 106: { lexer.NextToken(); #line 1002 "VBNET.ATG" m.Check(Modifiers.VBEvents); Location startPos = t.Location; EventDeclaration eventDeclaration; string name = String.Empty; List<InterfaceImplementation> implementsClause = null; Identifier(); #line 1008 "VBNET.ATG" name= t.val; if (la.kind == 50) { lexer.NextToken(); TypeName( #line 1010 "VBNET.ATG" out type); } else if (StartOf(16)) { if (la.kind == 25) { lexer.NextToken(); if (StartOf(4)) { FormalParameterList( #line 1012 "VBNET.ATG" p); } Expect(26); } } else SynErr(242); if (la.kind == 123) { ImplementsClause( #line 1014 "VBNET.ATG" out implementsClause); } #line 1016 "VBNET.ATG" eventDeclaration = new EventDeclaration { Name = name, TypeReference = type, Modifier = m.Modifier, Parameters = p, Attributes = attributes, InterfaceImplementations = implementsClause, StartLocation = m.GetDeclarationLocation(startPos), EndLocation = t.EndLocation }; compilationUnit.AddChild(eventDeclaration); EndOfStmt(); break; } case 2: case 45: case 49: case 51: case 52: case 53: case 54: case 57: case 74: case 91: case 94: case 103: case 108: case 113: case 120: case 126: case 130: case 133: case 156: case 162: case 169: case 188: case 197: case 198: case 208: case 209: case 215: { #line 1026 "VBNET.ATG" Location startPos = t.Location; #line 1028 "VBNET.ATG" m.Check(Modifiers.Fields); FieldDeclaration fd = new FieldDeclaration(attributes, null, m.Modifier); fd.StartLocation = m.GetDeclarationLocation(startPos); IdentifierForFieldDeclaration(); #line 1032 "VBNET.ATG" string name = t.val; VariableDeclaratorPartAfterIdentifier( #line 1033 "VBNET.ATG" variableDeclarators, name); while (la.kind == 12) { lexer.NextToken(); VariableDeclarator( #line 1034 "VBNET.ATG" variableDeclarators); } EndOfStmt(); #line 1037 "VBNET.ATG" fd.EndLocation = t.EndLocation; fd.Fields = variableDeclarators; compilationUnit.AddChild(fd); break; } case 75: { #line 1042 "VBNET.ATG" m.Check(Modifiers.Fields); lexer.NextToken(); #line 1043 "VBNET.ATG" m.Add(Modifiers.Const, t.Location); #line 1045 "VBNET.ATG" FieldDeclaration fd = new FieldDeclaration(attributes, type, m.Modifier); fd.StartLocation = m.GetDeclarationLocation(t.Location); List<VariableDeclaration> constantDeclarators = new List<VariableDeclaration>(); ConstantDeclarator( #line 1049 "VBNET.ATG" constantDeclarators); while (la.kind == 12) { lexer.NextToken(); ConstantDeclarator( #line 1050 "VBNET.ATG" constantDeclarators); } #line 1052 "VBNET.ATG" fd.Fields = constantDeclarators; fd.EndLocation = t.Location; EndOfStmt(); #line 1057 "VBNET.ATG" fd.EndLocation = t.EndLocation; compilationUnit.AddChild(fd); break; } case 171: { lexer.NextToken(); #line 1063 "VBNET.ATG" m.Check(Modifiers.VBProperties); Location startPos = t.Location; List<InterfaceImplementation> implementsClause = null; Identifier(); #line 1067 "VBNET.ATG" string propertyName = t.val; if (la.kind == 25) { lexer.NextToken(); if (StartOf(4)) { FormalParameterList( #line 1068 "VBNET.ATG" p); } Expect(26); } if (la.kind == 50) { lexer.NextToken(); TypeName( #line 1069 "VBNET.ATG" out type); } #line 1071 "VBNET.ATG" if(type == null) { type = new TypeReference("System.Object", true); } if (la.kind == 123) { ImplementsClause( #line 1075 "VBNET.ATG" out implementsClause); } EndOfStmt(); if ( #line 1079 "VBNET.ATG" IsMustOverride(m)) { #line 1081 "VBNET.ATG" PropertyDeclaration ParameterDeclarationExpressionl = new PropertyDeclaration(propertyName, type, m.Modifier, attributes); ParameterDeclarationExpressionl.StartLocation = m.GetDeclarationLocation(startPos); ParameterDeclarationExpressionl.EndLocation = t.Location; ParameterDeclarationExpressionl.TypeReference = type; ParameterDeclarationExpressionl.InterfaceImplementations = implementsClause; ParameterDeclarationExpressionl.Parameters = p; compilationUnit.AddChild(ParameterDeclarationExpressionl); } else if (StartOf(17)) { #line 1091 "VBNET.ATG" PropertyDeclaration ParameterDeclarationExpressionl = new PropertyDeclaration(propertyName, type, m.Modifier, attributes); ParameterDeclarationExpressionl.StartLocation = m.GetDeclarationLocation(startPos); ParameterDeclarationExpressionl.EndLocation = t.Location; ParameterDeclarationExpressionl.BodyStart = t.Location; ParameterDeclarationExpressionl.TypeReference = type; ParameterDeclarationExpressionl.InterfaceImplementations = implementsClause; ParameterDeclarationExpressionl.Parameters = p; PropertyGetRegion getRegion; PropertySetRegion setRegion; AccessorDecls( #line 1101 "VBNET.ATG" out getRegion, out setRegion); Expect(100); Expect(171); EndOfStmt(); #line 1105 "VBNET.ATG" ParameterDeclarationExpressionl.GetRegion = getRegion; ParameterDeclarationExpressionl.SetRegion = setRegion; ParameterDeclarationExpressionl.BodyEnd = t.EndLocation; compilationUnit.AddChild(ParameterDeclarationExpressionl); } else SynErr(243); break; } case 85: { lexer.NextToken(); #line 1112 "VBNET.ATG" Location startPos = t.Location; Expect(106); #line 1114 "VBNET.ATG" m.Check(Modifiers.VBCustomEvents); EventAddRemoveRegion eventAccessorDeclaration; EventAddRegion addHandlerAccessorDeclaration = null; EventRemoveRegion removeHandlerAccessorDeclaration = null; EventRaiseRegion raiseEventAccessorDeclaration = null; List<InterfaceImplementation> implementsClause = null; Identifier(); #line 1121 "VBNET.ATG" string customEventName = t.val; Expect(50); TypeName( #line 1122 "VBNET.ATG" out type); if (la.kind == 123) { ImplementsClause( #line 1123 "VBNET.ATG" out implementsClause); } EndOfStmt(); while (StartOf(18)) { EventAccessorDeclaration( #line 1126 "VBNET.ATG" out eventAccessorDeclaration); #line 1128 "VBNET.ATG" if(eventAccessorDeclaration is EventAddRegion) { addHandlerAccessorDeclaration = (EventAddRegion)eventAccessorDeclaration; } else if(eventAccessorDeclaration is EventRemoveRegion) { removeHandlerAccessorDeclaration = (EventRemoveRegion)eventAccessorDeclaration; } else if(eventAccessorDeclaration is EventRaiseRegion) { raiseEventAccessorDeclaration = (EventRaiseRegion)eventAccessorDeclaration; } } Expect(100); Expect(106); EndOfStmt(); #line 1144 "VBNET.ATG" if(addHandlerAccessorDeclaration == null) { Error("Need to provide AddHandler accessor."); } if(removeHandlerAccessorDeclaration == null) { Error("Need to provide RemoveHandler accessor."); } if(raiseEventAccessorDeclaration == null) { Error("Need to provide RaiseEvent accessor."); } EventDeclaration decl = new EventDeclaration { TypeReference = type, Name = customEventName, Modifier = m.Modifier, Attributes = attributes, StartLocation = m.GetDeclarationLocation(startPos), EndLocation = t.EndLocation, AddRegion = addHandlerAccessorDeclaration, RemoveRegion = removeHandlerAccessorDeclaration, RaiseRegion = raiseEventAccessorDeclaration }; compilationUnit.AddChild(decl); break; } case 147: case 158: case 217: { #line 1170 "VBNET.ATG" ConversionType opConversionType = ConversionType.None; if (la.kind == 147 || la.kind == 217) { if (la.kind == 217) { lexer.NextToken(); #line 1171 "VBNET.ATG" opConversionType = ConversionType.Implicit; } else { lexer.NextToken(); #line 1172 "VBNET.ATG" opConversionType = ConversionType.Explicit; } } Expect(158); #line 1175 "VBNET.ATG" m.Check(Modifiers.VBOperators); Location startPos = t.Location; TypeReference returnType = NullTypeReference.Instance; TypeReference operandType = NullTypeReference.Instance; string operandName; OverloadableOperatorType operatorType; AttributeSection section; List<ParameterDeclarationExpression> parameters = new List<ParameterDeclarationExpression>(); List<AttributeSection> returnTypeAttributes = new List<AttributeSection>(); OverloadableOperator( #line 1185 "VBNET.ATG" out operatorType); Expect(25); if (la.kind == 59) { lexer.NextToken(); } Identifier(); #line 1186 "VBNET.ATG" operandName = t.val; if (la.kind == 50) { lexer.NextToken(); TypeName( #line 1187 "VBNET.ATG" out operandType); } #line 1188 "VBNET.ATG" parameters.Add(new ParameterDeclarationExpression(operandType, operandName, ParameterModifiers.In)); while (la.kind == 12) { lexer.NextToken(); if (la.kind == 59) { lexer.NextToken(); } Identifier(); #line 1192 "VBNET.ATG" operandName = t.val; if (la.kind == 50) { lexer.NextToken(); TypeName( #line 1193 "VBNET.ATG" out operandType); } #line 1194 "VBNET.ATG" parameters.Add(new ParameterDeclarationExpression(operandType, operandName, ParameterModifiers.In)); } Expect(26); #line 1197 "VBNET.ATG" Location endPos = t.EndLocation; if (la.kind == 50) { lexer.NextToken(); while (la.kind == 28) { AttributeSection( #line 1198 "VBNET.ATG" out section); #line 1198 "VBNET.ATG" returnTypeAttributes.Add(section); } TypeName( #line 1198 "VBNET.ATG" out returnType); #line 1198 "VBNET.ATG" endPos = t.EndLocation; } Expect(1); Block( #line 1200 "VBNET.ATG" out stmt); Expect(100); Expect(158); EndOfStmt(); #line 1202 "VBNET.ATG" OperatorDeclaration operatorDeclaration = new OperatorDeclaration { Modifier = m.Modifier, Attributes = attributes, Parameters = parameters, TypeReference = returnType, OverloadableOperator = operatorType, ConversionType = opConversionType, ReturnTypeAttributes = returnTypeAttributes, Body = (BlockStatement)stmt, StartLocation = m.GetDeclarationLocation(startPos), EndLocation = endPos }; operatorDeclaration.Body.StartLocation = startPos; operatorDeclaration.Body.EndLocation = t.Location; compilationUnit.AddChild(operatorDeclaration); break; } default: SynErr(244); break; } }