本文整理汇总了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");
}
示例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;
}
示例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())));
}
示例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;
}
示例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;
}
示例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);
}
示例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.");
}
}
示例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);
}
示例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);
}
}
示例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);
}
示例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;
}
示例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;
}
示例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;
}
示例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);
}