Exemplo n.º 1
0
        private IEnumerable <AutoCompleteItem> GetAutoCompleteListNoLock(LuatAstNodeBase node, int offset)
        {
            var table = new Hashtable();

            foreach (LuatScript script in m_scripts)
            {
                if (script.CU != node.CU)
                {
                    continue;
                }

                foreach (AutoCompleteItem item in node.GetAutoCompleteList(script, offset))
                {
                    if (!table.ContainsKey(item.Name))
                    {
                        table.Add(item.Name, item);
                    }
                }
            }

            foreach (AutoCompleteItem item in table.Values)
            {
                yield return(item);
            }
        }
Exemplo n.º 2
0
 /// <summary>
 /// Returns an enumerable list of auto-complete suggestions for the given node and caret position
 /// </summary>
 /// <param name="node"></param>
 /// <param name="offset"></param>
 /// <returns>An enumerable list of auto-complete suggestions for the given node and caret position</returns>
 public IEnumerable <AutoCompleteItem> GetAutoCompleteList(LuatAstNodeBase node, int offset)
 {
     lock (this)
     {
         return(GetAutoCompleteListNoLock(node, offset));
     }
 }
Exemplo n.º 3
0
        private Item[] BuildList(string path, LuatAstNodeBase node)
        {
            var items = new List <Item>();

            var assignment = node as AssignmentStatement;

            if (assignment != null)
            {
                int count = Math.Min(assignment.Variables.Count, assignment.Values.Count);
                for (int index = 0; index < count; ++index)
                {
                    string name    = assignment.Variables[index].DisplayText;
                    var    expr    = assignment.Values[index] as Expression;
                    string subpath = (null != path) ? (path + "\u2219" + name) : name; // \u2219 is a bullet

                    if (expr == null)
                    {
                        continue;
                    }

                    foreach (LuatValue value in expr.ResolvedValues.Values)
                    {
                        var func     = value as LuatFunction;
                        var funcType = value.Type as LuatTypeFunction;
                        if ((func != null) && (funcType != null))
                        {
                            string desc = subpath + funcType.Arguments.ToArray().ToCommaSeperatedList().Parenthesize();
                            items.Add(new Item(desc, expr));
                            break;
                        }
                    }

                    foreach (LuatAstNodeBase child in expr.ChildNodes)
                    {
                        items.AddRange(BuildList(subpath, child));
                    }
                }
            }
            else
            {
                foreach (LuatAstNodeBase child in node.ChildNodes)
                {
                    items.AddRange(BuildList(path, child));
                }
            }

            return(items.ToArray());
        }
Exemplo n.º 4
0
 public Item(string text, LuatAstNodeBase node)
 {
     Text = text;
     Node = node;
 }
Exemplo n.º 5
0
        private Item[] BuildList(string path, LuatAstNodeBase node)
        {
            var items = new List<Item>();

            var assignment = node as AssignmentStatement;
            if (assignment != null)
            {
                int count = Math.Min(assignment.Variables.Count, assignment.Values.Count);
                for (int index = 0; index < count; ++index)
                {
                    string name = assignment.Variables[index].DisplayText;
                    var expr = assignment.Values[index] as Expression;
                    string subpath = (null != path) ? (path + "\u2219" + name) : name; // \u2219 is a bullet

                    if (expr == null)
                        continue;

                    foreach (LuatValue value in expr.ResolvedValues.Values)
                    {
                        var func = value as LuatFunction;
                        var funcType = value.Type as LuatTypeFunction;
                        if ((func != null) && (funcType != null))
                        {
                            string desc = subpath + funcType.Arguments.ToArray().ToCommaSeperatedList().Parenthesize();
                            items.Add(new Item(desc, expr));
                            break;
                        }
                    }

                    foreach (LuatAstNodeBase child in expr.ChildNodes)
                    {
                        items.AddRange(BuildList(subpath, child));
                    }
                }
            }
            else
            {
                foreach (LuatAstNodeBase child in node.ChildNodes)
                {
                    items.AddRange(BuildList(path, child));
                }
            }

            return items.ToArray();
        }
Exemplo n.º 6
0
        private IEnumerable<AutoCompleteItem> GetAutoCompleteListNoLock(LuatAstNodeBase node, int offset)
        {
            var table = new Hashtable();

            foreach (LuatScript script in m_scripts)
            {
                if (script.CU != node.CU)
                    continue;

                foreach (AutoCompleteItem item in node.GetAutoCompleteList(script, offset))
                {
                    if (!table.ContainsKey(item.Name))
                        table.Add(item.Name, item);
                }
            }

            foreach (AutoCompleteItem item in table.Values)
            {
                yield return item;
            }
        }
Exemplo n.º 7
0
 /// <summary>
 /// Returns an enumerable list of auto-complete suggestions for the given node and caret position
 /// </summary>
 /// <param name="node"></param>
 /// <param name="offset"></param>
 /// <returns>An enumerable list of auto-complete suggestions for the given node and caret position</returns>
 public IEnumerable<AutoCompleteItem> GetAutoCompleteList(LuatAstNodeBase node, int offset)
 {
     lock (this)
     {
         return GetAutoCompleteListNoLock(node, offset);
     }
 }
Exemplo n.º 8
0
		public IndexExpression(Expression lhs, IToken indexToken, LuatAstNodeBase rhs, TextRange textRange) : this( textRange ) {
			// Initialize parameters
			this.LHS        = lhs;
			this.IndexToken = indexToken;
			this.RHS        = rhs;
		}
Exemplo n.º 9
0
		/////////////////////////////////////////////////////////////////////////////////////////////////////
		// OBJECT
		/////////////////////////////////////////////////////////////////////////////////////////////////////

		/// <summary>
		/// Initializes a new instance of the <c>IndexExpression</c> class.
		/// </summary>
		/// <param name="lhs">The LHS expression.</param>
		/// <param name="rhs">The RHS index.</param>
		/// <param name="textRange">The <see cref="TextRange"/> of the AST node.</param>
		public IndexExpression(Expression lhs, IToken indexToken, LuatAstNodeBase rhs) : this(new TextRange( lhs.StartOffset, rhs.EndOffset ) ) {
			// Initialize parameters
			this.LHS        = lhs;
			this.IndexToken = indexToken;
			this.RHS        = rhs;
		}
Exemplo n.º 10
0
		/// <summary>
		/// Matches a <c>Arguments</c> non-terminal.
		/// </summary>
		/// <returns><c>true</c> if the <c>Arguments</c> was matched successfully; otherwise, <c>false</c>.</returns>
		/// <remarks>
		/// The non-terminal can start with: <c>OpenParenthesis</c>, <c>OpenCurlyBrace</c>, <c>String</c>.
		/// </remarks>
		protected virtual bool MatchArguments(out LuatAstNodeBase arguments) {
			arguments = null;
			if (this.TokenIs(this.LookAheadToken, LuatTokenId.OpenParenthesis)) {
				ArgumentList arglist;
				if (!this.MatchArgumentList(out arglist))
					return false;
				arguments = arglist;
			}
			else if (this.TokenIs(this.LookAheadToken, LuatTokenId.OpenCurlyBrace)) {
				Expression table;
				if (!this.MatchTableConstructor(out table))
					return false;
				arguments = table;
			}
			else if (this.TokenIs(this.LookAheadToken, LuatTokenId.String)) {
				Expression stringExp;
				if (!this.MatchStringExpression(out stringExp))
					return false;
				arguments = stringExp;
			}
			else
				return false;
			return true;
		}
Exemplo n.º 11
0
 public Item(string text, LuatAstNodeBase node)
 {
     Text = text;
     Node = node;
 }