From e92fce1c27eb04de697bc7331ae1c4648796b119 Mon Sep 17 00:00:00 2001 From: Joey Perrott Date: Mon, 6 Apr 2020 14:45:13 -0700 Subject: [PATCH] fix(language-service): remove circular dependency instance (#36463) PR Close #36463 --- goldens/packages-circular-deps.json | 4 ---- packages/language-service/src/completions.ts | 4 ++-- .../language-service/src/expression_diagnostics.ts | 14 ++++++++++++++ packages/language-service/src/locate_symbol.ts | 4 ++-- packages/language-service/src/utils.ts | 13 ------------- 5 files changed, 18 insertions(+), 21 deletions(-) diff --git a/goldens/packages-circular-deps.json b/goldens/packages-circular-deps.json index 669637271d..92e8e0aabd 100644 --- a/goldens/packages-circular-deps.json +++ b/goldens/packages-circular-deps.json @@ -1966,10 +1966,6 @@ "packages/language-service/src/typescript_host.ts", "packages/language-service/src/language_service.ts" ], - [ - "packages/language-service/src/expression_diagnostics.ts", - "packages/language-service/src/utils.ts" - ], [ "packages/language-service/src/template.ts", "packages/language-service/src/typescript_host.ts" diff --git a/packages/language-service/src/completions.ts b/packages/language-service/src/completions.ts index 80f7b363be..8c139042db 100644 --- a/packages/language-service/src/completions.ts +++ b/packages/language-service/src/completions.ts @@ -11,12 +11,12 @@ import {$$, $_, isAsciiLetter, isDigit} from '@angular/compiler/src/chars'; import {ATTR, getBindingDescriptor} from './binding_utils'; import {AstResult} from './common'; -import {getExpressionScope} from './expression_diagnostics'; +import {diagnosticInfoFromTemplateInfo, getExpressionScope} from './expression_diagnostics'; import {getExpressionCompletions} from './expressions'; import {attributeNames, elementNames, eventNames, propertyNames} from './html_info'; import {InlineTemplate} from './template'; import * as ng from './types'; -import {diagnosticInfoFromTemplateInfo, findTemplateAstAt, getPathToNodeAtPosition, getSelectors, inSpan, isStructuralDirective, spanOf} from './utils'; +import {findTemplateAstAt, getPathToNodeAtPosition, getSelectors, inSpan, isStructuralDirective, spanOf} from './utils'; const HIDDEN_HTML_ELEMENTS: ReadonlySet = new Set(['html', 'script', 'noscript', 'base', 'body', 'title', 'head', 'link']); diff --git a/packages/language-service/src/expression_diagnostics.ts b/packages/language-service/src/expression_diagnostics.ts index 61e62ec618..81950b5798 100644 --- a/packages/language-service/src/expression_diagnostics.ts +++ b/packages/language-service/src/expression_diagnostics.ts @@ -8,6 +8,7 @@ import {AST, AstPath, Attribute, BoundDirectivePropertyAst, BoundElementPropertyAst, BoundEventAst, BoundTextAst, CompileDirectiveSummary, CompileTypeMetadata, DirectiveAst, ElementAst, EmbeddedTemplateAst, identifierName, Node, ParseSourceSpan, RecursiveTemplateAstVisitor, ReferenceAst, TemplateAst, TemplateAstPath, templateVisitAll, tokenReference, VariableAst} from '@angular/compiler'; +import {AstResult} from './common'; import {createDiagnostic, Diagnostic} from './diagnostic_messages'; import {AstType} from './expression_type'; import {BuiltinType, Definition, Span, Symbol, SymbolDeclaration, SymbolQuery, SymbolTable} from './symbols'; @@ -385,3 +386,16 @@ function hasTemplateReference(type: CompileTypeMetadata): boolean { function spanOf(sourceSpan: ParseSourceSpan): Span { return {start: sourceSpan.start.offset, end: sourceSpan.end.offset}; } + + +export function diagnosticInfoFromTemplateInfo(info: AstResult): DiagnosticTemplateInfo { + return { + fileName: info.template.fileName, + offset: info.template.span.start, + query: info.template.query, + members: info.template.members, + htmlAst: info.htmlAst, + templateAst: info.templateAst, + source: info.template.source, + }; +} diff --git a/packages/language-service/src/locate_symbol.ts b/packages/language-service/src/locate_symbol.ts index fba5d1a812..97475ab27b 100644 --- a/packages/language-service/src/locate_symbol.ts +++ b/packages/language-service/src/locate_symbol.ts @@ -10,10 +10,10 @@ import {AST, Attribute, BoundDirectivePropertyAst, CssSelector, DirectiveAst, El import * as tss from 'typescript/lib/tsserverlibrary'; import {AstResult} from './common'; -import {getExpressionScope} from './expression_diagnostics'; +import {diagnosticInfoFromTemplateInfo, getExpressionScope} from './expression_diagnostics'; import {getExpressionSymbol} from './expressions'; import {Definition, DirectiveKind, Span, Symbol} from './types'; -import {diagnosticInfoFromTemplateInfo, findOutputBinding, findTemplateAstAt, getPathToNodeAtPosition, inSpan, invertMap, isNarrower, offsetSpan, spanOf} from './utils'; +import {findOutputBinding, findTemplateAstAt, getPathToNodeAtPosition, inSpan, invertMap, isNarrower, offsetSpan, spanOf} from './utils'; export interface SymbolInfo { symbol: Symbol; diff --git a/packages/language-service/src/utils.ts b/packages/language-service/src/utils.ts index e2f9de8bab..36fa25c71c 100644 --- a/packages/language-service/src/utils.ts +++ b/packages/language-service/src/utils.ts @@ -10,7 +10,6 @@ import {AstPath, BoundEventAst, CompileDirectiveSummary, CompileTypeMetadata, Cs import * as ts from 'typescript'; import {AstResult, SelectorInfo} from './common'; -import {DiagnosticTemplateInfo} from './expression_diagnostics'; import {Span, Symbol, SymbolQuery} from './types'; export interface SpanHolder { @@ -91,18 +90,6 @@ export function isTypescriptVersion(low: string, high?: string) { return true; } -export function diagnosticInfoFromTemplateInfo(info: AstResult): DiagnosticTemplateInfo { - return { - fileName: info.template.fileName, - offset: info.template.span.start, - query: info.template.query, - members: info.template.members, - htmlAst: info.htmlAst, - templateAst: info.templateAst, - source: info.template.source, - }; -} - export function findTemplateAstAt(ast: TemplateAst[], position: number): TemplateAstPath { const path: TemplateAst[] = []; const visitor = new class extends RecursiveTemplateAstVisitor {