Beispiel #1
0
        public void FindResults(string relationshipName,
                                IPeekResultCollection resultCollection,
                                CancellationToken cancellationToken,
                                IFindPeekResultsCallback callback)
        {
            if (relationshipName == PredefinedPeekRelationships.Definitions.Name)
            {
                using (var displayInfo = new PeekResultDisplayInfo(
                           label: _peekItem.DisplayName,
                           labelTooltip: _peekItem.FileName,
                           title: Path.GetFileName(_peekItem.FileName),
                           titleTooltip: _peekItem.FileName)) {
                    var result = _peekItem.PeekResultFactory.Create
                                 (
                        displayInfo,
                        _peekItem.FileName,
                        new Span(_peekItem.DefinitionNode.Start, _peekItem.DefinitionNode.Length),
                        _peekItem.DefinitionNode.Start,
                        false
                                 );

                    resultCollection.Add(result);
                    callback.ReportProgress(1);
                }
            }
        }
        public void FindResults(string relationshipName,
                                IPeekResultCollection resultCollection,
                                CancellationToken cancellationToken,
                                IFindPeekResultsCallback callback) {
            if (relationshipName == PredefinedPeekRelationships.Definitions.Name) {

                using (var displayInfo = new PeekResultDisplayInfo(
                    label: _peekItem.DisplayName,
                    labelTooltip: _peekItem.FileName,
                    title: Path.GetFileName(_peekItem.FileName),
                    titleTooltip: _peekItem.FileName)) {
                    var result = _peekItem.PeekResultFactory.Create
                    (
                        displayInfo,
                        _peekItem.FileName,
                        new Span(_peekItem.DefinitionNode.Start, _peekItem.DefinitionNode.Length),
                        _peekItem.DefinitionNode.Start,
                        false
                    );

                    resultCollection.Add(result);
                    callback.ReportProgress(1);
                }
            }
        }
        public void FindResults(string relationshipName, IPeekResultCollection resultCollection, CancellationToken cancellationToken, IFindPeekResultsCallback callback)
        {
            if (relationshipName != PredefinedPeekRelationships.Definitions.Name)
            {
                return;
            }

            RuleSet rule;
            string file = FindRuleSetInFile(new[] { ".less", ".scss", ".css" }, peekableItem._className, out rule);

            if (rule == null)
            {
                callback.ReportProgress(1);
                return;
            }

            using (var displayInfo = new PeekResultDisplayInfo(label: peekableItem._className, labelTooltip: file, title: Path.GetFileName(file), titleTooltip: file))
            {
                var result = peekableItem._peekResultFactory.Create
                (
                    displayInfo,
                    file,
                    new Span(rule.Start, rule.Length),
                    rule.Start,
                    false
                );

                resultCollection.Add(result);
                callback.ReportProgress(1);
            }
        }
Beispiel #4
0
        public void FindResults(string relationshipName, IPeekResultCollection resultCollection, CancellationToken cancellationToken, IFindPeekResultsCallback callback)
        {
            if (relationshipName != PredefinedPeekRelationships.Definitions.Name)
            {
                return;
            }

            RuleSet rule;
            string  file = FindRuleSetInFile(new[] { ".less", ".scss", ".css" }, peekableItem._id, out rule);

            if (rule == null)
            {
                callback.ReportProgress(1);
                return;
            }

            using (var displayInfo = new PeekResultDisplayInfo(label: peekableItem._id, labelTooltip: file, title: Path.GetFileName(file), titleTooltip: file))
            {
                var result = peekableItem._peekResultFactory.Create
                             (
                    displayInfo,
                    file,
                    new Span(rule.Start, rule.Length),
                    rule.Start,
                    false
                             );

                resultCollection.Add(result);
                callback.ReportProgress(1);
            }
        }
Beispiel #5
0
 public void FindResults(string relationshipName, IPeekResultCollection resultCollection,
                         CancellationToken cancellationToken, IFindPeekResultsCallback callback)
 {
     if (relationshipName == _relName)
     {
         resultCollection.Add(new RotPeekResult(_expandedTactic));
     }
 }
            public void FindResults(string relationshipName, IPeekResultCollection resultCollection, CancellationToken cancellationToken, IFindPeekResultsCallback callback)
            {
                if (relationshipName != PredefinedPeekRelationships.Definitions.Name)
                {
                    return;
                }

                // Note: this is called on a background thread, but we must block the thread since the API doesn't support proper asynchrony.
                var workspace   = _peekableItem._workspace;
                var solution    = workspace.CurrentSolution;
                var project     = solution.GetProject(_peekableItem._projectId);
                var compilation = project.GetCompilationAsync(cancellationToken).WaitAndGetResult_CanCallOnBackground(cancellationToken);

                var symbol = _peekableItem._symbolKey.Resolve(compilation, ignoreAssemblyKey: true, cancellationToken: cancellationToken).Symbol;

                if (symbol == null)
                {
                    callback.ReportFailure(new Exception(EditorFeaturesResources.No_information_found));
                    return;
                }

                var sourceLocations = symbol.Locations.Where(l => l.IsInSource).ToList();

                if (!sourceLocations.Any())
                {
                    // It's a symbol from metadata, so we want to go produce it from metadata
                    var options              = _peekableItem._globalOptions.GetMetadataAsSourceOptions();
                    var declarationFile      = _peekableItem._metadataAsSourceFileService.GetGeneratedFileAsync(project, symbol, signaturesOnly: true, options, cancellationToken).WaitAndGetResult_CanCallOnBackground(cancellationToken);
                    var peekDisplayInfo      = new PeekResultDisplayInfo(declarationFile.DocumentTitle, declarationFile.DocumentTitle, declarationFile.DocumentTitle, declarationFile.DocumentTitle);
                    var identifierSpan       = declarationFile.IdentifierLocation.GetLineSpan().Span;
                    var entityOfInterestSpan = PeekHelpers.GetEntityOfInterestSpan(symbol, workspace, declarationFile.IdentifierLocation, cancellationToken);
                    resultCollection.Add(PeekHelpers.CreateDocumentPeekResult(declarationFile.FilePath, identifierSpan, entityOfInterestSpan, peekDisplayInfo, _peekableItem.PeekResultFactory, isReadOnly: true));
                }

                var processedSourceLocations = 0;

                foreach (var declaration in sourceLocations)
                {
                    var declarationLocation = declaration.GetMappedLineSpan();

                    var entityOfInterestSpan = PeekHelpers.GetEntityOfInterestSpan(symbol, workspace, declaration, cancellationToken);
                    resultCollection.Add(PeekHelpers.CreateDocumentPeekResult(declarationLocation.Path, declarationLocation.Span, entityOfInterestSpan, _peekableItem.PeekResultFactory));
                    callback.ReportProgress(100 * ++processedSourceLocations / sourceLocations.Count);
                }
            }
            public void FindResults(string relationshipName, IPeekResultCollection resultCollection, CancellationToken cancellationToken, IFindPeekResultsCallback callback)
            {
                if (relationshipName != _peekableItem._relationship.Name)
                {
                    return;
                }

                resultCollection.Add(PeekHelpers.CreateDocumentPeekResult(_peekableItem._span.Path, _peekableItem._span.Span, _peekableItem._span.Span, _peekableItem.PeekResultFactory));
            }
Beispiel #8
0
            public void FindResults(string relationshipName, IPeekResultCollection resultCollection, CancellationToken cancellationToken, IFindPeekResultsCallback callback)
            {
                if (relationshipName != _peekableItem._relationship.Name)
                {
                    return;
                }

                resultCollection.Add(PeekHelpers.CreateDocumentPeekResult(_peekableItem._span.Path, _peekableItem._span.Span, _peekableItem._span.Span, _peekableItem.PeekResultFactory));
            }
        public void FindResults(string relationshipName, IPeekResultCollection resultCollection, CancellationToken cancellationToken, IFindPeekResultsCallback callback)
        {
            if (relationshipName != PredefinedPeekRelationships.Definitions.Name)
                return;

            var file = @"M:\Coding\Applications\DanTup.DartVS\DanTup.DartVS.Vsix\LICENCE.txt";
            using (var displayInfo = new PeekResultDisplayInfo("Danny Label", file, "My Title", file))
            {
                var result = peekableItem.peekResultFactory.Create(displayInfo, file, new Span(10, 10), 10, false);
                resultCollection.Add(result);
                callback.ReportProgress(1);
            }
        }
Beispiel #10
0
        public void FindResults(string relationshipName, IPeekResultCollection resultCollection, CancellationToken cancellationToken, IFindPeekResultsCallback callback)
        {
            if (resultCollection == null)
            {
                throw new ArgumentNullException(nameof(resultCollection));
            }

            if (!string.Equals(relationshipName, PredefinedPeekRelationships.Definitions.Name, StringComparison.OrdinalIgnoreCase))
            {
                return;
            }

            resultCollection.Add(CreateResult());
        }
Beispiel #11
0
 public void FindResults(string relationshipName, IPeekResultCollection resultCollection, System.Threading.CancellationToken cancellationToken, IFindPeekResultsCallback callback)
 {
     if (relationshipName == PredefinedPeekRelationships.Definitions.Name)
     {
         foreach (var location in _locations)
         {
             IPeekResult result = CreatePeekResult(location);
             if (result != null)
             {
                 resultCollection.Add(result);
             }
         }
     }
 }
Beispiel #12
0
        public void FindResults(string relationshipName, IPeekResultCollection resultCollection, CancellationToken cancellationToken, IFindPeekResultsCallback callback)
        {
            if (relationshipName != PredefinedPeekRelationships.Definitions.Name)
            {
                return;
            }

            var file = @"M:\Coding\Applications\DanTup.DartVS\DanTup.DartVS.Vsix\LICENCE.txt";

            using (var displayInfo = new PeekResultDisplayInfo("Danny Label", file, "My Title", file))
            {
                var result = peekableItem.peekResultFactory.Create(displayInfo, file, new Span(10, 10), 10, false);
                resultCollection.Add(result);
                callback.ReportProgress(1);
            }
        }
        public void FindResults(string relationshipName,
                                IPeekResultCollection resultCollection,
                                CancellationToken cancellationToken,
                                IFindPeekResultsCallback callback) {
            if (relationshipName != PredefinedPeekRelationships.Definitions.Name) {
                return;
            }

            // If task is still running, wait a bit, but not too long.
            LookupTask.Wait(_shell.IsUnitTestEnvironment ? 50000 : 2000);
            if (_exception != null) {
                callback.ReportFailure(_exception);
            } else if (LookupTask.IsCompleted && LookupTask.Result != null) {
                resultCollection.Add(LookupTask.Result);
            }
        }
Beispiel #14
0
        public void FindResults(string relationshipName, IPeekResultCollection resultCollection, CancellationToken cancellationToken, IFindPeekResultsCallback callback)
        {
            if (resultCollection == null)
            {
                throw new ArgumentNullException(nameof(resultCollection));
            }

            if (!string.Equals(relationshipName, PredefinedPeekRelationships.Definitions.Name, StringComparison.OrdinalIgnoreCase))
            {
                return;
            }

            foreach (var variable in _variables.Where(v => !string.IsNullOrEmpty(v.Location.FilePath)))
            {
                resultCollection.Add(CreateResult(variable));
            }
        }
Beispiel #15
0
        public void FindResults(string relationshipName, IPeekResultCollection resultCollection, CancellationToken cancellationToken, IFindPeekResultsCallback callback)
        {
            if (resultCollection == null)
            {
                throw new ArgumentNullException(nameof(resultCollection));
            }

            if (!string.Equals(relationshipName, PredefinedPeekRelationships.Definitions.Name, StringComparison.OrdinalIgnoreCase))
            {
                return;
            }

            var grouped = _variables.Where(v => !string.IsNullOrEmpty(v.Location.FilePath))
                          .OrderByDescending(v => v.Location.EndLine - v.Location.StartLine)
                          .ThenBy(v => v.Location.StartLine)
                          .GroupBy(v => v.Location.FilePath);

            var valueAndDefs = new List <IDocumentPeekResult>();
            var defOnly      = new List <IDocumentPeekResult>();

            foreach (var g in grouped)
            {
                bool anyValues = false;
                foreach (var value in g.Where(v => v.Type == VariableType.Value))
                {
                    var def = g.FirstOrDefault(v => v.Type == VariableType.Value && LocationContains(value.Location, v.Location))?.Location ??
                              new LocationInfo(value.Location.FilePath, value.Location.DocumentUri, value.Location.StartLine, value.Location.StartColumn);
                    valueAndDefs.Add(CreateResult(g.Key, def, value.Location));
                    anyValues = true;
                }
                if (!anyValues)
                {
                    foreach (var def in g.Where(v => v.Type == VariableType.Definition))
                    {
                        defOnly.Add(CreateResult(g.Key, def.Location));
                    }
                }
            }

            foreach (var v in valueAndDefs.Concat(defOnly))
            {
                resultCollection.Add(v);
            }
        }
        public void FindResults(string relationshipName, IPeekResultCollection resultCollection, CancellationToken cancellationToken, IFindPeekResultsCallback callback)
        {
            try
            {
                if (relationshipName != PredefinedPeekRelationships.Definitions.Name)
                {
                    return;
                }
                var fileName = Path.GetFileName(this.peekableItem._gotoElement.File.FullPath);
                if (string.IsNullOrEmpty(fileName))
                {
                    return;
                }
                var label = this.peekableItem._gotoElement.Name;
                var title = string.Format("{0} - ({1}, {2})", fileName, this.peekableItem._gotoElement.Range.StartLine, this.peekableItem._gotoElement.Range.StartColumn + 1);

                using (var displayInfo = new PeekResultDisplayInfo2(label: label, labelTooltip: this.peekableItem._gotoElement.File.FullPath, title: title, titleTooltip: this.peekableItem._gotoElement.File.FullPath, startIndexOfTokenInLabel: 0, lengthOfTokenInLabel: label.Length))
                {
                    var result = peekableItem._peekResultFactory.Create
                                 (
                        displayInfo,
                        default(ImageMoniker),
                        this.peekableItem._gotoElement.File.FullPath,
                        this.peekableItem._gotoElement.Range.StartLine,
                        this.peekableItem._gotoElement.Range.StartColumn - 1,
                        this.peekableItem._gotoElement.Range.EndLine,
                        this.peekableItem._gotoElement.Range.EndColumn - 1,
                        this.peekableItem._gotoElement.Range.StartLine,
                        this.peekableItem._gotoElement.Range.StartColumn - 1,
                        this.peekableItem._gotoElement.Range.EndLine,
                        this.peekableItem._gotoElement.Range.EndColumn - 1,
                        false,
                        new Guid(XSharpConstants.EditorFactoryGuidString)
                                 );

                    resultCollection.Add(result);
                    callback.ReportProgress(1);
                }
            }
            catch (Exception ex)
            {
                XSettings.LogException(ex, "XSharpResultSource.FindResults failed : ");
            }
        }
            public void FindResults(string relationshipName, IPeekResultCollection resultCollection, CancellationToken cancellationToken, IFindPeekResultsCallback callback)
            {
                if (relationshipName != PredefinedPeekRelationships.Definitions.Name)
                {
                    return;
                }

                // Note: this is called on a background thread, but we must block the thread since the API doesn't support proper asynchrony.
                var workspace = _peekableItem._workspace;
                var solution = workspace.CurrentSolution;
                var project = solution.GetProject(_peekableItem._projectId);
                var compilation = project.GetCompilationAsync(cancellationToken).WaitAndGetResult(cancellationToken);

                var symbol = _peekableItem._symbolKey.Resolve(compilation, ignoreAssemblyKey: true, cancellationToken: cancellationToken).Symbol;
                if (symbol == null)
                {
                    callback.ReportFailure(new Exception(EditorFeaturesResources.No_information_found));
                    return;
                }

                var sourceLocations = symbol.Locations.Where(l => l.IsInSource).ToList();

                if (!sourceLocations.Any())
                {
                    // It's a symbol from metadata, so we want to go produce it from metadata
                    var declarationFile = _peekableItem._metadataAsSourceFileService.GetGeneratedFileAsync(project, symbol, cancellationToken).WaitAndGetResult(cancellationToken);
                    var peekDisplayInfo = new PeekResultDisplayInfo(declarationFile.DocumentTitle, declarationFile.DocumentTitle, declarationFile.DocumentTitle, declarationFile.DocumentTitle);
                    var identifierSpan = declarationFile.IdentifierLocation.GetLineSpan().Span;
                    var entityOfInterestSpan = PeekHelpers.GetEntityOfInterestSpan(symbol, workspace, declarationFile.IdentifierLocation, cancellationToken);
                    resultCollection.Add(PeekHelpers.CreateDocumentPeekResult(declarationFile.FilePath, identifierSpan, entityOfInterestSpan, peekDisplayInfo, _peekableItem.PeekResultFactory, isReadOnly: true));
                }

                int processedSourceLocations = 0;

                foreach (var declaration in sourceLocations)
                {
                    var declarationLocation = declaration.GetLineSpan();

                    var entityOfInterestSpan = PeekHelpers.GetEntityOfInterestSpan(symbol, workspace, declaration, cancellationToken);
                    resultCollection.Add(PeekHelpers.CreateDocumentPeekResult(declarationLocation.Path, declarationLocation.Span, entityOfInterestSpan, _peekableItem.PeekResultFactory));
                    callback.ReportProgress(100 * ++processedSourceLocations / sourceLocations.Count);
                }
            }
Beispiel #18
0
        public void FindResults(string relationshipName,
                                IPeekResultCollection resultCollection,
                                CancellationToken cancellationToken,
                                IFindPeekResultsCallback callback)
        {
            if (relationshipName != PredefinedPeekRelationships.Definitions.Name)
            {
                return;
            }

            // If task is still running, wait a bit, but not too long.
            LookupTask.Wait(TestEnvironment.Current != null ? 50000 : 2000);
            if (_exception != null)
            {
                callback.ReportFailure(_exception);
            }
            else if (LookupTask.IsCompleted && LookupTask.Result != null)
            {
                resultCollection.Add(LookupTask.Result);
            }
        }
Beispiel #19
0
        public void FindResults(string relationshipName, IPeekResultCollection resultCollection, CancellationToken cancellationToken, IFindPeekResultsCallback callback)
        {
            if (relationshipName != PredefinedPeekRelationships.Definitions.Name)
            {
                return;
            }

            var temp = Path.GetTempFileName();

            using (var displayInfo = new PeekResultDisplayInfo(label: peekableItem._className, labelTooltip: "Comment", title: "Comment title", titleTooltip: "Comment"))
            {
                var result = peekableItem._peekResultFactory.Create
                             (
                    displayInfo,
                    temp,
                    new Span(0, 0),
                    0,
                    false
                             );

                resultCollection.Add(result);
                callback.ReportProgress(1);
            }
        }
 public void FindResults(string relationshipName, IPeekResultCollection resultCollection, CancellationToken cancellationToken, IFindPeekResultsCallback callback)
 {
     resultCollection.Add(new InlineCommentPeekResult(viewModel));
 }
Beispiel #21
0
 public void FindResults(string relationshipName, IPeekResultCollection resultCollection,
                         CancellationToken cancellationToken, IFindPeekResultsCallback callback)
 {
     resultCollection.Add(new F1PeekResult(_helpUrl));
 }
Beispiel #22
0
 public void FindResults(string relationshipName, IPeekResultCollection resultCollection,
     CancellationToken cancellationToken, IFindPeekResultsCallback callback)
 {
     resultCollection.Add(new F1PeekResult(_helpUrl));
 }
Beispiel #23
0
 public void FindResults(string relationshipName, IPeekResultCollection resultCollection, 
   CancellationToken cancellationToken, IFindPeekResultsCallback callback)
 {
   if(relationshipName==_relName) resultCollection.Add(new RotPeekResult(_expandedTactic));
 }