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


Java PsiElement.getParent方法代码示例

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


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

示例1: checkPsiElement

import com.intellij.psi.PsiElement; //导入方法依赖的package包/类
/**
 * @param psiElement checking element
 * @return true if this is process.env.*** variable
 */
public static boolean checkPsiElement(@NotNull PsiElement psiElement) {
    if(!(psiElement instanceof LeafPsiElement)) {
        return false;
    }

    IElementType elementType = ((LeafPsiElement) psiElement).getElementType();
    if(!elementType.toString().equals("JS:IDENTIFIER")) {
        return false;
    }

    PsiElement parent = psiElement.getParent();
    if(!(parent instanceof JSReferenceExpression)) {
        return false;
    }

    return ((JSReferenceExpression) parent).getCanonicalText().startsWith("process.env");
}
 
开发者ID:adelf,项目名称:idea-php-dotenv-plugin,代码行数:22,代码来源:JsPsiHelper.java

示例2: extractArrayIndexFromValue

import com.intellij.psi.PsiElement; //导入方法依赖的package包/类
@Nullable
public static String extractArrayIndexFromValue(PsiElement element) {
    PsiElement arrayElement;
    if (element.getParent() instanceof StringLiteralExpression) {
        arrayElement = element.getParent().getParent().getParent();
    } else {
        arrayElement = element.getParent().getParent();
    }

    if (arrayElement instanceof ArrayHashElement) {
        ArrayHashElement arrayHashElement = (ArrayHashElement) arrayElement;
        return extractIndexFromArrayHash(arrayHashElement);
    }

    return null;
}
 
开发者ID:cedricziel,项目名称:idea-php-typo3-plugin,代码行数:17,代码来源:PhpElementsUtil.java

示例3: getGotoDeclarationTargets

import com.intellij.psi.PsiElement; //导入方法依赖的package包/类
@Nullable
@Override
public PsiElement[] getGotoDeclarationTargets(@Nullable PsiElement psiElement, int i, Editor editor) {

    if(psiElement == null || psiElement.getParent() == null) {
        return new PsiElement[0];
    }

    if(!psiElement.getContainingFile().getName().equals("Dockerfile")) {
        return new PsiElement[0];
    }

    psiElement = psiElement.getParent();

    if(!(psiElement instanceof DockerFileEnvRegularDeclaration)) {
        return new PsiElement[0];
    }

    return EnvironmentVariablesApi.getKeyUsages(psiElement.getProject(), EnvironmentVariablesUtil.getKeyFromString((((DockerFileEnvRegularDeclaration) psiElement).getDeclaredName().getText())));
}
 
开发者ID:adelf,项目名称:idea-php-dotenv-plugin,代码行数:21,代码来源:DockerfileKeyGotoHandler.java

示例4: getTestContextElement

import com.intellij.psi.PsiElement; //导入方法依赖的package包/类
@Nullable
private PsiElement getTestContextElement(@NotNull PsiElement psiElement) {
    if(psiElement instanceof GherkinScenario || psiElement instanceof GherkinFeature) {
        return psiElement;
    }

    // Scenario: Foo<caret>bar
    PsiElement parent = psiElement.getParent();
    if(parent instanceof GherkinScenario || parent instanceof GherkinFeature) {
        return parent;
    }

    // Scenario: Foobar
    //   Given <caret>
    if(parent instanceof GherkinStep) {
        PsiElement parent1 = parent.getParent();
        if(parent1 instanceof GherkinScenario || parent1 instanceof GherkinFeature) {
            return parent;
        }
    }

    return null;
}
 
开发者ID:Haehnchen,项目名称:idea-php-behat-plugin,代码行数:24,代码来源:TestRunIntentionAction.java

示例5: isNotFoldableParent

import com.intellij.psi.PsiElement; //导入方法依赖的package包/类
@Contract(pure = true)
private boolean isNotFoldableParent(@Nullable final PsiElement element) {
    if (null == element) {
        return false;
    }

    PsiElement parent = element.getParent();
    while (null != parent) {
        if (isFoldable(parent)) {
            return false;
        }

        parent = parent.getParent();
    }

    return true;
}
 
开发者ID:AlexanderBartash,项目名称:hybris-integration-intellij-idea-plugin,代码行数:18,代码来源:SmartFoldingBlocksFilter.java

示例6: findParamRefByElement

import com.intellij.psi.PsiElement; //导入方法依赖的package包/类
@Nullable
public static PsiElement findParamRefByElement(PsiElement element) {
    int limit = 10;
    PsiElement prevElement = element;
    PsiElement currElement = element.getParent();
    while (limit > 0) {
        if (currElement instanceof ParameterList)
            return prevElement;
        else {
            prevElement = currElement;
            currElement = currElement.getParent();

            limit--;
        }
    }
    return null;
}
 
开发者ID:nvlad,项目名称:yii2support,代码行数:18,代码来源:MethodUtils.java

示例7: resolvePath

import com.intellij.psi.PsiElement; //导入方法依赖的package包/类
public static String resolvePath(PsiElement psiElement) {
    List<String> path = new ArrayList<>();
    do {
        if (psiElement instanceof YAMLKeyValue) {
            path.add(0, ((YAMLKeyValue) psiElement).getKeyText());
        }
    } while ((psiElement = psiElement.getParent()) != null);
    return String.join(".", path);
}
 
开发者ID:seedstack,项目名称:intellij-plugin,代码行数:10,代码来源:CoffigUtil.java

示例8: annotate

import com.intellij.psi.PsiElement; //导入方法依赖的package包/类
@Override
public void annotate(@NotNull PsiElement psiElement, @NotNull AnnotationHolder annotationHolder) {
  if (psiElement instanceof SoyAnyStringLiteral
      && psiElement.getParent() instanceof SoyExpr
      && psiElement.getText().startsWith("\"")) {
    annotationHolder.createErrorAnnotation(
        psiElement, "Strings in expressions must use single quotes.");
  }
}
 
开发者ID:google,项目名称:bamboo-soy,代码行数:10,代码来源:DoubleQuotedStringAnnotator.java

示例9: isR2Expression

import com.intellij.psi.PsiElement; //导入方法依赖的package包/类
private static boolean isR2Expression(PsiElement node) {
  if (node.getParent() == null) {
    return false;
  }
  String text = node.getText();
  PsiElement parent = LintUtils.skipParentheses(node.getParent());
  return (text.equals(R2) || text.contains(".R2"))
      && parent instanceof PsiExpression
      && endsWithAny(parent.getText(), SUPPORTED_TYPES);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:11,代码来源:InvalidR2UsageDetector.java

示例10: annotate

import com.intellij.psi.PsiElement; //导入方法依赖的package包/类
@Override
public void annotate(@NotNull PsiElement psiElement, @NotNull AnnotationHolder annotationHolder) {

    if (!(psiElement instanceof StringLiteralExpression)) {
        return;
    }

    StringLiteralExpression literalExpression = (StringLiteralExpression) psiElement;
    String value = literalExpression.getContents();

    if (TranslationUtil.isTranslationKeyString(value) && value.length() > 4 && !(psiElement.getParent() instanceof ConcatenationExpression)) {
        annotateTranslationUsage(psiElement, annotationHolder, value);
    }
}
 
开发者ID:cedricziel,项目名称:idea-php-typo3-plugin,代码行数:15,代码来源:TranslationAnnotator.java

示例11: generateDoc

import com.intellij.psi.PsiElement; //导入方法依赖的package包/类
@Override
public String generateDoc(PsiElement element, @Nullable PsiElement originalElement) {
    if (element instanceof PsiModuleName) {
        element = element.getParent();
        PsiElement previousElement = element == null ? null : PsiTreeUtil.prevVisibleLeaf(element);
        if (previousElement instanceof PsiComment) {
            StringBuilder sb = new StringBuilder();
            sb.append(previousElement.getText());
            return sb.toString();
        }
    }

    return super.generateDoc(element, originalElement);
}
 
开发者ID:reasonml-editor,项目名称:reasonml-idea-plugin,代码行数:15,代码来源:DocumentationProvider.java

示例12: getStringLiteral

import com.intellij.psi.PsiElement; //导入方法依赖的package包/类
@Nullable
private PyStringLiteralExpression getStringLiteral(@NotNull PsiElement psiElement) {
    PsiElement parent = psiElement.getParent();

    if(!(parent instanceof PyStringLiteralExpression)) {
        return null;
    }

    if(parent.getParent() == null) {
        return null;
    }

    PsiElement candidate = parent.getParent().getParent();

    if(candidate instanceof PyCallExpression) {
        PyCallExpression callExpression = (PyCallExpression) candidate;
        if(PythonPsiHelper.checkGetMethodCall(callExpression)
                && callExpression.getArgumentList() != null
                && callExpression.getArgumentList().getArguments().length > 0
                && callExpression.getArgumentList().getArguments()[0].isEquivalentTo(parent)) {

            return (PyStringLiteralExpression) parent;
        }

        return null;
    }

    if(candidate instanceof PyAssignmentStatement) {
        PyExpression assignedValue = ((PyAssignmentStatement) candidate).getAssignedValue();
        if(assignedValue instanceof PySubscriptionExpression) {
            if(PythonPsiHelper.checkIndexCall((PySubscriptionExpression) assignedValue)) {
                return (PyStringLiteralExpression) parent;
            }

            return null;
        }
    }

    return null;
}
 
开发者ID:adelf,项目名称:idea-php-dotenv-plugin,代码行数:41,代码来源:PythonEnvCompletionProvider.java

示例13: getArrayCreationByVarRef

import com.intellij.psi.PsiElement; //导入方法依赖的package包/类
@Nullable
static ArrayCreationExpression getArrayCreationByVarRef(Variable value) {
    ArrayCreationExpression arrayCreation;
    PsiElement arrayDecl = value.resolve();
    if (arrayDecl != null && arrayDecl.getParent() != null && arrayDecl.getParent().getChildren().length > 1 ) {
        PsiElement psiElement = arrayDecl.getParent().getLastChild();
        if (psiElement instanceof ArrayCreationExpression)
            arrayCreation = (ArrayCreationExpression)psiElement;
        else
            return null;
    } else
        return null;
    return arrayCreation;
}
 
开发者ID:nvlad,项目名称:yii2support,代码行数:15,代码来源:ObjectFactoryUtils.java

示例14: getNamedElement

import com.intellij.psi.PsiElement; //导入方法依赖的package包/类
@Nullable
@Override
public PsiElement getNamedElement(@NotNull PsiElement element) {
  final PsiElement parent = element.getParent();
  if (parent instanceof AppleScriptHandlerSelectorPart) {
    AppleScriptHandlerSelectorPart part = (AppleScriptHandlerSelectorPart) parent;
    if (element != part.findParameterNode()) {
      return part.getParent(); // AppleScriptHandler;
    }
  }
  return null;
}
 
开发者ID:ant-druha,项目名称:AppleScript-IDEA,代码行数:13,代码来源:AppleScriptTargetElementEvaluator.java

示例15: getMethodRef

import com.intellij.psi.PsiElement; //导入方法依赖的package包/类
@Nullable
public static MethodReference getMethodRef(PsiElement el, int recursionLimit) {
    if (el == null)
        return null;
    else if (el.getParent() instanceof MethodReference)
        return (MethodReference) el.getParent();
    else if (recursionLimit <= 0)
        return null;
    else
        return getMethodRef(el.getParent(), recursionLimit - 1);
}
 
开发者ID:nvlad,项目名称:yii2support,代码行数:12,代码来源:ClassUtils.java


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