Esempio n. 1
0
 public AutoCompleteData(string filename)
 {
     AutoCompleteData rst = DoxygenXMLParser.Parse(filename);
     m_typeManager = rst.Types;
     m_variableManager = rst.Variables;
     init();
 }
Esempio n. 2
0
        public AutoCompleteData()
        {
            m_typeManager     = new TypeManager();
            m_variableManager = new VariableManager();
            m_keywords        = new KeywordManager();
            m_typeManager.add(new Type("nil", true));
            m_typeManager.add(new Type("object", true));
            m_typeManager.add(new Type("int", true));
            m_typeManager.add(new Type("void", true));
            m_typeManager.add(new Type("char", true));
            m_typeManager.add(new Type("float", true));
            m_typeManager.add(new Type("double", true));
            m_typeManager.add(new Type("string", true));
            m_typeManager.add(new Type("table", true));
            m_typeManager.add(new Type("number", true));
            m_typeManager.add(new Type("boolean", true));
            m_typeManager.add(new Type("function", true));
            m_typeManager.add(new Type("thread", true));
            m_typeManager.add(new Type("userdata", true));

            m_keywords.add(new Keyword("break"));
            m_keywords.add(new Keyword("else"));
            m_keywords.add(new Keyword("elseif"));
            m_keywords.add(new Keyword("false"));
            m_keywords.add(new Keyword("function"));
            m_keywords.add(new Keyword("local"));
            m_keywords.add(new Keyword("repeat"));
            m_keywords.add(new Keyword("return"));
            m_keywords.add(new Keyword("then"));
            m_keywords.add(new Keyword("true"));
            m_keywords.add(new Keyword("until"));
            m_keywords.add(new Keyword("while"));
            init();
        }
Esempio n. 3
0
        public AutoCompleteData(string filename)
        {
            AutoCompleteData rst = DoxygenXMLParser.Parse(filename);

            m_typeManager     = rst.Types;
            m_variableManager = rst.Variables;
            init();
        }
Esempio n. 4
0
        public AutoCompleteData(AutoCompleteData parent)
        {
            m_typeManager     = new TypeManager(parent.Types);
            m_variableManager = new VariableManager(parent.Variables);
            m_keywords        = new KeywordManager();
            addKeywords();

            init();
        }
Esempio n. 5
0
        public AutoCompleteData(AutoCompleteData parent)
        {
            m_typeManager = new TypeManager(parent.Types);
            m_variableManager = new VariableManager(parent.Variables);
            m_keywords = new KeywordManager();
            addKeywords();

            init();
        }
Esempio n. 6
0
        public AutoCompleteData()
        {
            m_typeManager     = new TypeManager();
            m_variableManager = new VariableManager();
            m_keywords        = new KeywordManager();
            addDefaultTypes();

            addKeywords();
            init();
        }
Esempio n. 7
0
        public AutoCompleteData()
        {
            m_typeManager = new TypeManager();
            m_variableManager = new VariableManager();
            m_keywords = new KeywordManager();
            addDefaultTypes();

            addKeywords();
            init();
        }
Esempio n. 8
0
        public AutoCompleteData(AutoCompleteData parent)
        {
            m_typeManager     = new TypeManager(parent.Types);
            m_variableManager = new VariableManager(parent.Variables);
            m_keywords        = new KeywordManager();

            m_keywords.add(new Keyword("break"));
            m_keywords.add(new Keyword("else"));
            m_keywords.add(new Keyword("elseif"));
            m_keywords.add(new Keyword("false"));
            m_keywords.add(new Keyword("function"));
            m_keywords.add(new Keyword("local"));
            m_keywords.add(new Keyword("repeat"));
            m_keywords.add(new Keyword("return"));
            m_keywords.add(new Keyword("then"));
            m_keywords.add(new Keyword("true"));
            m_keywords.add(new Keyword("until"));
            m_keywords.add(new Keyword("while"));

            init();
        }
Esempio n. 9
0
        // Public Methods (2) 

        public static FunctionCall Parse(IntelluaSource source, AutoCompleteData data, int pos)
        {
            VariableManager variables    = data.Variables;
            const string    luaOperators = "+-*/^%<>=~";
            int             paramIndex   = 0;

            Byte[] str     = source.RawText;
            bool   running = true;

            while (pos > 0)
            {
                char c = Convert.ToChar(str[pos]);
                if (c == 0 || char.IsWhiteSpace(Convert.ToChar(str[pos])) || !Parser.isCode(source, pos))
                {
                    pos--;
                    continue;
                }
                if (c == ',')
                {
                    paramIndex++;
                    pos--;
                    break;
                }
                if (c == '(')
                {
                    running = false;
                    break;
                }
                break;
            }

            MemberChain chain = MemberChain.ParseBackward(source, pos);

            while (chain.Elements.Count != 0 && running)
            {
                pos = chain.StartPos;

                while (pos > 0 && pos < str.Length)
                {
                    if (char.IsWhiteSpace(Convert.ToChar(str[pos])) || !Parser.isCode(source, pos))
                    {
                        pos--;
                        continue;
                    }
                    if (str[pos] == ',')
                    {
                        paramIndex++;
                        pos--;
                        break;
                    }
                    if (luaOperators.Contains(Convert.ToChar(str[pos])))
                    {
                        pos--;
                        break;
                    }
                    if (str[pos] == '(')
                    {
                        running = false;
                        break;
                    }
                    return(null);
                }
                if (pos <= 0)
                {
                    return(null);
                }
                chain = MemberChain.ParseBackward(source, pos);
                if (chain.StartPos == -1)
                {
                    break;
                }
            }

            while (pos > 0 && pos < str.Length)
            {
                if (char.IsWhiteSpace(Convert.ToChar(str[pos])) || !Parser.isCode(source, pos))
                {
                    pos--;
                    continue;
                }

                if (str[pos] == '(')
                {
                    chain = MemberChain.ParseBackward(source, pos - 1);
                    chain.getType(data, true);

                    if (chain.LastFunction == null)
                    {
                        return(null);
                    }
                    FunctionCall fc = new FunctionCall();
                    fc.m_func     = chain.LastFunction;
                    fc.ParamIndex = paramIndex;

                    fc.update();
                    return(fc);
                }
                break;
            }

            return(null);
        }
Esempio n. 10
0
        public Type getType(AutoCompleteData data, bool lastAsFuncion = false)
        {
            if (Elements.Count == 0)
            {
                return(null);
            }
            VariableManager variables = data.Variables;
            string          word      = Elements[0].Name;
            Type            t         = null;

            if (Elements[0].IsFunction || (Elements.Count == 1 && lastAsFuncion))
            {
                Function func = variables.getFunction(word);
                if (func != null)
                {
                    LastFunction = func;
                    t            = func.ReturnType;
                }
            }
            else
            {
                Variable var = variables.getVariable(word, Elements[0].StartPos);
                if (var != null)
                {
                    IsNamespace = var.IsNamespace;
                    t           = var.Type;
                }
                else
                {
                    t = data.Types.get(word);
                    if (t.OuterClass != null)
                    {
                        return(null);
                    }
                    IsNamespace = true;
                }
            }

            if (t == null)
            {
                return(null);
            }

            if (Elements.Count == 1)
            {
                return(t);
            }

            for (int i = 1; i < Elements.Count - 1; i++)
            {
                if (t == null)
                {
                    return(null);
                }
                string name = Elements[i].Name;

                if (Elements[i].IsFunction)
                {
                    Function f = t.getMethod(name);
                    if (f != null)
                    {
                        IsNamespace = false;
                        t           = f.ReturnType;
                    }
                    else
                    {
                        return(null);
                    }
                }
                else
                {
                    Variable v = t.getMember(name);
                    if (v != null)
                    {
                        IsNamespace = v.IsNamespace;
                        t           = v.Type;
                    }
                    else
                    {
                        Type c = t.getClass(name);
                        if (t != null)
                        {
                            IsNamespace = true;
                            t           = c;
                        }
                        else
                        {
                            return(null);
                        }
                    }
                }
            }
            if (t == null)
            {
                return(null);
            }
            //last
            string last = getLastElement();

            if (lastAsFuncion || Elements[Elements.Count - 1].IsFunction)
            {
                IsNamespace = false;
                Function f = t.getMethod(last);
                if (f != null)
                {
                    LastFunction = f;
                    return(f.ReturnType);
                }
                else
                {
                    return(t);
                }
            }
            else
            {
                Variable v = t.getMember(last);
                if (v != null)
                {
                    IsNamespace = v.IsNamespace;
                    return(v.Type);
                }
                else
                {
                    Type c = t.getClass(last);
                    if (c != null)
                    {
                        IsNamespace = true;
                        return(c);
                    }
                    else
                    {
                        return(t);
                    }
                }
            }
        }
Esempio n. 11
0
 public VariableManager(VariableManager parent)
 {
     m_variables = new Dictionary<string, Variable>();
     m_globalFunctions = new Dictionary<string, Function>();
     m_parent = parent;
 }
Esempio n. 12
0
 public VariableManager(VariableManager parent)
 {
     m_variables       = new Dictionary <string, Variable>();
     m_globalFunctions = new Dictionary <string, Function>();
     m_parent          = parent;
 }