forked from finos/rune-dsl
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* implement import as * update documentation with import alias details * add extra validation tests for import as
- Loading branch information
Showing
8 changed files
with
255 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
64 changes: 64 additions & 0 deletions
64
rosetta-lang/src/main/java/com/regnosys/rosetta/scoping/AliasAwareImportNormalizer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
package com.regnosys.rosetta.scoping; | ||
|
||
import org.eclipse.xtext.naming.QualifiedName; | ||
import org.eclipse.xtext.scoping.impl.ImportNormalizer; | ||
|
||
public class AliasAwareImportNormalizer extends ImportNormalizer { | ||
private final ImportNormalizer aliasNormalizer; | ||
|
||
public AliasAwareImportNormalizer(QualifiedName importedNamespace, QualifiedName namespaceAlias, boolean wildCard, | ||
boolean ignoreCase) { | ||
super(importedNamespace, wildCard, ignoreCase); | ||
this.aliasNormalizer = new ImportNormalizer(namespaceAlias, wildCard, ignoreCase); | ||
} | ||
|
||
@Override | ||
public QualifiedName deresolve(QualifiedName fullyQualifiedName) { | ||
QualifiedName deresolved = super.deresolve(fullyQualifiedName); | ||
if (deresolved != null) { | ||
return aliasNormalizer.resolve(deresolved); | ||
} | ||
return null; | ||
} | ||
|
||
@Override | ||
public QualifiedName resolve(QualifiedName relativeName) { | ||
QualifiedName deresolved = aliasNormalizer.deresolve(relativeName); | ||
if (deresolved != null) { | ||
return super.resolve(deresolved); | ||
} | ||
return null; | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return getImportedNamespacePrefix().toString() + (hasWildCard() ? ".*" : "") | ||
+ "as " + aliasNormalizer.getImportedNamespacePrefix(); | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
final int prime = 31; | ||
int result = 1; | ||
result = super.hashCode(); | ||
result = prime * result + aliasNormalizer.hashCode(); | ||
return result; | ||
} | ||
|
||
@Override | ||
public boolean equals(Object obj) { | ||
if (this == obj) | ||
return true; | ||
if (obj == null) | ||
return false; | ||
if (super.equals(obj) == false) { | ||
return false; | ||
} | ||
if (obj instanceof AliasAwareImportNormalizer) { | ||
AliasAwareImportNormalizer other = (AliasAwareImportNormalizer) obj; | ||
return other.aliasNormalizer.equals(aliasNormalizer); | ||
} | ||
return false; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters