From 0f38219efb13d0cb5e3c8edabb07664549611ae8 Mon Sep 17 00:00:00 2001 From: "Maxim.Mossienko" Date: Wed, 2 May 2012 20:45:19 +0400 Subject: [PATCH] less garbage during indexing (-30M for IDEA project), just in case each TokenSet is 5K each --- .../src/com/intellij/lexer/JavaDocTokenTypes.java | 7 +++++++ .../core-api/src/com/intellij/lexer/DocCommentLexer.java | 3 +-- .../src/com/intellij/lexer/DocCommentTokenTypes.java | 2 ++ 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/java/java-psi-api/src/com/intellij/lexer/JavaDocTokenTypes.java b/java/java-psi-api/src/com/intellij/lexer/JavaDocTokenTypes.java index 109c7d6fbe93..2244cc99511b 100644 --- a/java/java-psi-api/src/com/intellij/lexer/JavaDocTokenTypes.java +++ b/java/java-psi-api/src/com/intellij/lexer/JavaDocTokenTypes.java @@ -17,12 +17,14 @@ package com.intellij.lexer; import com.intellij.psi.JavaDocTokenType; import com.intellij.psi.tree.IElementType; +import com.intellij.psi.tree.TokenSet; /** * @author yole */ public class JavaDocTokenTypes implements DocCommentTokenTypes { public static final DocCommentTokenTypes INSTANCE = new JavaDocTokenTypes(); + private final TokenSet mySpaceCommentsSet = TokenSet.create(JavaDocTokenType.DOC_SPACE, JavaDocTokenType.DOC_COMMENT_DATA); private JavaDocTokenTypes() { } @@ -41,6 +43,11 @@ public class JavaDocTokenTypes implements DocCommentTokenTypes { return JavaDocTokenType.DOC_COMMENT_DATA; } + @Override + public TokenSet spaceCommentsTokenSet() { + return mySpaceCommentsSet; + } + @Override public IElementType space() { return JavaDocTokenType.DOC_SPACE; diff --git a/platform/core-api/src/com/intellij/lexer/DocCommentLexer.java b/platform/core-api/src/com/intellij/lexer/DocCommentLexer.java index 76e56d9da9de..95ef5604fc61 100644 --- a/platform/core-api/src/com/intellij/lexer/DocCommentLexer.java +++ b/platform/core-api/src/com/intellij/lexer/DocCommentLexer.java @@ -16,7 +16,6 @@ package com.intellij.lexer; import com.intellij.psi.tree.IElementType; -import com.intellij.psi.tree.TokenSet; import com.intellij.util.text.CharArrayUtil; import java.io.IOException; @@ -24,7 +23,7 @@ import java.io.IOException; public class DocCommentLexer extends MergingLexerAdapter { public DocCommentLexer(final DocCommentTokenTypes tokenTypes, final boolean isJdk15Enabled) { super(new AsteriskStripperLexer(new _JavaDocLexer(isJdk15Enabled, tokenTypes), tokenTypes), - TokenSet.create(tokenTypes.commentData(), tokenTypes.space())); + tokenTypes.spaceCommentsTokenSet()); } private static class AsteriskStripperLexer extends LexerBase { diff --git a/platform/core-api/src/com/intellij/lexer/DocCommentTokenTypes.java b/platform/core-api/src/com/intellij/lexer/DocCommentTokenTypes.java index a41561ec1ec2..33ae054e6e49 100644 --- a/platform/core-api/src/com/intellij/lexer/DocCommentTokenTypes.java +++ b/platform/core-api/src/com/intellij/lexer/DocCommentTokenTypes.java @@ -17,6 +17,7 @@ package com.intellij.lexer; import com.intellij.psi.tree.IElementType; +import com.intellij.psi.tree.TokenSet; /** * Allows to specify a set of language-dependent token types for the doc comment lexer. @@ -27,6 +28,7 @@ public interface DocCommentTokenTypes { IElementType commentStart(); IElementType commentEnd(); IElementType commentData(); + TokenSet spaceCommentsTokenSet(); IElementType space(); IElementType tagValueToken(); IElementType tagValueLParen();