Skip to content

Commit

Permalink
fixed files form Closure #16
Browse files Browse the repository at this point in the history
  • Loading branch information
tdurieux committed Mar 7, 2017
1 parent 631cace commit 4f5f9fd
Showing 1 changed file with 9 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -167,17 +167,23 @@ public void applyAlias() {

private class AliasedTypeNode implements AliasUsage {
private final Node typeReference;
private final Node aliasDefinition;
private final String aliasName;

AliasedTypeNode(Node typeReference,
AliasedTypeNode(Node typeReference, Node aliasDefinition,
String aliasName) {
this.typeReference = typeReference;
this.aliasDefinition = aliasDefinition;
this.aliasName = aliasName;
}

@Override
public void applyAlias() {
typeReference.setString(aliasName);
String typeName = typeReference.getString();
String aliasExpanded =
Preconditions.checkNotNull(aliasDefinition.getQualifiedName());
Preconditions.checkState(typeName.startsWith(aliasName));
typeReference.setString(typeName.replaceFirst(aliasName, aliasExpanded));
}
}

Expand Down Expand Up @@ -465,7 +471,7 @@ private void fixTypeNode(Node typeNode) {
Var aliasVar = aliases.get(baseName);
if (aliasVar != null) {
Node aliasedNode = aliasVar.getInitialValue();
aliasUsages.add(new AliasedTypeNode(typeNode, aliasedNode.getQualifiedName() + name.substring(endIndex)));
aliasUsages.add(new AliasedTypeNode(typeNode, aliasedNode, baseName));
}
}

Expand Down

0 comments on commit 4f5f9fd

Please sign in to comment.