protected override async Task<IEnumerable<NavigationSegment>> RequestLinksAsync (int offset, int length, CancellationToken token) { var parsedDocument = DocumentContext.ParsedDocument; if (parsedDocument == null) return emptyList; var model = parsedDocument.GetAst<SemanticModel> (); if (model == null) return emptyList; try { var visitor = new NavigationVisitor (DocumentContext, model, new TextSpan (offset, length), token); visitor.Visit (await model.SyntaxTree.GetRootAsync (token).ConfigureAwait (false)); return visitor.result; } catch (OperationCanceledException) { return emptyList; } }
protected override async Task <IEnumerable <NavigationSegment> > RequestLinksAsync(int offset, int length, CancellationToken token) { var parsedDocument = DocumentContext.ParsedDocument; if (parsedDocument == null) { return(emptyList); } var model = parsedDocument.GetAst <SemanticModel> (); if (model == null) { return(emptyList); } try { var visitor = new NavigationVisitor(DocumentContext, model, new TextSpan(offset, length), token); visitor.Visit(await model.SyntaxTree.GetRootAsync(token).ConfigureAwait(false)); return(visitor.result); } catch (OperationCanceledException) { return(emptyList); } }
protected override async Task <IEnumerable <NavigationSegment> > RequestLinksAsync(int offset, int length, CancellationToken token) { var analysisDocument = DocumentContext.AnalysisDocument; if (analysisDocument == null) { return(Enumerable.Empty <NavigationSegment> ()); } var model = await analysisDocument.GetSemanticModelAsync(token); if (model == null) { return(Enumerable.Empty <NavigationSegment> ()); } return(await Task.Run(async delegate { try { var visitor = new NavigationVisitor(DocumentContext, model, new TextSpan(offset, length), token); visitor.Visit(await model.SyntaxTree.GetRootAsync(token).ConfigureAwait(false)); return (IEnumerable <NavigationSegment>)visitor.result; } catch (OperationCanceledException) { return (IEnumerable <NavigationSegment>)emptyList; } })); }