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


Java JSNewExpression类代码示例

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


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

示例1: visitJSNewExpression

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

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

示例2: invoke

import com.intellij.lang.javascript.psi.JSNewExpression; //导入依赖的package包/类
@Override
public void invoke(@NotNull Project project, @NotNull PsiFile psiFile, @Nullable("is null when called from inspection") Editor editor, @NotNull PsiElement element, @NotNull PsiElement end) throws IncorrectOperationException {
    PsiElement parent = element.getParent();
    if (!(parent instanceof JSNewExpression)) return;
    final JSExpressionCodeFragment useStrict = JSElementFactory.createExpressionCodeFragment(project, getNewExp(), parent);
    PsiElement child = useStrict.getFirstChild();
    parent.replace(child);
}
 
开发者ID:idok,项目名称:eslint-plugin,代码行数:9,代码来源:NoNewBaseActionFix.java

示例3: isLHSExpression

import com.intellij.lang.javascript.psi.JSNewExpression; //导入依赖的package包/类
public static boolean isLHSExpression(JSExpression expr)
{
	if(expr instanceof JSDefinitionExpression)
	{
		expr = ((JSDefinitionExpression) expr).getExpression();
	}

	if(expr instanceof JSReferenceExpression)
	{
		return true;
	}

	if(expr instanceof JSParenthesizedExpression)
	{
		return isLHSExpression(((JSParenthesizedExpression) expr).getInnerExpression());
	}

	if(expr instanceof JSIndexedPropertyAccessExpression)
	{
		return true;
	}

	if(expr instanceof JSCallExpression)
	{
		return true;
	}

	if(expr instanceof JSNewExpression)
	{
		return true;
	}

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

示例4: visitJSExpressionStatement

import com.intellij.lang.javascript.psi.JSNewExpression; //导入依赖的package包/类
@Override public void visitJSExpressionStatement(
        @NotNull JSExpressionStatement statement) {
    super.visitJSExpressionStatement(statement);
    if (!(statement.getExpression()instanceof JSNewExpression)) {
        return;
    }
    final JSNewExpression newExpression =
            (JSNewExpression) statement.getExpression();
    final JSExpression methodExpression =
            newExpression.getMethodExpression();
    if (methodExpression == null) {
        return;
    }
    registerError(methodExpression);
}
 
开发者ID:consulo,项目名称:consulo-javascript,代码行数:16,代码来源:ObjectAllocationIgnoredJSInspection.java

示例5: newExpressionDefinitelyRecurses

import com.intellij.lang.javascript.psi.JSNewExpression; //导入依赖的package包/类
private static boolean newExpressionDefinitelyRecurses(JSNewExpression exp,
                                                       JSFunction method) {
    final JSArgumentList argumentList = exp.getArgumentList();
    if (argumentList != null) {
        final JSExpression[] args = argumentList.getArguments();
        for (final JSExpression arg : args) {
            if (RecursionUtil.expressionDefinitelyRecurses(arg, method)) {
                return true;
            }
        }
    }
    return false;
}
 
开发者ID:consulo,项目名称:consulo-javascript,代码行数:14,代码来源:RecursionUtil.java

示例6: expressionDefinitelyRecurses

import com.intellij.lang.javascript.psi.JSNewExpression; //导入依赖的package包/类
private static boolean expressionDefinitelyRecurses(JSExpression exp,
                                                    JSFunction method) {
    if (exp == null) {
        return false;
    }
    if (exp instanceof JSNewExpression) {
        return RecursionUtil.newExpressionDefinitelyRecurses(
                (JSNewExpression) exp, method);
    }
    if (exp instanceof JSCallExpression) {
        return RecursionUtil.callExpressionDefinitelyRecurses(
                (JSCallExpression) exp, method);
    }
    if (exp instanceof JSAssignmentExpression) {
        return RecursionUtil.assignmentExpressionDefinitelyRecurses(
                (JSAssignmentExpression) exp, method);
    }
    if (exp instanceof JSArrayLiteralExpression) {
        return RecursionUtil.arrayLiteralExpressionDefinitelyRecurses(
                (JSArrayLiteralExpression) exp, method);
    }
    if (exp instanceof JSIndexedPropertyAccessExpression) {
        return RecursionUtil.indexedPropertyAccessExpressionDefinitelyRecurses(
                (JSIndexedPropertyAccessExpression) exp, method);
    }
    if (exp instanceof JSPrefixExpression) {
        return RecursionUtil.prefixExpressionDefinitelyRecurses(
                (JSPrefixExpression) exp, method);
    }
    if (exp instanceof JSPostfixExpression) {
        return RecursionUtil.postfixExpressionDefinitelyRecurses(
                (JSPostfixExpression) exp, method);
    }
    if (exp instanceof JSBinaryExpression) {
        return RecursionUtil.binaryExpressionDefinitelyRecurses(
                (JSBinaryExpression) exp, method);
    }
    if (exp instanceof JSConditionalExpression) {
        return RecursionUtil.conditionalExpressionDefinitelyRecurses(
                (JSConditionalExpression) exp, method);
    }
    if (exp instanceof JSParenthesizedExpression) {
        return RecursionUtil.parenthesizedExpressionDefinitelyRecurses(
                (JSParenthesizedExpression) exp, method);
    }
    if (exp instanceof JSReferenceExpression) {
        return RecursionUtil.referenceExpressionDefinitelyRecurses(
                (JSReferenceExpression) exp, method);
    }
    if (exp instanceof JSLiteralExpression ||
        exp instanceof JSThisExpression) {
        return false;
    }
    return false;
}
 
开发者ID:consulo,项目名称:consulo-javascript,代码行数:56,代码来源:RecursionUtil.java


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