當前位置: 首頁>>代碼示例>>Java>>正文


Java PsiElement.EMPTY_ARRAY屬性代碼示例

本文整理匯總了Java中com.intellij.psi.PsiElement.EMPTY_ARRAY屬性的典型用法代碼示例。如果您正苦於以下問題:Java PsiElement.EMPTY_ARRAY屬性的具體用法?Java PsiElement.EMPTY_ARRAY怎麽用?Java PsiElement.EMPTY_ARRAY使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在com.intellij.psi.PsiElement的用法示例。


在下文中一共展示了PsiElement.EMPTY_ARRAY屬性的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getGotoDeclarationTargets

@Nullable
@Override
public PsiElement[] getGotoDeclarationTargets(@Nullable PsiElement psiElement, int i, Editor editor) {
    if (psiElement == null) {
        return PsiElement.EMPTY_ARRAY;
    }
    Project project = psiElement.getProject();
    if (!PlatformPatterns
            .psiElement(StringLiteralExpression.class)
            .withLanguage(PhpLanguage.INSTANCE)
            .accepts(psiElement.getContext())
    ) {
        return PsiElement.EMPTY_ARRAY;
    }
    PsiFile containingFile = psiElement.getContainingFile();
    PsiDirectory appDir = PsiUtil.getAppDirectoryFromFile(containingFile);
    String elementFilename = String.format("View/Elements/%s.ctp", psiElement.getText());
    VirtualFile relativeFile = VfsUtil.findRelativeFile(appDir, elementFilename);
    if (relativeFile != null) {
        Collection<VirtualFile> files = new HashSet<>();
        files.add(relativeFile);
        return PsiUtil.convertVirtualFilesToPsiFiles(project, files).toArray(new PsiElement[files.size()]);
    }
    return PsiElement.EMPTY_ARRAY;
}
 
開發者ID:dmeybohm,項目名稱:chocolate-cakephp,代碼行數:25,代碼來源:ElementGotoDeclarationHandler.java

示例2: getGotoDeclarationTargets

@Nullable
@Override
public PsiElement[] getGotoDeclarationTargets(@Nullable PsiElement psiElement, int i, Editor editor) {
    if (psiElement == null) {
        return PsiElement.EMPTY_ARRAY;
    }
    if (!PlatformPatterns.psiElement().withParent(FieldReference.class).accepts(psiElement)) {
        return PsiElement.EMPTY_ARRAY;
    }
    String filename = PsiUtil.getFileNameWithoutExtension(psiElement);
    if (filename == null) {
        return PsiElement.EMPTY_ARRAY;
    }
    String controllerName = CakeUtil.controllerBaseNameFromControllerFileName(filename);
    if (controllerName == null) {
        return PsiElement.EMPTY_ARRAY;
    }
    PsiElement parent = psiElement.getParent();
    if (parent == null) {
        return PsiElement.EMPTY_ARRAY;
    }
    FieldReference fieldReference = (FieldReference)parent;
    String fieldName = fieldReference.getName();
    if (fieldName == null) {
        return PsiElement.EMPTY_ARRAY;
    }
    Collection<PhpClass> classes = PsiUtil.getControllerFieldClasses(fieldName, psiElement.getProject());
    return classes.toArray(new PsiElement[classes.size()]);
}
 
開發者ID:dmeybohm,項目名稱:chocolate-cakephp,代碼行數:29,代碼來源:ControllerFieldGotoDeclarationHandler.java

示例3: getGotoDeclarationTargets

@Nullable
@Override
public PsiElement[] getGotoDeclarationTargets(@Nullable PsiElement psiElement, int i, Editor editor) {
    if (psiElement == null) {
        return PsiElement.EMPTY_ARRAY;
    }
    Project project = psiElement.getProject();
    if (!PlatformPatterns
            .psiElement(StringLiteralExpression.class)
            .withLanguage(PhpLanguage.INSTANCE)
            .accepts(psiElement.getContext())
    ) {
        return PsiElement.EMPTY_ARRAY;
    }
    PsiFile containingFile = psiElement.getContainingFile();
    VirtualFile virtualFile = containingFile.getVirtualFile();
    String filename = virtualFile.getNameWithoutExtension();
    String controllerName = CakeUtil.controllerBaseNameFromControllerFileName(filename);
    if (controllerName == null) {
        return PsiElement.EMPTY_ARRAY;
    }

    PsiDirectory appDir = PsiUtil.getAppDirectoryFromFile(containingFile);
    String templatePath = String.format("View/%s/%s.ctp", controllerName, psiElement.getText());
    VirtualFile relativeFile = VfsUtil.findRelativeFile(appDir, templatePath);
    if (relativeFile != null) {
        Collection<VirtualFile> files = new HashSet<>();
        files.add(relativeFile);
        return PsiUtil.convertVirtualFilesToPsiFiles(project, files).toArray(new PsiElement[files.size()]);
    }
    return PsiElement.EMPTY_ARRAY;
}
 
開發者ID:dmeybohm,項目名稱:chocolate-cakephp,代碼行數:32,代碼來源:TemplateGotoDeclarationHandler.java

示例4: getGotoDeclarationTargets

@Nullable
@Override
public PsiElement[] getGotoDeclarationTargets(@Nullable PsiElement psiElement, int i, Editor editor) {
    if (psiElement == null) {
        return PsiElement.EMPTY_ARRAY;
    }
    if (!PlatformPatterns
            .psiElement(StringLiteralExpression.class)
            .withLanguage(PhpLanguage.INSTANCE)
            .accepts(psiElement.getContext())
            ) {
        return PsiElement.EMPTY_ARRAY;
    }
    Field field = (Field)PsiUtil.findParent(psiElement, Field.class);
    if (field == null) {
        return PsiElement.EMPTY_ARRAY;
    }
    String text = field.getText();
    // PhpStorm already has completion based on strings that contain class names, so
    // we only need to check for the components and helpers properties:
    if (text.contains("$components")) {
        return PsiUtil.getClassesAsArray(psiElement, psiElement.getText() + "Component");
    }
    if (text.contains("$helpers")) {
        return PsiUtil.getClassesAsArray(psiElement, psiElement.getText() + "Helper");
    }
    return PsiElement.EMPTY_ARRAY;
}
 
開發者ID:dmeybohm,項目名稱:chocolate-cakephp,代碼行數:28,代碼來源:ControllerComponentsGotoDeclarationHandler.java

示例5: getGotoDeclarationTargets

@Nullable
@Override
public PsiElement[] getGotoDeclarationTargets(@Nullable PsiElement psiElement, int i, Editor editor) {
    if (psiElement == null) {
        return PsiElement.EMPTY_ARRAY;
    }
    if (!PlatformPatterns.psiElement().withParent(FieldReference.class).accepts(psiElement)) {
        return PsiElement.EMPTY_ARRAY;
    }
    PsiElement parent = psiElement.getParent();
    if (parent == null) {
        return PsiElement.EMPTY_ARRAY;
    }
    FieldReference fieldReference = (FieldReference)parent;
    String fieldName = fieldReference.getName();
    if (fieldName == null) {
        return PsiElement.EMPTY_ARRAY;
    }
    PhpExpression classReference = fieldReference.getClassReference();
    if (classReference == null) {
        return null;
    }
    PhpType types = classReference.getType();
    String fieldReferenceName = fieldReference.getName();
    if (!StringUtil.startsWithUppercaseCharacter(fieldReferenceName)) {
        return null;
    }
    for (String type : types.getTypes()) {
        if (type.contains("#Vthis")) {
            Collection<PhpClass> classes = PsiUtil.getViewHelperClasses(fieldName, psiElement.getProject());
            return classes.toArray(new PsiElement[classes.size()]);
        }
    }
    return PsiElement.EMPTY_ARRAY;
}
 
開發者ID:dmeybohm,項目名稱:chocolate-cakephp,代碼行數:35,代碼來源:ViewHelperGotoDeclarationHandler.java

示例6: getChildren

@Override
public PsiElement[] getChildren()
{
  return PsiElement.EMPTY_ARRAY;
}
 
開發者ID:manifold-systems,項目名稱:manifold-ij,代碼行數:5,代碼來源:FakeTargetElement.java


注:本文中的com.intellij.psi.PsiElement.EMPTY_ARRAY屬性示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。