Ejemplo n.º 1
0
        private void RefreshDeclarationsForRequest(ParseRequest request, LuaParser parser, bool addLocals)
        {
            luaFileDeclarationProviders[request.FileName] = new TableDeclarationProvider();
            // Create an AST declaration parser to add the declarations from the parsed chunk
            var declarationParser = new AstDeclarationParser(luaFileDeclarationProviders[request.FileName]);

            // Parse the AST and add the declaarations
            if(addLocals)
                declarationParser.AddChunk(parser.Chunk, request.Line, request.Col);
            else
                declarationParser.AddChunk(parser.Chunk);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Adds the lua declarations.
        /// </summary>
        /// <param name="luaFile">The lua file.</param>
        private void AddLuaDeclarations(string luaFile)
        {
            // Make sure file exists and skip the one that triggered the request
            if (File.Exists(luaFile))
            {
                LuaParser parser;

                // Try to get a source for the file
                Source fileSource = (Source)GetSource(luaFile);

                if (fileSource != null)
                    parser = LanguageService.CreateParser(fileSource);
                else
                    parser = LanguageService.CreateParser(File.ReadAllText(luaFile));

                // Trigger the parse
                bool yyresult = parser.Parse();

                if (yyresult)
                {
                    luaFileDeclarationProviders[luaFile] = new TableDeclarationProvider();
                    AstDeclarationParser declarationParser = new AstDeclarationParser(luaFileDeclarationProviders[luaFile]);
                    // Parse the AST and add the declaarations
                    declarationParser.AddChunk(parser.Chunk);
                }
            }
        }