Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

- Include the global browsing path in unit import resolution.
- Reprioritize the analysis search path in the following order (highest to lowest):
- Analysis source files (`sonar.sources`)
- Referenced project files (`DCCReference`)
- Search path (`DCC_UnitSearchPath`)
- Debugger source path (`Debugger_DebugSourcePath`)
- Library path (`DelphiLibraryPath`/`DelphiTranslatedLibraryPath`)
- Browsing path (`DelphiBrowsingPath`)
- Standard library
- Analysis source files (`sonar.sources`)
- Empty anonymous methods are now ignored in `EmptyBlock`.
- Empty anonymous methods are now flagged in `EmptyRoutine`.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ private static boolean isPasFile(Path path) {
}

private void createUnitData(Path unitPath, boolean isSourceFile) {
if (unitPaths.add(unitPath)) {
if (unitPaths.add(unitPath) || isSourceFile) {
String unitName = FilenameUtils.getBaseName(unitPath.toString());
UnitData unitData = new UnitData(unitPath, isSourceFile);

Expand Down Expand Up @@ -459,11 +459,10 @@ public SymbolTable build() {
throw new SymbolTableConstructionException("typeFactory was not supplied.");
}

sourceFiles.forEach(file -> this.createUnitData(file, true));
referencedFiles.forEach(file -> this.createUnitData(file, false));
searchPath.getRootDirectories().forEach(this::processSearchPath);

processStandardLibrarySearchPaths();
sourceFiles.forEach(file -> this.createUnitData(file, true));

ProgressReport progressReport =
new ProgressReport(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,43 +159,6 @@ void testStandardLibrarySearchPathShouldExcludeToolsUnits(
assertThat(symbolTable.getUnitByPath(excludedPath.toString())).isNull();
}

@Test
void testSonarSourcesArePrioritizedOverReferencedFiles(
@TempDir Path standardLibraryPath,
@TempDir Path referencedFilesPath,
@TempDir Path sourceFilesPath)
throws IOException {
createStandardLibrary(standardLibraryPath);
createStandardLibrary(referencedFilesPath);
createStandardLibrary(sourceFilesPath);

List<Path> referencedFiles;
try (Stream<Path> referencedFilesStream = Files.list(referencedFilesPath)) {
referencedFiles = referencedFilesStream.collect(Collectors.toUnmodifiableList());
}

List<Path> sourceFiles;
try (Stream<Path> sourceFilesStream = Files.list(sourceFilesPath)) {
sourceFiles = sourceFilesStream.collect(Collectors.toUnmodifiableList());
}

SymbolTable symbolTable =
SymbolTable.builder()
.preprocessorFactory(new DelphiPreprocessorFactory(Platform.WINDOWS))
.typeFactory(TypeFactoryUtils.defaultFactory())
.standardLibraryPath(standardLibraryPath)
.referencedFiles(referencedFiles)
.sourceFiles(sourceFiles)
.build();

assertThat(symbolTable.getUnitByPath(standardLibraryPath.resolve("SysInit.pas").toString()))
.isNull();
assertThat(symbolTable.getUnitByPath(referencedFilesPath.resolve("SysInit.pas").toString()))
.isNull();
assertThat(symbolTable.getUnitByPath(sourceFilesPath.resolve("SysInit.pas").toString()))
.isNotNull();
}

@Test
void testReferencedFilesArePrioritizedOverSearchPath(
@TempDir Path standardLibraryPath,
Expand Down