當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。