Java 类com.intellij.psi.PsiElementVisitor 实例源码

项目:yii2support    文件:UndetectableTableInspection.java   
@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);
        }
    };
}
项目:idea-php-typo3-plugin    文件:ClassConstantMatcherInspection.java   
@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");
            }
        }
    };
}
项目:JNomad-Plugin    文件:JNomadInspection.java   
@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);
}
项目:laravel-insight    文件:UsingAsTypeInspection.java   
@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);
            }
        }
    };
}
项目:idea-php-typo3-plugin    文件:ExtbasePropertyInjectionInspection.java   
@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));
                }
            }
        }
    };
}
项目:hybris-integration-intellij-idea-plugin    文件:FlexibleSearchStringValueFunctionImpl.java   
public void accept(@NotNull PsiElementVisitor visitor) {
  if (visitor instanceof FlexibleSearchVisitor) accept((FlexibleSearchVisitor)visitor);
  else super.accept(visitor);
}
项目:Goal-Intellij-Plugin    文件:MasInstructionListImpl.java   
public void accept(@NotNull PsiElementVisitor visitor) {
  if (visitor instanceof MasVisitor) accept((MasVisitor)visitor);
  else super.accept(visitor);
}
项目:AppleScript-IDEA    文件:AppleScriptIndexReferenceClassFormImpl.java   
public void accept(@NotNull PsiElementVisitor visitor) {
  if (visitor instanceof AppleScriptVisitor) accept((AppleScriptVisitor)visitor);
  else super.accept(visitor);
}
项目:intellij-postfix-templates    文件:CptReplacementImpl.java   
public void accept(@NotNull PsiElementVisitor visitor) {
  if (visitor instanceof CptVisitor) accept((CptVisitor)visitor);
  else super.accept(visitor);
}
项目:intellij-postfix-templates    文件:CptMappingImpl.java   
public void accept(@NotNull PsiElementVisitor visitor) {
  if (visitor instanceof CptVisitor) accept((CptVisitor)visitor);
  else super.accept(visitor);
}
项目:greycat-idea-plugin    文件:GCMAnnotationImpl.java   
public void accept(@NotNull PsiElementVisitor visitor) {
  if (visitor instanceof GCMVisitor) accept((GCMVisitor)visitor);
  else super.accept(visitor);
}
项目:AppleScript-IDEA    文件:AppleScriptHandlerParameterLabelImpl.java   
public void accept(@NotNull PsiElementVisitor visitor) {
  if (visitor instanceof AppleScriptVisitor) accept((AppleScriptVisitor)visitor);
  else super.accept(visitor);
}
项目:idea-php-dotenv-plugin    文件:DotEnvEmptyLineImpl.java   
public void accept(@NotNull PsiElementVisitor visitor) {
  if (visitor instanceof DotEnvVisitor) accept((DotEnvVisitor)visitor);
  else super.accept(visitor);
}
项目:greycat-idea-plugin    文件:GCMConstDeclarationImpl.java   
public void accept(@NotNull PsiElementVisitor visitor) {
  if (visitor instanceof GCMVisitor) accept((GCMVisitor)visitor);
  else super.accept(visitor);
}
项目:AppleScript-IDEA    文件:AppleScriptVarAccessDeclarationImpl.java   
public void accept(@NotNull PsiElementVisitor visitor) {
  if (visitor instanceof AppleScriptVisitor) accept((AppleScriptVisitor)visitor);
  else super.accept(visitor);
}
项目:greycat-idea-plugin    文件:GCMToOneDeclarationImpl.java   
public void accept(@NotNull PsiElementVisitor visitor) {
  if (visitor instanceof GCMVisitor) accept((GCMVisitor)visitor);
  else super.accept(visitor);
}
项目:Goal-Intellij-Plugin    文件:TestIdentifierImpl.java   
public void accept(@NotNull PsiElementVisitor visitor) {
  if (visitor instanceof TestVisitor) accept((TestVisitor)visitor);
  else super.accept(visitor);
}
项目:hybris-integration-intellij-idea-plugin    文件:FlexibleSearchJoinSpecificationImpl.java   
public void accept(@NotNull PsiElementVisitor visitor) {
  if (visitor instanceof FlexibleSearchVisitor) accept((FlexibleSearchVisitor)visitor);
  else super.accept(visitor);
}
项目:AppleScript-IDEA    文件:AppleScriptEveryRangeReferenceImpl.java   
public void accept(@NotNull PsiElementVisitor visitor) {
  if (visitor instanceof AppleScriptVisitor) accept((AppleScriptVisitor)visitor);
  else super.accept(visitor);
}
项目:AppleScript-IDEA    文件:AppleScriptLaunchCommandExpressionImpl.java   
public void accept(@NotNull PsiElementVisitor visitor) {
  if (visitor instanceof AppleScriptVisitor) accept((AppleScriptVisitor)visitor);
  else super.accept(visitor);
}
项目:hybris-integration-intellij-idea-plugin    文件:FlexibleSearchCorrelationNameImpl.java   
public void accept(@NotNull PsiElementVisitor visitor) {
  if (visitor instanceof FlexibleSearchVisitor) accept((FlexibleSearchVisitor)visitor);
  else super.accept(visitor);
}
项目:AppleScript-IDEA    文件:AppleScriptGivenRawParameterExpressionImpl.java   
public void accept(@NotNull PsiElementVisitor visitor) {
  if (visitor instanceof AppleScriptVisitor) accept((AppleScriptVisitor)visitor);
  else super.accept(visitor);
}
项目:AppleScript-IDEA    文件:AppleScriptLabeledParameterDeclarationPartImpl.java   
public void accept(@NotNull PsiElementVisitor visitor) {
  if (visitor instanceof AppleScriptVisitor) accept((AppleScriptVisitor)visitor);
  else super.accept(visitor);
}
项目:greycat-idea-plugin    文件:GCMIndexParamsImpl.java   
public void accept(@NotNull PsiElementVisitor visitor) {
  if (visitor instanceof GCMVisitor) accept((GCMVisitor)visitor);
  else super.accept(visitor);
}
项目:hybris-integration-intellij-idea-plugin    文件:FlexibleSearchCharacterPatternImpl.java   
public void accept(@NotNull PsiElementVisitor visitor) {
  if (visitor instanceof FlexibleSearchVisitor) accept((FlexibleSearchVisitor)visitor);
  else super.accept(visitor);
}
项目:AppleScript-IDEA    文件:AppleScriptTargetListLiteralImpl.java   
public void accept(@NotNull PsiElementVisitor visitor) {
  if (visitor instanceof AppleScriptVisitor) accept((AppleScriptVisitor)visitor);
  else super.accept(visitor);
}
项目:AppleScript-IDEA    文件:AppleScriptObjectReferenceExpressionImpl.java   
public void accept(@NotNull PsiElementVisitor visitor) {
  if (visitor instanceof AppleScriptVisitor) accept((AppleScriptVisitor)visitor);
  else super.accept(visitor);
}
项目:Goal-Intellij-Plugin    文件:ModulePredicateImpl.java   
public void accept(@NotNull PsiElementVisitor visitor) {
  if (visitor instanceof ModuleVisitor) accept((ModuleVisitor)visitor);
  else super.accept(visitor);
}
项目:greycat-idea-plugin    文件:GCMNtupleValueImpl.java   
public void accept(@NotNull PsiElementVisitor visitor) {
  if (visitor instanceof GCMVisitor) accept((GCMVisitor)visitor);
  else super.accept(visitor);
}
项目:hybris-integration-intellij-idea-plugin    文件:FlexibleSearchTablePrimaryImpl.java   
public void accept(@NotNull PsiElementVisitor visitor) {
  if (visitor instanceof FlexibleSearchVisitor) accept((FlexibleSearchVisitor)visitor);
  else super.accept(visitor);
}
项目:AppleScript-IDEA    文件:AppleScriptDateLiteralExpressionImpl.java   
public void accept(@NotNull PsiElementVisitor visitor) {
  if (visitor instanceof AppleScriptVisitor) accept((AppleScriptVisitor)visitor);
  else super.accept(visitor);
}
项目:AppleScript-IDEA    文件:AppleScriptCountCommandExpressionImpl.java   
public void accept(@NotNull PsiElementVisitor visitor) {
  if (visitor instanceof AppleScriptVisitor) accept((AppleScriptVisitor)visitor);
  else super.accept(visitor);
}
项目:yii2inspections    文件:TranslationsCorrectnessInspector.java   
@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();
        }
    };
}
项目:Goal-Intellij-Plugin    文件:ModuleStringImpl.java   
public void accept(@NotNull PsiElementVisitor visitor) {
  if (visitor instanceof ModuleVisitor) accept((ModuleVisitor)visitor);
  else super.accept(visitor);
}
项目:AppleScript-IDEA    文件:AppleScriptHandlerArgumentImpl.java   
public void accept(@NotNull PsiElementVisitor visitor) {
  if (visitor instanceof AppleScriptVisitor) accept((AppleScriptVisitor)visitor);
  else super.accept(visitor);
}
项目:Goal-Intellij-Plugin    文件:ModuleBlockImpl.java   
public void accept(@NotNull PsiElementVisitor visitor) {
  if (visitor instanceof ModuleVisitor) accept((ModuleVisitor)visitor);
  else super.accept(visitor);
}
项目:AppleScript-IDEA    文件:AppleScriptCommandParameterSelectorImpl.java   
public void accept(@NotNull PsiElementVisitor visitor) {
  if (visitor instanceof AppleScriptVisitor) accept((AppleScriptVisitor)visitor);
  else super.accept(visitor);
}
项目:hybris-integration-intellij-idea-plugin    文件:FlexibleSearchBooleanValueExpressionImpl.java   
public void accept(@NotNull PsiElementVisitor visitor) {
  if (visitor instanceof FlexibleSearchVisitor) accept((FlexibleSearchVisitor)visitor);
  else super.accept(visitor);
}
项目:AppleScript-IDEA    文件:AppleScriptDirectParameterValImpl.java   
public void accept(@NotNull PsiElementVisitor visitor) {
  if (visitor instanceof AppleScriptVisitor) accept((AppleScriptVisitor)visitor);
  else super.accept(visitor);
}
项目:hybris-integration-intellij-idea-plugin    文件:FlexibleSearchTableReferenceImpl.java   
public void accept(@NotNull PsiElementVisitor visitor) {
  if (visitor instanceof FlexibleSearchVisitor) accept((FlexibleSearchVisitor)visitor);
  else super.accept(visitor);
}