Ejemplo n.º 1
0
        private DocumentRange GetDocumentRange(INumericValue firstValue, INumericValue lastValue)
        {
            var startOffset = firstValue.GetDocumentStartOffset();
            var endOffset   = lastValue.GetDocumentEndOffset();

            return(OldMsBuildWorkarounds.CreateDocumentRange(startOffset, endOffset));
        }
Ejemplo n.º 2
0
            protected override void CommitHighlighters(DaemonCommitContext context)
            {
                var instance = HighlightingSettingsManager.Instance;

                foreach (var highlightingInfo in context.HighlightingsToAdd)
                {
                    var severity = instance.GetSeverity(highlightingInfo.Highlighting, SourceFile, Solution, ContextBoundSettingsStore);
                    if (OldMsBuildWorkarounds.RangeContains(highlightingInfo.Range, myCaretRange) && severity == Severity.INFO)
                    {
                        if (highlightingInfo.Highlighting is CSharpIdentifierHighlighting)
                        {
                            HighlightingInfo = highlightingInfo;
                        }
                        break;
                    }
                }
            }
Ejemplo n.º 3
0
        public override ISpecificCodeCompletionContext GetCompletionContext(CodeCompletionContext context)
        {
            if (!(context.File is IShaderLabFile file))
            {
                return(null);
            }

            if (context.CodeCompletionType == CodeCompletionType.BasicCompletion &&
                !IsIntellisenseEnabled(context))
            {
                return(null);
            }

            var unterminatedContext = new ShaderLabReparsedCompletionContext(file, context.SelectedTreeRange, "aa");

            unterminatedContext.Init();

            var referenceToComplete = unterminatedContext.Reference;
            var elementToComplete   = unterminatedContext.TreeNode;

            if (elementToComplete == null)
            {
                return(null);
            }

            var referenceRange         = referenceToComplete?.GetTreeTextRange() ?? GetElementRange(elementToComplete);
            var referenceDocumentRange = unterminatedContext.ToDocumentRange(referenceRange);

            if (!referenceDocumentRange.IsValid())
            {
                return(null);
            }

            if (!OldMsBuildWorkarounds.RangeContains(referenceDocumentRange, context.EffectiveCaretDocumentOffset))
            {
                return(null);
            }

            var ranges = GetTextLookupRanges(context, referenceDocumentRange);

            return(new ShaderLabCodeCompletionContext(context, unterminatedContext, ranges));
        }
Ejemplo n.º 4
0
        private void RemoveFromTextualOccurrences(IRenameRefactoring executer, IFieldDeclaration fieldDeclaration)
        {
            if (!(executer.Workflow is RenameWorkflow workflow))
            {
                return;
            }

            var attributes = fieldDeclaration.Attributes;

            if (attributes.Count == 0)
            {
                return;
            }

            var attribute            = attributes[0];
            var attributeSectionList = AttributeSectionListNavigator.GetByAttribute(attribute);

            if (attributeSectionList == null)
            {
                return;
            }

            var attributesRange = attributeSectionList.GetDocumentRange();

            foreach (var occurrence in workflow.DataModel.ActualOccurrences ?? EmptyList <TextOccurrenceRenameMarker> .InstanceList)
            {
                if (!occurrence.Included)
                {
                    continue;
                }


                var occurrenceRange = occurrence.Marker.DocumentRange;
                if (OldMsBuildWorkarounds.RangeContains(attributesRange, occurrenceRange))
                {
                    occurrence.Included = false;
                    break;
                }
            }
        }
Ejemplo n.º 5
0
        private static void RemoveFromTextualOccurrences(IRenameRefactoring executer, DocumentRange handledRange)
        {
            if (!(executer.Workflow is RenameWorkflow workflow))
            {
                return;
            }

            foreach (var occurrence in workflow.DataModel.ActualOccurrences ?? EmptyList <TextOccurrenceRenameMarker> .InstanceList)
            {
                if (!occurrence.Included)
                {
                    continue;
                }

                var occurrenceRange = occurrence.Marker.DocumentRange;
                if (OldMsBuildWorkarounds.RangeContains(handledRange, occurrenceRange))
                {
                    occurrence.Included = false;
                    break;
                }
            }
        }
Ejemplo n.º 6
0
        public static DocumentRange GetParametersHighlightingRange(IMethodDeclaration methodDeclaration)
        {
            var nameRange = methodDeclaration.GetNameDocumentRange();

            if (!nameRange.IsValid())
            {
                return(DocumentRange.InvalidRange);
            }

            var @params = methodDeclaration.Params;

            if (@params == null)
            {
                return(nameRange);
            }

            var paramsRange = @params.GetDocumentRange();

            if (!paramsRange.IsValid())
            {
                return(nameRange);
            }

            if (!paramsRange.IsEmpty)
            {
                return(paramsRange);
            }

            var lparRange   = methodDeclaration.LPar?.GetDocumentRange();
            var rparRange   = methodDeclaration.RPar?.GetDocumentRange();
            var startOffset = lparRange != null && lparRange.Value.IsValid()
                ? lparRange.Value
                : paramsRange;
            var endOffset = rparRange != null && rparRange.Value.IsValid()
                ? rparRange.Value
                : paramsRange;

            return(OldMsBuildWorkarounds.CreateDocumentRange(startOffset.StartOffset, endOffset.EndOffset));
        }