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


Java PhpDocComment.getTagElementsByName方法代码示例

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


在下文中一共展示了PhpDocComment.getTagElementsByName方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: 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

示例3: resolveType

import com.jetbrains.php.lang.documentation.phpdoc.psi.PhpDocComment; //导入方法依赖的package包/类
@Nullable
@Override
public String resolveType(PsiElement psiElement)
{
    String variableName;
    try {
        Parameter parameter = (Parameter)psiElement;
        variableName = parameter.getName();
    }
    catch (Exception e) {
        return null;
    }
    MethodImpl method = PsiTreeUtil.getParentOfType(psiElement, MethodImpl.class);
    if (method == null) {
        return null;
    }

    PhpDocComment comment = method.getDocComment();
    if (comment == null) {
        return null;
    }

    PhpDocTag[] phpDocTags = comment.getTagElementsByName("@ContentType");
    if (phpDocTags.length == 0) {
        return null;
    }

    for (PhpDocTag tag : phpDocTags) {
        if (tagMatches(tag, variableName)) {
            return parsePhpDoc(tag);
        }
    }

    return null;
}
 
开发者ID:whitefire,项目名称:eZ-completion,代码行数:36,代码来源:MethodParameterTypeProvider.java

示例4: resolveType

import com.jetbrains.php.lang.documentation.phpdoc.psi.PhpDocComment; //导入方法依赖的package包/类
@Nullable
@Override
public String resolveType(PsiElement psiElement)
{
    PhpDocComment comment;
    try {
        FieldImpl field = (FieldImpl)psiElement;
        comment = field.getDocComment();
    }
    catch (Exception e) {
        return null;
    }

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

    PhpDocTag[] phpDocTags = comment.getTagElementsByName("@ContentType");
    if (phpDocTags.length != 1) {
        return null;
    }
    PhpDocTag tag = phpDocTags[0];
    String[] tagParts = tag.getTagValue().split(" ");
    if (tagParts.length != 1) {
        return null;
    }

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

示例5: attachDeprecatedProblem

import com.jetbrains.php.lang.documentation.phpdoc.psi.PhpDocComment; //导入方法依赖的package包/类
public void attachDeprecatedProblem(PsiElement element, String text, ProblemsHolder holder) {

            PhpClass phpClass = ServiceUtil.getResolvedClassDefinition(element.getProject(), text, getLazyServiceCollector(element.getProject()));
            if(phpClass == null) {
                return;
            }

            PhpDocComment docComment = phpClass.getDocComment();
            if(docComment != null && docComment.getTagElementsByName("@deprecated").length > 0) {
                holder.registerProblem(element, String.format("Class '%s' is deprecated", phpClass.getName()), ProblemHighlightType.LIKE_DEPRECATED);
            }

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

示例6: isAnnotationClass

import com.jetbrains.php.lang.documentation.phpdoc.psi.PhpDocComment; //导入方法依赖的package包/类
public static boolean isAnnotationClass(@NotNull PhpClass phpClass) {
    PhpDocComment phpDocComment = phpClass.getDocComment();
    if(phpDocComment != null) {
        PhpDocTag[] annotationDocTags = phpDocComment.getTagElementsByName("@Annotation");
        if(annotationDocTags.length > 0) {
            return true;
        }
    }

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

示例7: attachLookupElement

import com.jetbrains.php.lang.documentation.phpdoc.psi.PhpDocComment; //导入方法依赖的package包/类
private void attachLookupElement(CompletionResultSet completionResultSet, Field field) {
    if(field.isConstant()) {
       return;
    }

    String propertyName = field.getName();

    // private $isNillable = false;
    PhpType type = field.getType();
    if(type.toString().equals("bool")) {
        completionResultSet.addElement(new PhpAnnotationPropertyLookupElement(new AnnotationProperty(propertyName, AnnotationPropertyEnum.BOOLEAN)));
        return;
    }

    // private $isNillable = array();
    if(type.toString().equals("array")) {
        completionResultSet.addElement(new PhpAnnotationPropertyLookupElement(new AnnotationProperty(propertyName, AnnotationPropertyEnum.ARRAY)));
        return;
    }

    PhpDocComment docComment = field.getDocComment();
    if(docComment != null) {
        for(PhpDocTag varDocTag: docComment.getTagElementsByName("@var")) {
            PhpPsiElement phpPsiElement = varDocTag.getFirstPsiChild();
            if(phpPsiElement != null) {
                String typeText = phpPsiElement.getText().toLowerCase();
                if(!StringUtils.isBlank(typeText)) {

                    // @var array<string>
                    if(typeText.startsWith("array")) {
                        completionResultSet.addElement(new PhpAnnotationPropertyLookupElement(new AnnotationProperty(propertyName, AnnotationPropertyEnum.ARRAY)));
                        return;
                    }

                    if(typeText.equalsIgnoreCase("integer") || typeText.equalsIgnoreCase("int")) {
                        completionResultSet.addElement(new PhpAnnotationPropertyLookupElement(new AnnotationProperty(propertyName, AnnotationPropertyEnum.INTEGER)));
                        return;
                    }

                    if(typeText.equalsIgnoreCase("boolean") || typeText.equalsIgnoreCase("bool")) {
                        completionResultSet.addElement(new PhpAnnotationPropertyLookupElement(new AnnotationProperty(propertyName, AnnotationPropertyEnum.BOOLEAN)));
                        return;
                    }

                }
            }
        }
    }

    // public $var = array();
    if(field.getDefaultValue() instanceof ArrayCreationExpression) {
        completionResultSet.addElement(new PhpAnnotationPropertyLookupElement(new AnnotationProperty(propertyName, AnnotationPropertyEnum.ARRAY)));
        return;
    }

    // fallback
    completionResultSet.addElement(new PhpAnnotationPropertyLookupElement(new AnnotationProperty(propertyName, AnnotationPropertyEnum.STRING)));
}
 
开发者ID:Haehnchen,项目名称:idea-php-annotation-plugin,代码行数:59,代码来源:AnnotationCompletionContributor.java

示例8: getClassAnnotation

import com.jetbrains.php.lang.documentation.phpdoc.psi.PhpDocComment; //导入方法依赖的package包/类
/**
 * Provide a annotation class container. Allows easy access to @Target attributes
 * Array and single value supported: @Target("PROPERTY", "METHOD"), @Target("CLASS")
 */
@Nullable
public static PhpAnnotation getClassAnnotation(@NotNull PhpClass phpClass) {
    if(!AnnotationUtil.isAnnotationClass(phpClass)) {
        return null;
    }

    PhpDocComment phpDocComment = phpClass.getDocComment();
    if(phpDocComment == null) {
        return null;
    }

    List<AnnotationTarget> targets = new ArrayList<>();

    PhpDocTag[] tagElementsByName = phpDocComment.getTagElementsByName("@Target");

    if(tagElementsByName.length > 0) {
        for (PhpDocTag phpDocTag : tagElementsByName) {
            // @Target("PROPERTY", "METHOD")
            // @Target("CLASS")
            // @Target("ALL")
            String text = phpDocTag.getText();
            Matcher matcher = Pattern.compile("\"(\\w+)\"").matcher(text);

            // regex matched; on invalid we at target to UNKNOWN condition
            boolean isMatched = false;

            // match enum value
            while (matcher.find()) {
                isMatched = true;
                try {
                    targets.add(AnnotationTarget.valueOf(matcher.group(1).toUpperCase()));
                } catch (IllegalArgumentException e) {
                    targets.add(AnnotationTarget.UNKNOWN);
                }
            }

            // regex failed provide UNKNOWN target
            if(!isMatched) {
                targets.add(AnnotationTarget.UNKNOWN);
            }
        }
    } else {
        // no target attribute so UNDEFINED target
        targets.add(AnnotationTarget.UNDEFINED);
    }

    if(targets.size() == 0) {
        return null;
    }

    return new PhpAnnotation(phpClass, targets);
}
 
开发者ID:Haehnchen,项目名称:idea-php-annotation-plugin,代码行数:57,代码来源:AnnotationUtil.java


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