Home
last modified time | relevance | path

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

12345678910>>...17

/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 = (findChild("foo", sourceFile) as FunctionDeclaration).body!.statements.slice(1);
95 … changeTracker.insertNodeBefore(sourceFile, /*before*/findChild("M2", sourceFile), newFunction);
[all …]
/third_party/typescript/src/services/
DtextChanges.ts135 readonly sourceFile: SourceFile; property
163 …function getAdjustedRange(sourceFile: SourceFile, startNode: Node, endNode: Node, options: Configu…
164 …return { pos: getAdjustedStartPosition(sourceFile, startNode, options), end: getAdjustedEndPositio…
167 …function getAdjustedStartPosition(sourceFile: SourceFile, node: Node, options: ConfigurableStartEn…
170 return node.getStart(sourceFile);
173 const startPos = node.getStart(sourceFile);
174 const pos = getLineStartPositionForPosition(startPos, sourceFile);
178 const JSDocComments = getJSDocCommentRanges(node, sourceFile.text);
180 return getLineStartPositionForPosition(JSDocComments[0].pos, sourceFile);
184 const start = node.getStart(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);
46 … addOutliningForLeadingCommentsForPos(n.statements.end, sourceFile, cancellationToken, out);
[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 …]
Drename.ts3 …export function getRenameInfo(program: Program, sourceFile: SourceFile, position: number, preferen…
4 const node = getAdjustedRenameLocation(getTouchingPropertyName(sourceFile, position));
6 …const renameInfo = getRenameInfoForNode(node, program.getTypeChecker(), sourceFile, program, prefe…
17 sourceFile: SourceFile,
27 … return getRenameInfoSuccess(node.text, node.text, ScriptElementKind.string, "", node, sourceFile);
32 …InfoSuccess(name, name, ScriptElementKind.label, ScriptElementKindModifier.none, node, sourceFile);
51 …return preferences.allowRenameOfImportPath ? getRenameInfoForModule(node, sourceFile, symbol) : un…
55 …const wouldRenameNodeModules = wouldRenameInOtherNodeModules(sourceFile, symbol, typeChecker, pref…
66 …me, fullDisplayName, kind, SymbolDisplay.getSymbolModifiers(typeChecker,symbol), node, sourceFile);
70 const sourceFile = declaration.getSourceFile(); constant
[all …]
Dutilities.ts495 …export function getLineStartPositionForPosition(position: number, sourceFile: SourceFileLike): num…
496 const lineStarts = getLineStarts(sourceFile);
497 const line = sourceFile.getLineAndCharacterOfPosition(position).line;
529 …export function nodeOverlapsWithStartEnd(node: Node, sourceFile: SourceFile, start: number, end: n…
530 return startEndOverlapsWithStartEnd(node.getStart(sourceFile), node.end, start, end);
542 …export function positionBelongsToNode(candidate: Node, position: number, sourceFile: SourceFile): …
544 return position < candidate.end || !isCompletedNode(candidate, sourceFile);
547 function isCompletedNode(n: Node | undefined, sourceFile: SourceFile): boolean {
565 return nodeEndsWith(n, SyntaxKind.CloseBraceToken, sourceFile);
567 return isCompletedNode((n as CatchClause).block, sourceFile);
[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),
50 …function getSyntacticDocumentHighlights(node: Node, sourceFile: SourceFile): DocumentHighlights[] …
51 const highlightSpans = getHighlightSpans(node, sourceFile);
[all …]
DgoToDefinition.ts3 …export function getDefinitionAtPosition(program: Program, sourceFile: SourceFile, position: number…
4 const resolvedRef = getReferenceAtPosition(sourceFile, position, program);
11 const node = getTouchingPropertyName(sourceFile, position);
12 if (node === sourceFile) {
41 const sourceFile = node.getSourceFile(); constant
44 pos = skipTrivia(sourceFile.text, pos);
65 …const ref = sourceFile.resolvedModules?.get(fallbackNode.text, getModeForUsageLocation(sourceFile,…
87 …Only && every(symbol.declarations, d => d.getSourceFile().fileName === sourceFile.fileName)) retur…
211 …export function getReferenceAtPosition(sourceFile: SourceFile, position: number, program: Program)…
212 const referencePath = findReferenceInPosition(sourceFile.referencedFiles, position);
[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;
58 const currentToken = getTokenAtPosition(sourceFile, position);
81 return getBlockIndent(sourceFile, position, options);
86 …ctualIndentation = getActualIndentationForListItemBeforeComma(precedingToken, sourceFile, options);
[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 …const { emitSkipped, diagnostics } = program.emit(sourceFile, writeFile, cancellationToken, emitOn…
178 …function getReferencedFiles(program: Program, sourceFile: SourceFile, getCanonicalFileName: GetCan…
184 if (sourceFile.imports && sourceFile.imports.length > 0) {
186 for (const importName of sourceFile.imports) {
192 const sourceFileDirectory = getDirectoryPath(sourceFile.resolvedPath);
194 if (sourceFile.referencedFiles && sourceFile.referencedFiles.length > 0) {
195 for (const referencedFile of sourceFile.referencedFiles) {
202 if (sourceFile.resolvedTypeReferenceDirectiveNames) {
203sourceFile.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 …]
DaddMissingAwait.ts34 const { sourceFile, errorCode, span, cancellationToken, program } = context; constant
35 …const expression = getAwaitErrorSpanExpression(sourceFile, errorCode, span, cancellationToken, pro…
47 const { sourceFile, program, cancellationToken } = context; constant
51 …const expression = getAwaitErrorSpanExpression(sourceFile, diagnostic.code, diagnostic, cancellati…
62 …function getAwaitErrorSpanExpression(sourceFile: SourceFile, errorCode: number, span: TextSpan, ca…
63 const expression = getFixableErrorSpanExpression(sourceFile, span);
65 && isMissingAwaitError(sourceFile, errorCode, span, cancellationToken, program)
70 const { sourceFile, program, cancellationToken } = context; constant
71 …const awaitableInitializers = findAwaitableInitializers(expression, sourceFile, cancellationToken,…
74 …nitializers.initializers, ({ expression }) => makeChange(t, errorCode, sourceFile, checker, expres…
[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 …]
DconvertToEsModule.ts6 const { sourceFile, program, preferences } = context; constant
8 …leToEsModule(sourceFile, program.getTypeChecker(), changes, getEmitScriptTarget(program.getCompile…
11 …fixImportOfModuleExports(importingFile, sourceFile, changes, getQuotePreference(importingFile, pre…
42 …function convertFileToEsModule(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 …]
DimportFixes.ts20 const { errorCode, preferences, sourceFile, span, program } = context; constant
23 const quotePreference = getQuotePreference(sourceFile, preferences);
26 sourceFile,
35 const { sourceFile, program, preferences, host, cancellationToken } = context; constant
36 …const importAdder = createImportAdderWorker(sourceFile, program, /*useAutoImportProvider*/ true, p…
52 …export function createImportAdder(sourceFile: SourceFile, program: Program, preferences: UserPrefe…
53 …return createImportAdderWorker(sourceFile, program, /*useAutoImportProvider*/ false, preferences, …
62 …function createImportAdderWorker(sourceFile: SourceFile, program: Program, useAutoImportProvider: …
86 …const exportInfo = getAllExportInfoForSymbol(sourceFile, symbol, symbolName, /*isJsxTagName*/ fals…
87 const useRequire = shouldUseRequire(sourceFile, program);
[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(
27 …function createAction(context: CodeFixContext, sourceFile: SourceFile, node: Node, replacement: No…
28 …const changes = textChanges.ChangeTracker.with(context, t => t.replaceNode(sourceFile, node, repla…
41 const sourceFile = context.sourceFile; constant
43 …const node = findAncestor(getTokenAtPosition(sourceFile, context.span.start), a => a.kind === targ…
70 const sourceFile = context.sourceFile; constant
71 …const node = findAncestor(getTokenAtPosition(sourceFile, context.span.start), a => a.getStart() ==…
89 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.checkDefined(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 …]
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);
DfixAwaitInSyncFunction.ts12 const { sourceFile, span } = context; constant
13 const nodes = getNodes(sourceFile, span.start);
15 … const changes = textChanges.ChangeTracker.with(context, t => doChange(t, sourceFile, nodes));
24 doChange(changes, context.sourceFile, nodes);
40 …function getNodes(sourceFile: SourceFile, start: number): { insertBefore: Node, returnType: TypeNo…
41 const token = getTokenAtPosition(sourceFile, start);
54 … insertBefore = findChildOfKind(containingFunction, SyntaxKind.FunctionKeyword, sourceFile);
58 …insertBefore = findChildOfKind(containingFunction, kind, sourceFile) || first(containingFunction.p…
72 sourceFile: SourceFile,
78 …changes.replaceNode(sourceFile, returnType, factory.createTypeReferenceNode("Promise", factory.cre…
[all …]
/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>>...17