• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java JSExpression类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



JSExpression类属于com.intellij.lang.javascript.psi包,在下文中一共展示了JSExpression类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: getElementByReference

import com.intellij.lang.javascript.psi.JSExpression; //导入依赖的package包/类
@Nullable
@Override
public PsiElement getElementByReference(@NotNull PsiReference ref, int flags) {
    if (ref instanceof JSTextReference) {
        final PsiElement element = ref.getElement();
        final JSCallExpression call = PsiTreeUtil.getParentOfType(element, JSCallExpression.class);
        final JSExpression expression = call != null ? call.getMethodExpression() : null;
        if (expression instanceof JSReferenceExpression) {
            JSReferenceExpression callee = (JSReferenceExpression)expression;
            JSExpression qualifier = callee.getQualifier();

            if (qualifier != null && "component".equals(callee.getReferencedName()) &&
                    EmberIndexUtil.hasEmberJS(element.getProject())) {
                return element;
            }
        }
    }
    return null;
}
 
开发者ID:kristianmandrup,项目名称:emberjs-plugin,代码行数:20,代码来源:EmberJSTargetElementEvaluator.java


示例2: visitJSCallExpression

import com.intellij.lang.javascript.psi.JSExpression; //导入依赖的package包/类
@Override public void visitJSCallExpression(JSCallExpression jsCallExpression) {
    super.visitJSCallExpression(jsCallExpression);
    final JSExpression methodExpression;
    try {
        methodExpression = jsCallExpression.getMethodExpression();
    } catch (Exception e) {
        return; //catching an intelliJ CCE
    }
    if (!(methodExpression instanceof JSReferenceExpression)) {
        return;
    }
    final JSReferenceExpression referenceExpression = (JSReferenceExpression) methodExpression;
    final JSExpression qualifier = referenceExpression.getQualifier();

    @NonNls final String methodName = referenceExpression.getReferencedName();
    if (!"eval".equals(methodName) && !"setTimeout".equals(methodName) && !"setInterval".equals(methodName)) {
        return;
    }
    registerError(methodExpression);
}
 
开发者ID:consulo,项目名称:consulo-javascript,代码行数:21,代码来源:DynamicallyGeneratedCodeJSInspection.java


示例3: processIntention

import com.intellij.lang.javascript.psi.JSExpression; //导入依赖的package包/类
@Override
public void processIntention(@NotNull PsiElement element) throws IncorrectOperationException {
       final JSIfStatement exp             = (JSIfStatement) element;
       final JSExpression  condition       = exp.getCondition();
       final JSStatement   thenBranch      = exp.getThen();
       final JSStatement   elseBranch      = exp.getElse();
       final String        negatedText     = BoolUtils.getNegatedExpressionText(condition);
       final boolean       emptyThenBranch = (thenBranch == null  ||
                                              (thenBranch instanceof JSBlockStatement &&
                                               ((JSBlockStatement) thenBranch).getStatements().length == 0));
       final String        thenText        = (emptyThenBranch      ? ""   : ELSE_KEYWORD + thenBranch.getText());
       final String        elseText        = ((elseBranch == null) ? "{}" : elseBranch.getText());

       final String newStatement = IF_PREFIX + negatedText + ')' + elseText + thenText;

       JSElementFactory.replaceStatement(exp, newStatement);
   }
 
开发者ID:consulo,项目名称:consulo-javascript,代码行数:18,代码来源:JSFlipIfIntention.java


示例4: processIntention

import com.intellij.lang.javascript.psi.JSExpression; //导入依赖的package包/类
@Override
public void processIntention(@NotNull PsiElement element) throws IncorrectOperationException {
       assert (element.getParent() != null);
       assert (element.getParent() instanceof JSIfStatement || element instanceof JSIfStatement);

       final JSIfStatement parentStatement     = (JSIfStatement) (element.getParent() instanceof JSIfStatement ? element.getParent() : element);
       final JSIfStatement childStatement      = (JSIfStatement) ConditionalUtils.stripBraces(parentStatement.getThen());
       final JSExpression  childCondition      = childStatement.getCondition();
       final JSExpression  parentCondition     = parentStatement.getCondition();
       final String        childConditionText  = ParenthesesUtils.getParenthesized(childCondition,  ParenthesesUtils.AND_PRECENDENCE);
       final String        parentConditionText = ParenthesesUtils.getParenthesized(parentCondition, ParenthesesUtils.AND_PRECENDENCE);
       final JSStatement   childThenBranch     = childStatement.getThen();
       final String        statement           = IF_STATEMENT_PREFIX + parentConditionText + " && " + childConditionText + ')' +
                                                 childThenBranch.getText();

       JSElementFactory.replaceStatement(parentStatement, statement);
   }
 
开发者ID:consulo,项目名称:consulo-javascript,代码行数:18,代码来源:JSMergeIfAndIntention.java


示例5: isConstantMask

import com.intellij.lang.javascript.psi.JSExpression; //导入依赖的package包/类
private static boolean isConstantMask(JSExpression expression) {
    if (expression == null) {
        return false;
    }
    if (!(expression instanceof JSBinaryExpression)) {
        return false;
    }
    final JSBinaryExpression binaryExpression =
            (JSBinaryExpression) expression;
    final IElementType tokenType = binaryExpression.getOperationSign();
    if (!JSTokenTypes.OR.equals(tokenType) &&
            !JSTokenTypes.AND.equals(tokenType)) {
        return false;
    }
    final JSExpression rhs = binaryExpression.getROperand();
    if (ExpressionUtil.isConstantExpression(rhs)) {
        return true;
    }
    final JSExpression lhs = binaryExpression.getLOperand();
    return ExpressionUtil.isConstantExpression(lhs);
}
 
开发者ID:consulo,项目名称:consulo-javascript,代码行数:22,代码来源:IncompatibleMaskJSInspection.java


示例6: satisfiedBy

import com.intellij.lang.javascript.psi.JSExpression; //导入依赖的package包/类
@Override
public boolean satisfiedBy(@NotNull PsiElement element) {
          if (!(element instanceof JSBinaryExpression)) {
              return false;
          }

          final JSBinaryExpression expression = (JSBinaryExpression) element;
          final IElementType       sign       = expression.getOperationSign();

          if (!sign.equals(JSTokenTypes.PLUS)) {
              return false;
          }
          final JSExpression lhs = expression.getLOperand();
          final JSExpression rhs = expression.getROperand();

          if (!isApplicableLiteral(lhs)) {
              return false;
          }
          if (!isApplicableLiteral(rhs)) {
              return false;
          }

          return true;
      }
 
开发者ID:consulo,项目名称:consulo-javascript,代码行数:25,代码来源:JSJoinConcatenatedStringLiteralsIntention.java


示例7: satisfiedBy

import com.intellij.lang.javascript.psi.JSExpression; //导入依赖的package包/类
@Override
public boolean satisfiedBy(@NotNull PsiElement element) {
          if (!(element instanceof JSConditionalExpression)) {
              return false;
          }
          if (ErrorUtil.containsError(element)) {
              return false;
          }

          final JSConditionalExpression condition      = (JSConditionalExpression) element;
          final JSExpression            thenExpression = ParenthesesUtils.stripParentheses(condition.getThen());
          final JSExpression            elseExpression = ParenthesesUtils.stripParentheses(condition.getElse());

          if (condition.getCondition() == null ||
              thenExpression           == null ||
              elseExpression           == null) {
              return false;
          }

          final String thenText = thenExpression.getText();
          final String elseText = elseExpression.getText();

          return  ((BoolUtils.TRUE.equals(elseText) && BoolUtils.FALSE.equals(thenText)) ||
                   (BoolUtils.TRUE.equals(thenText) && BoolUtils.FALSE.equals(elseText)));
      }
 
开发者ID:consulo,项目名称:consulo-javascript,代码行数:26,代码来源:JSRemoveConditionalIntention.java


示例8: getIndexExpression

import com.intellij.lang.javascript.psi.JSExpression; //导入依赖的package包/类
@Override
public JSExpression getIndexExpression()
{
	ASTNode child = getNode().getFirstChildNode();
	boolean bracketPassed = false;
	while(child != null)
	{
		final IElementType type = child.getElementType();
		if(type == JSTokenTypes.LBRACKET)
		{
			bracketPassed = true;
		}
		if(bracketPassed && JSElementTypes.EXPRESSIONS.contains(type))
		{
			return (JSExpression) child.getPsi();
		}
		child = child.getTreeNext();
	}
	return null;
}
 
开发者ID:consulo,项目名称:consulo-javascript,代码行数:21,代码来源:JSIndexedPropertyAccessExpressionImpl.java


示例9: binaryExpressionDefinitelyRecurses

import com.intellij.lang.javascript.psi.JSExpression; //导入依赖的package包/类
private static boolean binaryExpressionDefinitelyRecurses(
        JSBinaryExpression expression, JSFunction method) {
    final JSExpression lhs = expression.getLOperand();

    if (RecursionUtil.expressionDefinitelyRecurses(lhs, method)) {
        return true;
    }

    final IElementType tokenType = expression.getOperationSign();

    if (tokenType.equals(JSTokenTypes.ANDAND) ||
        tokenType.equals(JSTokenTypes.OROR)) {
        return false;
    }

    return RecursionUtil.expressionDefinitelyRecurses(expression.getROperand(), method);
}
 
开发者ID:consulo,项目名称:consulo-javascript,代码行数:18,代码来源:RecursionUtil.java


示例10: visitJSBinaryExpression

import com.intellij.lang.javascript.psi.JSExpression; //导入依赖的package包/类
@Override public void visitJSBinaryExpression(@NotNull JSBinaryExpression expression) {
    super.visitJSBinaryExpression(expression);
    if (!(expression.getROperand() != null)) {
        return;
    }
    if (!ComparisonUtils.isComparison(expression)) {
        return;
    }
    final JSExpression lhs = expression.getLOperand();
    final JSExpression rhs = expression.getROperand();
    if (lhs instanceof JSLiteralExpression ||
            !(rhs instanceof JSLiteralExpression)) {
        return;
    }
    registerError(expression);
}
 
开发者ID:consulo,项目名称:consulo-javascript,代码行数:17,代码来源:ConstantOnRHSOfComparisonJSInspection.java


示例11: visitJSBinaryExpression

import com.intellij.lang.javascript.psi.JSExpression; //导入依赖的package包/类
@Override public void visitJSBinaryExpression(
        @NotNull JSBinaryExpression expression) {
    super.visitJSBinaryExpression(expression);
    final JSExpression rhs = expression.getROperand();
    if (rhs == null) {
        return;
    }
    final IElementType tokenType = expression.getOperationSign();
    if (!JSTokenTypes.DIV.equals(tokenType) &&
            !JSTokenTypes.PERC.equals(tokenType)) {
        return;
    }
    if(!isZero(rhs))
    {
        return;
    }
    registerError(expression);
}
 
开发者ID:consulo,项目名称:consulo-javascript,代码行数:19,代码来源:DivideByZeroJSInspection.java


示例12: visitJSConditionalExpression

import com.intellij.lang.javascript.psi.JSExpression; //导入依赖的package包/类
@Override public void visitJSConditionalExpression(JSConditionalExpression exp) {
    super.visitJSConditionalExpression(exp);
    final JSExpression thenExpression = exp.getThen();
    if (thenExpression == null) {
        return;
    }
    final JSExpression elseExpression = exp.getElse();
    if (elseExpression == null) {
        return;
    }
    if (((isFalse(thenExpression) && isTrue(elseExpression))
            || (isTrue(thenExpression) && isFalse(elseExpression))) &&
        "Boolean".equals(JSResolveUtil.getExpressionType(exp.getCondition(), exp.getContainingFile())) 
       ) {
        registerError(exp);
    }
}
 
开发者ID:consulo,项目名称:consulo-javascript,代码行数:18,代码来源:TrivialConditionalJSInspection.java


示例13: getCollectionExpression

import com.intellij.lang.javascript.psi.JSExpression; //导入依赖的package包/类
@Override
public JSExpression getCollectionExpression()
{
	ASTNode child = getNode().getFirstChildNode();
	boolean inPassed = false;
	while(child != null)
	{
		if(child.getElementType() == JSTokenTypes.IN_KEYWORD)
		{
			inPassed = true;
		}
		if(inPassed && JSElementTypes.EXPRESSIONS.contains(child.getElementType()))
		{
			return (JSExpression) child.getPsi();
		}
		child = child.getTreeNext();
	}

	return null;
}
 
开发者ID:consulo,项目名称:consulo-javascript,代码行数:21,代码来源:JSForInStatementImpl.java


示例14: processDeclarations

import com.intellij.lang.javascript.psi.JSExpression; //导入依赖的package包/类
@Override
public boolean processDeclarations(@NotNull PsiScopeProcessor processor, @NotNull ResolveState state, PsiElement lastParent,
		@NotNull PsiElement place)
{
	if(lastParent != null)
	{
		final JSVarStatement statement = getDeclarationStatement();
		if(statement != null)
		{
			return statement.processDeclarations(processor, state, lastParent, place);
		}
		else
		{
			final JSExpression expression = getVariableExpression();
			if(expression != null && !processor.execute(expression, null))
			{
				return false;
			}
		}
	}
	return true;
}
 
开发者ID:consulo,项目名称:consulo-javascript,代码行数:23,代码来源:JSForInStatementImpl.java


示例15: getType

import com.intellij.lang.javascript.psi.JSExpression; //导入依赖的package包/类
@NotNull
@Override
public JavaScriptType getType()
{
	final JSExpression initializer = getInitializer();
	if(initializer != null)
	{
		JavaScriptType javaScriptType = RecursionManager.doPreventingRecursion(this, false, new Computable<JavaScriptType>()
		{
			@Override
			@RequiredReadAction
			public JavaScriptType compute()
			{
				return initializer.getType();
			}
		});
		return javaScriptType == null ? JavaScriptType.UNKNOWN : javaScriptType;
	}
	return JavaScriptType.UNKNOWN;
}
 
开发者ID:consulo,项目名称:consulo-javascript,代码行数:21,代码来源:JSVariableBaseImpl.java


示例16: replaceExpression

import com.intellij.lang.javascript.psi.JSExpression; //导入依赖的package包/类
public static JSExpression replaceExpression(@NotNull JSExpression expression,
                                             @NotNull JSExpression newExpression)
    throws IncorrectOperationException {
    final ASTNode    newExpressionNode = newExpression.getNode();
    final ASTNode    oldExpressionNode = expression.getNode();
    final PsiElement parentNode        = expression.getParent();
    final ASTNode    grandParentNode   = parentNode.getNode();

    if (grandParentNode == null || oldExpressionNode == null || newExpressionNode == null) {
        return null;
    }

    grandParentNode.replaceChild(oldExpressionNode, newExpressionNode);
    reformat(parentNode);

    return (JSExpression) newExpressionNode.getPsi();
}
 
开发者ID:consulo,项目名称:consulo-javascript,代码行数:18,代码来源:JSElementFactory.java


示例17: getCondition

import com.intellij.lang.javascript.psi.JSExpression; //导入依赖的package包/类
@Override
public JSExpression getCondition()
{
	ASTNode child = getNode().getFirstChildNode();
	int semicolonCount = 0;
	while(child != null)
	{
		if(child.getElementType() == JSTokenTypes.SEMICOLON)
		{
			semicolonCount++;
			if(semicolonCount == 2)
			{
				return null;
			}
		}
		else if(semicolonCount == 1 && JSElementTypes.EXPRESSIONS.contains(child.getElementType()))
		{
			return (JSExpression) child.getPsi();
		}
		child = child.getTreeNext();
	}
	return null;
}
 
开发者ID:consulo,项目名称:consulo-javascript,代码行数:24,代码来源:JSForStatementImpl.java


示例18: getUpdate

import com.intellij.lang.javascript.psi.JSExpression; //导入依赖的package包/类
@Override
public JSExpression getUpdate()
{
	ASTNode child = getNode().getFirstChildNode();
	int semicolonCount = 0;
	while(child != null)
	{
		if(child.getElementType() == JSTokenTypes.SEMICOLON)
		{
			semicolonCount++;
		}
		else if(semicolonCount == 2 && JSElementTypes.EXPRESSIONS.contains(child.getElementType()))
		{
			return (JSExpression) child.getPsi();
		}
		child = child.getTreeNext();
	}
	return null;
}
 
开发者ID:consulo,项目名称:consulo-javascript,代码行数:20,代码来源:JSForStatementImpl.java


示例19: mergeForInStatements

import com.intellij.lang.javascript.psi.JSExpression; //导入依赖的package包/类
private void mergeForInStatements(StringBuilder  statementBuffer,
                                  JSForInStatement firstStatement,
                                  JSForInStatement secondStatement) {
    final JSExpression   variableExpression   = getVariableExpression(firstStatement);
    final JSVarStatement declaration          = firstStatement.getDeclarationStatement();
    final JSExpression   collectionExpression = getCollectionExpression(firstStatement);
    final JSStatement    firstBody            = firstStatement .getBody();
    final JSStatement    secondBody           = secondStatement.getBody();

    statementBuffer.append(FOR_IN_PREFIX)
                   .append((declaration == null) ? variableExpression.getText() : declaration.getText())
                   .append(FOR_IN_COLLECTION_PREFIX)
                   .append(collectionExpression.getText())
                   .append(')');
    ControlFlowUtils.appendStatementsInSequence(statementBuffer, firstBody, secondBody);
}
 
开发者ID:consulo,项目名称:consulo-javascript,代码行数:17,代码来源:JSMergeParallelForInLoopsIntention.java


示例20: callExpressionDefinitelyRecurses

import com.intellij.lang.javascript.psi.JSExpression; //导入依赖的package包/类
private static boolean callExpressionDefinitelyRecurses(
        JSCallExpression exp, JSFunction method) {
    final JSFunction calledMethod = ControlFlowUtils.resolveMethod(exp);

    if (calledMethod != null && calledMethod.equals(method)) {
        return true;
    }

    final JSExpression methodExpression = exp.getMethodExpression();

    if (methodExpression == null) {
        return false;
    } else if (RecursionUtil.expressionDefinitelyRecurses(methodExpression, method)) {
        return true;
    }

    for (final JSExpression arg : exp.getArgumentList().getArguments()) {
        if (RecursionUtil.expressionDefinitelyRecurses(arg, method)) {
            return true;
        }
    }
    return false;
}
 
开发者ID:consulo,项目名称:consulo-javascript,代码行数:24,代码来源:RecursionUtil.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java HadoopShims类代码示例发布时间:2022-05-22
下一篇:
Java GenericPreference类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap