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


Java JSReferenceExpression.getQualifier方法代码示例

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


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

示例1: getElementByReference

import com.intellij.lang.javascript.psi.JSReferenceExpression; //导入方法依赖的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.JSReferenceExpression; //导入方法依赖的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: visitJSNewExpression

import com.intellij.lang.javascript.psi.JSReferenceExpression; //导入方法依赖的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

示例4: visitJSReferenceExpression

import com.intellij.lang.javascript.psi.JSReferenceExpression; //导入方法依赖的package包/类
@SuppressWarnings({"HardCodedStringLiteral"})
@Override public void visitJSReferenceExpression(JSReferenceExpression referenceExpression) {
    super.visitJSReferenceExpression(referenceExpression);
    final JSExpression qualifier = referenceExpression.getQualifier();
    if (qualifier == null) {
        return;
    }
    final String qualifierText = qualifier.getText();

    if (!"document".equalsIgnoreCase(qualifierText)) {
        return;
    }
    final String methodName = referenceExpression.getReferencedName();
    if (!"images".equalsIgnoreCase(methodName) &&
            !"body".equalsIgnoreCase(methodName) &&
            !"applets".equalsIgnoreCase(methodName) &&
            !"links".equalsIgnoreCase(methodName) &&
            !"forms".equalsIgnoreCase(methodName) &&
            !"anchors".equalsIgnoreCase(methodName)
            ) {
        return;
    }
    registerError(referenceExpression);
}
 
开发者ID:consulo,项目名称:consulo-javascript,代码行数:25,代码来源:XHTMLIncompatabilitiesJSInspection.java

示例5: visitJSCallExpression

import com.intellij.lang.javascript.psi.JSReferenceExpression; //导入方法依赖的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();
    if(qualifier == null)
    {
        return;
    }
    @NonNls final String qualifierText = qualifier.getText();
    if(!"document".equals(qualifierText))
    {
        return;
    }
    @NonNls final String methodName = referenceExpression.getReferencedName();
    if(!"write".equals(methodName) && !"writeln".equals(methodName))
    {
        return;
    }
    registerError(methodExpression);
}
 
开发者ID:consulo,项目名称:consulo-javascript,代码行数:31,代码来源:DocumentWriteJSInspection.java

示例6: visitJSAssignmentExpression

import com.intellij.lang.javascript.psi.JSReferenceExpression; //导入方法依赖的package包/类
@Override public void visitJSAssignmentExpression(@NotNull JSAssignmentExpression assignment) {
    super.visitJSAssignmentExpression(assignment);

    final IElementType sign = assignment.getOperationSign();
    if (!JSTokenTypes.EQ.equals(sign)) {
        return;
    }
    JSExpression lhs = assignment.getLOperand();
    if(lhs instanceof JSDefinitionExpression)
    {
        lhs = ((JSDefinitionExpression)lhs).getExpression();
    }
    final JSExpression rhs = assignment.getROperand();
    if(rhs == null || lhs == null)
    {
        return;
    }
    if(!(rhs instanceof JSReferenceExpression) ||
            !(lhs instanceof JSReferenceExpression) )
    {
        return;
    }
    final JSReferenceExpression rhsReference = (JSReferenceExpression) rhs;
    final JSReferenceExpression lhsReference = (JSReferenceExpression) lhs;
    final JSExpression rhsQualifier = rhsReference.getQualifier();
    final JSExpression lhsQualifier = lhsReference.getQualifier();
    if(rhsQualifier !=null || lhsQualifier !=null)
    {
        if(!EquivalenceChecker.expressionsAreEquivalent(rhsQualifier, lhsQualifier))
        {
            return;
        }
    }
    final String rhsName = rhsReference.getReferencedName();
    final String lhsName = lhsReference.getReferencedName();
    if(rhsName == null || lhsName == null)
    {
        return;
    }
    if(!rhsName.equals(lhsName))
    {
        return;
    }
    final PsiElement rhsReferent = rhsReference.resolve();
    final PsiElement lhsReferent = lhsReference.resolve();
    if(rhsReferent != null && lhsReferent != null &&
            !rhsReferent.equals(lhsReferent))
    {
        return;
    }

    if (lhsName.equals("location") && lhsQualifier != null && lhsQualifier.getText().equals("document")) {
      // document.location = document.location causes browser refresh
      return;
    }
    registerError(assignment);
}
 
开发者ID:consulo,项目名称:consulo-javascript,代码行数:58,代码来源:SillyAssignmentJSInspection.java

示例7: referenceExpressionDefinitelyRecurses

import com.intellij.lang.javascript.psi.JSReferenceExpression; //导入方法依赖的package包/类
private static boolean referenceExpressionDefinitelyRecurses(
        JSReferenceExpression expression, JSFunction method) {
    final JSExpression qualifierExpression = expression.getQualifier();
    return (qualifierExpression != null &&
            RecursionUtil.expressionDefinitelyRecurses(qualifierExpression, method));
}
 
开发者ID:consulo,项目名称:consulo-javascript,代码行数:7,代码来源:RecursionUtil.java


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