Skip to content

Commit

Permalink
Explicitly depend on SimpleLanguage.INSTANCE (JetBrains#34)
Browse files Browse the repository at this point in the history
The use of `Language.findInstance()` implicitly depended on the fact that
`SimpleLanguage.INSTANCE` was referenced at some earlier point in time. In this
case, that happens because the instantiation of `SimpleParserDefinition`
triggers the instantiation of `COMMENTS`, which relies on
`SimpleTypes.COMMENT`.

When basing one's work on this sample project, however, one may run into
issues. Specifically, the absence of a custom comment token type will mean a
failure to correctly instantiate the singleton language object. Making the
dependence on `SimpleLanguage.INSTANCE` explicit prevents that issue from
occurring.
  • Loading branch information
elliterate authored and ignatov committed Feb 15, 2017
1 parent f89664a commit a725cd5
Showing 1 changed file with 1 addition and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@ public class SimpleParserDefinition implements ParserDefinition {
public static final TokenSet WHITE_SPACES = TokenSet.create(TokenType.WHITE_SPACE);
public static final TokenSet COMMENTS = TokenSet.create(SimpleTypes.COMMENT);

public static final IFileElementType FILE =
new IFileElementType(Language.<SimpleLanguage>findInstance(SimpleLanguage.class));
public static final IFileElementType FILE = new IFileElementType(SimpleLanguage.INSTANCE);

@NotNull
@Override
Expand Down

0 comments on commit a725cd5

Please sign in to comment.