/** Created by Michal on 18.11.2015. */
public class VaadinDesignParserDefinition implements ParserDefinition {

  public static final TokenSet WHITE_SPACES = TokenSet.create(TokenType.WHITE_SPACE);
  public static final TokenSet STRING_LITERALS = TokenSet.create(VDTypes.ATTR_VALUE);
  //    public static final TokenSet COMMENTS = TokenSet.create(SimpleTypes.COMMENT);

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

  @NotNull
  @Override
  public Lexer createLexer(Project project) {
    return new FlexAdapter(new VaadinDesignLexer(null));
  }

  @Override
  public PsiParser createParser(Project project) {
    return new VaadinDesignParser();
  }

  @Override
  public IFileElementType getFileNodeType() {
    return FILE;
  }

  @NotNull
  @Override
  public TokenSet getWhitespaceTokens() {
    return WHITE_SPACES;
  }

  @NotNull
  @Override
  public TokenSet getCommentTokens() {
    return TokenSet.EMPTY;
  }

  @NotNull
  @Override
  public TokenSet getStringLiteralElements() {
    return STRING_LITERALS;
  }

  @NotNull
  @Override
  public PsiElement createElement(ASTNode node) {
    return VDTypes.Factory.createElement(node);
  }

  @Override
  public PsiFile createFile(FileViewProvider viewProvider) {
    return new VaadinDesignFile(viewProvider);
  }

  @Override
  public SpaceRequirements spaceExistanceTypeBetweenTokens(ASTNode left, ASTNode right) {
    return SpaceRequirements.MAY;
  }
}
Ejemplo n.º 2
0
/** @author fernandohur */
public class EamlParserDefinition implements ParserDefinition {

  public static final TokenSet WHITE_SPACES = TokenSet.create(TokenType.WHITE_SPACE);
  public static final IFileElementType FILE =
      new IFileElementType(Language.<EamlLanguage>findInstance(EamlLanguage.class));

  @NotNull
  @Override
  public Lexer createLexer(final Project project) {
    return new EamlLexerAdapter();
  }

  @NotNull
  @Override
  public TokenSet getWhitespaceTokens() {
    return WHITE_SPACES;
  }

  @NotNull
  @Override
  public TokenSet getCommentTokens() {
    return TokenSet.EMPTY;
  }

  @NotNull
  @Override
  public TokenSet getStringLiteralElements() {
    return TokenSet.EMPTY;
  }

  @Override
  public PsiParser createParser(final Project project) {
    return new EamlParser();
  }

  @Override
  public IFileElementType getFileNodeType() {
    return FILE;
  }

  @Override
  public PsiFile createFile(final FileViewProvider fileViewProvider) {
    return new EamlFile(fileViewProvider);
  }

  @Override
  public SpaceRequirements spaceExistanceTypeBetweenTokens(
      final ASTNode astNode, final ASTNode astNode1) {
    return SpaceRequirements.MAY;
  }

  @NotNull
  @Override
  public PsiElement createElement(final ASTNode astNode) {
    return EamlTypes.Factory.createElement(astNode);
  }
}
public class PerlParserDefinition implements ParserDefinition {
  public static final TokenSet WHITE_SPACES = TokenSet.create(TokenType.WHITE_SPACE);
  public static final TokenSet COMMENT = TokenSet.create(PerlTypes.COMMENT);
  public static final TokenSet LITERAL = TokenSet.create(PerlTypes.LITERAL);

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

  @NotNull
  @Override
  public Lexer createLexer(Project project) {
    return new FlexAdapter(new PerlLexer((Reader) null));
  }

  @NotNull
  public TokenSet getWhitespaceTokens() {
    return WHITE_SPACES;
  }

  @NotNull
  public TokenSet getCommentTokens() {
    return COMMENT;
  }

  @NotNull
  public TokenSet getStringLiteralElements() {
    return LITERAL;
  }

  @NotNull
  public PsiParser createParser(final Project project) {
    return new PerlParser();
  }

  @Override
  public IFileElementType getFileNodeType() {
    return FILE;
  }

  public PsiFile createFile(FileViewProvider viewProvider) {
    return new PerlFile(viewProvider);
  }

  public SpaceRequirements spaceExistanceTypeBetweenTokens(ASTNode left, ASTNode right) {
    return SpaceRequirements.MAY;
  }

  @NotNull
  public PsiElement createElement(ASTNode node) {
    return PerlTypes.Factory.createElement(node);
  }
}
 public HaskellPsiFileImpl(
     @NotNull FileViewProvider viewProvider, @NotNull HaskellFileType fileType) {
   super(viewProvider, Language.findInstance(HaskellLanguage.class));
   this.fileType = fileType;
 }