@Nullable public static String findUri(PsiFile file, int offset) { PsiElement element = file.findElementAt(offset); if (element == null || element instanceof PsiWhiteSpace ) { return null; } PsiReference currentRef = file.getViewProvider().findReferenceAt(offset, file.getLanguage()); if (currentRef == null) currentRef = file.getViewProvider().findReferenceAt(offset); if (currentRef instanceof URLReference || currentRef instanceof DependentNSReference) { return currentRef.getCanonicalText(); } return null; }
public static PsiReference[] getUrlReferencesForAttributeValue(final XmlAttributeValue element) { return getReferencesForAttributeValue(element, new PairFunction<String, Integer, PsiReference>() { @Nullable @Override public PsiReference fun(String token, Integer 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; } }); }
@Nullable public static String findUri(PsiFile file, int offset) { PsiReference currentRef = file.getViewProvider().findReferenceAt(offset, file.getLanguage()); if (currentRef == null) currentRef = file.getViewProvider().findReferenceAt(offset); if (currentRef instanceof URLReference || currentRef instanceof DependentNSReference) { return currentRef.getCanonicalText(); } return null; }
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; }); }