use of com.intellij.util.containers.MostlySingularMultiMap in project intellij-community by JetBrains.
the class GroovyFileImpl method processCachedDeclarations.
private static boolean processCachedDeclarations(@NotNull PsiScopeProcessor processor, @NotNull ResolveState state, MostlySingularMultiMap<String, ResultWithContext> cache) {
for (PsiScopeProcessor each : GroovyResolverProcessor.allProcessors(processor)) {
String name = ResolveUtil.getNameHint(each);
Processor<ResultWithContext> cacheProcessor = res -> each.execute(res.getElement(), state.put(ClassHint.RESOLVE_CONTEXT, res.getFileContext()));
boolean result = name != null ? cache.processForKey(name, cacheProcessor) : cache.processAllValues(cacheProcessor);
if (!result)
return false;
}
return true;
}
use of com.intellij.util.containers.MostlySingularMultiMap in project intellij-community by JetBrains.
the class BaseExternalAnnotationsManager method getDataFromFile.
@NotNull
MostlySingularMultiMap<String, AnnotationData> getDataFromFile(@NotNull PsiFile file) {
Pair<MostlySingularMultiMap<String, AnnotationData>, Long> cached = myAnnotationFileToDataAndModStampCache.get(file);
long fileModificationStamp = file.getModificationStamp();
if (cached != null && cached.getSecond() == fileModificationStamp) {
return cached.getFirst();
}
DataParsingSaxHandler handler = new DataParsingSaxHandler(file);
try {
SAXParser saxParser = SAXParserFactory.newInstance().newSAXParser();
saxParser.parse(new InputSource(new CharSequenceReader(escapeAttributes(file.getViewProvider().getContents()))), handler);
} catch (IOException e) {
LOG.error(e);
} catch (ParserConfigurationException e) {
LOG.error(e);
} catch (SAXException e) {
LOG.error(e);
}
MostlySingularMultiMap<String, AnnotationData> result = handler.getResult();
myAnnotationFileToDataAndModStampCache.put(file, Pair.create(result, fileModificationStamp));
return result;
}
use of com.intellij.util.containers.MostlySingularMultiMap in project intellij-community by JetBrains.
the class XmlPropertiesFileImpl method ensurePropertiesLoaded.
private void ensurePropertiesLoaded() {
while (myFileModificationStamp != myFile.getModificationStamp() || myPropertiesMap == null) {
myFileModificationStamp = myFile.getModificationStamp();
MostlySingularMultiMap<String, IProperty> propertiesMap = new MostlySingularMultiMap<>();
XmlTag rootTag = myFile.getRootTag();
final List<IProperty> propertiesOrder = new ArrayList<>();
if (rootTag != null) {
XmlTag[] entries = rootTag.findSubTags(ENTRY_TAG_NAME);
for (XmlTag entry : entries) {
XmlProperty property = new XmlProperty(entry, this);
propertiesOrder.add(property);
final String key = property.getKey();
if (key != null) {
propertiesMap.add(key, property);
}
}
}
myAlphaSorted = PropertiesImplUtil.isAlphaSorted(propertiesOrder);
myProperties = propertiesOrder;
myPropertiesMap = propertiesMap;
}
}
use of com.intellij.util.containers.MostlySingularMultiMap in project intellij-community by JetBrains.
the class GroovyFileImpl method buildDeclarationCache.
@NotNull
private MostlySingularMultiMap<String, ResultWithContext> buildDeclarationCache() {
MostlySingularMultiMap<String, ResultWithContext> results = new MostlySingularMultiMap<>();
processDeclarationsNoGuess(new BaseScopeProcessor() {
@Override
public boolean execute(@NotNull PsiElement element, @NotNull ResolveState state) {
if (element instanceof PsiNamedElement) {
PsiElement context = state.get(ClassHint.RESOLVE_CONTEXT);
String name = getDeclarationName((PsiNamedElement) element, context);
if (name != null) {
results.add(name, new ResultWithContext((PsiNamedElement) element, context));
}
}
return true;
}
private String getDeclarationName(@NotNull PsiNamedElement element, @Nullable PsiElement context) {
String name = context instanceof GrImportStatement ? ((GrImportStatement) context).getImportedName() : null;
return name != null ? name : element.getName();
}
}, ResolveState.initial(), null, this);
return results;
}
Aggregations