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


Java ProblemsHolder類代碼示例

本文整理匯總了Java中com.intellij.codeInspection.ProblemsHolder的典型用法代碼示例。如果您正苦於以下問題:Java ProblemsHolder類的具體用法?Java ProblemsHolder怎麽用?Java ProblemsHolder使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


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

示例1: buildVisitor

import com.intellij.codeInspection.ProblemsHolder; //導入依賴的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.codeInspection.ProblemsHolder; //導入依賴的package包/類
@NotNull
@Override
public PsiElementVisitor buildVisitor(@NotNull ProblemsHolder problemsHolder, boolean isOnTheFly) {
    return new PhpElementVisitor() {
        @Override
        public void visitPhpClass(PhpClass clazz) {
            if (clazz.getSuperClass() != null && clazz.getSuperClass().getFQN().equals("\\yii\\db\\ActiveQuery")) {
                PhpIndex index = PhpIndex.getInstance(clazz.getProject());

                PhpClass activeRecordClass = ClassUtils.findClassInSeeTags(index, clazz, "\\yii\\db\\BaseActiveRecord");
                if (activeRecordClass == null) {
                    problemsHolder.registerProblem(clazz.getFirstChild(),
                            "Can not find connected ActiveRecord class.\nYou should add @see tag with linked ActiveRecord",
                            ProblemHighlightType.WEAK_WARNING);
                }
            }
            super.visitPhpClass(clazz);

        }
    };
}
 
開發者ID:nvlad,項目名稱:yii2support,代碼行數:22,代碼來源:MissingActiveRecordInActiveQueryInspection.java

示例3: buildVisitor

import com.intellij.codeInspection.ProblemsHolder; //導入依賴的package包/類
@NotNull
@Override
public PsiElementVisitor buildVisitor(@NotNull ProblemsHolder problemsHolder, boolean b) {
    return new PhpElementVisitor() {
        @Override
        public void visitPhpClassReference(ClassReference classReference) {
            if (classReference.getFQN() != null && LegacyClassesForIDEIndex.isLegacyClass(classReference.getProject(), classReference.getFQN())) {
                problemsHolder.registerProblem(classReference, "Legacy class usage", ProblemHighlightType.LIKE_DEPRECATED, new LegacyClassesForIdeQuickFix());
            }

            super.visitPhpClassReference(classReference);
        }

        @Override
        public void visitPhpClassConstantReference(ClassConstantReference constantReference) {
            super.visitPhpClassConstantReference(constantReference);
        }
    };
}
 
開發者ID:cedricziel,項目名稱:idea-php-typo3-plugin,代碼行數:20,代碼來源:LegacyClassesForIDEInspection.java

示例4: buildVisitor

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

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

            ConstantReference constantReference = (ConstantReference) element;
            Set<String> constants = getRemovedConstantsFQNs(constantReference);
            if (constants.contains(constantReference.getFQN())) {
                problemsHolder.registerProblem(element, "Constant removed with TYPO3 9, consider using an alternative");
            }
        }
    };
}
 
開發者ID:cedricziel,項目名稱:idea-php-typo3-plugin,代碼行數:20,代碼來源:ConstantMatcherInspection.java

示例5: buildVisitor

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

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

            Set<String> constants = getRemovedGlobalFuntions(element);
            FunctionReference constantReference = (FunctionReference) element;
            if (constants.contains(constantReference.getFQN())) {
                problemsHolder.registerProblem(element, "Global function removed with TYPO3 9, consider using an alternative");
            }
        }
    };
}
 
開發者ID:cedricziel,項目名稱:idea-php-typo3-plugin,代碼行數:20,代碼來源:FunctionCallMatcherInspection.java

示例6: buildVisitor

import com.intellij.codeInspection.ProblemsHolder; //導入依賴的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

示例7: buildVisitor

import com.intellij.codeInspection.ProblemsHolder; //導入依賴的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_REFERENCE).accepts(element)) {
                return;
            }

            Set<String> constants = getDeprecatedClasses(element);
            ClassReference classReference = (ClassReference) element;
            if (constants.contains(classReference.getFQN())) {
                problemsHolder.registerProblem(element, "Class removed with TYPO3 9, consider using an alternative");
            }
        }
    };
}
 
開發者ID:cedricziel,項目名稱:idea-php-typo3-plugin,代碼行數:20,代碼來源:ClassNameMatcherInspection.java

示例8: buildVisitor

import com.intellij.codeInspection.ProblemsHolder; //導入依賴的package包/類
@NotNull
@Override
public PsiElementVisitor buildVisitor(@NotNull ProblemsHolder problemsHolder, boolean b) {
    return new PhpElementVisitor() {
        @Override
        public void visitPhpStringLiteralExpression(StringLiteralExpression expression) {
            if (expression == null || expression.getParent() instanceof ConcatenationExpression) {
                return;
            }

            String contents = expression.getContents();
            if (TranslationUtil.isTranslationKeyString(contents) && contents.length() > 4 && !TranslationUtil.keyExists(problemsHolder.getProject(), contents)) {
                // new CreateMissingTranslationQuickFix(contents)
                problemsHolder.registerProblem(expression, MESSAGE);
            }
        }
    };
}
 
開發者ID:cedricziel,項目名稱:idea-php-typo3-plugin,代碼行數:19,代碼來源:TranslationMissingInspection.java

示例9: buildVisitor

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

            boolean isArrayStringValue = PhpElementsUtil.isStringArrayValue().accepts(element);
            if (!isArrayStringValue || !insideTCAColumnDefinition(element)) {
                return;
            }

            String arrayIndex = extractArrayIndexFromValue(element);
            if (arrayIndex != null && Arrays.asList(TCAUtil.TCA_NUMERIC_CONFIG_KEYS).contains(arrayIndex)) {
                if (element instanceof StringLiteralExpression) {
                    problemsHolder.registerProblem(element, "Config key only accepts integer values");
                }
            }
        }
    };
}
 
開發者ID:cedricziel,項目名稱:idea-php-typo3-plugin,代碼行數:22,代碼來源:InvalidQuantityInspection.java

示例10: buildVisitor

import com.intellij.codeInspection.ProblemsHolder; //導入依賴的package包/類
@NotNull
@Override
public PsiElementVisitor buildVisitor(
    @NotNull final ProblemsHolder problemsHolder,
    final boolean isOnTheFly
) {
    return new PhpElementVisitor() {
        @Override
        public void visitPhpNewExpression(final NewExpression expression) {
            if (FluentUtil.isUsingDirectly(expression)) {
                final ClassReference classReference = expression.getClassReference();
                assert classReference != null;

                problemsHolder.registerProblem(classReference, messageDirectInstantiation, ProblemHighlightType.WEAK_WARNING,
                                               new TextRange(0, classReference.getTextLength()));
            }
        }
    };
}
 
開發者ID:rentalhost,項目名稱:laravel-insight,代碼行數:20,代碼來源:DirectInstantiationInspection.java

示例11: reportRelationship

import com.intellij.codeInspection.ProblemsHolder; //導入依賴的package包/類
static void reportRelationship(
    @NotNull final ProblemsHolder problemsHolder,
    @NotNull final Function method,
    @NotNull final PhpClass methodClass
) {
    final PhpType methodReturnType = PhpFunctionUtil.getReturnType(method);

    if (!isRelationship(methodReturnType.getTypes())) {
        return;
    }

    final PsiElement methodIdentifier = method.getNameIdentifier();
    assert methodIdentifier != null;

    validatePropertyAnnotation(problemsHolder, methodClass, methodIdentifier, CaseFormat.UPPER_CAMEL.to(CaseFormat.LOWER_UNDERSCORE, method.getName()), "mixed");
}
 
開發者ID:rentalhost,項目名稱:laravel-insight,代碼行數:17,代碼來源:ColumnWithoutAnnotationInspection.java

示例12: buildVisitor

import com.intellij.codeInspection.ProblemsHolder; //導入依賴的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

示例13: analyzeFile

import com.intellij.codeInspection.ProblemsHolder; //導入依賴的package包/類
@NotNull
private ProblemsHolder analyzeFile(@NotNull PsiFile file, @NotNull InspectionManager manager, boolean isOnTheFly) {
    DotEnvPsiElementsVisitor visitor = new DotEnvPsiElementsVisitor();
    file.acceptChildren(visitor);

    ProblemsHolder problemsHolder = new ProblemsHolder(manager, file, isOnTheFly);

    Map<String, PsiElement> existingKeys = new HashMap<>();
    Set<PsiElement> markedElements = new HashSet<>();
    for(KeyValuePsiElement keyValue : visitor.getCollectedItems()) {
        if(existingKeys.containsKey(keyValue.getKey())) {
            problemsHolder.registerProblem(keyValue.getElement(), "Duplicate key");

            PsiElement markedElement = existingKeys.get(keyValue.getKey());
            if(!markedElements.contains(markedElement)) {
                problemsHolder.registerProblem(markedElement, "Duplicate key");
                markedElements.add(markedElement);
            }
        } else {
            existingKeys.put(keyValue.getKey(), keyValue.getElement());
        }
    }

    return problemsHolder;
}
 
開發者ID:adelf,項目名稱:idea-php-dotenv-plugin,代碼行數:26,代碼來源:DuplicateKeyInspection.java

示例14: buildVisitor

import com.intellij.codeInspection.ProblemsHolder; //導入依賴的package包/類
@Override
@NotNull
public PsiElementVisitor buildVisitor(@NotNull final ProblemsHolder holder, final boolean isOnTheFly) {
    final List<PsiMethod> patternMethods = new ArrayList<>();
    final IntArrayList indices = new IntArrayList();
    return new JavaElementVisitor() {
        @Override
        public void visitReferenceExpression(final PsiReferenceExpression expression) {
            visitExpression(expression);
        }

        @Override
        public void visitMethodCallExpression(PsiMethodCallExpression methodCall) {
            super.visitMethodCallExpression(methodCall);
            final String message = getSuspiciousMethodCallMessage(methodCall,
                                                                  REPORT_CONVERTIBLE_METHOD_CALLS,
                                                                  patternMethods,
                                                                  indices
            );
            if (message != null) {
                holder.registerProblem(methodCall.getArgumentList().getExpressions()[0], message);
            }
        }
    };
}
 
開發者ID:aewhite,項目名稱:intellij-eclipse-collections-plugin,代碼行數:26,代碼來源:EclipseCollectionsSuspiciousMethodCallsInspection.java

示例15: RunQueryCodeInspection

import com.intellij.codeInspection.ProblemsHolder; //導入依賴的package包/類
private void RunQueryCodeInspection(PsiMethod method, String annotation, @NotNull ProblemsHolder holder) {
    //Remove UnWanted String
    //so we get only the sql query String
    annotation = annotation.substring(annotation.indexOf(ANNOTATION_QUERY) + ANNOTATION_QUERY.length());

    PsiParameterList methodParameterList = method.getParameterList();
    List<String> methodParameterNameList = new ArrayList<>();

    for (PsiParameter methodParameter : methodParameterList.getParameters()) {
        methodParameterNameList.add(methodParameter.getName());
    }

    runQueryBindVariableCodeInspection(method, annotation, holder, methodParameterNameList);

    runQueryTableNameCodeInspection(method, annotation, holder);

}
 
開發者ID:MukeshMM,項目名稱:Android-Room-Support-Plugin-For-Android-Studio,代碼行數:18,代碼來源:RoomQueryCodeInspection.java


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