File tree Expand file tree Collapse file tree 2 files changed +15
-1
lines changed
delphi-frontend/src/main/java/au/com/integradev/delphi/symbol/scope Expand file tree Collapse file tree 2 files changed +15
-1
lines changed Original file line number Diff line number Diff line change @@ -12,6 +12,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1212- The ` Copy ` intrinsic inferred an incorrect return type for ` PChar ` , ` PAnsiChar ` , and variants.
1313- The ` Concat ` intrinsic inferred an incorrect return type for single-character string literals.
1414- Ideographic space (U+3000) was erroneously accepted as a valid identifier character.
15+ - Duplicate imports in a ` requires ` clause now log a warning instead of throwing an exception.
1516
1617## [ 1.1.0] - 2024-01-02
1718
Original file line number Diff line number Diff line change 3232import java .util .Map ;
3333import java .util .Set ;
3434import java .util .stream .Collectors ;
35+ import org .slf4j .Logger ;
36+ import org .slf4j .LoggerFactory ;
3537import org .sonar .plugins .communitydelphi .api .ast .ArrayAccessorNode ;
3638import org .sonar .plugins .communitydelphi .api .ast .NameDeclarationNode ;
3739import org .sonar .plugins .communitydelphi .api .ast .NameReferenceNode ;
4850import org .sonar .plugins .communitydelphi .api .type .Type .HelperType ;
4951
5052public abstract class FileScopeImpl extends DelphiScopeImpl implements FileScope {
53+ private static final Logger LOG = LoggerFactory .getLogger (FileScopeImpl .class );
5154 private final String name ;
5255 private final Deque <FileScope > imports = new ArrayDeque <>();
5356 private Map <Integer , DelphiScope > registeredScopes = new HashMap <>();
@@ -107,7 +110,17 @@ public void addDeclaration(NameDeclaration declaration) {
107110 imports .addFirst (scope );
108111 }
109112 }
110- super .addDeclaration (declaration );
113+
114+ try {
115+ super .addDeclaration (declaration );
116+ } catch (DuplicatedDeclarationException e ) {
117+ if (declaration instanceof UnitImportNameDeclaration ) {
118+ // 'requires' clauses can have multiple occurrences of the same unit import
119+ LOG .warn ("Duplicate unit import found: {}" , e .getMessage ());
120+ } else {
121+ throw e ;
122+ }
123+ }
111124 }
112125
113126 @ Override
You can’t perform that action at this time.
0 commit comments