From b446095c4dee992bbce3a82c12ed8560530ba81a Mon Sep 17 00:00:00 2001 From: Alan Date: Fri, 22 Feb 2019 11:55:10 +0100 Subject: [PATCH] refactor: remove unused functions and classes in diagnostics (#28923) PR Close #28923 --- .../src/diagnostics/typescript_symbols.ts | 60 +------------------ 1 file changed, 2 insertions(+), 58 deletions(-) diff --git a/packages/compiler-cli/src/diagnostics/typescript_symbols.ts b/packages/compiler-cli/src/diagnostics/typescript_symbols.ts index 30fa65cb52..ccd3897661 100644 --- a/packages/compiler-cli/src/diagnostics/typescript_symbols.ts +++ b/packages/compiler-cli/src/diagnostics/typescript_symbols.ts @@ -6,12 +6,11 @@ * found in the LICENSE file at https://angular.io/license */ -import {AotSummaryResolver, CompileMetadataResolver, CompilePipeSummary, CompilerConfig, DEFAULT_INTERPOLATION_CONFIG, DirectiveNormalizer, DirectiveResolver, DomElementSchemaRegistry, HtmlParser, InterpolationConfig, NgAnalyzedModules, NgModuleResolver, ParseTreeResult, PipeResolver, ResourceLoader, StaticReflector, StaticSymbol, StaticSymbolCache, StaticSymbolResolver, SummaryResolver} from '@angular/compiler'; -import * as fs from 'fs'; +import {CompilePipeSummary, StaticSymbol} from '@angular/compiler'; import * as path from 'path'; import * as ts from 'typescript'; -import {BuiltinType, DeclarationKind, Definition, PipeInfo, Pipes, Signature, Span, Symbol, SymbolDeclaration, SymbolQuery, SymbolTable} from './symbols'; +import {BuiltinType, DeclarationKind, Definition, Signature, Span, Symbol, SymbolDeclaration, SymbolQuery, SymbolTable} from './symbols'; import {isVersionBetween} from './typescript_version'; // In TypeScript 2.1 these flags moved @@ -647,50 +646,6 @@ class EmptyTable implements SymbolTable { static instance = new EmptyTable(); } -function findTsConfig(fileName: string): string|undefined { - let dir = path.dirname(fileName); - while (fs.existsSync(dir)) { - const candidate = path.join(dir, 'tsconfig.json'); - if (fs.existsSync(candidate)) return candidate; - const parentDir = path.dirname(dir); - if (parentDir === dir) break; - dir = parentDir; - } -} - -function isBindingPattern(node: ts.Node): node is ts.BindingPattern { - return !!node && (node.kind === ts.SyntaxKind.ArrayBindingPattern || - node.kind === ts.SyntaxKind.ObjectBindingPattern); -} - -function walkUpBindingElementsAndPatterns(node: ts.Node): ts.Node { - while (node && (node.kind === ts.SyntaxKind.BindingElement || isBindingPattern(node))) { - node = node.parent !; - } - - return node; -} - -function getCombinedNodeFlags(node: ts.Node): ts.NodeFlags { - node = walkUpBindingElementsAndPatterns(node); - - let flags = node.flags; - if (node.kind === ts.SyntaxKind.VariableDeclaration) { - node = node.parent !; - } - - if (node && node.kind === ts.SyntaxKind.VariableDeclarationList) { - flags |= node.flags; - node = node.parent !; - } - - if (node && node.kind === ts.SyntaxKind.VariableStatement) { - flags |= node.flags; - } - - return flags; -} - function isSymbolPrivate(s: ts.Symbol): boolean { return !!s.valueDeclaration && isPrivate(s.valueDeclaration); } @@ -753,15 +708,6 @@ function setParents(node: T, parent: ts.Node): T { return node; } -function spanOf(node: ts.Node): Span { - return {start: node.getStart(), end: node.getEnd()}; -} - -function shrink(span: Span, offset?: number) { - if (offset == null) offset = 1; - return {start: span.start + offset, end: span.end - offset}; -} - function spanAt(sourceFile: ts.SourceFile, line: number, column: number): Span|undefined { if (line != null && column != null) { const position = ts.getPositionOfLineAndCharacter(sourceFile, line, column); @@ -863,8 +809,6 @@ function typeKindOf(type: ts.Type | undefined): BuiltinType { return BuiltinType.Other; } - - function getFromSymbolTable(symbolTable: ts.SymbolTable, key: string): ts.Symbol|undefined { const table = symbolTable as any; let symbol: ts.Symbol|undefined;