Esempio n. 1
0
        public static IEnumerable <(CppFileLocation Location, bool IsInclude)> GetCppFileLocations(
            IPsiSourceFile sourceFile)
        {
            var lexer = new ShaderLabLexerGenerated(sourceFile.Document.Buffer);

            lexer.Start();
            bool prevCGInclude = false;

            while (lexer.TokenType != null)
            {
                if (lexer.TokenType == ShaderLabTokenType.CG_INCLUDE)
                {
                    prevCGInclude = true;
                }
                else if (lexer.TokenType == ShaderLabTokenType.CG_CONTENT)
                {
                    yield return(new CppFileLocation(sourceFile, new TextRange(lexer.TokenStart, lexer.TokenEnd)),
                                 prevCGInclude);

                    prevCGInclude = false;
                }
                else if (!lexer.TokenType.IsFiltered)
                {
                    prevCGInclude = false;
                }

                lexer.Advance();
            }
        }
        public static IEnumerable <(CppFileLocation Location, InjectedHlslProgramType ProgramType)> GetCppFileLocations(
            IPsiSourceFile sourceFile)
        {
            var lexer = new ShaderLabLexerGenerated(sourceFile.Document.Buffer);

            lexer.Start();
            while (lexer.TokenType != null)
            {
                var type = GetProgramType(lexer.TokenType);
                if (type != InjectedHlslProgramType.Uknown)
                {
                    lexer.Advance();
                    if (lexer.TokenType == null)
                    {
                        yield break;
                    }

                    yield return(new CppFileLocation(sourceFile, new TextRange(lexer.TokenStart, lexer.TokenEnd)), type);
                }
                lexer.Advance();
            }
        }