示例#1
0
        private void GotoDefinitionAtCursor()
        {
            if (_scope == null)
            {
                return;
            }

            var expressions = new List <ExpressionBase>();

            if (!_parsedContent.GetExpressionsForLine(expressions, CursorLine))
            {
                return;
            }

            var column = CursorColumn;

            foreach (var expression in expressions)
            {
                if (column < expression.Column || column > expression.EndColumn + 1)
                {
                    continue;
                }

                var functionCall = expression as FunctionCallExpression;
                if (functionCall != null)
                {
                    var function = _scope.GetFunction(functionCall.FunctionName.Name);
                    if (function != null && function.Line != 0)
                    {
                        GotoLine(function.Name.Line);
                        MoveCursorTo(function.Name.Line, function.Name.Column, MoveCursorFlags.None);
                        MoveCursorTo(function.Name.EndLine, function.Name.EndColumn + 1, MoveCursorFlags.Highlighting);
                    }

                    break;
                }

                var variableReference = expression as VariableExpression;
                if (variableReference != null)
                {
                    var variable = _scope.GetVariableDefinition(variableReference.Name);
                    if (variable != null && variable.Line != 0)
                    {
                        MoveCursorTo(variable.Line, variable.Column, MoveCursorFlags.None);
                        MoveCursorTo(variable.EndLine, variable.EndColumn + 1, MoveCursorFlags.Highlighting);
                    }

                    break;
                }
            }
        }