Skip to content

Commit

Permalink
refactor: Remove getRelativePathToSourceFile and getRelativePathToSou…
Browse files Browse the repository at this point in the history
…rceFileAsModuleSpecifier.

BREAKING CHANGE: SourceFile.getRelativePathToSourceFile and getRelativePathToSourceFileAsModuleSpecifier is now getRelativePathTo and getRelativePathAsModuleSpecifierTo respectively.
  • Loading branch information
dsherret committed Apr 22, 2018
1 parent 0b098a5 commit 734b7a0
Show file tree
Hide file tree
Showing 8 changed files with 13 additions and 31 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
"run-sequence": "^2.2.1",
"ts-nameof": "^0.10.3",
"ts-node": "^6.0.0",
"ts-simple-ast": "10.3.1",
"ts-simple-ast": "10.5.0",
"tslint": "^5.8.0"
},
"dependencies": {
Expand Down
2 changes: 1 addition & 1 deletion scripts/createCompilerApiLayer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export function createCompilerApiLayer(factory: InspectorFactory) {
moduleSpecifier: "typescript"
}, {
namedImports: ["ObjectUtils"],
moduleSpecifier: sourceFile.getRelativePathToSourceFileAsModuleSpecifier(project.getSourceFileOrThrow("src/utils/ObjectUtils.ts"))
moduleSpecifier: sourceFile.getRelativePathAsModuleSpecifier(project.getSourceFileOrThrow("src/utils/ObjectUtils.ts"))
}]);

addSeparatedDeclarations();
Expand Down
4 changes: 2 additions & 2 deletions scripts/createKindToNodeMappings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ export function createKindToNodeMappings(inspector: TsSimpleAstInspector, tsInsp
// add imports
kindToNodeMappingsFile.addImportDeclaration({
namespaceImport: "compiler",
moduleSpecifier: kindToNodeMappingsFile.getRelativePathToSourceFileAsModuleSpecifier(project.getSourceFileOrThrow("src/compiler/index.ts"))
moduleSpecifier: kindToNodeMappingsFile.getRelativePathAsModuleSpecifierTo(project.getSourceFileOrThrow("src/compiler/index.ts"))
});
kindToNodeMappingsFile.addImportDeclaration({
namedImports: ["SyntaxKind"],
moduleSpecifier: kindToNodeMappingsFile.getRelativePathToSourceFileAsModuleSpecifier(project.getSourceFileOrThrow("src/typescript/index.ts"))
moduleSpecifier: kindToNodeMappingsFile.getRelativePathAsModuleSpecifierTo(project.getSourceFileOrThrow("src/typescript/index.ts"))
});

addTypeForSubSet("KindToNodeMappings", project.getSourceFileOrThrow("Node.ts").getClassOrThrow("Node"));
Expand Down
6 changes: 3 additions & 3 deletions scripts/createStructurePrinterFactory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,15 @@ export function createStructurePrinterFactory(inspector: TsSimpleAstInspector) {
// add imports
sourceFile.addImportDeclaration({
namespaceImport: "structurePrinters",
moduleSpecifier: sourceFile.getRelativePathToSourceFileAsModuleSpecifier(project.getSourceFileOrThrow("src/structurePrinters/index.ts"))
moduleSpecifier: sourceFile.getRelativePathAsModuleSpecifierTo(project.getSourceFileOrThrow("src/structurePrinters/index.ts"))
});
sourceFile.addImportDeclaration({
namedImports: ["SupportedFormatCodeSettings"],
moduleSpecifier: sourceFile.getRelativePathToSourceFileAsModuleSpecifier(project.getSourceFileOrThrow("src/options/index.ts"))
moduleSpecifier: sourceFile.getRelativePathAsModuleSpecifierTo(project.getSourceFileOrThrow("src/options/index.ts"))
});
sourceFile.addImportDeclaration({
namedImports: ["Memoize"],
moduleSpecifier: sourceFile.getRelativePathToSourceFileAsModuleSpecifier(project.getSourceFileOrThrow("src/utils/index.ts"))
moduleSpecifier: sourceFile.getRelativePathAsModuleSpecifierTo(project.getSourceFileOrThrow("src/utils/index.ts"))
});

sourceFile.addClass({
Expand Down
4 changes: 2 additions & 2 deletions scripts/flattenDeclarationFiles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@ export function flattenDeclarationFiles(project: Project, mainFile: SourceFile)
mainFile.addImportDeclaration({
namedImports: ["ts", "SyntaxKind", "CompilerOptions", "EmitHint", "ScriptKind", "NewLineKind", "LanguageVariant", "ScriptTarget",
"TypeFlags", "ObjectFlags", "SymbolFlags", "TypeFormatFlags", "DiagnosticCategory", "EditorSettings", "ModuleResolutionKind"],
moduleSpecifier: mainFile.getRelativePathToSourceFileAsModuleSpecifier(compilerApiFile)
moduleSpecifier: mainFile.getRelativePathAsModuleSpecifierTo(compilerApiFile)
});

mainFile.addExportDeclaration({ moduleSpecifier: mainFile.getRelativePathToSourceFileAsModuleSpecifier(compilerApiFile) });
mainFile.addExportDeclaration({ moduleSpecifier: mainFile.getRelativePathAsModuleSpecifierTo(compilerApiFile) });

// update the main.d.ts file
mainFile.getClassOrThrow("Project").setIsDefaultExport(true);
Expand Down
18 changes: 0 additions & 18 deletions src/compiler/file/SourceFile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -915,15 +915,6 @@ export class SourceFile extends SourceFileBase<ts.SourceFile> {
return this._refreshFromFileSystemInternal(fileReadResult);
}

/**
* Gets the relative path to another source file.
* @param sourceFile - Source file.
* @deprecated Use `getRelativePathTo`.
*/
getRelativePathToSourceFile(sourceFile: SourceFile) {
return this.getRelativePathTo(sourceFile);
}

/**
* Gets the relative path to another source file.
* @param sourceFile - Source file.
Expand All @@ -938,15 +929,6 @@ export class SourceFile extends SourceFileBase<ts.SourceFile> {
return this.getDirectory().getRelativePathTo(sourceFileOrDir);
}

/**
* Gets the relative path to the specified source file as a module specifier.
* @param sourceFile - Source file.
* @deprecated Use `getRelativePathAsModuleSpecifierTo`.
*/
getRelativePathToSourceFileAsModuleSpecifier(sourceFile: SourceFile) {
return this.getRelativePathAsModuleSpecifierTo(sourceFile);
}

/**
* Gets the relative path to the specified source file as a module specifier.
* @param sourceFile - Source file.
Expand Down
1 change: 0 additions & 1 deletion src/next-major-deprecations.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,4 @@

Remove:

* `getRelativePathToSourceFile` and `getRelativePathToSourceFileAsModuleSpecifier`
* `Directory.remove`
7 changes: 4 additions & 3 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2709,9 +2709,9 @@ ts-node@^6.0.0:
source-map-support "^0.5.3"
yn "^2.0.0"

ts-simple-ast@10.3.1:
version "10.3.1"
resolved "https://registry.yarnpkg.com/ts-simple-ast/-/ts-simple-ast-10.3.1.tgz#6cfb84a607086a3bd6c1f4d486fdf17d311ab953"
ts-simple-ast@10.5.0:
version "10.5.0"
resolved "https://registry.yarnpkg.com/ts-simple-ast/-/ts-simple-ast-10.5.0.tgz#4729db16b911adb6536394d6e63c8a7f978fadee"
dependencies:
"@dsherret/to-absolute-glob" "^2.0.2"
code-block-writer "6.13.0"
Expand All @@ -2720,6 +2720,7 @@ ts-simple-ast@10.3.1:
is-negated-glob "^1.0.0"
multimatch "^2.1.0"
object-assign "^4.1.1"
tslib "^1.9.0"
typescript "2.8.1"

tslib@^1.8.0, tslib@^1.8.1, tslib@^1.9.0:
Expand Down

0 comments on commit 734b7a0

Please sign in to comment.