Пример #1
0
        /// <summary>
        /// Returns an array consisting of meta declarations orderd from outer to inner-most, depending on the 'Where' parameter.
        /// </summary>
        public List <IMetaDeclaration> GetMetaBlockStack(CodeLocation Where, bool takeBlockStartLocations = false, bool mindAttributeSections = false)
        {
            var l = new List <IMetaDeclaration>();

            IMetaDeclaration lastSr = null;

            foreach (var mb in MetaBlocks)
            {
                if (mb is AttributeMetaDeclarationSection)
                {
                    if (mindAttributeSections && Where >= mb.EndLocation)
                    {
                        // Don't let multiple section attributes like 'private:' nest within each other
                        if (lastSr is AttributeMetaDeclarationSection)
                        {
                            l.Remove(lastSr);
                        }
                        l.Add(lastSr = mb);
                    }
                    continue;
                }
                if (lastSr != null && !(mindAttributeSections && lastSr is AttributeMetaDeclarationSection) && mb.Location < lastSr.Location && mb.EndLocation > lastSr.EndLocation)
                {
                    continue;
                }
                // Check if 1) block is inside last inner-most meta block
                if (((takeBlockStartLocations && mb is IMetaDeclarationBlock) ? ((IMetaDeclarationBlock)mb).BlockStartLocation : mb.Location) <= Where && mb.EndLocation >= Where)
                {
                    // and 2) if Where is completely inside the currently handled block.
                    l.Add(lastSr = mb);
                }
            }

            return(l);
        }
Пример #2
0
		public ISyntaxRegion GetNextMetaBlockOrStatStmt(CodeLocation until)
		{
			if (nextStatStmt == null && StaticStatementEnum != null) {
				if (StaticStatementEnum.MoveNext ())
					nextStatStmt = StaticStatementEnum.Current;
				else
					StaticStatementEnum = null;
			}
			if (nextMetaDecl == null && MetaBlockEnum != null) {
				if (MetaBlockEnum.MoveNext ())
					nextMetaDecl = MetaBlockEnum.Current;
				else
					MetaBlockEnum = null;
			}

			ISyntaxRegion sr;

			if (nextStatStmt != null) {
				if (nextMetaDecl == null)
					sr = nextStatStmt;
				else
					sr = nextStatStmt.First (nextMetaDecl);
			} else if (nextMetaDecl != null)
				sr = nextMetaDecl;
			else
				return null;

			return sr.Location < until ? sr : null;
		}
Пример #3
0
        public ISyntaxRegion GetNextMetaBlockOrStatStmt(CodeLocation until)
        {
            if (nextStatStmt == null && StaticStatementEnum != null)
            {
                if (StaticStatementEnum.MoveNext())
                {
                    nextStatStmt = StaticStatementEnum.Current;
                }
                else
                {
                    StaticStatementEnum = null;
                }
            }
            if (nextMetaDecl == null && MetaBlockEnum != null)
            {
                if (MetaBlockEnum.MoveNext())
                {
                    nextMetaDecl = MetaBlockEnum.Current;
                }
                else
                {
                    MetaBlockEnum = null;
                }
            }

            ISyntaxRegion sr;

            if (nextStatStmt != null)
            {
                if (nextMetaDecl == null)
                {
                    sr = nextStatStmt;
                }
                else
                {
                    sr = nextStatStmt.First(nextMetaDecl);
                }
            }
            else if (nextMetaDecl != null)
            {
                sr = nextMetaDecl;
            }
            else
            {
                return(null);
            }

            return(sr.Location < until ? sr : null);
        }
Пример #4
0
        public ConditionsFrame(IEnumerable<StaticStatement> ssEnum, IEnumerable<IMetaDeclaration> metaBlocks)
        {
            this.StaticStatementEnum = (IEnumerator<StaticStatement>)ssEnum.GetEnumerator();
            this.MetaBlockEnum = (IEnumerator<IMetaDeclaration>)metaBlocks.GetEnumerator();

            // opt-in: Initially check whether there are any static statements or meta decls available
            if(StaticStatementEnum.MoveNext())
                nextStatStmt = StaticStatementEnum.Current;
            else
                StaticStatementEnum = null;

            if(MetaBlockEnum.MoveNext())
                nextMetaDecl = MetaBlockEnum.Current;
            else
                MetaBlockEnum = null;
        }
Пример #5
0
        public ConditionsFrame(IEnumerable <StaticStatement> ssEnum, IEnumerable <IMetaDeclaration> metaBlocks)
        {
            this.StaticStatementEnum = (IEnumerator <StaticStatement>)ssEnum.GetEnumerator();
            this.MetaBlockEnum       = (IEnumerator <IMetaDeclaration>)metaBlocks.GetEnumerator();

            // opt-in: Initially check whether there are any static statements or meta decls available
            if (StaticStatementEnum.MoveNext())
            {
                nextStatStmt = StaticStatementEnum.Current;
            }
            else
            {
                StaticStatementEnum = null;
            }

            if (MetaBlockEnum.MoveNext())
            {
                nextMetaDecl = MetaBlockEnum.Current;
            }
            else
            {
                MetaBlockEnum = null;
            }
        }
Пример #6
0
 public void Add(IMetaDeclaration MetaDecl)
 {
     MetaBlocks.Add(MetaDecl);
 }
		void VisitMetaBlockChildren(List<INode> children, List<StaticStatement> staticStatements, IMetaDeclaration mb)
		{
			for(int k = 0; k < children.Count; k++)
			{
				var ch = children[k];
				if(ch.Location > mb.Location)
				{
					if(ch.EndLocation < mb.EndLocation || mb is AttributeMetaDeclarationSection)
					{
						ch.Accept(this);
						children.RemoveAt(k--);
					}
					else
						break;
				}
			}
			
			for(int k = 0; k < staticStatements.Count; k++)
			{
				var ss = staticStatements[k];
				if(ss.Location > mb.Location && (ss.EndLocation < mb.EndLocation || mb is AttributeMetaDeclarationSection))
				{
					ss.Accept(this);
					staticStatements.RemoveAt(k--);
				}
			}
		}
Пример #8
0
		void HandleMetaDecl(IMetaDeclaration md)
		{

		}
Пример #9
0
        void VisitMetaBlockChildren(List <INode> children, List <StaticStatement> staticStatements, IMetaDeclaration mb)
        {
            for (int k = 0; k < children.Count; k++)
            {
                var ch = children[k];
                if (ch.Location > mb.Location)
                {
                    if (ch.EndLocation < mb.EndLocation || mb is AttributeMetaDeclarationSection)
                    {
                        ch.Accept(this);
                        children.RemoveAt(k--);
                    }
                    else
                    {
                        break;
                    }
                }
            }

            for (int k = 0; k < staticStatements.Count; k++)
            {
                var ss = staticStatements[k];
                if (ss.Location > mb.Location && (ss.EndLocation < mb.EndLocation || mb is AttributeMetaDeclarationSection))
                {
                    ss.Accept(this);
                    staticStatements.RemoveAt(k--);
                }
            }
        }
Пример #10
0
 void HandleMetaDecl(IMetaDeclaration md)
 {
 }