Skip to content

Commit 335d43b

Browse files
author
Max Schaefer
committed
JavaScript: Make AutoBuild less stateful.
1 parent bca941d commit 335d43b

2 files changed

Lines changed: 11 additions & 12 deletions

File tree

javascript/extractor/src/com/semmle/js/extractor/AutoBuild.java

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -167,14 +167,13 @@
167167
public class AutoBuild {
168168
private final ExtractorOutputConfig outputConfig;
169169
private final ITrapCache trapCache;
170-
private Set<Path> includes = new LinkedHashSet<>();
171-
private Set<Path> excludes = new LinkedHashSet<>();
170+
private final Set<Path> includes = new LinkedHashSet<>();
171+
private final Set<Path> excludes = new LinkedHashSet<>();
172172
private ProjectLayout filters;
173173
private final Path LGTM_SRC, SEMMLE_DIST;
174174
private final TypeScriptMode typeScriptMode;
175175
private final String defaultEncoding;
176176
private ExtractorState extractorState;
177-
private long timedLogMessageStart = 0;
178177

179178
public AutoBuild() {
180179
this.LGTM_SRC = toRealPath(getPathFromEnvVar("LGTM_SRC"));
@@ -502,9 +501,9 @@ public FileVisitResult preVisitDirectory(Path dir, BasicFileAttributes attrs) th
502501
Set<Path> extractedFiles = new LinkedHashSet<>();
503502
for (Path projectPath : tsconfigFiles) {
504503
File projectFile = projectPath.toFile();
505-
logBeginProcess("Opening project " + projectFile);
504+
long start = logBeginProcess("Opening project " + projectFile);
506505
ParsedProject project = tsParser.openProject(projectFile);
507-
logEndProcess();
506+
logEndProcess(start);
508507
// Extract all files belonging to this project which are also matched
509508
// by our include/exclude filters.
510509
List<File> typeScriptFiles = new ArrayList<File>();
@@ -605,25 +604,25 @@ protected void extract(FileExtractor extractor, Path file) throws IOException {
605604
return;
606605
}
607606

608-
logBeginProcess("Extracting " + file);
607+
long start = logBeginProcess("Extracting " + file);
609608
extractor.extract(f);
610-
logEndProcess();
609+
logEndProcess(start);
611610
}
612611

613612
private void warn(String msg) {
614613
System.err.println(msg);
615614
System.err.flush();
616615
}
617616

618-
private void logBeginProcess(String message) {
617+
private long logBeginProcess(String message) {
619618
System.out.print(message + "...");
620619
System.out.flush();
621-
this.timedLogMessageStart = System.nanoTime();
620+
return System.nanoTime();
622621
}
623622

624-
private void logEndProcess() {
623+
private void logEndProcess(long timedLogMessageStart) {
625624
long end = System.nanoTime();
626-
int milliseconds = (int) ((end - this.timedLogMessageStart) / 1000000);
625+
int milliseconds = (int) ((end - timedLogMessageStart) / 1000000);
627626
System.out.println(" done (" + milliseconds + " ms)");
628627
}
629628

javascript/extractor/src/com/semmle/js/extractor/test/AutoBuildTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ public void verifyTypeScriptInstallation() {
103103
}
104104

105105
@Override
106-
public void extractTypeScriptFiles(List<File> files, Set<Path> extractedFiles, FileExtractor extractor) throws IOException {
106+
public void extractTypeScriptFiles(java.util.List<File> files, java.util.Set<Path> extractedFiles, FileExtractor extractor, ExtractorState extractorState) {
107107
for (File f : files) {
108108
actual.add(f.toString());
109109
}

0 commit comments

Comments
 (0)