internal bool CanInvokeRename(
                ISyntaxFactsService syntaxFactsService,
                IRenameTrackingLanguageHeuristicsService languageHeuristicsService,
                bool isSmartTagCheck,
                bool waitForResult,
                CancellationToken cancellationToken)
            {
                if (IsRenamableIdentifier(_isRenamableIdentifierTask, waitForResult, cancellationToken))
                {
                    var isRenamingDeclaration = _isRenamableIdentifierTask.Result == TriggerIdentifierKind.RenamableDeclaration;
                    var newName    = TrackingSpan.GetText(TrackingSpan.TextBuffer.CurrentSnapshot);
                    var comparison = isRenamingDeclaration || syntaxFactsService.IsCaseSensitive ? StringComparison.Ordinal : StringComparison.OrdinalIgnoreCase;

                    if (!string.Equals(OriginalName, newName, comparison) &&
                        syntaxFactsService.IsValidIdentifier(newName) &&
                        languageHeuristicsService.IsIdentifierValidForRenameTracking(newName))
                    {
                        // At this point, we want to allow renaming if the user invoked Ctrl+. explicitly, but we
                        // want to avoid showing a smart tag if we're renaming a reference that binds to an existing
                        // symbol.
                        if (!isSmartTagCheck || isRenamingDeclaration || !NewIdentifierDefinitelyBindsToReference())
                        {
                            return(true);
                        }
                    }
                }

                return(false);
            }
Beispiel #2
0
 internal Definition(string documentation, DefinitionKind kind, Scope scope, TrackingSpan span)
 {
     this.Kind           = kind;
     this.Documentation  = documentation;
     this.Scope          = scope;
     this.DefinitionSpan = span;
 }
Beispiel #3
0
        public void Invoke(CancellationToken cancellationToken)
        {
            // Count the use of the tag
            HugTags.I.Count(Item);

            // Surround the selection with the tags
            TrackingSpan.TextBuffer.Replace(TrackingSpan.GetSpan(Snapshot), Tagged);
        }
Beispiel #4
0
        public bool Contains(Snapshot snapshot, TrackingSpan span)
        {
            if (this.isBuiltIn)
            {
                return(true);
            }

            return(this.Contains(snapshot, span?.GetSpan(snapshot)));
        }
Beispiel #5
0
        public static ITrackingSpan ToITrackingSpan(this TrackingSpan span)
        {
            VSTrackingSpan trackingSpan = span as VSTrackingSpan;

            if (trackingSpan == null)
            {
                throw new ArgumentException($"{nameof(span)} must be a VSTrackingSpan and not null");
            }

            return(trackingSpan.TrackingSpan);
        }
        internal void Advance(ITextVersion toVersion)
        {
            if (TrackingSpan != null)
            {
                TrackingSpan.GetSpan(toVersion);
            }

            foreach (var child in Children)
            {
                child.Advance(toVersion);
            }
        }
Beispiel #7
0
        internal SyntaxToken(SyntaxTree tree, SyntaxType type, TrackingSpan span, string text, SyntaxTrivia leadingTrivia, SyntaxTrivia trailingTrivia, Snapshot snapshot, bool isMissing = false) : base(tree, type, span)
        {
            this.Text           = text;
            this.LeadingTrivia  = leadingTrivia;
            this.TrailingTrivia = trailingTrivia;

            int start = this.HasLeadingTrivia ? this.LeadingTrivia.Span.GetSpan(snapshot).Start : this.Span.GetSpan(snapshot).Start;
            int end   = this.HasTrailingTrivia ? this.TrailingTrivia.Span.GetSpan(snapshot).End : this.Span.GetSpan(snapshot).End;

            this.fullSpan  = snapshot.CreateTrackingSpan(GLSL.Text.Span.Create(start, end));
            this.IsMissing = isMissing;
        }
            internal void CheckNewIdentifier(StateMachine stateMachine, ITextSnapshot snapshot)
            {
                AssertIsForeground();

                _newIdentifierBindsTask = _isRenamableIdentifierTask.SafeContinueWithFromAsync(
                    async t => t.Result != TriggerIdentifierKind.NotRenamable &&
                    TriggerIdentifierKind.RenamableReference ==
                    await DetermineIfRenamableIdentifierAsync(
                        TrackingSpan.GetSpan(snapshot),
                        initialCheck: false).ConfigureAwait(false),
                    _cancellationToken,
                    TaskContinuationOptions.OnlyOnRanToCompletion,
                    TaskScheduler.Default);

                QueueUpdateToStateMachine(stateMachine, _newIdentifierBindsTask);
            }
Beispiel #9
0
        public GLSLSignature(Definition definition, TrackingSpan trackingSpan, Snapshot snapshot, ITextView textView, ISignatureHelpSession session)
        {
            GLSL.Text.Span span = trackingSpan.GetSpan(snapshot);

            this.ApplicableToSpan = snapshot.CreateTrackingSpan(GLSL.Text.Span.Create(span.Start, span.End - 1)).ToITrackingSpan();
            this.Content          = definition.ToString();
            this.Documentation    = definition.Documentation;
            this.Parameters       = new ReadOnlyCollection <IParameter>(definition.GetParameters(this));
            this.textView         = textView;
            this.session          = session;

            this.textView.TextBuffer.Changed    += this.TextBufferChanged;
            this.textView.Caret.PositionChanged += this.CaretPositionChanged;

            this.session.Dismissed += this.OnDismissed;

            this.ComputeCurrentParamter(this.textView.TextBuffer.CurrentSnapshot);
        }
Beispiel #10
0
        private SyntaxToken CreateToken(SyntaxType type, TrackingSpan span, bool isMissing = false)
        {
            if (type == SyntaxType.IdentifierToken)
            {
                if (isMissing)
                {
                    return(new IdentifierSyntax(this.tree, span, string.Empty, null, null, this.snapshot, isMissing));
                }

                return(new IdentifierSyntax(this.tree, span, this.CurrentToken.Text, this.CurrentToken.LeadingTrivia, this.CurrentToken.TrailingTrivia, this.snapshot, isMissing));
            }
            else
            {
                if (isMissing)
                {
                    return(new SyntaxToken(this.tree, type, span, string.Empty, null, null, this.snapshot, isMissing));
                }

                return(new SyntaxToken(this.tree, type, span, this.CurrentToken.Text, this.CurrentToken.LeadingTrivia, this.CurrentToken.TrailingTrivia, this.snapshot));
            }
        }
 public InterfaceBlockDefinition(IReadOnlyList <SyntaxType> typeQualifier, string typeName, string documentation, Scope scope, TrackingSpan span)
     : this(typeQualifier, typeName, documentation, null, scope, span)
 {
 }
Beispiel #12
0
 internal TypeNameSyntax(SyntaxTree tree, TrackingSpan span) : base(tree, SyntaxType.TypeName, span)
 {
 }
 public InterfaceBlockDefinition(IReadOnlyList <SyntaxType> typeQualifier, string typeName, string documentation, List <FieldDefinition> fields, Scope scope, TrackingSpan span)
     : base(ColoredString.Create(typeName, ColorType.TypeName), documentation, DefinitionKind.InterfaceBlock, scope, span)
 {
     this.TypeQualifiers = typeQualifier ?? new List <SyntaxType>();
     this.InternalFields = fields ?? new List <FieldDefinition>();
 }
 internal PrecisionDeclarationSyntax(SyntaxTree tree, TrackingSpan span) : base(tree, SyntaxType.PrecisionDeclaration, span)
 {
 }
Beispiel #15
0
 internal ConstantExpressionSyntax(SyntaxTree tree, TrackingSpan span) : base(tree, SyntaxType.ConstantExpression, span)
 {
 }
Beispiel #16
0
 internal TypeNameDefinition(string name, string documentation, Scope scope, TrackingSpan span)
     : base(ColoredString.Create(name, ColorType.TypeName), documentation, DefinitionKind.TypeName, scope, span)
 {
 }
Beispiel #17
0
 public ParameterDefinition(IReadOnlyList <SyntaxType> typeQualifier, TypeDefinition type, string identifier, string documentation, IReadOnlyList <ColoredString> arraySpecifiers, Scope scope, TrackingSpan span)
     : base(ColoredString.Create(identifier, ColorType.Parameter), documentation, DefinitionKind.Parameter, scope, span)
 {
     this.TypeQualifiers  = typeQualifier ?? new List <SyntaxType>();
     this.Type            = type;
     this.ArraySpecifiers = arraySpecifiers ?? new List <ColoredString>();
 }
Beispiel #18
0
 internal ConstructorSyntax(SyntaxTree tree, TrackingSpan span) : base(tree, SyntaxType.Constructor, span)
 {
 }
Beispiel #19
0
 internal WhileStatementSyntax(SyntaxTree tree, TrackingSpan span) : base(tree, SyntaxType.WhileStatement, span)
 {
 }
Beispiel #20
0
 internal InterpolationQualifierSyntax(SyntaxTree tree, TrackingSpan span) : base(tree, SyntaxType.InterpolationQualifier, span)
 {
 }
Beispiel #21
0
 protected ParameterDefinition(IReadOnlyList <SyntaxType> typeQualifier, TypeDefinition type, string identifier, string documentation, Scope scope, TrackingSpan span)
     : this(typeQualifier, type, identifier, documentation, new List <ColoredString>(), scope, span)
 {
 }
Beispiel #22
0
 internal StructDeclaratorSyntax(SyntaxTree tree, TrackingSpan span) : base(tree, SyntaxType.StructDeclarator, span)
 {
 }
Beispiel #23
0
 internal IfDefinedPreprocessorSyntax(SyntaxTree tree, TrackingSpan span) : base(tree, SyntaxType.IfDefinedPreprocessor, span)
 {
 }
 internal PrecisionQualifierSyntax(SyntaxTree tree, TrackingSpan span) : base(tree, SyntaxType.PrecisionQualifier, span)
 {
 }
Beispiel #25
0
 public MacroDefinition(string name, IReadOnlyList <ColoredString> parameters, IReadOnlyList <ColoredString> tokenString, string documentation, Scope scope, TrackingSpan span)
     : base(ColoredString.Create(name, ColorType.Macro), documentation, DefinitionKind.Macro, scope, span)
 {
     this.Parameters  = parameters ?? new List <ColoredString>();
     this.TokenString = tokenString ?? new List <ColoredString>();
 }
 internal ExpressionStatementSyntax(SyntaxTree tree, TrackingSpan span) : base(tree, SyntaxType.ExpressionStatement, span)
 {
 }
Beispiel #27
0
 internal ReturnTypeSyntax(SyntaxTree tree, TrackingSpan span) : base(tree, SyntaxType.ReturnType, span)
 {
 }
Beispiel #28
0
 internal TypeNameDefinition(string name, string documentation, List <FieldDefinition> fields, Scope scope, TrackingSpan span)
     : base(ColoredString.Create(name, ColorType.TypeName), documentation, DefinitionKind.TypeName, scope, span)
 {
     this.InternalFields = fields;
 }
Beispiel #29
0
 internal BlockSyntax(SyntaxTree tree, TrackingSpan span) : base(tree, SyntaxType.Block, span)
 {
 }
 internal PostfixArrayAccessSyntax(SyntaxTree tree, TrackingSpan span) : base(tree, SyntaxType.PostfixArrayAccess, span)
 {
 }