use of com.intellij.psi.templateLanguages.TemplateLanguageFileViewProvider in project intellij-community by JetBrains.
the class ExternalDocumentValidator method doValidation.
public static synchronized void doValidation(final XmlDocument document, final Validator.ValidationHost host) {
final PsiFile containingFile = document.getContainingFile();
if (containingFile == null) {
return;
}
if (containingFile.getViewProvider() instanceof TemplateLanguageFileViewProvider) {
return;
}
final FileType fileType = containingFile.getViewProvider().getFileType();
if (fileType != XmlFileType.INSTANCE && fileType != XHtmlFileType.INSTANCE) {
return;
}
for (Language lang : containingFile.getViewProvider().getLanguages()) {
if ("ANT".equals(lang.getID()))
return;
}
final XmlTag rootTag = document.getRootTag();
if (rootTag == null)
return;
String namespace = rootTag.getNamespace();
if (XmlUtil.ANT_URI.equals(namespace))
return;
final Project project = document.getProject();
final InspectionProfile profile = InspectionProjectProfileManager.getInstance(project).getCurrentProfile();
final InspectionToolWrapper toolWrapper = profile.getInspectionTool(INSPECTION_SHORT_NAME, containingFile);
if (toolWrapper == null)
return;
if (!profile.isToolEnabled(HighlightDisplayKey.find(INSPECTION_SHORT_NAME), containingFile))
return;
SoftReference<ExternalDocumentValidator> validatorReference = project.getUserData(validatorInstanceKey);
ExternalDocumentValidator validator = SoftReference.dereference(validatorReference);
if (validator == null) {
validator = new ExternalDocumentValidator();
project.putUserData(validatorInstanceKey, new SoftReference<>(validator));
}
validator.runJaxpValidation(document, host);
}
use of com.intellij.psi.templateLanguages.TemplateLanguageFileViewProvider in project intellij-community by JetBrains.
the class HtmlUtil method isHtmlTagContainingFile.
public static boolean isHtmlTagContainingFile(PsiElement element) {
if (element == null) {
return false;
}
final PsiFile containingFile = element.getContainingFile();
if (containingFile != null) {
final XmlTag tag = PsiTreeUtil.getParentOfType(element, XmlTag.class, false);
if (tag instanceof HtmlTag) {
return true;
}
final XmlDocument document = PsiTreeUtil.getParentOfType(element, XmlDocument.class, false);
if (document instanceof HtmlDocumentImpl) {
return true;
}
final FileViewProvider provider = containingFile.getViewProvider();
Language language;
if (provider instanceof TemplateLanguageFileViewProvider) {
language = ((TemplateLanguageFileViewProvider) provider).getTemplateDataLanguage();
} else {
language = provider.getBaseLanguage();
}
return language == XHTMLLanguage.INSTANCE;
}
return false;
}
use of com.intellij.psi.templateLanguages.TemplateLanguageFileViewProvider in project intellij-community by JetBrains.
the class EmmetEditPointUtil method moveToNextPoint.
private static void moveToNextPoint(Editor editor, PsiFile file, int offset, int inc) {
final Document doc = editor.getDocument();
final TemplateLanguageFileViewProvider provider = ObjectUtils.tryCast(file.getViewProvider(), TemplateLanguageFileViewProvider.class);
final Language additionalLanguage = provider != null ? provider.getTemplateDataLanguage() : null;
PsiDocumentManager.getInstance(file.getProject()).commitDocument(doc);
for (int i = offset + inc; i < doc.getTextLength() && i >= 0; i += inc) {
PsiElement current = InjectedLanguageUtil.findElementAtNoCommit(file, i);
if (checkAndMove(editor, doc, i, current))
return;
if (additionalLanguage != null) {
current = provider.findElementAt(i, additionalLanguage);
if (checkAndMove(editor, doc, i, current))
return;
}
}
}
Aggregations