本文整理匯總了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);
}