use of com.intellij.patterns.ElementPattern in project intellij-community by JetBrains.
the class MavenPropertyPsiReferenceContributor method registerReferenceProviders.
@Override
public void registerReferenceProviders(@NotNull PsiReferenceRegistrar registrar) {
ElementPattern pattern = XmlPatterns.xmlTag().withParent(DomPatterns.tagWithDom("properties", DomPatterns.domElement(MavenDomProperties.class)));
registrar.registerReferenceProvider(pattern, new MavenPropertyPsiReferenceProvider(), PsiReferenceRegistrar.DEFAULT_PRIORITY);
registrar.registerReferenceProvider(PlatformPatterns.psiElement(), new MavenFilteredPropertyPsiReferenceProvider(), PsiReferenceRegistrar.DEFAULT_PRIORITY);
}
use of com.intellij.patterns.ElementPattern in project intellij-community by JetBrains.
the class FrameworkDetectionIndex method getIndexer.
@NotNull
@Override
public DataIndexer<Integer, Void, FileContent> getIndexer() {
final MultiMap<FileType, Pair<ElementPattern<FileContent>, Integer>> detectors = new MultiMap<>();
FrameworkDetectorRegistry registry = FrameworkDetectorRegistry.getInstance();
for (FrameworkDetector detector : FrameworkDetector.EP_NAME.getExtensions()) {
detectors.putValue(detector.getFileType(), Pair.create(detector.createSuitableFilePattern(), registry.getDetectorId(detector)));
}
return new DataIndexer<Integer, Void, FileContent>() {
@NotNull
@Override
public Map<Integer, Void> map(@NotNull FileContent inputData) {
final FileType fileType = inputData.getFileType();
if (!detectors.containsKey(fileType)) {
return Collections.emptyMap();
}
Map<Integer, Void> result = null;
for (Pair<ElementPattern<FileContent>, Integer> pair : detectors.get(fileType)) {
if (pair.getFirst().accepts(inputData)) {
if (LOG.isDebugEnabled()) {
LOG.debug(inputData.getFile() + " accepted by detector " + pair.getSecond());
}
if (result == null) {
result = new HashMap<>();
}
myDispatcher.getMulticaster().fileUpdated(inputData.getFile(), pair.getSecond());
result.put(pair.getSecond(), null);
}
}
return result != null ? result : Collections.<Integer, Void>emptyMap();
}
};
}
use of com.intellij.patterns.ElementPattern in project intellij-community by JetBrains.
the class NamedObjectProviderBinding method addMatchingProviders.
static void addMatchingProviders(@NotNull PsiElement position, @Nullable final List<ProviderInfo<ElementPattern>> providerList, @NotNull Collection<ProviderInfo<ProcessingContext>> output, @NotNull PsiReferenceService.Hints hints) {
if (providerList == null)
return;
//noinspection ForLoopReplaceableByForEach
for (int i = 0; i < providerList.size(); i++) {
ProviderInfo<ElementPattern> info = providerList.get(i);
if (hints != PsiReferenceService.Hints.NO_HINTS && !info.provider.acceptsHints(position, hints)) {
continue;
}
final ProcessingContext context = new ProcessingContext();
if (hints != PsiReferenceService.Hints.NO_HINTS) {
context.put(PsiReferenceService.HINTS, hints);
}
boolean suitable = false;
try {
suitable = info.processingContext.accepts(position, context);
} catch (IndexNotReadyException ignored) {
}
if (suitable) {
output.add(new ProviderInfo<>(info.provider, context, info.priority));
}
}
}
use of com.intellij.patterns.ElementPattern in project intellij-community by JetBrains.
the class XmlLanguageInjector method getXmlAnnotatedElementsValue.
private Trinity<Long, Pattern, Collection<String>> getXmlAnnotatedElementsValue() {
Trinity<Long, Pattern, Collection<String>> index = myXmlIndex;
if (index == null || myConfiguration.getModificationCount() != index.first.longValue()) {
final Map<ElementPattern<?>, BaseInjection> map = new THashMap<>();
for (BaseInjection injection : myConfiguration.getInjections(XmlLanguageInjectionSupport.XML_SUPPORT_ID)) {
for (InjectionPlace place : injection.getInjectionPlaces()) {
if (!place.isEnabled() || place.getElementPattern() == null)
continue;
map.put(place.getElementPattern(), injection);
}
}
final Collection<String> stringSet = PatternValuesIndex.buildStringIndex(map.keySet());
index = Trinity.create(myConfiguration.getModificationCount(), buildPattern(stringSet), stringSet);
myXmlIndex = index;
}
return index;
}
use of com.intellij.patterns.ElementPattern in project intellij-community by JetBrains.
the class CompletionProgressIndicator method prefixUpdated.
public void prefixUpdated() {
final int caretOffset = myEditor.getCaretModel().getOffset();
if (caretOffset < myStartCaret) {
scheduleRestart();
myRestartingPrefixConditions.clear();
return;
}
final CharSequence text = myEditor.getDocument().getCharsSequence();
for (Pair<Integer, ElementPattern<String>> pair : myRestartingPrefixConditions) {
int start = pair.first;
if (caretOffset >= start && start >= 0) {
final String newPrefix = text.subSequence(start, caretOffset).toString();
if (pair.second.accepts(newPrefix)) {
scheduleRestart();
myRestartingPrefixConditions.clear();
return;
}
}
}
hideAutopopupIfMeaningless();
}
Aggregations