use of com.intellij.psi.impl.source.resolve.reference.impl.providers.URLReference in project intellij-community by JetBrains.
the class XmlLocationCompletionContributor method fillCompletionVariants.
@Override
public void fillCompletionVariants(@NotNull CompletionParameters parameters, @NotNull CompletionResultSet result) {
PsiReference reference = parameters.getPosition().getContainingFile().findReferenceAt(parameters.getOffset());
if (reference instanceof URLReference) {
if (((URLReference) reference).isSchemaLocation()) {
Object[] objects = completeSchemaLocation(reference.getElement());
result.addAllElements(ContainerUtil.map(objects, MAPPING));
return;
}
Object[] objects = completeNamespace(reference.getElement());
result.addAllElements(ContainerUtil.map(objects, MAPPING));
return;
}
if (reference instanceof PsiMultiReference)
reference = ((PsiMultiReference) reference).getReferences()[0];
if (reference instanceof DependentNSReference) {
MultiMap<String, String> map = ExternalResourceManagerEx.getInstanceEx().getUrlsByNamespace(parameters.getOriginalFile().getProject());
String namespace = ((DependentNSReference) reference).getNamespaceReference().getCanonicalText();
Collection<String> strings = map.get(namespace);
for (String string : strings) {
if (!namespace.equals(string)) {
// exclude namespaces from location urls
result.consume(PrioritizedLookupElement.withPriority(LookupElementBuilder.create(string), 100));
}
}
if (!strings.isEmpty())
result.stopHere();
}
}
use of com.intellij.psi.impl.source.resolve.reference.impl.providers.URLReference in project intellij-community by JetBrains.
the class MicrodataUtil method getUrlReferencesForAttributeValue.
public static PsiReference[] getUrlReferencesForAttributeValue(final XmlAttributeValue element) {
return getReferencesForAttributeValue(element, (token, offset) -> {
if (HtmlUtil.hasHtmlPrefix(token)) {
final TextRange range = TextRange.from(offset, token.length());
final URLReference urlReference = new URLReference(element, range, true);
return new DependentNSReference(element, range, urlReference, true);
}
return null;
});
}
Aggregations