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


Java PsiElementVisitor类代码示例

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


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

示例1: buildVisitor

import com.intellij.psi.PsiElementVisitor; //导入依赖的package包/类
@NotNull
@Override
public PsiElementVisitor buildVisitor(@NotNull ProblemsHolder problemsHolder, boolean b) {
    return new PhpElementVisitor() {
        @Override
        public void visitPhpClass(PhpClass clazz) {
            PhpIndex index = PhpIndex.getInstance(problemsHolder.getProject());
            if (DatabaseUtils.HasConnections(problemsHolder.getProject()) &&
                    ClassUtils.isClassInheritsOrEqual(clazz, ClassUtils.getClass(index, "\\yii\\db\\ActiveRecord"))) {
                String table = DatabaseUtils.getTableByActiveRecordClass(clazz);
                if (table == null) {
                    problemsHolder.registerProblem(clazz.getFirstChild(), "Can not detect database table for class " + clazz.getFQN(), ProblemHighlightType.WEAK_WARNING);
                } else if (! DatabaseUtils.isTableExists(table, problemsHolder.getProject())) {
                    problemsHolder.registerProblem(clazz.getFirstChild(), "Table '" + table + "' not found in database connections", ProblemHighlightType.WEAK_WARNING);

                }
            }
            super.visitPhpClass(clazz);
        }
    };
}
 
开发者ID:nvlad,项目名称:yii2support,代码行数:22,代码来源:UndetectableTableInspection.java

示例2: buildVisitor

import com.intellij.psi.PsiElementVisitor; //导入依赖的package包/类
@NotNull
@Override
public PsiElementVisitor buildVisitor(@NotNull ProblemsHolder problemsHolder, boolean b) {
    return new PhpElementVisitor() {
        @Override
        public void visitPhpElement(PhpPsiElement element) {

            if (!PlatformPatterns.psiElement(PhpElementTypes.CLASS_CONSTANT_REFERENCE).accepts(element)) {
                return;
            }

            Set<String> constants = getDeprecatedClassConstants(element);
            ClassConstantReference classConstantReference = (ClassConstantReference) element;
            if (constants.contains(classConstantReference.getText())) {
                problemsHolder.registerProblem(element, "Deprecated class constant");
            }
        }
    };
}
 
开发者ID:cedricziel,项目名称:idea-php-typo3-plugin,代码行数:20,代码来源:ClassConstantMatcherInspection.java

示例3: buildVisitor

import com.intellij.psi.PsiElementVisitor; //导入依赖的package包/类
@NotNull
@Override
public PsiElementVisitor buildVisitor(@NotNull final ProblemsHolder holder, boolean isOnTheFly) {
    if (JNomadInspection.jnomad == null) {
        setupJNomad();
    }

    List<EnvFileFullReport> fileFullReports;
    VirtualFile virtualFile = holder.getFile().getVirtualFile();
    if (virtualFile.getPath().endsWith("java") && virtualFile instanceof VirtualFileImpl) {
        CharSequence contents = holder.getFile().getViewProvider().getContents();
        fileFullReports = getFileFullReports(contents);
        return new JNomadQueryVisitor(holder, holder.getFile().getVirtualFile(), fileFullReports.toArray(new EnvFileFullReport[0]));
    }
    return new JNomadQueryVisitor(holder, holder.getFile().getVirtualFile(), null);
}
 
开发者ID:BFergerson,项目名称:JNomad-Plugin,代码行数:17,代码来源:JNomadInspection.java

示例4: buildVisitor

import com.intellij.psi.PsiElementVisitor; //导入依赖的package包/类
@NotNull
@Override
public PsiElementVisitor buildVisitor(
    @NotNull final ProblemsHolder problemsHolder,
    final boolean isOnTheFly
) {
    return new PhpElementVisitor() {
        @Override
        public void visitPhpMethod(final Method method) {
            final PhpReturnType  returnType                     = method.getReturnType();
            final ClassReference methodReturnTypeClassReference = (returnType != null) ? returnType.getClassReference() : null;

            if (FluentUtil.isUsingDirectly(methodReturnTypeClassReference)) {
                problemsHolder.registerProblem(methodReturnTypeClassReference, messageDirectInstantiation, ProblemHighlightType.WEAK_WARNING);
            }
        }

        @Override
        public void visitPhpFunction(final Function function) {
            final PhpReturnType functionReturnType = function.getReturnType();
            if ((functionReturnType != null) && FluentUtil.isUsingDirectly(functionReturnType.getClassReference())) {
                problemsHolder.registerProblem(functionReturnType, messageDirectInstantiation, ProblemHighlightType.WEAK_WARNING);
            }
        }

        @Override
        public void visitPhpParameter(final Parameter parameter) {
            if (FluentUtil.isUsingDirectly(parameter)) {
                problemsHolder.registerProblem(parameter, messageDirectInstantiation, ProblemHighlightType.WEAK_WARNING);
            }
        }

        @Override
        public void visitPhpDocType(final PhpDocType type) {
            if (FluentUtil.isUsingDirectly(type)) {
                problemsHolder.registerProblem(type, messageDirectInstantiation, ProblemHighlightType.WEAK_WARNING);
            }
        }
    };
}
 
开发者ID:rentalhost,项目名称:laravel-insight,代码行数:41,代码来源:UsingAsTypeInspection.java

示例5: buildVisitor

import com.intellij.psi.PsiElementVisitor; //导入依赖的package包/类
@NotNull
@Override
public PsiElementVisitor buildVisitor(@NotNull ProblemsHolder problemsHolder, boolean b) {
    return new PhpElementVisitor() {
        @Override
        public void visitPhpElement(PhpPsiElement element) {
            if (element instanceof PhpDocTag) {
                PhpDocTag tag = (PhpDocTag) element;
                if ("@inject".equals(tag.getName())) {
                    problemsHolder.registerProblem(element, "Extbase property injection", new CreateInjectorQuickFix(element));
                }
            }
        }
    };
}
 
开发者ID:cedricziel,项目名称:idea-php-typo3-plugin,代码行数:16,代码来源:ExtbasePropertyInjectionInspection.java

示例6: accept

import com.intellij.psi.PsiElementVisitor; //导入依赖的package包/类
public void accept(@NotNull PsiElementVisitor visitor) {
  if (visitor instanceof FlexibleSearchVisitor) accept((FlexibleSearchVisitor)visitor);
  else super.accept(visitor);
}
 
开发者ID:AlexanderBartash,项目名称:hybris-integration-intellij-idea-plugin,代码行数:5,代码来源:FlexibleSearchStringValueFunctionImpl.java

示例7: accept

import com.intellij.psi.PsiElementVisitor; //导入依赖的package包/类
public void accept(@NotNull PsiElementVisitor visitor) {
  if (visitor instanceof MasVisitor) accept((MasVisitor)visitor);
  else super.accept(visitor);
}
 
开发者ID:ceddy4395,项目名称:Goal-Intellij-Plugin,代码行数:5,代码来源:MasInstructionListImpl.java

示例8: accept

import com.intellij.psi.PsiElementVisitor; //导入依赖的package包/类
public void accept(@NotNull PsiElementVisitor visitor) {
  if (visitor instanceof AppleScriptVisitor) accept((AppleScriptVisitor)visitor);
  else super.accept(visitor);
}
 
开发者ID:ant-druha,项目名称:AppleScript-IDEA,代码行数:5,代码来源:AppleScriptIndexReferenceClassFormImpl.java

示例9: accept

import com.intellij.psi.PsiElementVisitor; //导入依赖的package包/类
public void accept(@NotNull PsiElementVisitor visitor) {
  if (visitor instanceof CptVisitor) accept((CptVisitor)visitor);
  else super.accept(visitor);
}
 
开发者ID:xylo,项目名称:intellij-postfix-templates,代码行数:5,代码来源:CptReplacementImpl.java

示例10: accept

import com.intellij.psi.PsiElementVisitor; //导入依赖的package包/类
public void accept(@NotNull PsiElementVisitor visitor) {
  if (visitor instanceof GCMVisitor) accept((GCMVisitor)visitor);
  else super.accept(visitor);
}
 
开发者ID:datathings,项目名称:greycat-idea-plugin,代码行数:5,代码来源:GCMAnnotationImpl.java

示例11: accept

import com.intellij.psi.PsiElementVisitor; //导入依赖的package包/类
public void accept(@NotNull PsiElementVisitor visitor) {
  if (visitor instanceof DotEnvVisitor) accept((DotEnvVisitor)visitor);
  else super.accept(visitor);
}
 
开发者ID:adelf,项目名称:idea-php-dotenv-plugin,代码行数:5,代码来源:DotEnvEmptyLineImpl.java

示例12: accept

import com.intellij.psi.PsiElementVisitor; //导入依赖的package包/类
public void accept(@NotNull PsiElementVisitor visitor) {
  if (visitor instanceof TestVisitor) accept((TestVisitor)visitor);
  else super.accept(visitor);
}
 
开发者ID:ceddy4395,项目名称:Goal-Intellij-Plugin,代码行数:5,代码来源:TestIdentifierImpl.java

示例13: accept

import com.intellij.psi.PsiElementVisitor; //导入依赖的package包/类
public void accept(@NotNull PsiElementVisitor visitor) {
  if (visitor instanceof ModuleVisitor) accept((ModuleVisitor)visitor);
  else super.accept(visitor);
}
 
开发者ID:ceddy4395,项目名称:Goal-Intellij-Plugin,代码行数:5,代码来源:ModulePredicateImpl.java

示例14: buildVisitor

import com.intellij.psi.PsiElementVisitor; //导入依赖的package包/类
@Override
@NotNull
public PsiElementVisitor buildVisitor(@NotNull final ProblemsHolder holder, boolean isOnTheFly) {
    return new PhpElementVisitor() {
        @Override
        public void visitPhpMethodReference(MethodReference reference) {
            /* ensure that it's a target call; category is not empty and has no injections; we have messages */
            TranslationCallsProcessUtil.ProcessingResult extracted = TranslationCallsProcessUtil.process(reference, true);
            if (null == extracted) {
                return;
            }

            /* handle `category` and `category/subcategory` cases */
            String categoryForFileName = extracted.getCategory().getContents();
            if (-1 != categoryForFileName.indexOf('/')) {
                categoryForFileName
                    = categoryForFileName.substring(1 + categoryForFileName.lastIndexOf('/'), categoryForFileName.length());
            }
            final String expectedFileName = categoryForFileName + ".php";

            /* iterate found translations and validate correctness */
            final Map<StringLiteralExpression, PsiElement> messages = extracted.getMessages();
            for (StringLiteralExpression literal : messages.keySet()) {
                /* only quotes, no content presented */
                if (literal.getTextLength() <= 2) {
                    continue;
                }

                final String message             = literal.getContents();
                final PsiElement reportingTarget = messages.get(literal);

                /* warn injections are presented and skip further processing */
                if (REPORT_INJECTIONS && null != literal.getFirstPsiChild()) {
                    holder.registerProblem(reportingTarget, messageInjection, ProblemHighlightType.WEAK_WARNING);
                    continue;
                }
                /* warn if non-ascii characters has been used */
                if (REPORT_NONASCII_CHARACTERS && nonAsciiCharsRegex.matcher(message).matches()) {
                    holder.registerProblem(reportingTarget, messageNonAscii, ProblemHighlightType.WEAK_WARNING);
                }

                /* warn if the message is have no translations in the group */
                final Set<String> searchEntry
                    = new HashSet<>(Collections.singletonList(PhpStringUtil.unescapeText(message, literal.isSingleQuote())));
                GlobalSearchScope theScope = GlobalSearchScope.allScope(reference.getProject());
                theScope                   = GlobalSearchScope.getScopeRestrictedByFileTypes(theScope, PhpFileType.INSTANCE);
                final Set<VirtualFile> providers = new HashSet<>();
                FileBasedIndex.getInstance()
                        .getFilesWithKey(TranslationKeysIndexer.identity, searchEntry, virtualFile -> {
                            if (virtualFile.getName().equals(expectedFileName)) {
                                providers.add(virtualFile);
                            }

                            return true;
                        }, theScope);

                /* report found cases */
                if (REPORT_UNKNOWN_TRANSLATIONS && 0 == providers.size()) {
                    holder.registerProblem(reportingTarget, messageNoTranslations, ProblemHighlightType.WEAK_WARNING);
                }
                providers.clear();
            }

            extracted.dispose();
        }
    };
}
 
开发者ID:kalessil,项目名称:yii2inspections,代码行数:68,代码来源:TranslationsCorrectnessInspector.java


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