Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

style(compiler-cli): remove unused codes #38462

Closed
wants to merge 1 commit into from
Closed

Conversation

ahnpnl
Copy link
Contributor

@ahnpnl ahnpnl commented Aug 14, 2020

PR Checklist

Please check if your PR fulfills the following requirements:

PR Type

What kind of change does this PR introduce?

  • Bugfix
  • Feature
  • Code style update (formatting, local variables)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • CI related changes
  • Documentation content changes
  • angular.io application / infrastructure changes
  • Other... Please describe:

What is the current behavior?

  • The private property _programWithStubs is not used anywhere in class AngularCompilerProgram.

  • The const codegen is not used anywhere in _createProgramWithBasicStubs method.

This PR is to remove those 2 above.

Issue Number: N.A.

What is the new behavior?

N.A.

Does this PR introduce a breaking change?

  • Yes
  • No

Other information

N.A.

@pullapprove pullapprove bot requested a review from alxhub August 14, 2020 08:37
@petebacondarwin petebacondarwin added area: compiler Issues related to `ngc`, Angular's template compiler action: review The PR is still awaiting reviews from at least one requested reviewer target: patch This PR is targeted for the next patch release refactoring Issue that involves refactoring or code-cleanup labels Aug 14, 2020
@ngbot ngbot bot modified the milestone: needsTriage Aug 14, 2020
- Remove unused private property _programWithStubs
- Remove unused const codegen in _createProgramWithBasicStubs method
@petebacondarwin
Copy link
Member

There are actually quite a few places in this file that could be cleaned up. Perhaps you could include these too?
That being said, this is ViewEngine specific code, which is deprecated and at some point removed entirely, so I don't see this PR as a priority.

diff --git a/packages/compiler-cli/src/transformers/program.ts b/packages/compiler-cli/src/transformers/program.ts
index f82477b43a..42f7010eb3 100644
--- a/packages/compiler-cli/src/transformers/program.ts
+++ b/packages/compiler-cli/src/transformers/program.ts
@@ -102,9 +102,7 @@ class AngularCompilerProgram implements Program {
   private _analyzedModules: NgAnalyzedModules|undefined;
   private _analyzedInjectables: NgAnalyzedFileWithInjectables[]|undefined;
   private _structuralDiagnostics: Diagnostic[]|undefined;
-  private _programWithStubs: ts.Program|undefined;
   private _optionsDiagnostics: Diagnostic[] = [];
-  private _transformTsDiagnostics: ts.Diagnostic[] = [];
 
   constructor(
       rootNames: ReadonlyArray<string>, private options: CompilerOptions,
@@ -155,8 +153,7 @@ class AngularCompilerProgram implements Program {
       this.oldProgramLibrarySummaries.forEach((summary, fileName) => result.set(fileName, summary));
     }
     if (this.emittedLibrarySummaries) {
-      this.emittedLibrarySummaries.forEach(
-          (summary, fileName) => result.set(summary.fileName, summary));
+      this.emittedLibrarySummaries.forEach((summary) => result.set(summary.fileName, summary));
     }
     return result;
   }
@@ -269,7 +266,6 @@ class AngularCompilerProgram implements Program {
 
   private _emitRender2({
     emitFlags = EmitFlags.Default,
-    cancellationToken,
     customTransformers,
     emitCallback = defaultEmitCallback,
     mergeEmitResultsCallback = mergeEmitResults,
@@ -305,7 +301,6 @@ class AngularCompilerProgram implements Program {
     const genFileByFileName = new Map<string, GeneratedFile>();
     genFiles.forEach(genFile => genFileByFileName.set(genFile.genFileUrl, genFile));
     this.emittedLibrarySummaries = [];
-    this._transformTsDiagnostics = [];
     const emittedSourceFiles = [] as ts.SourceFile[];
     const writeTsFile: ts.WriteFileCallback =
         (outFileName, outData, writeByteOrderMark, onError?, sourceFiles?) => {
@@ -605,11 +600,6 @@ class AngularCompilerProgram implements Program {
     const oldTsProgram = this.oldTsProgram;
     this.oldTsProgram = undefined;
 
-    const codegen: CodeGenerator = {
-      generateFile: (genFileName, baseFileName) =>
-          this.compiler.emitBasicStub(genFileName, baseFileName),
-      findGeneratedFileNames: (fileName) => this.compiler.findGeneratedFileNames(fileName),
-    };
 
 
     let rootNames = [...this.rootNames];
@@ -909,7 +899,6 @@ export function createSrcToOutPathMapper(
       relative: typeof path.relative
     } = path): (srcFileName: string) => string {
   if (outDir) {
-    let path: {} = {};  // Ensure we error if we use `path` instead of `host`.
     if (sampleSrcFileName == null || sampleOutFileName == null) {
       throw new Error(`Can't calculate the rootDir without a sample srcFileName / outFileName. `);
     }
@@ -1019,15 +1008,6 @@ function diagnosticSourceOfSpan(span: ParseSourceSpan): ts.SourceFile {
   return ({fileName: span.start.file.url, text: span.start.file.content} as any);
 }
 
-function diagnosticSourceOfFileName(fileName: string, program: ts.Program): ts.SourceFile {
-  const sourceFile = program.getSourceFile(fileName);
-  if (sourceFile) return sourceFile;
-
-  // If we are reporting diagnostics for a source file that is not in the project then we need
-  // to fake a source file so the diagnostic formatting routines can emit the file name.
-  // The redundant '()' are here is to avoid having clang-format breaking the line incorrectly.
-  return ({fileName, text: ''} as any);
-}
 
 
 function diagnosticChainFromFormattedDiagnosticChain(chain: FormattedMessageChain):

@petebacondarwin petebacondarwin added the action: cleanup The PR is in need of cleanup, either due to needing a rebase or in response to comments from reviews label Dec 2, 2020
@pullapprove pullapprove bot removed the area: compiler Issues related to `ngc`, Angular's template compiler label Dec 9, 2020
@ngbot ngbot bot removed this from the needsTriage milestone Dec 9, 2020
@pullapprove pullapprove bot added the area: compiler Issues related to `ngc`, Angular's template compiler label Dec 10, 2020
@ngbot ngbot bot added this to the Backlog milestone Dec 10, 2020
@AndrewKushnir
Copy link
Contributor

Closing this PR since it's ViewEngine-specific and ViewEngine is deprecated (so only critical and security fixes would be merged into ViewEngine-specific code).

@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Feb 20, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
action: cleanup The PR is in need of cleanup, either due to needing a rebase or in response to comments from reviews action: review The PR is still awaiting reviews from at least one requested reviewer area: compiler Issues related to `ngc`, Angular's template compiler cla: yes refactoring Issue that involves refactoring or code-cleanup target: patch This PR is targeted for the next patch release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants