Ejemplo n.º 1
0
 static void RemoveConstraints(EntityDeclaration decl)
 {
     foreach (var child in decl.GetChildrenByRole(Roles.Constraint).ToArray())
     {
         child.Remove();
     }
 }
Ejemplo n.º 2
0
        /// <summary>
        ///   Inserts the given EntityDeclaration with the given
        ///   script at the end of the type declaration under the
        ///   cursor (e.g. class / struct).
        /// </summary>
        /// <remarks>
        ///   Alters the given script. Returns its CurrentDocument
        ///   property. Alters the given memberDeclaration, adding
        ///   Modifiers.Override to its Modifiers as well as removing
        ///   Modifiers.Virtual.
        /// </remarks>
        IDocument runOverrideTargetWorker
            (Request request
            , OmniSharpRefactoringContext refactoringContext
            , ParsedResult parsedContent
            , EntityDeclaration memberDeclaration
            , OmniSharpScript script)
        {
            // Add override flag
            memberDeclaration.Modifiers |= Modifiers.Override;
            // Remove virtual flag
            memberDeclaration.Modifiers &= ~Modifiers.Virtual;
            // Remove abstract flag
            memberDeclaration.Modifiers &= ~Modifiers.Abstract;

            // The current type declaration, e.g. class, struct..
            var typeDeclaration = parsedContent.SyntaxTree.GetNodeAt
                                      (refactoringContext.Location
                                      , n => n.NodeType == NodeType.TypeDeclaration);

            // Even empty classes have nodes, so this works
            var lastNode =
                typeDeclaration.Children.Last();

            script.InsertBefore
                (node: lastNode
                , newNode: memberDeclaration);
            script.FormatText(memberDeclaration);

            return(script.CurrentDocument);
        }
Ejemplo n.º 3
0
            void CheckNode(EntityDeclaration node)
            {
                if (!node.HasModifier(Modifiers.Override))
                {
                    return;
                }
                var type = node.Parent as TypeDeclaration;

                if (type == null || !type.HasModifier(Modifiers.Sealed))
                {
                    return;
                }
                foreach (var token_ in node.ModifierTokens)
                {
                    var token = token_;
                    if (token.Modifier == Modifiers.Sealed)
                    {
                        AddIssue(new CodeIssue(
                                     token,
                                     ctx.TranslateString("Keyword 'sealed' is redundant in sealed classes."),
                                     ctx.TranslateString("Remove redundant 'sealed' modifier"),
                                     script => script.ChangeModifier(node, node.Modifiers & ~Modifiers.Sealed)
                                     )
                        {
                            IssueMarker = IssueMarker.GrayOut
                        });
                    }
                }
            }
        public override async void Execute(EditorRefactoringContext context)
        {
            SyntaxTree st = await context.GetSyntaxTreeAsync().ConfigureAwait(false);

            ICompilation compilation = await context.GetCompilationAsync().ConfigureAwait(false);

            CSharpFullParseInformation info = await context.GetParseInformationAsync().ConfigureAwait(false) as CSharpFullParseInformation;

            EntityDeclaration node     = (EntityDeclaration)st.GetNodeAt(context.CaretLocation, n => n is TypeDeclaration || n is DelegateDeclaration);
            IDocument         document = context.Editor.Document;

            FileName newFileName = FileName.Create(Path.Combine(Path.GetDirectoryName(context.FileName), MakeValidFileName(node.Name)));
            string   header      = CopyFileHeader(document, info);
            string   footer      = CopyFileEnd(document, info);

            AstNode newNode = node.Clone();

            foreach (var ns in node.Ancestors.OfType <NamespaceDeclaration>())
            {
                var newNS = new NamespaceDeclaration(ns.Name);
                newNS.Members.AddRange(ns.Children.Where(ch => ch is UsingDeclaration ||
                                                         ch is UsingAliasDeclaration ||
                                                         ch is ExternAliasDeclaration).Select(usingDecl => usingDecl.Clone()));
                newNS.AddMember(newNode);
                newNode = newNS;
            }

            var topLevelUsings = st.Children.Where(ch => ch is UsingDeclaration ||
                                                   ch is UsingAliasDeclaration ||
                                                   ch is ExternAliasDeclaration);
            StringBuilder       newCode = new StringBuilder(header);
            CSharpOutputVisitor visitor = new CSharpOutputVisitor(new StringWriter(newCode), FormattingOptionsFactory.CreateSharpDevelop());

            foreach (var topLevelUsing in topLevelUsings)
            {
                topLevelUsing.AcceptVisitor(visitor);
            }

            newNode.AcceptVisitor(visitor);

            newCode.AppendLine(footer);

            IViewContent viewContent = FileService.NewFile(newFileName, newCode.ToString());

            viewContent.PrimaryFile.SaveToDisk(newFileName);
            // now that the code is saved in the other file, remove it from the original document
            RemoveExtractedNode(context, node);

            IProject project = (IProject)compilation.GetProject();

            if (project != null)
            {
                FileProjectItem projectItem = new FileProjectItem(project, ItemType.Compile);
                projectItem.FileName = newFileName;
                ProjectService.AddProjectItem(project, projectItem);
                FileService.FireFileCreated(newFileName, false);
                project.Save();
                ProjectBrowserPad.RefreshViewAsync();
            }
        }
 static AstNode WrapInType(IUnresolvedTypeDefinition entity, EntityDeclaration decl)
 {
     if (entity == null)
     {
         return(decl);
     }
     // Wrap decl in TypeDeclaration
     decl = new TypeDeclaration {
         ClassType = GetClassType(entity),
         Modifiers = Modifiers.Partial,
         Name      = entity.Name,
         Members   = { decl }
     };
     if (entity.DeclaringTypeDefinition != null)
     {
         // Handle nested types
         return(WrapInType(entity.DeclaringTypeDefinition, decl));
     }
     if (string.IsNullOrEmpty(entity.Namespace))
     {
         return(decl);
     }
     return(new NamespaceDeclaration(entity.Namespace)
     {
         Members =
         {
             decl
         }
     });
 }
Ejemplo n.º 6
0
 void CheckVirtual(EntityDeclaration entity)
 {
     if (!curType.Peek().HasModifier(Modifiers.Static) && !curType.Peek().HasModifier(Modifiers.Sealed) && entity.HasModifier(Modifiers.Virtual))
     {
         if (!entity.HasModifier(Modifiers.Public) && !entity.HasModifier(Modifiers.Protected) && !entity.HasModifier(Modifiers.Internal))
         {
             AddIssue(
                 entity.NameToken,
                 ctx.TranslateString("'virtual' members can't be private")
                 );
             return;
         }
     }
     if (!curType.Peek().HasModifier(Modifiers.Sealed) || !entity.HasModifier(Modifiers.Virtual))
     {
         return;
     }
     AddIssue(
         entity.ModifierTokens.First(t => t.Modifier == Modifiers.Virtual),
         ctx.TranslateString("'virtual' modifier is not usable in a sealed class"),
         ctx.TranslateString("Remove 'virtual' modifier"),
         s => {
         s.ChangeModifier(entity, entity.Modifiers & ~Modifiers.Virtual);
     }
         );
 }
 // test ok
 void processEntiry(EntityDeclaration ed, TEntity te)
 {
     if (ed.HasModifier(Modifiers.Public))
     {
         te.isPublic = true;
     }
     if (ed.HasModifier(Modifiers.Private))
     {
         te.isPrivate = true;
     }
     if (ed.HasModifier(Modifiers.Internal))
     {
         te.isInternal = true;
     }
     if (ed.HasModifier(Modifiers.Override))
     {
         te.isOverride = true;
     }
     if (ed.HasModifier(Modifiers.Static))
     {
         te.isStatic = true;
     }
     te.name = ed.Name;
     te.type = ed.ReturnType.GetText();
     foreach (var attr in ed.Attributes)
     {
         te.attributes += attr.GetText();
     }
 }
Ejemplo n.º 8
0
        public ProjectTypeFromFile(object obs)
        {
            VSParsers.ProjectItemInfo p = obs as VSParsers.ProjectItemInfo;
            if (p == null)
            {
                return;
            }
            EntityDeclaration e = p.mapper;

            if (e == null)
            {
                return;
            }
            Name = e.Name;
            if (e is FieldDeclaration)
            {
                FieldDeclaration f = e as FieldDeclaration;
                Name = f.Name;
                if (string.IsNullOrEmpty(Name))
                {
                    if (f.Variables != null)
                    {
                        if (f.Variables.Count > 0)
                        {
                            Name = f.Variables.ToList()[0].Name;
                        }
                    }
                }
            }
        }
Ejemplo n.º 9
0
        private void getTypeAttributes <T>(CodeItemBase <T> type, EntityDeclaration decl)
        {
            if (decl.Attributes.Count == 0)
            {
                return;
            }
            foreach (var typeAttrib in decl.Attributes)
            {
                foreach (var attribute in typeAttrib.Attributes)
                {
                    var codeAttrib = new CodeAttribute()
                    {
                        Name = signatureFrom(attribute.Type)
                    };
                    if (!codeAttrib.Name.EndsWith("Attribute"))
                    {
                        codeAttrib.Name += "Attribute";
                    }
                    foreach (var arg in attribute.Arguments)
                    {
                        codeAttrib.AddParameter(arg.ToString().Replace("\"", ""));
                    }

                    type.AddAttribute(codeAttrib);
                }
            }
        }
Ejemplo n.º 10
0
        void WriteTypeDeclarationName(ITypeDefinition typeDef, TokenWriter writer, CSharpFormattingOptions formattingPolicy)
        {
            TypeSystemAstBuilder astBuilder = CreateAstBuilder();
            EntityDeclaration    node       = astBuilder.ConvertEntity(typeDef);

            if (typeDef.DeclaringTypeDefinition != null &&
                ((ConversionFlags & ConversionFlags.ShowDeclaringType) == ConversionFlags.ShowDeclaringType ||
                 (ConversionFlags & ConversionFlags.UseFullyQualifiedEntityNames) == ConversionFlags.UseFullyQualifiedEntityNames))
            {
                WriteTypeDeclarationName(typeDef.DeclaringTypeDefinition, writer, formattingPolicy);
                writer.WriteToken(Roles.Dot, ".");
            }
            else if ((ConversionFlags & ConversionFlags.UseFullyQualifiedEntityNames) == ConversionFlags.UseFullyQualifiedEntityNames)
            {
                if (!string.IsNullOrEmpty(typeDef.Namespace))
                {
                    WriteQualifiedName(typeDef.Namespace, writer, formattingPolicy);
                    writer.WriteToken(Roles.Dot, ".");
                }
            }
            writer.WriteIdentifier(node.NameToken);
            if ((ConversionFlags & ConversionFlags.ShowTypeParameterList) == ConversionFlags.ShowTypeParameterList)
            {
                var outputVisitor = new CSharpOutputVisitor(writer, formattingPolicy);
                outputVisitor.WriteTypeParameters(node.GetChildrenByRole(Roles.TypeParameter));
            }
        }
            void CheckStaticRequired(EntityDeclaration entity)
            {
                if (!curType.Peek().HasModifier(Modifiers.Static) || entity.HasModifier(Modifiers.Static) || entity.HasModifier(Modifiers.Const))
                {
                    return;
                }
                var fd = entity as FieldDeclaration;

                if (fd != null)
                {
                    foreach (var init in fd.Variables)
                    {
                        AddStaticRequiredError(entity, init.NameToken);
                    }
                    return;
                }

                var ed = entity as EventDeclaration;

                if (ed != null)
                {
                    foreach (var init in ed.Variables)
                    {
                        AddStaticRequiredError(entity, init.NameToken);
                    }
                    return;
                }

                AddStaticRequiredError(entity, entity.NameToken);
            }
Ejemplo n.º 12
0
        private string getMemberProperties(EntityDeclaration type)
        {
            var json = new JSONWriter();

            getTypeModifiers(type);
            //getTypeAttributes(type, json);
            return(json.ToString());
        }
Ejemplo n.º 13
0
 internal static string GetCorrectFileName(MDRefactoringContext context, EntityDeclaration type)
 {
     if (type == null)
     {
         return(context.Document.FileName);
     }
     return(Path.Combine(Path.GetDirectoryName(context.Document.FileName), type.Name + Path.GetExtension(context.Document.FileName)));
 }
Ejemplo n.º 14
0
 public virtual UstNode Visit(EntityDeclaration entityDeclaration)
 {
     if (entityDeclaration == null)
     {
         return(null);
     }
     return(Visit((dynamic)entityDeclaration));
 }
Ejemplo n.º 15
0
        private JsFunctionDefinitionExpression CompileMethod(EntityDeclaration node, BlockStatement body, IMethod method, MethodScriptSemantics options)
        {
            var mc     = CreateMethodCompiler();
            var result = mc.CompileMethod(node, body, method, options);

            OnMethodCompiled(method, result, mc);
            return(result);
        }
Ejemplo n.º 16
0
        void RemoveExtractedNode(EditorRefactoringContext context, EntityDeclaration node)
        {
            IDocument document = context.Editor.Document;
            int       start    = document.GetOffset(node.StartLocation);
            int       end      = document.GetOffset(node.EndLocation);

            document.Remove(start, end - start);
        }
Ejemplo n.º 17
0
        public virtual string GetEntityName(EntityDeclaration entity)
        {
            if (Resolver.ResolveNode(entity) is MemberResolveResult rr)
            {
                return(GetEntityName(rr.Member));
            }

            return(null);
        }
Ejemplo n.º 18
0
        public void AddTo(TypeDeclaration typeDecl, EntityDeclaration entityDecl)
        {
            var startOffset = GetCurrentOffset(typeDecl.LBraceToken.EndLocation);
            var output      = OutputNode(1 + GetIndentLevelAt(startOffset), entityDecl, true);

            InsertText(startOffset, output.Text);
            output.RegisterTrackedSegments(this, startOffset);
            CorrectFormatting(null, entityDecl);
        }
Ejemplo n.º 19
0
        protected virtual IMember FindMember(EntityDeclaration entity)
        {
            if (this.Emitter.Resolver.ResolveNode(entity) is MemberResolveResult rr)
            {
                return(rr.Member);
            }

            return(null);
        }
Ejemplo n.º 20
0
 bool IsIgnored(EntityDeclaration entity)
 {
     return(entity
            .Attributes
            .SelectMany(section => section.Attributes)
            .Where(attr => attr.Type.ToString() == "Ignore")
            .Any(attr => (Backend)Enum.Parse(typeof(Backend),
                                             ((MemberReferenceExpression)attr.Arguments.First()).MemberName) == Backend));
 }
Ejemplo n.º 21
0
        public virtual string GetEntityName(EntityDeclaration entity, bool forcePreserveMemberCase = false, bool ignoreInterface = false)
        {
            var rr = this.Resolver.ResolveNode(entity, this) as MemberResolveResult;

            if (rr != null)
            {
                return(this.GetEntityName(rr.Member, forcePreserveMemberCase, ignoreInterface));
            }
            return(null);
        }
            Modifiers GetAccessibiltiy(EntityDeclaration decl, Modifiers defaultModifier)
            {
                var accessibility = (decl.Modifiers & Modifiers.VisibilityMask);

                if (accessibility == Modifiers.None)
                {
                    return(defaultModifier);
                }
                return(accessibility);
            }
Ejemplo n.º 23
0
        /// <summary>
        /// Adds an attribute section to a given entity.
        /// </summary>
        /// <param name="entity">The entity to add the attribute to.</param>
        /// <param name="attr">The attribute to add.</param>
        public void AddAttribute(EntityDeclaration entity, AttributeSection attr)
        {
            var node = entity.FirstChild;

            while (node.NodeType == NodeType.Whitespace || node.Role == Roles.Attribute)
            {
                node = node.NextSibling;
            }
            InsertBefore(node, attr);
        }
Ejemplo n.º 24
0
        public virtual string GetEntityName(EntityDeclaration entity)
        {
            var rr = this.Resolver.ResolveNode(entity, this) as MemberResolveResult;

            if (rr != null)
            {
                return(this.GetEntityName(rr.Member));
            }

            return(null);
        }
 void AddStaticRequiredError(EntityDeclaration entity, AstNode node)
 {
     AddIssue(new CodeIssue(
                  node,
                  ctx.TranslateString("'static' modifier is required inside a static class"),
                  ctx.TranslateString("Add 'static' modifier"),
                  s => {
         s.ChangeModifier(entity, (entity.Modifiers & ~(Modifiers.Virt | Modifiers.Override)) | Modifiers.Static);
     }
                  ));
 }
        bool CheckInterfaceImplementation(EntityDeclaration entityDeclaration)
        {
            var result = resolver.Resolve(entityDeclaration, cancellationToken) as MemberResolveResult;

            if (result.Member.ImplementedInterfaceMembers.Count == 0)
            {
                Colorize(entityDeclaration.NameToken, syntaxErrorColor);
                return(false);
            }
            return(true);
        }
Ejemplo n.º 27
0
        public virtual string GetInline(EntityDeclaration method)
        {
            if (Resolver.ResolveNode(method) is MemberResolveResult mrr)
            {
                return(GetInline(mrr.Member));
            }

            var attr = GetAttribute(method.Attributes, H5.Translator.Translator.H5_ASSEMBLY + ".Template");

            return(attr != null && attr.Arguments.Count > 0 ? ((string)((PrimitiveExpression)attr.Arguments.First()).Value) : null);
        }
Ejemplo n.º 28
0
        protected virtual IMember FindMember(EntityDeclaration entity)
        {
            var rr = this.Emitter.Resolver.ResolveNode(entity, this.Emitter) as MemberResolveResult;

            if (rr != null)
            {
                return(rr.Member);
            }

            return(null);
        }
Ejemplo n.º 29
0
        private EntityInfo CreateEntityInfo(EntityDeclaration entityDeclaration)
        {
            var entityInfo = new EntityInfo(entityDeclaration.Name, CurrentDeclaringSymbol);

            CurrentDeclaringSymbol.AddDeclaration(entityInfo);

            SetEntityBaseTypes(entityDeclaration, entityInfo);

            symbols_.Add(entityDeclaration, entityInfo);

            return(entityInfo);
        }
Ejemplo n.º 30
0
        public IMember getmember(EntityDeclaration ent)
        {
            foreach (IMember m in members)
            {
                if (m.FullName == ent.Name)
                {
                    return(m);
                }
            }

            return(null);
        }
Ejemplo n.º 31
0
			void CheckNode(EntityDeclaration node)
			{
				foreach (var token_ in node.ModifierTokens) {
					var token = token_;
					if (token.Modifier == Modifiers.Private) {
						AddIssue(token, ctx.TranslateString("Remove redundant 'private' modifier"), script => {
							int offset = script.GetCurrentOffset(token.StartLocation);
							int endOffset = script.GetCurrentOffset(token.GetNextNode().StartLocation);
							script.RemoveText(offset, endOffset - offset);
						});
					}
				}
			}
Ejemplo n.º 32
0
		/// <summary>
		/// Adds an attribute section to a given entity.
		/// </summary>
		/// <param name="entity">The entity to add the attribute to.</param>
		/// <param name="attr">The attribute to add.</param>
		public void AddAttribute(EntityDeclaration entity, AttributeSection attr)
		{
			var node = entity.FirstChild;
			while (node.NodeType == NodeType.Whitespace || node.Role == Roles.Attribute) {
				node = node.NextSibling;
			}
			InsertBefore(node, attr);
		}
Ejemplo n.º 33
0
		/// <summary>
		/// Changes the modifier of a given entity declaration.
		/// </summary>
		/// <param name="entity">The entity.</param>
		/// <param name="modifiers">The new modifiers.</param>
		public void ChangeModifier(EntityDeclaration entity, Modifiers modifiers)
		{
			var dummyEntity = new MethodDeclaration ();
			dummyEntity.Modifiers = modifiers;

			int offset;
			int endOffset;

			if (entity.ModifierTokens.Any ()) {
				offset = GetCurrentOffset(entity.ModifierTokens.First ().StartLocation);
				endOffset = GetCurrentOffset(entity.ModifierTokens.Last ().GetNextSibling (s => s.Role != Roles.NewLine && s.Role != Roles.Whitespace).StartLocation);
			} else {
				var child = entity.FirstChild;
				while (child.NodeType == NodeType.Whitespace ||
				       child.Role == EntityDeclaration.AttributeRole ||
				       child.Role == Roles.NewLine) {
					child = child.NextSibling;
				}
				offset = endOffset = GetCurrentOffset(child.StartLocation);
			}

			var sb = new StringBuilder();
			foreach (var modifier in dummyEntity.ModifierTokens) {
				sb.Append(modifier.ToString());
				sb.Append(' ');
			}

			Replace(offset, endOffset - offset, sb.ToString());
		}
Ejemplo n.º 34
0
		public void AddTo(TypeDeclaration typeDecl, EntityDeclaration entityDecl)
		{
			var startOffset = GetCurrentOffset(typeDecl.LBraceToken.EndLocation);
			var output = OutputNode(1 + GetIndentLevelAt(startOffset), entityDecl, true);
			InsertText(startOffset, output.Text);
			output.RegisterTrackedSegments(this, startOffset);
			CorrectFormatting (null, entityDecl);
		}
Ejemplo n.º 35
0
        void FuncDecl(out EntityDeclaration decl, Modifiers modifiers)
        {
            Identifier ident = null;
            string name; AstType type = null; BlockStatement block;
            var type_params = new List<ParameterType>();
            var @params = new List<ParameterDeclaration>();
            var start_loc = NextLocation;

            while (!(la.kind == 0 || la.kind == 38)) {SynErr(105); Get();}
            Expect(38);
            Symbols.AddScope();
            Expect(14);
            name = t.val;
            if(!CheckKeyword(name)){
               ident = AstNode.MakeIdentifier(name, new PlaceholderType(TextLocation.Empty), CurrentLocation);
               Symbols.AddSymbol(name, ident);
            }else{
               // The name is unsuitable for a method or a function name.
               // Leave the parser to recover its state.
            }

            if (la.kind == 42) {
            GenericTypeParameters(ref type_params);
            }
            Expect(8);
            GoDownScope();
            Symbols.Name = "func " + name + "`" + ScopeId++;

            if (la.kind == 14) {
            ParamList(type_params, ref @params);
            }
            Expect(10);
            if (la.kind == 39) {
            Get();
            Type(out type);
            }
            if(type == null)
               type = new PlaceholderType(TextLocation.Empty);

            if(type_params.Any(tp => tp.Identifier == type.Name)){
               var type_param = type_params.Where(tp => tp.Identifier == type.Name)
               .Select(tp => tp)
               .First()
               .Clone();

            }

            Block(out block);
            decl = EntityDeclaration.MakeFunc(ident, @params, block, type, modifiers, start_loc);
                GoUpScope();
        }
Ejemplo n.º 36
0
        void ClassDecl(out EntityDeclaration decl, Modifiers modifiers)
        {
            EntityDeclaration entity = null; var decls = new List<EntityDeclaration>(); AstType type_path;
            string name; var bases = new List<AstType>(); Modifiers cur_flag; var start_loc = NextLocation;
            Identifier ident = null;

            while (!(la.kind == 0 || la.kind == 33)) {SynErr(106); Get();}
            Expect(33);
            Symbols.AddScope();
            Expect(14);
            name = t.val;
                            if(!CheckKeyword(name)){
                                ident = AstNode.MakeIdentifier(name, CurrentLocation);
                                Symbols.AddTypeSymbol(name, ident);
                                cur_class_name = name;
                            }else{
                                // Failed to parse an identifier.
                                // Leave the parser to recover its state.
                            }

            if (la.kind == 4) {
            Get();
            Type(out type_path);
            bases.Add(type_path);
            while (la.kind == 12) {
                Get();
                Type(out type_path);
                bases.Add(type_path);
            }
            }
            Expect(7);
            GoDownScope();
            Symbols.Name = "class " + name + "`" + ScopeId++;

            while (StartOf(1)) {
            cur_flag = ExpressoModifiers.Private;
            while (StartOf(2)) {
                Modifiers(ref cur_flag);
            }

            if (la.kind == 38) {
                FuncDecl(out entity, cur_flag);
                decls.Add(entity);
            } else if (la.kind == 27 || la.kind == 28) {
                FieldDecl(out entity, cur_flag);
                decls.Add(entity);
            } else if (la.kind == 33) {
                ClassDecl(out entity, cur_flag);
                decls.Add(entity);
            } else SynErr(107);
            }
            while (!(la.kind == 0 || la.kind == 11)) {SynErr(108); Get();}
            Expect(11);
            decl = EntityDeclaration.MakeClassDecl(ident, bases, decls, modifiers, start_loc, CurrentLocation);
                           GoUpScope();
        }
Ejemplo n.º 37
0
		static void RemoveConstraints(EntityDeclaration decl)
		{
			foreach (var child in decl.GetChildrenByRole(Roles.Constraint).ToArray()) {
				child.Remove();
			}
		}
			Modifiers GetAccessibiltiy(EntityDeclaration decl, Modifiers defaultModifier)
			{
				var accessibility = (decl.Modifiers & Modifiers.VisibilityMask);
				if (accessibility == Modifiers.None) {
					return defaultModifier;
				}
				return accessibility;
			}
Ejemplo n.º 39
0
        void FieldDecl(out EntityDeclaration field, Modifiers modifiers)
        {
            Expression rhs; Identifier ident; var start_loc = NextLocation;
            var idents = new List<Identifier>(); var exprs = new List<Expression>();

            if (la.kind == 27) {
            Get();
            modifiers |= ExpressoModifiers.Immutable;
            } else if (la.kind == 28) {
            Get();
            } else SynErr(114);
            VarDef(out ident, out rhs);
            idents.Add(ident);
            exprs.Add(rhs);

            while (la.kind == 12) {
            Get();
            VarDef(out ident, out rhs);
            idents.Add(ident);
            exprs.Add(rhs);

            }
            while (!(la.kind == 0 || la.kind == 6)) {SynErr(115); Get();}
            Expect(6);
            field = EntityDeclaration.MakeField(idents, exprs, modifiers, start_loc, CurrentLocation);
        }