Skip to content

Commit 737d197

Browse files
cirrasfourls
authored andcommitted
Add debug logging for name resolution failures
1 parent 70e0626 commit 737d197

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1010
### Added
1111

1212
- Support for MSBuild item and item metadata expressions in project files.
13+
- Debug logging for name resolution failures (enabled with `sonar-scanner -X`).
1314
- `ExhaustiveEnumCase` analysis rule, which flags `case` statements that do not handle all values in an enumeration.
1415
- `IterationPastHighBound` analysis rule, which flags `for` loops that iterate past the end of the collection.
1516
- `ExplicitBitwiseNot` analysis rule, which flags potentially incorrect bitwise `not` operations.

delphi-frontend/src/main/java/au/com/integradev/delphi/symbol/resolve/NameResolver.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,18 @@ private void checkAmbiguity() {
217217
}
218218
}
219219

220+
private void checkNameResolutionFailed() {
221+
if (LOG.isDebugEnabled() && nameResolutionFailed()) {
222+
Node location = Iterables.getLast(names).getLocation();
223+
LOG.debug(
224+
"Name resolution failed on symbol '{}' ({} line {}:{})",
225+
location.getImage(),
226+
location.getUnitName(),
227+
location.getBeginLine(),
228+
location.getBeginColumn());
229+
}
230+
}
231+
220232
void updateType(Type type) {
221233
currentType = type;
222234
ScopedType scopedType = extractScopedType(currentType);
@@ -233,6 +245,7 @@ public boolean isExplicitInvocation() {
233245

234246
public void addToSymbolTable() {
235247
addResolvedDeclaration();
248+
checkNameResolutionFailed();
236249

237250
for (int i = 0; i < resolvedDeclarations.size(); ++i) {
238251
NameOccurrenceImpl name = names.get(i);

0 commit comments

Comments
 (0)