Skip to content

Commit

Permalink
don't assume a token in uIdentifierToCeylon
Browse files Browse the repository at this point in the history
This is for consistency with changes necessary for ceylon#114.
  • Loading branch information
jvasileff committed Jun 23, 2016
1 parent f2c2b33 commit bac9ff4
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions source/ceylon/ast/redhat/Identifier.ceylon
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,16 @@ shared LIdentifier lIdentifierToCeylon(JIdentifier identifier, Anything(JNode,No
"Converts a RedHat AST [[Identifier|JIdentifier]] to a `ceylon.ast` [[UIdentifier]]."
throws (`class AssertionError`, "If the token type is not `UIDENTIFIER`.")
shared UIdentifier uIdentifierToCeylon(JIdentifier identifier, Anything(JNode,Node) update = noop) {
"Need CommonToken to get length of token (!= text’s length for \\iCONSTANT)"
assert (is CommonToken token = identifier.mainToken);
"Must be UIDENTIFIER token"
assert (token.type == uidentifier);
value result = UIdentifier(identifier.text, isPrefixed(token));
"Need CommonToken to get length of token (!= text’s length for \\iCONSTANT).
For synthetic nodes produced by the typechecker during desugaring, a token
may not exist."
assert (is CommonToken? token = identifier.mainToken);
if (exists token) {
"Must be UIDENTIFIER token"
assert (token.type == uidentifier);
}
value prefixed = if (exists token) then isPrefixed(token) else false;
value result = UIdentifier(identifier.text, prefixed);
update(identifier, result);
return result;
}
Expand Down

0 comments on commit bac9ff4

Please sign in to comment.