public static bool IsVariable(this GLSLTokenTypes type) =>
 type == GLSLTokenTypes.InputVariable ||
 type == GLSLTokenTypes.OutputVariable ||
 type == GLSLTokenTypes.UniformVariable ||
 type == GLSLTokenTypes.BufferVariable ||
 type == GLSLTokenTypes.SharedVariable ||
 type == GLSLTokenTypes.BuiltInVariable ||
 type == GLSLTokenTypes.LocalVariable ||
 type == GLSLTokenTypes.ParameterVariable;
示例#2
0
        private void ParseContentForTokens(string contents, GLSLTokenTypes glslType)
        {
            var lines = new List <string>();

            foreach (var line in Regex.Split(contents, Environment.NewLine))
            {
                if (string.IsNullOrWhiteSpace(line))
                {
                    if (lines.Count > 0)
                    {
                        var    names       = lines.First().Split(',');
                        string description = null;

                        if (lines.Count > 1)
                        {
                            description = string.Join(Environment.NewLine, lines.Skip(1));
                        }

                        foreach (var name in names)
                        {
                            var tokenInfo = new TokenInfo(name, glslType)
                            {
                                Definition = description
                            };

                            _infoByToken[name] = tokenInfo;
                        }

                        lines.Clear();
                    }
                }
                else
                {
                    lines.Add(line);
                }
            }
        }
        public object GetQuickInfo(SnapshotSpan span, GLSLTokenTypes tokenType)
        {
            string token = span.GetText();

            switch (tokenType)
            {
            case GLSLTokenTypes.Keyword:
                return(_keywordTagger.GetQuickInfo(token));

            case GLSLTokenTypes.Type:
                return(_typeTagger.GetQuickInfo(token));

            case GLSLTokenTypes.BuiltInVariable:
            case GLSLTokenTypes.InputVariable:
            case GLSLTokenTypes.OutputVariable:
            case GLSLTokenTypes.UniformVariable:
            case GLSLTokenTypes.BufferVariable:
            case GLSLTokenTypes.SharedVariable:
            case GLSLTokenTypes.LocalVariable:
            case GLSLTokenTypes.ParameterVariable:
                var scope = _bracketTagger.GetScope(span);
                return(_variableTagger.GetQuickInfo(token, scope));

            case GLSLTokenTypes.BuiltInFunction:
            case GLSLTokenTypes.Function:
                return(_functionTagger.GetQuickInfo(token));

            case GLSLTokenTypes.BuiltInConstant:
                return(_constantTagger.GetQuickInfo(token));

            case GLSLTokenTypes.Directive:
                return(_directiveTagger.GetQuickInfo(token));
            }

            return(null);
        }
        public static string GetDisplayName(this GLSLTokenTypes type)
        {
            switch (type)
            {
            case GLSLTokenTypes.Directive:
                return("Directive");

            case GLSLTokenTypes.Comment:
                return("Comment");

            case GLSLTokenTypes.Keyword:
                return("Keyword");

            case GLSLTokenTypes.Type:
                return("Type");

            case GLSLTokenTypes.InputVariable:
                return("Input Variable");

            case GLSLTokenTypes.OutputVariable:
                return("Output Variable");

            case GLSLTokenTypes.UniformVariable:
                return("Uniform Variable");

            case GLSLTokenTypes.BufferVariable:
                return("Buffer Variable");

            case GLSLTokenTypes.SharedVariable:
                return("Shared Variable");

            case GLSLTokenTypes.BuiltInVariable:
                return("Built-In Variable");

            case GLSLTokenTypes.LocalVariable:
                return("Local Variable");

            case GLSLTokenTypes.ParameterVariable:
                return("Parameter Variable");

            case GLSLTokenTypes.Struct:
                return("Struct");

            case GLSLTokenTypes.IntegerConstant:
                return("Integer Constant");

            case GLSLTokenTypes.FloatingConstant:
                return("Floating Constant");

            case GLSLTokenTypes.BuiltInConstant:
                return("Built-In Constant");

            case GLSLTokenTypes.Function:
                return("Function");

            case GLSLTokenTypes.BuiltInFunction:
                return("Built-In Function");

            case GLSLTokenTypes.Operator:
                return("Operator");

            case GLSLTokenTypes.Semicolon:
                return("Semicolon");

            case GLSLTokenTypes.Parenthesis:
                return("Parenthesis");

            case GLSLTokenTypes.CurlyBracket:
                return("Curly Bracket");

            case GLSLTokenTypes.SquareBracket:
                return("Square Bracket");

            default:
                throw new NotImplementedException("Could not handle type " + type);
            }
        }
 public static bool IsPreprocessor(this GLSLTokenTypes type) =>
 type == GLSLTokenTypes.Directive ||
 type == GLSLTokenTypes.Comment;
 public static bool IsBuiltIn(this GLSLTokenTypes type) =>
 type == GLSLTokenTypes.BuiltInConstant ||
 type == GLSLTokenTypes.BuiltInFunction ||
 type == GLSLTokenTypes.BuiltInVariable;
 public static bool IsFunction(this GLSLTokenTypes type) =>
 type == GLSLTokenTypes.Function ||
 type == GLSLTokenTypes.BuiltInFunction;
示例#8
0
 public GLSLClassifierTag(GLSLTokenTypes type) => TokenType = type;
示例#9
0
 public GLSLOutlineTag(GLSLTokenTypes type, string collapseText = COLLAPSE_TEXT, string collapseHint = COLLAPSE_HINT)
 {
     TokenType = type;
     RegionTag = new OutliningRegionTag(false, false, collapseText, collapseHint);
 }
 public TokenInfo(string token, GLSLTokenTypes glslType)
 {
     Token    = token;
     GLSLType = glslType;
 }
 public FunctionSet(string contents, GLSLTokenTypes glslType)
 {
     ParseContentForTokens(contents, glslType);
 }
示例#12
0
        public TokenTagCollection AddToken(SnapshotSpan span, Scope scope, string variableType, GLSLTokenTypes tokenType)
        {
            var tokenTags = new TokenTagCollection(span)
            {
                ClassifierTagSpan = new TagSpan <GLSLClassifierTag>(span, new GLSLClassifierTag(tokenType))
            };

            // TODO - We need to check the span to ensure that this is a valid variable name
            // If not, we need to mark it as an error

            _variableInfos.Add(new VariableInfo(span, scope, variableType, tokenType));

            return(tokenTags);
        }
 public FunctionInfo(string token, GLSLTokenTypes glslType) : base(token, glslType)
 {
 }
示例#14
0
 public VariableInfo(SnapshotSpan span, Scope scope, string variableType, GLSLTokenTypes glslType) : base(span.GetText(), glslType)
 {
     DefinitionSpan = span;
     Scope          = scope;
     VariableType   = variableType;
 }
 public GLSLHighlightTag(GLSLTokenTypes type) : base("MarkerFormatDefinition/HighlightWordFormatDefinition")
 {
     TokenType = type;
 }
 public static bool IsConstant(this GLSLTokenTypes type) =>
 type == GLSLTokenTypes.IntegerConstant ||
 type == GLSLTokenTypes.FloatingConstant ||
 type == GLSLTokenTypes.BuiltInConstant;
        private void ParseContentForTokens(string contents, GLSLTokenTypes glslType)
        {
            var lines = new List <string>();

            foreach (var line in Regex.Split(contents, Environment.NewLine))
            {
                if (string.IsNullOrWhiteSpace(line))
                {
                    if (lines.Count > 0)
                    {
                        var match = Regex.Match(lines.First(),
                                                @"^(?<returnType>[a-zA-Z0-9]+) (?<name>[a-zA-Z0-9]+) \(((?<parameterType>[a-zA-Z0-9]+) (?<parameterName>[a-zA-Z_0-9]+)(, )?)*\)( )*$");

                        if (match.Success)
                        {
                            var returnType = match.Groups["returnType"].Value;
                            var name       = match.Groups["name"].Value;

                            string definition = null;

                            if (lines.Count > 1)
                            {
                                definition = string.Join(Environment.NewLine, lines.Skip(1));
                            }

                            if (!_infoByToken.ContainsKey(name))
                            {
                                _infoByToken[name] = new FunctionInfo(name, glslType)
                                {
                                    Definition = definition
                                };
                            }

                            var functionOverload = new FunctionOverload(returnType)
                            {
                                Documentation = definition
                            };

                            if (match.Groups["parameterType"].Success && match.Groups["parameterName"].Success)
                            {
                                for (var i = 0; i < match.Groups["parameterType"].Captures.Count && i < match.Groups["parameterName"].Captures.Count; i++)
                                {
                                    var parameterType = match.Groups["parameterType"].Captures[i].Value;
                                    var parameterName = match.Groups["parameterName"].Captures[i].Value;

                                    functionOverload.Parameters.Add(new ParameterInfo(parameterName, parameterType));
                                }
                            }

                            _infoByToken[name].Overloads.Add(functionOverload);
                        }

                        lines.Clear();
                    }
                }
                else
                {
                    lines.Add(line);
                }
            }
        }