public void registerProblem(@NotNull ProblemDescriptor problemDescriptor) { PsiElement element = problemDescriptor.getPsiElement(); if (element != null && !isInPsiFile(element)) { ExternallyDefinedPsiElement external = PsiTreeUtil.getParentOfType(element, ExternallyDefinedPsiElement.class, false); if (external != null) { PsiElement newTarget = external.getProblemTarget(); if (newTarget != null) { redirectProblem(problemDescriptor, newTarget); return; } } PsiFile containingFile = element.getContainingFile(); PsiElement context = InjectedLanguageManager.getInstance(containingFile.getProject()).getInjectionHost(containingFile); PsiElement myContext = InjectedLanguageManager.getInstance(myFile.getProject()).getInjectionHost(myFile); LOG.error("Reported element " + element + " is not from the file '" + myFile + "' the inspection was invoked for. Message: '" + problemDescriptor.getDescriptionTemplate()+"'.\n" + "Element' containing file: "+ containingFile +"; context: "+(context == null ? null : context.getContainingFile())+"\n" +"Inspection invoked for file: "+ myFile +"; context: "+(myContext == null ? null : myContext.getContainingFile())+"\n" ); } myProblems.add(problemDescriptor); }
@NotNull private Map<String, PsiField> getFieldsMap() { PsiField[] fields = getFields(); if(fields.length == 0) { return Collections.emptyMap(); } Map<String, PsiField> cachedFields = new THashMap<String, PsiField>(); for(PsiField field : fields) { String name = field.getName(); if(!(field instanceof ExternallyDefinedPsiElement) || !cachedFields.containsKey(name)) { cachedFields.put(name, field); } } return cachedFields; }
@NotNull private Map<String, PsiClass> getInnerClassesMap() { PsiClass[] classes = getInnerClasses(); if(classes.length == 0) { return Collections.emptyMap(); } Map<String, PsiClass> cachedInners = new THashMap<String, PsiClass>(); for(PsiClass psiClass : classes) { String name = psiClass.getName(); if(!(psiClass instanceof ExternallyDefinedPsiElement) || !cachedInners.containsKey(name)) { cachedInners.put(name, psiClass); } } return cachedInners; }
public void registerProblem(@NotNull ProblemDescriptor problemDescriptor) { PsiElement element = problemDescriptor.getPsiElement(); if (element != null && !isInPsiFile(element)) { ExternallyDefinedPsiElement external = PsiTreeUtil.getParentOfType(element, ExternallyDefinedPsiElement.class, false); if (external != null) { PsiElement newTarget = external.getProblemTarget(); if (newTarget != null) { redirectProblem(problemDescriptor, newTarget); return; } } } myProblems.add(problemDescriptor); }
@Nullable private Map<String, PsiField> getFieldsMap() { final PsiField[] fields = getFields(); if (fields.length == 0) return null; final Map<String, PsiField> cachedFields = new THashMap<String, PsiField>(); for (final PsiField field : fields) { final String name = field.getName(); if (!(field instanceof ExternallyDefinedPsiElement) || !cachedFields.containsKey(name)) { cachedFields.put(name, field); } } return cachedFields; }
@Nullable private Map<String, PsiClass> getInnerClassesMap() { final PsiClass[] classes = getInnerClasses(); if (classes.length == 0) return null; final Map<String, PsiClass> cachedInners = new THashMap<String, PsiClass>(); for (final PsiClass psiClass : classes) { final String name = psiClass.getName(); if (!(psiClass instanceof ExternallyDefinedPsiElement) || !cachedInners.containsKey(name)) { cachedInners.put(name, psiClass); } } return cachedInners; }
public void registerProblem(@Nonnull ProblemDescriptor problemDescriptor) { PsiElement element = problemDescriptor.getPsiElement(); if (element != null && !isInPsiFile(element)) { ExternallyDefinedPsiElement external = PsiTreeUtil.getParentOfType(element, ExternallyDefinedPsiElement.class, false); if (external != null) { PsiElement newTarget = external.getProblemTarget(); if (newTarget != null) { redirectProblem(problemDescriptor, newTarget); return; } } } myProblems.add(problemDescriptor); }