@NotNull private List<AnnotationData> doCollect(@NotNull PsiModifierListOwner listOwner, boolean onlyWritable) { String externalName = getExternalName(listOwner, false); if (externalName == null) return NO_DATA; List<PsiFile> files = findExternalAnnotationsFiles(listOwner); if (files == null) return NO_DATA; SmartList<AnnotationData> result = new SmartList<AnnotationData>(); for (PsiFile file : files) { if (!file.isValid()) continue; if (onlyWritable && !file.isWritable()) continue; MostlySingularMultiMap<String, AnnotationData> fileData = getDataFromFile(file); ContainerUtil.addAll(result, fileData.get(externalName)); } if (result.isEmpty()) return NO_DATA; result.trimToSize(); return result; }
private void ensurePropertiesLoaded() { while (myFileModificationStamp != myFile.getModificationStamp() || myPropertiesMap == null) { myFileModificationStamp = myFile.getModificationStamp(); MostlySingularMultiMap<String, IProperty> propertiesMap = new MostlySingularMultiMap<String, IProperty>(); XmlTag rootTag = myFile.getRootTag(); final List<IProperty> propertiesOrder = new ArrayList<IProperty>(); if (rootTag != null) { XmlTag[] entries = rootTag.findSubTags("entry"); for (XmlTag entry : entries) { XmlProperty property = new XmlProperty(entry, this); propertiesOrder.add(property); propertiesMap.add(property.getKey(), property); } } final boolean isAlphaSorted = PropertiesImplUtil.isAlphaSorted(propertiesOrder); myAlphaSorted = isAlphaSorted; myProperties = propertiesOrder; myPropertiesMap = propertiesMap; } }
private void ensurePropertiesLoaded() { if (myPropertiesMap != null) return; final ASTNode[] props = getPropertiesList().getChildren(PropertiesElementTypes.PROPERTIES); MostlySingularMultiMap<String, IProperty> propertiesMap = new MostlySingularMultiMap<String, IProperty>(); List<IProperty> properties = new ArrayList<IProperty>(props.length); for (final ASTNode prop : props) { final Property property = (Property)prop.getPsi(); String key = property.getUnescapedKey(); propertiesMap.add(key, property); properties.add(property); } final boolean isAlphaSorted = PropertiesImplUtil.isAlphaSorted(properties); synchronized (lock) { if (myPropertiesMap != null) return; myProperties = properties; myPropertiesMap = propertiesMap; myAlphaSorted = isAlphaSorted; } }
@Nullable static HighlightInfo checkDuplicateMethod(PsiClass aClass, @NotNull PsiMethod method, @NotNull MostlySingularMultiMap<MethodSignature, PsiMethod> duplicateMethods) { if (aClass == null || method instanceof ExternallyDefinedPsiElement) return null; MethodSignature methodSignature = method.getSignature(PsiSubstitutor.EMPTY); int methodCount = 1; List<PsiMethod> methods = (List<PsiMethod>)duplicateMethods.get(methodSignature); if (methods.size() > 1) { methodCount++; } if (methodCount == 1 && aClass.isEnum() && GenericsHighlightUtil.isEnumSyntheticMethod(methodSignature, aClass.getProject())) { methodCount++; } if (methodCount > 1) { String description = JavaErrorMessages.message("duplicate.method", JavaHighlightUtil.formatMethod(method), HighlightUtil.formatClass(aClass)); TextRange textRange = HighlightNamesUtil.getMethodDeclarationTextRange(method); return HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(textRange).descriptionAndTooltip(description).create(); } return null; }
private void ensurePropertiesLoaded() { if (myPropertiesMap != null) return; final ASTNode[] props = getPropertiesList().getChildren(PropertiesElementTypes.PROPERTIES); MostlySingularMultiMap<String, IProperty> propertiesMap = new MostlySingularMultiMap<String, IProperty>(); List<IProperty> properties = new ArrayList<IProperty>(props.length); for (final ASTNode prop : props) { final Property property = (Property)prop.getPsi(); String key = property.getUnescapedKey(); propertiesMap.add(key, property); properties.add(property); } synchronized (lock) { if (myPropertiesMap != null) return; myProperties = properties; myPropertiesMap = propertiesMap; } }
@NotNull private MostlySingularMultiMap<MethodSignature, PsiMethod> getDuplicateMethods(@NotNull PsiClass aClass) { MostlySingularMultiMap<MethodSignature, PsiMethod> signatures = myDuplicateMethods.get(aClass); if(signatures == null) { signatures = new MostlySingularMultiMap<>(); for(PsiMethod method : aClass.getMethods()) { if(method instanceof ExternallyDefinedPsiElement) { continue; // ignore aspectj-weaved methods; they are checked elsewhere } MethodSignature signature = method.getSignature(PsiSubstitutor.EMPTY); signatures.add(signature, method); } myDuplicateMethods.put(aClass, signatures); } return signatures; }
public MostlySingularMultiMap<String, AnnotationData> getResult() { if (myData.isEmpty()) { return MostlySingularMultiMap.emptyMap(); } myData.compact(); return myData; }
@Override public Result<MostlySingularMultiMap<String, SymbolCollectingProcessor.ResultWithContext>> compute() { SymbolCollectingProcessor p = new SymbolCollectingProcessor(); myFile.processDeclarationsNoGuess(p, ResolveState.initial(), myFile, myFile); MostlySingularMultiMap<String, SymbolCollectingProcessor.ResultWithContext> results = p.getResults(); return Result.create(results, PsiModificationTracker.MODIFICATION_COUNT, myFile); }
@Nullable static HighlightInfo checkDuplicateMethod(PsiClass aClass, @NotNull PsiMethod method, @NotNull MostlySingularMultiMap<MethodSignature, PsiMethod> duplicateMethods) { if (aClass == null || method instanceof ExternallyDefinedPsiElement) return null; MethodSignature methodSignature = method.getSignature(PsiSubstitutor.EMPTY); int methodCount = 1; List<PsiMethod> methods = (List<PsiMethod>)duplicateMethods.get(methodSignature); if (methods.size() > 1) { methodCount++; } if (methodCount == 1 && aClass.isEnum() && GenericsHighlightUtil.isEnumSyntheticMethod(methodSignature, aClass.getProject())) { methodCount++; } if (methodCount > 1) { String description = JavaErrorMessages.message("duplicate.method", JavaHighlightUtil.formatMethod(method), HighlightUtil.formatClass(aClass)); TextRange textRange = HighlightNamesUtil.getMethodDeclarationTextRange(method); return HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR). range(method, textRange.getStartOffset(), textRange.getEndOffset()). descriptionAndTooltip(description).create(); } return null; }
@NotNull private MostlySingularMultiMap<MethodSignature, PsiMethod> getDuplicateMethods(@NotNull PsiClass aClass) { MostlySingularMultiMap<MethodSignature, PsiMethod> signatures = myDuplicateMethods.get(aClass); if (signatures == null) { signatures = new MostlySingularMultiMap<MethodSignature, PsiMethod>(); for (PsiMethod method : aClass.getMethods()) { if (method instanceof ExternallyDefinedPsiElement) continue; // ignore aspectj-weaved methods; they are checked elsewhere MethodSignature signature = method.getSignature(PsiSubstitutor.EMPTY); signatures.add(signature, method); } myDuplicateMethods.put(aClass, signatures); } return signatures; }
@Override public Result<MostlySingularMultiMap<String, SymbolCollectingProcessor.ResultWithContext>> compute() { SymbolCollectingProcessor p = new SymbolCollectingProcessor(); myFile.processDeclarationsNoGuess(p, ResolveState.initial(), myFile, myFile); MostlySingularMultiMap<String, SymbolCollectingProcessor.ResultWithContext> results = p.getResults(); return Result.create(results, PsiModificationTracker.JAVA_STRUCTURE_MODIFICATION_COUNT); }
@NotNull private MostlySingularMultiMap<MethodSignature, PsiMethod> getDuplicateMethods(PsiClass aClass) { MostlySingularMultiMap<MethodSignature, PsiMethod> signatures = myDuplicateMethods.get(aClass); if (signatures == null) { signatures = new MostlySingularMultiMap<MethodSignature, PsiMethod>(); for (PsiMethod method : aClass.getMethods()) { if (method instanceof ExternallyDefinedPsiElement) continue; // ignore aspectj-weaved methods; they are checked elsewhere MethodSignature signature = method.getSignature(PsiSubstitutor.EMPTY); signatures.add(signature, method); } myDuplicateMethods.put(aClass, signatures); } return signatures; }
@NotNull private List<AnnotationData> doCollect(@NotNull PsiModifierListOwner listOwner, boolean onlyWritable) { String externalName = getExternalName(listOwner, false); if(externalName == null) { return NO_DATA; } List<PsiFile> files = findExternalAnnotationsFiles(listOwner); if(files == null) { return NO_DATA; } SmartList<AnnotationData> result = new SmartList<AnnotationData>(); for(PsiFile file : files) { if(!file.isValid()) { continue; } if(onlyWritable && !file.isWritable()) { continue; } MostlySingularMultiMap<String, AnnotationData> fileData = getDataFromFile(file); ContainerUtil.addAll(result, fileData.get(externalName)); } if(result.isEmpty()) { return NO_DATA; } result.trimToSize(); return result; }
public MostlySingularMultiMap<String, AnnotationData> getResult() { if(myData.isEmpty()) { return MostlySingularMultiMap.emptyMap(); } myData.compact(); return myData; }
@Nullable static HighlightInfo checkDuplicateMethod(PsiClass aClass, @NotNull PsiMethod method, @NotNull MostlySingularMultiMap<MethodSignature, PsiMethod> duplicateMethods) { if(aClass == null || method instanceof ExternallyDefinedPsiElement) { return null; } MethodSignature methodSignature = method.getSignature(PsiSubstitutor.EMPTY); int methodCount = 1; List<PsiMethod> methods = (List<PsiMethod>) duplicateMethods.get(methodSignature); if(methods.size() > 1) { methodCount++; } if(methodCount == 1 && aClass.isEnum() && GenericsHighlightUtil.isEnumSyntheticMethod(methodSignature, aClass.getProject())) { methodCount++; } if(methodCount > 1) { String description = JavaErrorMessages.message("duplicate.method", JavaHighlightUtil.formatMethod(method), HighlightUtil.formatClass(aClass)); TextRange textRange = HighlightNamesUtil.getMethodDeclarationTextRange(method); return HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR). range(method, textRange.getStartOffset(), textRange.getEndOffset()). descriptionAndTooltip(description).create(); } return null; }
public MostlySingularMultiMap<String, ResultWithContext> getResults() { return myResult; }