コード例 #1
0
ファイル: LuaASTWalker.cs プロジェクト: juntalis/intellua
 public void walk(LuaAST chunk, AutoCompleteData ac) {
     m_ac = ac;
     m_ac.Variables.scope = new Scope();
     m_currentScope = m_ac.Variables.scope;
     m_currentScope.StartPos = chunk.start;
     m_currentScope.EndPos = chunk.end;
     walkChuck(chunk);
 }
コード例 #2
0
ファイル: AutoCompleteData.cs プロジェクト: juntalis/intellua
        public AutoCompleteData(AutoCompleteData parent)
        {
            m_typeManager = new TypeManager(parent.Types);
            m_variableManager = new VariableManager(parent.Variables);
            m_keywords = new KeywordManager();
            addKeywords();

            init();
        }
コード例 #3
0
ファイル: FileParser.cs プロジェクト: juntalis/intellua
        public FileParser(IntelluaSource source)
        {
            m_source = source;
            result = new AutoCompleteData();
            result.setParent(source.m_intellua.AutoCompleteData.getParent());
            //result.Variables.scope = source.m_intellua.parseScope(0, source.m_intellua.Lines.Count - 1);

            m_lastCheckTime = System.DateTime.Now;
            if (source.FilePath.Length != 0)
            {
                m_lastWriteTime = System.IO.File.GetLastWriteTime(m_source.FilePath);
            }
            m_required[source.FilePath] = 0;
        }
コード例 #4
0
ファイル: Intellua.cs プロジェクト: juntalis/intellua
        public Intellua()
        {
            

            this.CallTipClick += new System.EventHandler<ScintillaNET.CallTipClickEventArgs>(this.intellua_CallTipClick);
            this.CharAdded += new System.EventHandler<ScintillaNET.CharAddedEventArgs>(this.intellua_CharAdded);
            this.TextDeleted += new System.EventHandler<ScintillaNET.TextModifiedEventArgs>(this.intellua_TextDeleted);
            this.TextInserted += new System.EventHandler<ScintillaNET.TextModifiedEventArgs>(this.intellua_TextInserted);
            this.SelectionChanged += new EventHandler(this.Intellua_SelectionChanged);

            m_tooltip = new ToolTip(this);
            m_autoCompleteData = new AutoCompleteData();

            ScintillaNET.Configuration.Configuration config =
                new ScintillaNET.Configuration.Configuration(Assembly.GetExecutingAssembly().GetManifestResourceStream("Intellua.ScintillaNET.xml"),
                    "lua", true);
            ConfigurationManager.Language = "lua";
            ConfigurationManager.Configure(config);
            Folding.IsEnabled = true;
            /*Margins[0].Width = 20;
            Margins[1].Width = 20;
            Margins[2].Width = 20;*/
            AutoComplete.IsCaseSensitive = false;
            AutoComplete.AutoHide = false;
            //Indentation.ShowGuides = true;

            List<Bitmap> list = new List<Bitmap>();
            Assembly asm = Assembly.GetExecutingAssembly();
            Stream str;
            str = asm.GetManifestResourceStream("Intellua.member.png");
            list.Add(new Bitmap(str));
            str = asm.GetManifestResourceStream("Intellua.method.png");
            list.Add(new Bitmap(str));
            str = asm.GetManifestResourceStream("Intellua.function.png");
            list.Add(new Bitmap(str));
            str = asm.GetManifestResourceStream("Intellua.type.png");
            list.Add(new Bitmap(str));
            AutoComplete.RegisterImages(list);

            m_source = new IntelluaSource(this);
        }
コード例 #5
0
ファイル: Intellua.cs プロジェクト: juntalis/intellua
 private void parseFileDone(object sender, System.ComponentModel.RunWorkerCompletedEventArgs e)
 {
     FileParserResult rst = e.Result as FileParserResult;
     m_autoCompleteData = rst.result;
     setStatus(rst.msg);
     if (m_parsePending)
     {
         m_parsePending = false;
         parseFile();
     }
 }
コード例 #6
0
ファイル: Intellua.cs プロジェクト: juntalis/intellua
 public void setParent(AutoCompleteData parent)
 {
     m_autoCompleteData.setParent(parent);
 }
コード例 #7
0
ファイル: MemberChain.cs プロジェクト: juntalis/intellua
        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;
                    }
                }
            }
        }
コード例 #8
0
ファイル: DeclParser.cs プロジェクト: juntalis/intellua
        public void apply(AutoCompleteData ac)
        {
            if (m_declarations == null) return;

            foreach (Decl.Class c in m_declarations.Classes)
            {
                c.registerClass(ac);
            }

            foreach (Decl.Class c in m_declarations.Classes)
            {
                c.apply(ac);
            }

            foreach (Decl.Variable v in m_declarations.Variables)
            {
                v.apply(ac, null);
            }

            foreach (Decl.Function v in m_declarations.Functions)
            {
                v.apply(ac, null);
            }
        }
コード例 #9
0
ファイル: DoxygenXMLParser.cs プロジェクト: juntalis/intellua
        // Public Methods (1) 

        public static AutoCompleteData Parse(string filename)
        {
            XDocument doc = XDocument.Load(AppDomain.CurrentDomain.BaseDirectory + filename);
            AutoCompleteData autoCompleteData = new AutoCompleteData();
            //scan all classes first.
            foreach (XElement node in doc.Descendants("compounddef"))
            {
                if (node.Attribute("kind").Value == "struct") {
                    node.Attribute("kind").Value = "class";
                }

                if (node.Attribute("kind").Value == "class" || node.Attribute("kind").Value == "namespace")
                {
                    string name = node.Element("compoundname").Value;
                    string id = node.Attribute("id").Value;

                    if (name.Contains(':'))
                    {
                        int pos = name.LastIndexOf(':');
                        name = name.Substring(pos + 1);
                    }

                    Type t = new Type(id);
                    t.DisplayName = name;

                    //System.Diagnostics.Debug.Print("Type added: " + name);
                    if (name.StartsWith("__"))
                    {
                        int pos = name.LastIndexOf('_');
                        t.DisplayName = name.Substring(pos + 1).ToLower();
                        t.HideDeclare = true;
                    }
                    autoCompleteData.Types.add(t);
                }
            }
            //scan enums
            foreach (XElement node in doc.Descendants("memberdef"))
            {
                if (node.Attribute("kind").Value == "enum")
                {
                    string name = node.Element("name").Value;
                    string id = node.Attribute("id").Value;

                    Type t = new Type(id);
                    t.DisplayName = "enum " + name;

                    //System.Diagnostics.Debug.Print("Enum added: " + name);
                    autoCompleteData.Types.add(t);
                }
            }

            //set outer class for inner class
            foreach (XElement node in doc.Descendants("compounddef"))
            {
                if (node.Attribute("kind").Value == "class" || node.Attribute("kind").Value == "namespace")
                {
                    string id = node.Attribute("id").Value;
                    Type t = autoCompleteData.Types.get(id);

                    foreach (XElement inner in node.Descendants("innerclass"))
                    {
                        if (inner.Attribute("refid") != null)
                        {
                            Type i = autoCompleteData.Types.get(inner.Attribute("refid").Value);
                            i.OuterClass = t;
                            t.addClass(i);
                        }
                    }
                }
            }

            //add a static variable for access to classes
            /*
            foreach (XElement node in doc.Descendants("compounddef"))
            {
                if (node.Attribute("kind").Value == "class" || node.Attribute("kind").Value == "namespace")
                {
                    string id = node.Attribute("id").Value;
                    Type t = autoCompleteData.Types.get(id);

                    Variable var = new Variable(t.DisplayName);
                    var.IsNamespace = true;
                    var.IsStatic = true;
                    var.Type = t;
                    var.Desc = node.Element("briefdescription").Value;

                    if (t.OuterClass == null)
                    {
                        autoCompleteData.Variables.add(var);
                    }
                    else
                    {
                        t.OuterClass.addMember(var);
                    }
                }
            }*/

            //add member and methods for classes
            foreach (XElement node in doc.Descendants("compounddef"))
            {
                if (node.Attribute("kind").Value == "class" || node.Attribute("kind").Value == "namespace")
                {
                    bool isNamespace = node.Attribute("kind").Value == "namespace";

                    string id = node.Attribute("id").Value;
                    Type t = autoCompleteData.Types.get(id);
                    string name = t.DisplayName;
                    if (node.Element("basecompoundref") != null)
                    {
                        t.Base = autoCompleteData.Types.get(node.Element("basecompoundref").Attribute("refid").Value);
                    }

                    foreach (XElement member in node.Descendants("memberdef"))
                    {
                        if (member.Attribute("kind").Value == "variable")
                        {
                            string memberName = member.Element("name").Value;
                            string memberType = member.Element("type").Value;
                            string memberTypeID = null;
                            if (member.Element("type").Element("ref") != null)
                                memberTypeID = member.Element("type").Element("ref").Attribute("refid").Value;
                            else {
                                memberTypeID = memberType;
                            }
                            Type mt = autoCompleteData.Types.get(memberTypeID);
                            Variable var = new Variable(memberName);
                            var.Type = mt;
                            var.Desc = member.Element("briefdescription").Value;

                            if (member.Attribute("static").Value == "yes")
                            {
                                var.IsStatic = true;
                            }

                            if (isNamespace) var.IsStatic = true;
                            t.addMember(var);
                            //System.Diagnostics.Debug.Print("Member added: " + memberType + " " + name + "::" + memberName);
                        }
                        else if (member.Attribute("kind").Value == "function")
                        {
                            string memberName = member.Element("name").Value;
                            string memberType = member.Element("type").Value;
                            string memberTypeID = null;
                            if (member.Element("type").Element("ref") != null)
                                memberTypeID = member.Element("type").Element("ref").Attribute("refid").Value;
                            else memberTypeID = memberType;

                            Function f = new Function(memberName);
                            f.Param.Add(member.Element("argsstring").Value);
                            f.Desc.Add(member.Element("briefdescription").Value);
                            if (memberName == name)
                            {
                                f.ReturnType = t;
                                f.Static = true;
                                if (t.OuterClass == null)
                                    autoCompleteData.Variables.add(f);
                                else t.OuterClass.addMethod(f);

                                //System.Diagnostics.Debug.Print("Constructor added: " + name + "::" + f.getName() + member.Element("argsstring").Value);
                            }
                            else
                            {
                                if (member.Attribute("static").Value == "yes")
                                {
                                    f.Static = true;
                                }
                                if (isNamespace) f.Static = true;
                                Type mt = autoCompleteData.Types.get(memberTypeID);

                                f.ReturnType = mt;

                                t.addMethod(f);
                                //System.Diagnostics.Debug.Print("Method added: " + memberType + " " + name + ":" + f.getName() + member.Element("argsstring").Value);
                            }
                        }
                        else if (member.Attribute("kind").Value == "enum")
                        {
                            string eid = member.Attribute("id").Value;
                            Type e = autoCompleteData.Types.get(eid);
                            foreach (XElement evalue in member.Descendants("enumvalue"))
                            {
                                Variable var = new Variable(evalue.Element("name").Value);
                                var.IsStatic = true;
                                var.Type = autoCompleteData.Types.NullType;
                                var.Class = e;
                                var.Desc = evalue.Element("briefdescription").Value;
                                t.addMember(var);
                            }
                        }
                    }
                }
                else if (node.Attribute("kind").Value == "file")
                {
                    foreach (XElement member in node.Descendants("memberdef"))
                    {
                        if (member.Attribute("kind").Value == "variable")
                        {
                            string memberName = member.Element("name").Value;
                            string memberType = member.Element("type").Value;
                            string memberTypeID = null;
                            if (member.Element("type").Element("ref") != null)
                                memberTypeID = member.Element("type").Element("ref").Attribute("refid").Value;
                            else memberTypeID = memberType;
                            Type mt = autoCompleteData.Types.get(memberTypeID);
                            Variable var = new Variable(memberName);
                            var.Type = mt;
                            var.IsStatic = true;
                            var.Desc = member.Element("briefdescription").Value;
                            autoCompleteData.Variables.add(var);
                            //System.Diagnostics.Debug.Print("Static variable added: " + memberType + " " + memberName);
                        }
                        else if (member.Attribute("kind").Value == "function")
                        {
                            string memberName = member.Element("name").Value;
                            string memberType = member.Element("type").Value;
                            string memberTypeID = null; ;
                            if (member.Element("type").Element("ref") != null)
                                memberTypeID = member.Element("type").Element("ref").Attribute("refid").Value;
                            else memberTypeID = memberType;
                            Type mt = autoCompleteData.Types.get(memberTypeID);
                            Function f = new Function(memberName);
                            f.Param.Add(member.Element("argsstring").Value);
                            f.ReturnType = mt;
                            f.Desc.Add(member.Element("briefdescription").Value);
                            f.Static = true;
                            autoCompleteData.Variables.add(f);
                            //System.Diagnostics.Debug.Print("Global function added: " + memberType + " " + f.getName() + member.Element("argsstring").Value);
                        }
                        else if (member.Attribute("kind").Value == "enum")
                        {
                            string eid = member.Attribute("id").Value;
                            Type e = autoCompleteData.Types.get(eid);
                            foreach (XElement evalue in member.Descendants("enumvalue"))
                            {
                                Variable var = new Variable(evalue.Element("name").Value);
                                var.IsStatic = true;
                                var.Type = autoCompleteData.Types.NullType;
                                var.Class = e;
                                var.Desc = evalue.Element("briefdescription").Value;
                                autoCompleteData.Variables.add(var);
                            }
                        }
                    }
                }
            }
            autoCompleteData.Variables.removeEmptyNamespace();
            autoCompleteData.Types.removeEmptyNamespace();

            return autoCompleteData;
        }
コード例 #10
0
ファイル: FunctionCall.cs プロジェクト: juntalis/intellua
        // 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;
        }
コード例 #11
0
ファイル: AutoCompleteData.cs プロジェクト: juntalis/intellua
 public void setParent(AutoCompleteData parent)
 {
     m_parent = parent;
     if (m_parent != null)
     {
         m_typeManager.Parent = parent.Types;
         m_variableManager.Parent = parent.Variables;
     }
     else
     {
         m_typeManager.Parent = null;
         m_variableManager.Parent = null;
     }
 }