本文整理汇总了Java中com.intellij.psi.PsiLiteralExpression.getText方法的典型用法代码示例。如果您正苦于以下问题:Java PsiLiteralExpression.getText方法的具体用法?Java PsiLiteralExpression.getText怎么用?Java PsiLiteralExpression.getText使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.intellij.psi.PsiLiteralExpression
的用法示例。
在下文中一共展示了PsiLiteralExpression.getText方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: visitLiteralExpression
import com.intellij.psi.PsiLiteralExpression; //导入方法依赖的package包/类
@Override
public void visitLiteralExpression(@NotNull PsiLiteralExpression expression) {
super.visitLiteralExpression(expression);
final PsiType type = expression.getType();
if (type == null || !TypeUtils.isJavaLangString(type) && !type.equals(PsiType.CHAR)) {
return;
}
final String text = expression.getText();
final Matcher matcher = newlines.matcher(text);
int end = 0;
while (matcher.find(end)) {
final int start = matcher.start();
end = matcher.end();
registerErrorAtOffset(expression, start, end - start);
}
}
示例2: visitLiteralExpression
import com.intellij.psi.PsiLiteralExpression; //导入方法依赖的package包/类
@Override
public void visitLiteralExpression(
@NotNull PsiLiteralExpression expression) {
super.visitLiteralExpression(expression);
final PsiType type = expression.getType();
if (type == null) {
return;
}
if (!type.equals(PsiType.CHAR)) {
return;
}
final String text = expression.getText();
if (text == null) {
return;
}
if (text.equals(" ")) {
return;
}
if (ExpressionUtils.isDeclaredConstant(expression)) {
return;
}
if (NonNlsUtils.isNonNlsAnnotatedUse(expression)) {
return;
}
registerError(expression);
}
示例3: visitLiteralExpression
import com.intellij.psi.PsiLiteralExpression; //导入方法依赖的package包/类
@Override
public void visitLiteralExpression(
@NotNull PsiLiteralExpression expression) {
super.visitLiteralExpression(expression);
final PsiType type = expression.getType();
if (type == null) {
return;
}
if (!type.equals(PsiType.LONG)) {
return;
}
final String text = expression.getText();
if (text == null) {
return;
}
final int length = text.length();
if (length == 0) {
return;
}
if (text.charAt(length - 1) != 'l') {
return;
}
registerError(expression);
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:25,代码来源:LongLiteralsEndingWithLowercaseLInspection.java
示例4: satisfiedBy
import com.intellij.psi.PsiLiteralExpression; //导入方法依赖的package包/类
public boolean satisfiedBy(PsiElement element) {
if (!(element instanceof PsiLiteralExpression)) {
return false;
}
final PsiLiteralExpression expression = (PsiLiteralExpression)element;
final PsiType type = expression.getType();
if (!PsiType.DOUBLE.equals(type) && !PsiType.FLOAT.equals(type)) {
return false;
}
String text = expression.getText();
if (text == null) {
return false;
}
text = text.toLowerCase();
if (text.startsWith("-")) {
text = text.substring(1);
}
if (!text.contains(".") && text.startsWith("0")) {
return false; //Octal integer
}
return !text.contains("e");
}
示例5: satisfiedBy
import com.intellij.psi.PsiLiteralExpression; //导入方法依赖的package包/类
public boolean satisfiedBy(PsiElement element) {
if (!(element instanceof PsiLiteralExpression)) {
return false;
}
final PsiLiteralExpression expression = (PsiLiteralExpression)element;
final PsiType type = expression.getType();
if (!(PsiType.INT.equals(type) || PsiType.LONG.equals(type))) {
return false;
}
@NonNls final String text = expression.getText();
if (text.charAt(0) != '0') {
return true;
}
if (text.length() < 2) {
return true;
}
final char c1 = text.charAt(1);
if (c1 != '_' && (c1 < '0' || c1 > '7')) {
return true;
}
return false;
}
示例6: visitLiteralExpression
import com.intellij.psi.PsiLiteralExpression; //导入方法依赖的package包/类
@Override
public void visitLiteralExpression(
@NotNull PsiLiteralExpression literal) {
super.visitLiteralExpression(literal);
final PsiType type = literal.getType();
if (type == null) {
return;
}
if (!(type.equals(PsiType.FLOAT) || type.equals(PsiType.DOUBLE))) {
return;
}
final String text = literal.getText();
if (text == null) {
return;
}
if (!isConfusing(text)) {
return;
}
registerError(literal);
}
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:21,代码来源:ConfusingFloatingPointLiteralInspection.java
示例7: satisfiedBy
import com.intellij.psi.PsiLiteralExpression; //导入方法依赖的package包/类
public boolean satisfiedBy(PsiElement element) {
if (!(element instanceof PsiLiteralExpression)) {
return false;
}
final PsiLiteralExpression expression = (PsiLiteralExpression)element;
final PsiType type = expression.getType();
if (!PsiType.DOUBLE.equals(type) && !PsiType.FLOAT.equals(type)) {
return false;
}
String text = expression.getText();
if (text == null) {
return false;
}
text = text.toLowerCase();
if (text.startsWith("-")) {
text = text.substring(1);
}
if (!text.contains("") && text.startsWith("0")) {
return false; //Octal integer
}
return !text.contains("e");
}
示例8: visitLiteralExpression
import com.intellij.psi.PsiLiteralExpression; //导入方法依赖的package包/类
@Override
public void visitLiteralExpression(@NotNull PsiLiteralExpression literal) {
super.visitLiteralExpression(literal);
final PsiType type = literal.getType();
final String literalText = literal.getText();
if ((!PsiType.FLOAT.equals(type) && !PsiType.DOUBLE.equals(type)) || !isConfusing(literalText)) {
return;
}
if (ignoreScientificNotation && StringUtil.containsAnyChar(literalText, "EePp")) {
return;
}
registerError(literal);
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:14,代码来源:ConfusingFloatingPointLiteralInspection.java
示例9: isDecimalLiteral
import com.intellij.psi.PsiLiteralExpression; //导入方法依赖的package包/类
private static boolean isDecimalLiteral(PsiLiteralExpression literal) {
final PsiType type = literal.getType();
if (!PsiType.INT.equals(type) &&
!PsiType.LONG.equals(type)) {
return false;
}
final String text = literal.getText();
if ("0".equals(text)) {
return false;
}
return text.charAt(0) != '0';
}
示例10: isOctalLiteral
import com.intellij.psi.PsiLiteralExpression; //导入方法依赖的package包/类
private static boolean isOctalLiteral(PsiLiteralExpression literal) {
final PsiType type = literal.getType();
if (!PsiType.INT.equals(type) && !PsiType.LONG.equals(type)) {
return false;
}
@NonNls final String text = literal.getText();
if ("0".equals(text) || "0L".equals(text)) {
return false;
}
return text.charAt(0) == '0' && !text.startsWith("0x") &&
!text.startsWith("0X");
}
示例11: processIntention
import com.intellij.psi.PsiLiteralExpression; //导入方法依赖的package包/类
@Override
public void processIntention(@NotNull PsiElement element)
throws IncorrectOperationException {
final PsiLiteralExpression charLiteral =
(PsiLiteralExpression)element;
final String charLiteralText = charLiteral.getText();
final String stringLiteral = stringForCharLiteral(charLiteralText);
PsiReplacementUtil.replaceExpression(charLiteral, stringLiteral);
}
示例12: processIntention
import com.intellij.psi.PsiLiteralExpression; //导入方法依赖的package包/类
@Override
public void processIntention(PsiElement element)
throws IncorrectOperationException {
final PsiLiteralExpression stringLiteral =
(PsiLiteralExpression)element;
final String stringLiteralText = stringLiteral.getText();
final String charLiteral = charForStringLiteral(stringLiteralText);
PsiReplacementUtil.replaceExpression(stringLiteral, charLiteral);
}
示例13: satisfiedBy
import com.intellij.psi.PsiLiteralExpression; //导入方法依赖的package包/类
public boolean satisfiedBy(PsiElement element) {
if (!(element instanceof PsiLiteralExpression)) {
return false;
}
final PsiLiteralExpression expression = (PsiLiteralExpression)element;
final PsiType type = expression.getType();
if (!PsiType.DOUBLE.equals(type) && !PsiType.FLOAT.equals(type)) {
return false;
}
final String text = expression.getText();
return text != null && (text.contains("e") || text.contains("E"));
}
示例14: processIntention
import com.intellij.psi.PsiLiteralExpression; //导入方法依赖的package包/类
@Override
public void processIntention(@NotNull PsiElement element)
throws IncorrectOperationException {
final PsiLiteralExpression charLiteral =
(PsiLiteralExpression)element;
final String charLiteralText = charLiteral.getText();
final String stringLiteral = stringForCharLiteral(charLiteralText);
replaceExpression(stringLiteral, charLiteral);
}
示例15: processIntention
import com.intellij.psi.PsiLiteralExpression; //导入方法依赖的package包/类
@Override
public void processIntention(PsiElement element)
throws IncorrectOperationException {
final PsiLiteralExpression stringLiteral =
(PsiLiteralExpression)element;
final String stringLiteralText = stringLiteral.getText();
final String charLiteral = charForStringLiteral(stringLiteralText);
replaceExpression(charLiteral, stringLiteral);
}