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


Java PhpDocComment类代码示例

本文整理汇总了Java中com.jetbrains.php.lang.documentation.phpdoc.psi.PhpDocComment的典型用法代码示例。如果您正苦于以下问题:Java PhpDocComment类的具体用法?Java PhpDocComment怎么用?Java PhpDocComment使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


PhpDocComment类属于com.jetbrains.php.lang.documentation.phpdoc.psi包,在下文中一共展示了PhpDocComment类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: buildVisitor

import com.jetbrains.php.lang.documentation.phpdoc.psi.PhpDocComment; //导入依赖的package包/类
@NotNull
@Override
public PsiElementVisitor buildVisitor(@NotNull ProblemsHolder holder, boolean isOnTheFly) {
    return new PhpElementVisitor() {
        @Override
        public void visitPhpClass(PhpClass phpClass) {
            if ( ! TesterUtil.isTestClass(phpClass)) {
                return;
            }

            PhpDocComment docComment = phpClass.getDocComment();
            if (docComment == null || docComment.getTagElementsByName("@testCase").length == 0) {
                holder.registerProblem(phpClass, TesterBundle.message("inspections.annotation.description"), QUICK_FIX);
            }
        }
    };
}
 
开发者ID:jiripudil,项目名称:intellij-nette-tester,代码行数:18,代码来源:TestCaseAnnotationInspection.java

示例2: fixMissingInheritDocForNamedElement

import com.jetbrains.php.lang.documentation.phpdoc.psi.PhpDocComment; //导入依赖的package包/类
static void fixMissingInheritDocForNamedElement(final PhpNamedElement phpNamedElement)
{
    if (phpNamedElement.getDocComment() != null) {
        return;
    }

    // write a new docblock with inheritdoc
    new WriteCommandAction.Simple(phpNamedElement.getProject(), phpNamedElement.getContainingFile()) {
        @Override
        protected void run() throws Throwable {
            String commentString = "/**\n * {@inheritDoc} \n*/";

            PhpDocComment comment = PhpPsiElementFactory.createFromText(
                    phpNamedElement.getProject(),
                    PhpDocComment.class,
                    commentString
            );

            if (comment == null) {
                return;
            }

            PhpCodeEditUtil.insertDocCommentBeforeAndGetTextRange(phpNamedElement, comment);
        }
    }.execute();
}
 
开发者ID:thanosp,项目名称:phpstorm-inheritdoc,代码行数:27,代码来源:InheritDocUtil.java

示例3: replaceDocblockForNamedElement

import com.jetbrains.php.lang.documentation.phpdoc.psi.PhpDocComment; //导入依赖的package包/类
static void replaceDocblockForNamedElement(final PhpNamedElement phpNamedElement)
{
    // write a new docblock with inheritdoc
    new WriteCommandAction.Simple(phpNamedElement.getProject(), phpNamedElement.getContainingFile()) {
        @Override
        protected void run() throws Throwable {
            PhpDocComment docComment = phpNamedElement.getDocComment();
            if (docComment == null) {
                return;
            }
            docComment.delete();
        }
    }.execute();

    InheritDocUtil.fixMissingInheritDocForNamedElement(phpNamedElement);
}
 
开发者ID:thanosp,项目名称:phpstorm-inheritdoc,代码行数:17,代码来源:InheritDocUtil.java

示例4: isValidReference

import com.jetbrains.php.lang.documentation.phpdoc.psi.PhpDocComment; //导入依赖的package包/类
private static boolean isValidReference(PhpNamedElement referencedElement, PsiElement contextElement) {
    MagentoModule referenceSourceModule = getMagentoModule(referencedElement);
    MagentoModule currentModule = getMagentoModule(contextElement);


    if (!areDifferentModules(referenceSourceModule, currentModule)) {
        return true;
    }

    PhpDocComment docComment = referencedElement.getDocComment();
    if(docComment == null) {
        return false;
    }

    PhpDocTag[] elements = docComment.getTagElementsByName(API_TAG);
    return elements.length > 0;
}
 
开发者ID:dkvashninbay,项目名称:magento2plugin,代码行数:18,代码来源:MagentoApiInspection.java

示例5: matches

import com.jetbrains.php.lang.documentation.phpdoc.psi.PhpDocComment; //导入依赖的package包/类
@Override
public boolean matches(PhpNamedElement element) {
    if (!canMatchElement(element)) {
        return false;
    }
    PhpDocComment docComment = element.getDocComment();
    if (docComment == null) {
        return false;
    }

    List<PhpDocTag> docTagList = PsiTreeUtil.getChildrenOfTypeAsList(docComment, PhpDocTag.class);
    for (PhpDocTag phpDocTag : docTagList) {
        PhpClass annotationReference = AnnotationUtil.getAnnotationReference(phpDocTag);
        if (annotationReference == null || annotationReference.getPresentableFQN() == null) {
            continue;
        }
        String fqn = annotationReference.getFQN();
        if (fqn != null && fqn.equals(expectedClass)) {
            return true;
        };
    }

    return false;
}
 
开发者ID:goaop,项目名称:idea-plugin,代码行数:25,代码来源:AnnotationPointcut.java

示例6: invoke

import com.jetbrains.php.lang.documentation.phpdoc.psi.PhpDocComment; //导入依赖的package包/类
@Override
public void invoke(@NotNull Project project, Editor editor, PsiFile psiFile) throws IncorrectOperationException
{
    int primaryCaretOffset = editor.getCaretModel().getPrimaryCaret().getOffset();

    PsiElement currentPsiElement = psiFile.findElementAt(primaryCaretOffset);
    PsiElement statement = PsiTreeUtil.getParentOfType(currentPsiElement, Statement.class);
    if (statement == null) {
        return;
    }

    String commentStart = "/** @ContentType IDENTIFIER ";
    String commentContent = commentStart + currentPsiElement.getText() + "*/";
    PhpDocComment comment = PhpPsiElementFactory.createFromText(project, PhpDocComment.class, commentContent);
    if (comment == null) {
        return;
    }

    PsiElement result = statement.addBefore(comment, statement.getFirstChild());
    editor.getCaretModel().getPrimaryCaret().moveToOffset(result.getTextOffset() + commentStart.length() - 1);

    editor.getCaretModel().getPrimaryCaret().selectWordAtCaret(true);
}
 
开发者ID:whitefire,项目名称:eZ-completion,代码行数:24,代码来源:EzDocVariableIntention.java

示例7: resolveType

import com.jetbrains.php.lang.documentation.phpdoc.psi.PhpDocComment; //导入依赖的package包/类
@Nullable
@Override
public String resolveType(PsiElement psiElement)
{
    String variableName = psiElement.getText();
    PsiElement statement = PsiTreeUtil.getParentOfType(psiElement, Statement.class);
    PsiElement sibling = PsiTreeUtil.getPrevSiblingOfType(statement, PhpDocComment.class);
    PhpDocTag tag;

    // Check all statements within current scope for doc-blocks.
    do {
        tag = PsiTreeUtil.getChildOfType(sibling, PhpDocTag.class);
        if (tagMatches(tag, variableName)) {
            break;
        }
        sibling = PsiTreeUtil.getPrevSiblingOfType(sibling, PhpDocComment.class);
        tag = null;
    } while (sibling != null);

    if (tag == null) {
        return null;
    }

    return parsePhpDoc(tag);
}
 
开发者ID:whitefire,项目名称:eZ-completion,代码行数:26,代码来源:ContentVariableTypeProvider.java

示例8: getTemplateAnnotationFilesWithSiblingMethod

import com.jetbrains.php.lang.documentation.phpdoc.psi.PhpDocComment; //导入依赖的package包/类
/**
 * Get templates on "@Template()" and on method attached to given PhpDocTag
 */
@NotNull
public static Map<String, Collection<PsiElement>> getTemplateAnnotationFilesWithSiblingMethod(@NotNull PhpDocTag phpDocTag) {
    Map<String, Collection<PsiElement>> targets = new HashMap<>();

    // template on direct PhpDocTag
    Pair<String, Collection<PsiElement>> templateAnnotationFiles = TwigUtil.getTemplateAnnotationFiles(phpDocTag);
    if(templateAnnotationFiles != null) {
        targets.put(templateAnnotationFiles.getFirst(), templateAnnotationFiles.getSecond());
    }

    // templates on "Method" of PhpDocTag
    PhpDocComment phpDocComment = PsiTreeUtil.getParentOfType(phpDocTag, PhpDocComment.class);
    if(phpDocComment != null) {
        PsiElement method = phpDocComment.getNextPsiSibling();
        if(method instanceof Method) {
            for (String name : TwigUtil.getControllerMethodShortcut((Method) method)) {
                targets.put(name, new HashSet<>(getTemplatePsiElements(method.getProject(), name)));
            }
        }
    }

    return targets;
}
 
开发者ID:Haehnchen,项目名称:idea-php-symfony2-plugin,代码行数:27,代码来源:TwigUtil.java

示例9: getUseImportMap

import com.jetbrains.php.lang.documentation.phpdoc.psi.PhpDocComment; //导入依赖的package包/类
@NotNull
public static Map<String, String> getUseImportMap(@NotNull PhpDocComment phpDocComment) {

    // search for use alias in local file
    final Map<String, String> useImports = new HashMap<>();

    PhpPsiElement scope = PhpCodeInsightUtil.findScopeForUseOperator(phpDocComment);
    if(scope == null) {
        return useImports;
    }

    for (PhpUseList phpUseList : PhpCodeInsightUtil.collectImports(scope)) {
        for (PhpUse phpUse : phpUseList.getDeclarations()) {
            String alias = phpUse.getAliasName();
            if (alias != null) {
                useImports.put(alias, phpUse.getFQN());
            } else {
                useImports.put(phpUse.getName(), phpUse.getFQN());
            }
        }
    }

    return useImports;
}
 
开发者ID:Haehnchen,项目名称:idea-php-symfony2-plugin,代码行数:25,代码来源:AnnotationBackportUtil.java

示例10: hasReference

import com.jetbrains.php.lang.documentation.phpdoc.psi.PhpDocComment; //导入依赖的package包/类
public static boolean hasReference(@Nullable PhpDocComment docComment, String... className) {
    if(docComment == null) return false;

    Map<String, String> uses = AnnotationBackportUtil.getUseImportMap(docComment);

    for(PhpDocTag phpDocTag: PsiTreeUtil.findChildrenOfAnyType(docComment, PhpDocTag.class)) {
        if(!AnnotationBackportUtil.NON_ANNOTATION_TAGS.contains(phpDocTag.getName())) {
            PhpClass annotationReference = AnnotationBackportUtil.getAnnotationReference(phpDocTag, uses);
            if(annotationReference != null && PhpElementsUtil.isEqualClassName(annotationReference, className)) {
                return true;
            }
        }

    }

    return false;
}
 
开发者ID:Haehnchen,项目名称:idea-php-symfony2-plugin,代码行数:18,代码来源:AnnotationBackportUtil.java

示例11: getReference

import com.jetbrains.php.lang.documentation.phpdoc.psi.PhpDocComment; //导入依赖的package包/类
public static PhpDocTag getReference(@Nullable PhpDocComment docComment, String className) {
    if(docComment == null) return null;

    Map<String, String> uses = AnnotationBackportUtil.getUseImportMap(docComment);

    for(PhpDocTag phpDocTag: PsiTreeUtil.findChildrenOfAnyType(docComment, PhpDocTag.class)) {
        if(AnnotationBackportUtil.NON_ANNOTATION_TAGS.contains(phpDocTag.getName())) {
            continue;
        }

        PhpClass annotationReference = AnnotationBackportUtil.getAnnotationReference(phpDocTag, uses);
        if(annotationReference != null && PhpElementsUtil.isEqualClassName(annotationReference, className)) {
            return phpDocTag;
        }
    }

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

示例12: getPropertyValueCompletions

import com.jetbrains.php.lang.documentation.phpdoc.psi.PhpDocComment; //导入依赖的package包/类
@Override
public void getPropertyValueCompletions(AnnotationPropertyParameter annotationPropertyParameter, AnnotationCompletionProviderParameter completionParameter) {

    String propertyName = annotationPropertyParameter.getPropertyName();
    if(propertyName == null) {
        return;
    }

    if(propertyName.equals("name") && PhpLangUtil.equalsClassNames(annotationPropertyParameter.getPhpClass().getPresentableFQN(), "Doctrine\\ORM\\Mapping\\Column")) {
        PhpDocComment phpDocComment = PsiTreeUtil.getParentOfType(annotationPropertyParameter.getElement(), PhpDocComment.class);
        if(phpDocComment != null) {
            PhpPsiElement classField = phpDocComment.getNextPsiSibling();
            if(classField != null && classField.getNode().getElementType() == PhpElementTypes.CLASS_FIELDS) {
                Field field = PsiTreeUtil.getChildOfType(classField, Field.class);
                if(field != null) {
                    String name = field.getName();
                    if(StringUtils.isNotBlank(name)) {
                        completionParameter.getResult().addElement(LookupElementBuilder.create(underscore(name)));
                    }
                }
            }
        }
    }

}
 
开发者ID:Haehnchen,项目名称:idea-php-annotation-plugin,代码行数:26,代码来源:ColumnNameCompletionProvider.java

示例13: addCompletions

import com.jetbrains.php.lang.documentation.phpdoc.psi.PhpDocComment; //导入依赖的package包/类
@Override
protected void addCompletions(@NotNull CompletionParameters completionParameters, ProcessingContext processingContext, @NotNull CompletionResultSet completionResultSet) {
    PsiElement psiElement = completionParameters.getOriginalPosition();
    if(psiElement == null) {
        return;
    }

    PhpDocComment parentOfType = PsiTreeUtil.getParentOfType(psiElement, PhpDocComment.class);
    if(parentOfType == null) {
        return;
    }

    AnnotationTarget annotationTarget = PhpElementsUtil.findAnnotationTarget(parentOfType);
    if(annotationTarget == null) {
        return;
    }

    Map<String, String> importMap = AnnotationUtil.getUseImportMap(parentOfType);

    Project project = completionParameters.getPosition().getProject();
    attachLookupElements(project, importMap , annotationTarget, completionResultSet);

}
 
开发者ID:Haehnchen,项目名称:idea-php-annotation-plugin,代码行数:24,代码来源:AnnotationCompletionContributor.java

示例14: getUseImportMap

import com.jetbrains.php.lang.documentation.phpdoc.psi.PhpDocComment; //导入依赖的package包/类
@NotNull
public static Map<String, String> getUseImportMap(@Nullable PhpDocComment phpDocComment) {
    if(phpDocComment == null) {
        return Collections.emptyMap();
    }

    PhpPsiElement scope = PhpCodeInsightUtil.findScopeForUseOperator(phpDocComment);
    if(scope == null) {
        return Collections.emptyMap();
    }

    Map<String, String> useImports = new HashMap<>();

    for (PhpUseList phpUseList : PhpCodeInsightUtil.collectImports(scope)) {
        for(PhpUse phpUse : phpUseList.getDeclarations()) {
            String alias = phpUse.getAliasName();
            if (alias != null) {
                useImports.put(alias, phpUse.getFQN());
            } else {
                useImports.put(phpUse.getName(), phpUse.getFQN());
            }
        }
    }

    return useImports;
}
 
开发者ID:Haehnchen,项目名称:idea-php-annotation-plugin,代码行数:27,代码来源:AnnotationUtil.java

示例15: getPhpDocCommentAnnotationContainer

import com.jetbrains.php.lang.documentation.phpdoc.psi.PhpDocComment; //导入依赖的package包/类
@Nullable
public static PhpDocCommentAnnotation getPhpDocCommentAnnotationContainer(@Nullable PhpDocComment phpDocComment) {
    if(phpDocComment == null) return null;

    Map<String, String> uses = AnnotationUtil.getUseImportMap(phpDocComment);

    Map<String, PhpDocTagAnnotation> annotationRefsMap = new HashMap<>();
    for(PhpDocTag phpDocTag: PsiTreeUtil.findChildrenOfType(phpDocComment, PhpDocTag.class)) {
        if(!AnnotationUtil.NON_ANNOTATION_TAGS.contains(phpDocTag.getName())) {
            PhpClass annotationClass = AnnotationUtil.getAnnotationReference(phpDocTag, uses);
            if(annotationClass != null) {
                annotationRefsMap.put(annotationClass.getPresentableFQN(), new PhpDocTagAnnotation(annotationClass, phpDocTag));
            }
        }

    }

    return new PhpDocCommentAnnotation(annotationRefsMap, phpDocComment);
}
 
开发者ID:Haehnchen,项目名称:idea-php-annotation-plugin,代码行数:20,代码来源:AnnotationUtil.java


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