decrease the invocation counts of psi.getText in several java places

This commit is contained in:
peter
2016-09-01 10:00:39 +02:00
parent dbf3491ae6
commit 7d670211a6
5 changed files with 33 additions and 27 deletions
@@ -16,7 +16,6 @@
package com.intellij.psi.impl.source.tree.java;
import com.intellij.codeInsight.CodeInsightUtilCore;
import com.intellij.extapi.psi.StubBasedPsiElementBase;
import com.intellij.lang.ASTNode;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.psi.*;
@@ -120,6 +119,17 @@ public class PsiLiteralExpressionImpl
@Override
public Object getValue() {
final IElementType type = getLiteralElementType();
if (type == JavaTokenType.TRUE_KEYWORD) {
return Boolean.TRUE;
}
if (type == JavaTokenType.FALSE_KEYWORD) {
return Boolean.FALSE;
}
if (type == JavaTokenType.STRING_LITERAL) {
String innerText = getInnerText();
return innerText == null ? null : internedParseStringCharacters(innerText);
}
String text = NUMERIC_LITERALS.contains(type) ? getCanonicalText().toLowerCase(Locale.ENGLISH) : getCanonicalText();
final int textLength = text.length();
@@ -201,16 +211,6 @@ public class PsiLiteralExpressionImpl
if (chars.length() != 1) return null;
return Character.valueOf(chars.charAt(0));
}
if (type == JavaTokenType.STRING_LITERAL) {
String innerText = getInnerText();
return innerText == null ? null : internedParseStringCharacters(innerText);
}
if (type == JavaTokenType.TRUE_KEYWORD) {
return Boolean.TRUE;
}
if (type == JavaTokenType.FALSE_KEYWORD) {
return Boolean.FALSE;
}
return null;
}