|
54 | 54 | import java.util.function.Supplier; |
55 | 55 | import java.util.stream.Collectors; |
56 | 56 | import javax.annotation.Nullable; |
57 | | -import org.apache.commons.lang3.StringUtils; |
| 57 | +import org.slf4j.Logger; |
| 58 | +import org.slf4j.LoggerFactory; |
58 | 59 | import org.sonar.plugins.communitydelphi.api.ast.ArgumentListNode; |
59 | 60 | import org.sonar.plugins.communitydelphi.api.ast.ArrayAccessorNode; |
60 | 61 | import org.sonar.plugins.communitydelphi.api.ast.AttributeNode; |
|
105 | 106 | import org.sonar.plugins.communitydelphi.api.type.Typed; |
106 | 107 |
|
107 | 108 | public class NameResolver { |
| 109 | + private static final Logger LOG = LoggerFactory.getLogger(NameResolver.class); |
108 | 110 | private final TypeFactory typeFactory; |
109 | 111 | private final List<NameOccurrenceImpl> names = new ArrayList<>(); |
110 | 112 | private final List<NameDeclaration> resolvedDeclarations = new ArrayList<>(); |
@@ -196,7 +198,12 @@ NameDeclaration addResolvedDeclaration() { |
196 | 198 |
|
197 | 199 | public void checkAmbiguity() { |
198 | 200 | if (declarations.size() > 1) { |
199 | | - throw new DisambiguationException(declarations, Iterables.getLast(names)); |
| 201 | + LOG.warn( |
| 202 | + "Ambiguous declarations could not be resolved\n[Occurrence] {}{}", |
| 203 | + Iterables.getLast(names), |
| 204 | + declarations.stream().map(declaration -> "\n[Declaration] " + declaration)); |
| 205 | + |
| 206 | + declarations.clear(); |
200 | 207 | } |
201 | 208 | } |
202 | 209 |
|
@@ -1389,14 +1396,4 @@ private static void registerOccurrence(NameOccurrenceImpl occurrence) { |
1389 | 1396 | FileScope scope = occurrence.getLocation().getScope().getEnclosingScope(FileScope.class); |
1390 | 1397 | ((FileScopeImpl) scope).registerOccurrence(occurrence.getLocation(), occurrence); |
1391 | 1398 | } |
1392 | | - |
1393 | | - private static class DisambiguationException extends RuntimeException { |
1394 | | - DisambiguationException(Set<NameDeclaration> declarations, NameOccurrence occurrence) { |
1395 | | - super( |
1396 | | - "Ambiguous declarations could not be resolved\n[Occurrence] " |
1397 | | - + occurrence |
1398 | | - + "\n[Declaration] " |
1399 | | - + StringUtils.join(declarations, "\n[Declaration] ")); |
1400 | | - } |
1401 | | - } |
1402 | 1399 | } |
0 commit comments