Home
last modified time | relevance | path

Searched refs:sourceFile (Results 1 – 25 of 452) sorted by relevance

12345678910>>...19

/third_party/typescript/src/testRunner/unittests/services/
DtextChanges.ts28 const sourceFile = createSourceFile("f.ts", text, ScriptTarget.ES2015); constant
29 const parsedNodeList = flattenNodes(sourceFile.statements[0]);
47 …rFunctions: boolean, text: string, validateNodes: boolean, testBlock: (sourceFile: SourceFile, cha…
49 …const sourceFile = createSourceFile("source.ts", text, ScriptTarget.ES2015, /*setParentNodes*/ tru… constant
52 testBlock(sourceFile, changeTracker);
55 assert.equal(changes[0].fileName, sourceFile.fileName);
56 const modified = textChanges.applyChanges(sourceFile.text, changes[0].textChanges);
83 …eOpenBraceOnNewLineForFunctions*/ true, text, /*validateNodes*/ true, (sourceFile, changeTracker) …
84 … const statements = (<FunctionDeclaration>findChild("foo", sourceFile)).body!.statements.slice(1);
96 … changeTracker.insertNodeBefore(sourceFile, /*before*/findChild("M2", sourceFile), newFunction);
[all …]
/third_party/typescript/src/services/
DtextChanges.ts139 readonly sourceFile: SourceFile; property
167 …function getAdjustedRange(sourceFile: SourceFile, startNode: Node, endNode: Node, options: Configu…
168 …return { pos: getAdjustedStartPosition(sourceFile, startNode, options), end: getAdjustedEndPositio…
171 …function getAdjustedStartPosition(sourceFile: SourceFile, node: Node, options: ConfigurableStart) {
174 return node.getStart(sourceFile);
177 return getLineStartPositionForPosition(node.getStart(sourceFile), sourceFile);
180 const JSDocComments = getJSDocCommentRanges(node, sourceFile.text);
182 return getLineStartPositionForPosition(JSDocComments[0].pos, sourceFile);
186 const start = node.getStart(sourceFile);
190 const fullStartLine = getLineStartPositionForPosition(fullStart, sourceFile);
[all …]
DoutliningElementsCollector.ts3 …export function collectElements(sourceFile: SourceFile, cancellationToken: CancellationToken): Out…
5 addNodeOutliningSpans(sourceFile, cancellationToken, res);
6 addRegionOutliningSpans(sourceFile, res);
10 …function addNodeOutliningSpans(sourceFile: SourceFile, cancellationToken: CancellationToken, out: …
14 const statements = [...sourceFile.statements, sourceFile.endOfFileToken]; constant
24 … addOutliningForLeadingCommentsForNode(statements[current], sourceFile, cancellationToken, out);
29 …ldOfKind(statements[firstImport], SyntaxKind.ImportKeyword, sourceFile)!.getStart(sourceFile), sta…
38 addOutliningForLeadingCommentsForNode(n, sourceFile, cancellationToken, out);
42 … addOutliningForLeadingCommentsForNode(n.parent.left, sourceFile, cancellationToken, out);
45 const span = getOutliningSpanForNode(n, sourceFile);
[all …]
DsignatureHelp.ts23 …export function getSignatureHelpItems(program: Program, sourceFile: SourceFile, position: number, …
27 const startingToken = findTokenOnLeftOfPosition(sourceFile, position);
37 …if (onlyUseSyntacticOwners && (isInString(sourceFile, position, startingToken) || isInComment(sour…
42 …const argumentInfo = getContainingArgumentInfo(startingToken, position, sourceFile, typeChecker, i…
48 …const candidateInfo = getCandidateOrTypeInfo(argumentInfo, typeChecker, sourceFile, startingToken,…
54 …return isSourceFileJS(sourceFile) ? createJSSignatureHelpItems(argumentInfo, program, cancellation…
59 …s(candidateInfo.candidates, candidateInfo.resolvedSignature, argumentInfo, sourceFile, typeChecker)
60 : createTypeHelpItems(candidateInfo.symbol, argumentInfo, sourceFile, typeChecker));
74 …{ invocation, argumentCount }: ArgumentListInfo, checker: TypeChecker, sourceFile: SourceFile, sta…
77 … if (onlyUseSyntacticOwners && !isSyntacticOwner(startingToken, invocation.node, sourceFile)) {
[all …]
Dservices.ts47 public getStart(sourceFile?: SourceFileLike, includeJsDocComment?: boolean): number {
49 return getTokenPosOfNode(this, sourceFile, includeJsDocComment);
62 public getWidth(sourceFile?: SourceFile): number {
64 return this.getEnd() - this.getStart(sourceFile);
72 public getLeadingTriviaWidth(sourceFile?: SourceFile): number {
74 return this.getStart(sourceFile) - this.pos;
77 public getFullText(sourceFile?: SourceFile): string {
79 return (sourceFile || this.getSourceFile()).text.substring(this.pos, this.end);
82 public getText(sourceFile?: SourceFile): string {
84 if (!sourceFile) {
[all …]
Dutilities.ts491 …export function getLineStartPositionForPosition(position: number, sourceFile: SourceFileLike): num…
492 const lineStarts = getLineStarts(sourceFile);
493 const line = sourceFile.getLineAndCharacterOfPosition(position).line;
525 …export function nodeOverlapsWithStartEnd(node: Node, sourceFile: SourceFile, start: number, end: n…
526 return startEndOverlapsWithStartEnd(node.getStart(sourceFile), node.end, start, end);
538 …export function positionBelongsToNode(candidate: Node, position: number, sourceFile: SourceFile): …
540 return position < candidate.end || !isCompletedNode(candidate, sourceFile);
543 function isCompletedNode(n: Node | undefined, sourceFile: SourceFile): boolean {
561 return nodeEndsWith(n, SyntaxKind.CloseBraceToken, sourceFile);
563 return isCompletedNode((<CatchClause>n).block, sourceFile);
[all …]
Drename.ts3 …export function getRenameInfo(program: Program, sourceFile: SourceFile, position: number, options?…
4 const node = getAdjustedRenameLocation(getTouchingPropertyName(sourceFile, position));
6 …const renameInfo = getRenameInfoForNode(node, program.getTypeChecker(), sourceFile, declaration =>…
14 …function getRenameInfoForNode(node: Node, typeChecker: TypeChecker, sourceFile: SourceFile, isDefi…
22 … return getRenameInfoSuccess(node.text, node.text, ScriptElementKind.string, "", node, sourceFile);
27 …InfoSuccess(name, name, ScriptElementKind.label, ScriptElementKindModifier.none, node, sourceFile);
46 …ions && options.allowRenameOfImportPath ? getRenameInfoForModule(node, sourceFile, symbol) : undef…
55 …me, fullDisplayName, kind, SymbolDisplay.getSymbolModifiers(typeChecker,symbol), node, sourceFile);
58 …function getRenameInfoForModule(node: StringLiteralLike, sourceFile: SourceFile, moduleSymbol: Sym…
70 …const triggerSpan = createTextSpan(node.getStart(sourceFile) + 1 + indexAfterLastSlash, node.text.…
[all …]
DdocumentHighlights.ts9 …mentHighlights(program: Program, cancellationToken: CancellationToken, sourceFile: SourceFile, pos…
10 const node = getTouchingPropertyName(sourceFile, position);
15 …openingElement, closingElement].map(({ tagName }) => getHighlightSpanForNode(tagName, sourceFile));
16 return [{ fileName: sourceFile.fileName, highlightSpans }];
19 …ogram, cancellationToken, sourceFilesToSearch) || getSyntacticDocumentHighlights(node, sourceFile);
22 function getHighlightSpanForNode(node: Node, sourceFile: SourceFile): HighlightSpan {
24 fileName: sourceFile.fileName,
25 textSpan: createTextSpanFromNode(node, sourceFile),
47 …function getSyntacticDocumentHighlights(node: Node, sourceFile: SourceFile): DocumentHighlights[] …
48 const highlightSpans = getHighlightSpans(node, sourceFile);
[all …]
/third_party/typescript/src/services/formatting/
DsmartIndenter.ts24 …export function getIndentation(position: number, sourceFile: SourceFile, options: EditorSettings, …
25 if (position > sourceFile.text.length) {
35 …const precedingToken = findPrecedingToken(position, sourceFile, /*startNode*/ undefined, /*exclude…
38 …const enclosingCommentRange = getRangeOfEnclosingComment(sourceFile, position, precedingToken || n…
40 return getCommentIndent(sourceFile, position, options, enclosingCommentRange);
49 …if (precedingTokenIsLiteral && precedingToken.getStart(sourceFile) <= position && position < prece…
53 const lineAtPosition = sourceFile.getLineAndCharacterOfPosition(position).line;
59 return getBlockIndent(sourceFile, position, options);
64 …ctualIndentation = getActualIndentationForListItemBeforeComma(precedingToken, sourceFile, options);
70 const containerList = getListByPosition(position, precedingToken.parent, sourceFile);
[all …]
Dformatting.ts77 …export function formatOnEnter(position: number, sourceFile: SourceFile, formatContext: FormatConte…
78 const line = sourceFile.getLineAndCharacterOfPosition(position).line;
87 let endOfFormatSpan = getEndLinePosition(line, sourceFile);
88 while (isWhiteSpaceSingleLine(sourceFile.text.charCodeAt(endOfFormatSpan))) {
94 if (isLineBreak(sourceFile.text.charCodeAt(endOfFormatSpan))) {
99 pos: getStartPositionOfLine(line - 1, sourceFile),
103 return formatSpan(span, sourceFile, formatContext, FormattingRequestKind.FormatOnEnter);
106 …export function formatOnSemicolon(position: number, sourceFile: SourceFile, formatContext: FormatC…
107 …t semicolon = findImmediatelyPrecedingTokenOfKind(position, SyntaxKind.SemicolonToken, sourceFile);
108 …return formatNodeLines(findOutermostNodeWithinListLevel(semicolon), sourceFile, formatContext, For…
[all …]
DformattingContext.ts25 …constructor(public readonly sourceFile: SourceFileLike, public formattingRequestKind: FormattingRe…
61 … const startLine = this.sourceFile.getLineAndCharacterOfPosition(this.currentTokenSpan.pos).line;
62 … const endLine = this.sourceFile.getLineAndCharacterOfPosition(this.nextTokenSpan.pos).line;
86 …const startLine = this.sourceFile.getLineAndCharacterOfPosition(node.getStart(this.sourceFile)).li…
87 const endLine = this.sourceFile.getLineAndCharacterOfPosition(node.getEnd()).line;
92 const openBrace = findChildOfKind(node, SyntaxKind.OpenBraceToken, this.sourceFile);
93 const closeBrace = findChildOfKind(node, SyntaxKind.CloseBraceToken, this.sourceFile);
95 … const startLine = this.sourceFile.getLineAndCharacterOfPosition(openBrace.getEnd()).line;
96 …const endLine = this.sourceFile.getLineAndCharacterOfPosition(closeBrace.getStart(this.sourceFile)…
/third_party/typescript/src/compiler/
DbuilderState.ts3 …export function getFileEmitOutput(program: Program, sourceFile: SourceFile, emitOnlyDtsFiles: bool…
6 …pped, diagnostics, exportedModulesFromDeclarationEmit } = program.emit(sourceFile, writeFile, canc…
116 …function getReferencedFiles(program: Program, sourceFile: SourceFile, getCanonicalFileName: GetCan…
122 if (sourceFile.imports && sourceFile.imports.length > 0) {
124 for (const importName of sourceFile.imports) {
132 const sourceFileDirectory = getDirectoryPath(sourceFile.resolvedPath);
134 if (sourceFile.referencedFiles && sourceFile.referencedFiles.length > 0) {
135 for (const referencedFile of sourceFile.referencedFiles) {
142 if (sourceFile.resolvedTypeReferenceDirectiveNames) {
143sourceFile.resolvedTypeReferenceDirectiveNames.forEach((resolvedTypeReferenceDirective) => {
[all …]
/third_party/typescript/src/services/codefixes/
DfixUnusedIdentifier.ts21 const { errorCode, sourceFile, program, cancellationToken } = context; constant
24 const token = getTokenAtPosition(sourceFile, context.span.start);
27 …[createDeleteFix(textChanges.ChangeTracker.with(context, t => t.delete(sourceFile, token)), Diagno…
30 …changes = textChanges.ChangeTracker.with(context, t => deleteTypeParameters(t, sourceFile, token));
35 … const changes = textChanges.ChangeTracker.with(context, t => t.delete(sourceFile, importDecl));
39 …on = textChanges.ChangeTracker.with(context, t => tryDeleteDeclaration(sourceFile, token, t, check…
41 …ion, [Diagnostics.Remove_unused_declaration_for_Colon_0, token.getText(sourceFile)], fixIdDeleteIm…
50 map(elements, e => e.getText(sourceFile)).join(", ")
54 …deleteDestructuringElements(t, sourceFile, token.parent as ObjectBindingPattern | ArrayBindingPatt…
59 … t.delete(sourceFile, token.parent.parent)), Diagnostics.Remove_unused_destructuring_declaration)
[all …]
DimportFixes.ts18 const { errorCode, preferences, sourceFile, span } = context; constant
22 const quotePreference = getQuotePreference(sourceFile, preferences);
23 … return fixes.map(fix => codeActionForFix(context, sourceFile, symbolName, fix, quotePreference));
27 const { sourceFile, program, preferences, host } = context; constant
28 …const importAdder = createImportAdderWorker(sourceFile, program, /*useAutoImportProvider*/ true, p…
40 …export function createImportAdder(sourceFile: SourceFile, program: Program, preferences: UserPrefe…
41 …return createImportAdderWorker(sourceFile, program, /*useAutoImportProvider*/ false, preferences, …
44 …function createImportAdderWorker(sourceFile: SourceFile, program: Program, useAutoImportProvider: …
65 …const exportInfos = getAllReExportingModules(sourceFile, symbol, moduleSymbol, symbolName, host, p…
67 const useRequire = shouldUseRequire(sourceFile, program);
[all …]
DaddMissingAwait.ts33 const { sourceFile, errorCode, span, cancellationToken, program } = context; constant
34 …const expression = getFixableErrorSpanExpression(sourceFile, errorCode, span, cancellationToken, p…
46 const { sourceFile, program, cancellationToken } = context; constant
50 …const expression = getFixableErrorSpanExpression(sourceFile, diagnostic.code, diagnostic, cancella…
62 const { sourceFile, program, cancellationToken } = context; constant
63 …const awaitableInitializers = findAwaitableInitializers(expression, sourceFile, cancellationToken,…
66 …nitializers.initializers, ({ expression }) => makeChange(t, errorCode, sourceFile, checker, expres…
68 makeChange(t, errorCode, sourceFile, checker, expression, fixedDeclarations);
83 …const changes = trackChanges(t => makeChange(t, errorCode, context.sourceFile, checker, expression…
87 …function isMissingAwaitError(sourceFile: SourceFile, errorCode: number, span: TextSpan, cancellati…
[all …]
DdisableJsDiagnostics.ts13 const { sourceFile, program, span, host, formatContext } = context; constant
15 …if (!isInJSFile(sourceFile) || !isCheckJsEnabledForFile(sourceFile, program.getCompilerOptions()))…
19 …const newLineCharacter = sourceFile.checkJsDirective ? "" : getNewLineOrDefaultFromHost(host, form…
24 [createFileTextChanges(sourceFile.fileName, [
25 createTextChange(sourceFile.checkJsDirective
26 … ? createTextSpanFromBounds(sourceFile.checkJsDirective.pos, sourceFile.checkJsDirective.end)
32 if (textChanges.isValidLocationToAddComment(sourceFile, span.start)) {
33 …on(fixName, textChanges.ChangeTracker.with(context, t => makeChange(t, sourceFile, span.start)), D…
49 …function makeChange(changes: textChanges.ChangeTracker, sourceFile: SourceFile, position: number, …
50 const { line: lineNumber } = getLineAndCharacterOfPosition(sourceFile, position);
[all …]
DconvertToEs6Module.ts6 const { sourceFile, program, preferences } = context; constant
8 …ertFileToEs6Module(sourceFile, program.getTypeChecker(), changes, program.getCompilerOptions().tar…
11 …fixImportOfModuleExports(importingFile, sourceFile, changes, getQuotePreference(importingFile, pre…
42 …function convertFileToEs6Module(sourceFile: SourceFile, checker: TypeChecker, changes: textChanges…
43 …const identifiers: Identifiers = { original: collectFreeIdentifiers(sourceFile), additional: new S…
44 const exports = collectExportRenames(sourceFile, checker, identifiers);
45 convertExportsAccesses(sourceFile, exports, changes);
49 for (const statement of filter(sourceFile.statements, isVariableStatement)) {
50 …const newUseSites = convertVariableStatement(sourceFile, statement, changes, checker, identifiers,…
56 for (const statement of filter(sourceFile.statements, s => !isVariableStatement(s))) {
[all …]
DfixInvalidImportSyntax.ts6 const sourceFile = getSourceFileOfNode(node); constant
12 …tion(context, sourceFile, node, makeImport(namespace.name, /*namedImports*/ undefined, node.module…
16 … variations.push(createAction(context, sourceFile, node, factory.createImportEqualsDeclaration(
28 …function createAction(context: CodeFixContext, sourceFile: SourceFile, node: Node, replacement: No…
29 …const changes = textChanges.ChangeTracker.with(context, t => t.replaceNode(sourceFile, node, repla…
42 const sourceFile = context.sourceFile; constant
44 …const node = findAncestor(getTokenAtPosition(sourceFile, context.span.start), a => a.kind === targ…
72 const sourceFile = context.sourceFile; constant
73 …const node = findAncestor(getTokenAtPosition(sourceFile, context.span.start), a => a.getStart() ==…
91 const sourceFile = context.sourceFile; constant
[all …]
DfixImplicitThis.ts8 const { sourceFile, program, span } = context; constant
11 diagnostic = doChange(t, sourceFile, span.start, program.getTypeChecker());
21 …function doChange(changes: textChanges.ChangeTracker, sourceFile: SourceFile, pos: number, checker…
22 const token = getTokenAtPosition(sourceFile, pos);
29 …const fnKeyword = Debug.assertDefined(findChildOfKind(fn, SyntaxKind.FunctionKeyword, sourceFile));
33 … if (name && FindAllReferences.Core.isSymbolReferencedInFile(name, checker, sourceFile, body)) {
39 changes.delete(sourceFile, fnKeyword);
41 changes.delete(sourceFile, name);
43 changes.insertText(sourceFile, body.pos, " =>");
49 … changes.replaceNode(sourceFile, fnKeyword, factory.createToken(SyntaxKind.ConstKeyword));
[all …]
DfixClassIncorrectlyImplementsInterface.ts11 const { sourceFile, span } = context; constant
12 const classDeclaration = getClass(sourceFile, span.start);
14 …ith(context, t => addMissingDeclarations(context, implementedTypeNode, sourceFile, classDeclaratio…
15 …anges, [Diagnostics.Implement_interface_0, implementedTypeNode.getText(sourceFile)], fixId, Diagno…
32 function getClass(sourceFile: SourceFile, pos: number): ClassLikeDeclaration {
33 …return Debug.checkDefined(getContainingClass(getTokenAtPosition(sourceFile, pos)), "There should b…
43 sourceFile: SourceFile,
66 … const importAdder = createImportAdder(sourceFile, context.program, preferences, context.host);
67 …istedInHeritageClauseMembers, sourceFile, context, preferences, importAdder, member => insertInter…
73 …insertInterfaceMemberNode(sourceFile, classDeclaration, checker.indexInfoToIndexSignatureDeclarati…
[all …]
DfixAwaitInSyncFunction.ts11 const { sourceFile, span } = context; constant
12 const nodes = getNodes(sourceFile, span.start);
14 … const changes = textChanges.ChangeTracker.with(context, t => doChange(t, sourceFile, nodes));
23 doChange(changes, context.sourceFile, nodes);
39 …function getNodes(sourceFile: SourceFile, start: number): { insertBefore: Node, returnType: TypeNo…
40 const token = getTokenAtPosition(sourceFile, start);
53 … insertBefore = findChildOfKind(containingFunction, SyntaxKind.FunctionKeyword, sourceFile);
56 …efore = findChildOfKind(containingFunction, SyntaxKind.OpenParenToken, sourceFile) || first(contai…
70 sourceFile: SourceFile,
76 …changes.replaceNode(sourceFile, returnType, factory.createTypeReferenceNode("Promise", factory.cre…
[all …]
DfixUnusedLabel.ts8 …ges = textChanges.ChangeTracker.with(context, t => doChange(t, context.sourceFile, context.span.st…
15 …function doChange(changes: textChanges.ChangeTracker, sourceFile: SourceFile, start: number): void…
16 const token = getTokenAtPosition(sourceFile, start);
18 const pos = token.getStart(sourceFile);
19 const statementPos = labeledStatement.statement.getStart(sourceFile);
21 const end = positionsAreOnSameLine(pos, statementPos, sourceFile) ? statementPos
22 …: skipTrivia(sourceFile.text, findChildOfKind(labeledStatement, SyntaxKind.ColonToken, sourceFile)…
23 changes.deleteRange(sourceFile, { pos, end });
DfixClassSuperMustPrecedeThisAccess.ts8 const { sourceFile, span } = context; constant
9 const nodes = getNodes(sourceFile, span.start);
12 …const changes = textChanges.ChangeTracker.with(context, t => doChange(t, sourceFile, constructor, …
17 const { sourceFile } = context; constant
24 doChange(changes, sourceFile, constructor, superCall);
30 …function doChange(changes: textChanges.ChangeTracker, sourceFile: SourceFile, constructor: Constru…
31 changes.insertNodeAtConstructorStart(sourceFile, constructor, superCall);
32 changes.delete(sourceFile, superCall);
35 …function getNodes(sourceFile: SourceFile, pos: number): { readonly constructor: ConstructorDeclara…
36 const token = getTokenAtPosition(sourceFile, pos);
DfixClassDoesntImplementInheritedAbstractMember.ts11 const { sourceFile, span } = context; constant
13 … addMissingMembers(getClass(sourceFile, span.start), sourceFile, context, t, context.preferences));
22 … addMissingMembers(classDeclaration, context.sourceFile, context, changes, context.preferences);
28 function getClass(sourceFile: SourceFile, pos: number): ClassLikeDeclaration {
31 const token = getTokenAtPosition(sourceFile, pos);
35 …function addMissingMembers(classDeclaration: ClassLikeDeclaration, sourceFile: SourceFile, context…
44 … const importAdder = createImportAdder(sourceFile, context.program, preferences, context.host);
45 …nPrivateExtendsSymbols, sourceFile, context, preferences, importAdder, member => changeTracker.ins…
/third_party/typescript/src/testRunner/unittests/tsserver/
DdocumentRegistry.ts58 const sourceFile = moduleInfo.cacheSourceFile!.sourceFile; constant
59 assert.equal(project.getSourceFile(moduleInfo.path), sourceFile);
63 assert.equal(moduleInfo.cacheSourceFile!.sourceFile, sourceFile);
67 assert.equal(moduleInfo.cacheSourceFile!.sourceFile, sourceFile);
68 assert.equal(project.getSourceFile(moduleInfo.path), sourceFile);
76 const sourceFile = moduleInfo.cacheSourceFile!.sourceFile; constant
77 assert.equal(project.getSourceFile(moduleInfo.path), sourceFile);
81 assert.equal(moduleInfo.cacheSourceFile!.sourceFile, sourceFile);
88 assert.notEqual(moduleInfo.cacheSourceFile!.sourceFile, sourceFile);
89 … assert.equal(project.getSourceFile(moduleInfo.path), moduleInfo.cacheSourceFile!.sourceFile);
[all …]

12345678910>>...19