当前位置: 首页>>代码示例>>Java>>正文


Java JSExpression.getText方法代码示例

本文整理汇总了Java中com.intellij.lang.javascript.psi.JSExpression.getText方法的典型用法代码示例。如果您正苦于以下问题:Java JSExpression.getText方法的具体用法?Java JSExpression.getText怎么用?Java JSExpression.getText使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.intellij.lang.javascript.psi.JSExpression的用法示例。


在下文中一共展示了JSExpression.getText方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getNegated

import com.intellij.lang.javascript.psi.JSExpression; //导入方法依赖的package包/类
public static JSExpression getNegated(JSExpression condition) {
    if (condition instanceof JSPrefixExpression) {
        final JSPrefixExpression prefixExp = (JSPrefixExpression) condition;
        final JSExpression       operand   = prefixExp.getExpression();

        return ParenthesesUtils.stripParentheses(operand);
    } else if (condition instanceof JSBinaryExpression) {
        final JSBinaryExpression binaryExpression = (JSBinaryExpression) condition;
        final IElementType sign        = binaryExpression.getOperationSign();
        final JSExpression lhs         = binaryExpression.getLOperand();
        final JSExpression rhs         = binaryExpression.getROperand();
        final String       negatedSign = ComparisonUtils.getNegatedOperatorText(sign);
        final String       negatedText = lhs.getText() + negatedSign + rhs.getText();

        return (JSExpression) JSChangeUtil.createExpressionFromText(
          condition.getProject(),
          negatedText);
    } else if (condition instanceof JSParenthesizedExpression) {
        return getNegated(((JSParenthesizedExpression) condition).getInnerExpression());
    }
    return condition;
}
 
开发者ID:consulo,项目名称:consulo-javascript,代码行数:23,代码来源:BoolUtils.java

示例2: getLogBase2

import com.intellij.lang.javascript.psi.JSExpression; //导入方法依赖的package包/类
public static int getLogBase2(JSExpression rhs) {
    final String value = rhs.getText();
    long         intValue;

    try {
        intValue = Integer.decode(value).longValue();
    } catch (NumberFormatException e) {
        assert(false);
        return 0;
    }

    int log      = 0;
    while ((intValue & 1) == 0) {
        intValue >>= 1;
        log++;
    }
    return log;
}
 
开发者ID:consulo,项目名称:consulo-javascript,代码行数:19,代码来源:ShiftUtils.java

示例3: getInitializerText

import com.intellij.lang.javascript.psi.JSExpression; //导入方法依赖的package包/类
@Override
public String getInitializerText()
{
	final T stub = getStub();
	if(stub != null)
	{
		return stub.getInitializerText();
	}

	final JSExpression expression = getInitializer();
	return expression != null ? expression.getText() : null;
}
 
开发者ID:consulo,项目名称:consulo-javascript,代码行数:13,代码来源:JSVariableBaseImpl.java

示例4: visitJSForStatement

import com.intellij.lang.javascript.psi.JSExpression; //导入方法依赖的package包/类
@Override public void visitJSForStatement(@NotNull JSForStatement statement) {
    super.visitJSForStatement(statement);
    final JSVarStatement varStatement = statement.getVarDeclaration();
    if(varStatement!=null)
    {
        return;
    }
    final JSExpression initialization = statement.getInitialization();
    if (initialization != null ) {
        return;
    }
    final JSExpression update = statement.getUpdate();
    if (update != null ) {
        return;
    }
    if (m_ignoreLoopsWithoutConditions) {
        final JSExpression condition = statement.getCondition();
        if (condition == null) {
            return;
        }
        final String conditionText = condition.getText();
        if ("true".equals(conditionText)) {
            return;
        }
    }
    registerStatementError(statement);
}
 
开发者ID:consulo,项目名称:consulo-javascript,代码行数:28,代码来源:ForLoopReplaceableByWhileJSInspection.java

示例5: calculateReplacementExpression

import com.intellij.lang.javascript.psi.JSExpression; //导入方法依赖的package包/类
private static String calculateReplacementExpression(JSConditionalExpression exp) {
    final JSExpression thenExpression = exp.getThen();
    final JSExpression elseExpression = exp.getElse();
    final JSExpression condition = exp.getCondition();

    if (isFalse(thenExpression) && isTrue(elseExpression)) {
        return BoolUtils.getNegatedExpressionText(condition);
    } else {
        return condition.getText();
    }
}
 
开发者ID:consulo,项目名称:consulo-javascript,代码行数:12,代码来源:TrivialConditionalJSInspection.java

示例6: processIntention

import com.intellij.lang.javascript.psi.JSExpression; //导入方法依赖的package包/类
@Override
public void processIntention(@NotNull PsiElement element) throws IncorrectOperationException {
       final JSBinaryExpression exp  = (JSBinaryExpression) element;
       final JSExpression       lhs  = exp.getLOperand();
       final JSExpression       rhs  = exp.getROperand();
       final IElementType       sign = exp.getOperationSign();

       assert (rhs != null);

       final String expString = rhs.getText() + ComparisonUtils.getFlippedOperatorText(sign) + lhs.getText();
       JSElementFactory.replaceExpression(exp, expString);
   }
 
开发者ID:consulo,项目名称:consulo-javascript,代码行数:13,代码来源:JSFlipComparisonIntention.java

示例7: getNegatedExpressionText

import com.intellij.lang.javascript.psi.JSExpression; //导入方法依赖的package包/类
public static String getNegatedExpressionText(JSExpression condition) {
    if (BoolUtils.isNegation(condition)) {
        return ParenthesesUtils.getParenthesized(BoolUtils.getNegated(condition), ParenthesesUtils.OR_PRECENDENCE);
    } else if(ComparisonUtils.isComparisonOperator(condition)) {
        final JSBinaryExpression binaryExpression  = (JSBinaryExpression) condition;
        final IElementType       sign              = binaryExpression.getOperationSign();
        final String             negatedComparison = ComparisonUtils.getNegatedOperatorText(sign);
        final JSExpression       leftOperand       = binaryExpression.getLOperand();
        final JSExpression       rightOperand      = binaryExpression.getROperand();

        return leftOperand.getText() + negatedComparison + (rightOperand != null ? rightOperand.getText():"");
    } else {
        return '!' + ParenthesesUtils.getParenthesized(condition, ParenthesesUtils.PREFIX_PRECENDENCE);
    }
}
 
开发者ID:consulo,项目名称:consulo-javascript,代码行数:16,代码来源:BoolUtils.java

示例8: processIntention

import com.intellij.lang.javascript.psi.JSExpression; //导入方法依赖的package包/类
@Override
public void processIntention(@NotNull PsiElement element) throws IncorrectOperationException {
       final JSBinaryExpression exp             = (JSBinaryExpression) element;
       final JSExpression       lhs             = exp.getLOperand();
       final JSExpression       rhs             = exp.getROperand();
       final IElementType       sign            = exp.getOperationSign();
       final String             negatedOperator = ComparisonUtils.getNegatedOperatorText(sign);
       final String             lhsText         = lhs.getText();

       assert (rhs != null);

       JSElementFactory.replaceExpressionWithNegatedExpressionString(exp, lhsText +
                                                                          negatedOperator +
                                                                          rhs.getText());
   }
 
开发者ID:consulo,项目名称:consulo-javascript,代码行数:16,代码来源:JSNegateComparisonIntention.java

示例9: replaceShiftAssignWithMultiplyOrDivideAssign

import com.intellij.lang.javascript.psi.JSExpression; //导入方法依赖的package包/类
private void replaceShiftAssignWithMultiplyOrDivideAssign(JSAssignmentExpression exp)
        throws IncorrectOperationException {
    final JSExpression  lhs          = exp.getLOperand();
    final JSExpression  rhs          = exp.getROperand();
    final IElementType  tokenType    = exp.getOperationSign();
    final String        assignString = ((tokenType.equals(JSTokenTypes.LTLTEQ)) ? "*=" : "/=");

    final String expString = lhs.getText() + assignString + ShiftUtils.getExpBase2(rhs);

    JSElementFactory.replaceExpression(exp, expString);
}
 
开发者ID:consulo,项目名称:consulo-javascript,代码行数:12,代码来源:JSReplaceShiftWithMultiplyIntention.java

示例10: isZero

import com.intellij.lang.javascript.psi.JSExpression; //导入方法依赖的package包/类
/**
 * @noinspection FloatingPointEquality
 */
private static boolean isZero(JSExpression expression) {
    @NonNls final String text = expression.getText();
    return text.equals("0")||
            text.equals("0x0")||
            text.equals("0X0")||
            text.equals("0.0")||
            text.equals("0L")||
            text.equals("0l");
}
 
开发者ID:consulo,项目名称:consulo-javascript,代码行数:13,代码来源:PointlessArithmeticExpressionJSInspection.java

示例11: replaceSimplifiableImplicitReturn

import com.intellij.lang.javascript.psi.JSExpression; //导入方法依赖的package包/类
public static void replaceSimplifiableImplicitReturn(JSIfStatement statement, boolean negated)
        throws IncorrectOperationException {
    final JSExpression   condition     = statement.getCondition();
    final String         conditionText = (negated ? BoolUtils.getNegatedExpressionText(condition) : condition.getText());
    final JSElement      nextStatement = (JSElement) JSElementFactory.getNonWhiteSpaceSibling(statement, true);
    @NonNls final String newStatement  = "return " + conditionText + ';';

    JSElementFactory.replaceStatement(statement, newStatement);
    assert (nextStatement != null);
    JSElementFactory.removeElement(nextStatement);
}
 
开发者ID:consulo,项目名称:consulo-javascript,代码行数:12,代码来源:ConditionalUtils.java

示例12: isOne

import com.intellij.lang.javascript.psi.JSExpression; //导入方法依赖的package包/类
/**
 * @noinspection FloatingPointEquality
 */
private static boolean isOne(JSExpression expression) {
    @NonNls final String text = expression.getText();
    return text.equals("1") ||
            text.equals("0x1") ||
            text.equals("0X1") ||
            text.equals("1.0") ||
            text.equals("1L") ||
            text.equals("1l");
}
 
开发者ID:consulo,项目名称:consulo-javascript,代码行数:13,代码来源:PointlessArithmeticExpressionJSInspection.java

示例13: isTrue

import com.intellij.lang.javascript.psi.JSExpression; //导入方法依赖的package包/类
public static boolean isTrue(@Nullable JSExpression test) {
    if (test == null) {
        return false;
    }
    @NonNls final String text = test.getText();
    return "true".equals(text);
}
 
开发者ID:consulo,项目名称:consulo-javascript,代码行数:8,代码来源:BoolUtils.java

示例14: isFalse

import com.intellij.lang.javascript.psi.JSExpression; //导入方法依赖的package包/类
public static boolean isFalse(@Nullable JSExpression test) {
    if (test == null) {
        return false;
    }
    @NonNls final String text = test.getText();
    return "false".equals(text);
}
 
开发者ID:consulo,项目名称:consulo-javascript,代码行数:8,代码来源:BoolUtils.java

示例15: mayCauseCoercion

import com.intellij.lang.javascript.psi.JSExpression; //导入方法依赖的package包/类
private static boolean mayCauseCoercion(JSExpression expression) {
    @NonNls
    final String text = expression.getText();
    return "0".equals(text) ||
            "0x0".equals(text) ||
            "0X0".equals(text) ||
            "0.0".equals(text) ||
            "0L".equals(text) ||
            "0l".equals(text) ||
            "null".equals(text) ||
            "undefined".equals(text) ||
            "true".equals(text) ||
            "false".equals(text) ||
            "''".equals(text);
}
 
开发者ID:consulo,项目名称:consulo-javascript,代码行数:16,代码来源:EqualityComparisonWithCoercionJSInspection.java


注:本文中的com.intellij.lang.javascript.psi.JSExpression.getText方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。