use of com.intellij.psi.FileViewProvider in project intellij-community by JetBrains.
the class HtmlUnknownTagInspection method createChangeTemplateDataFix.
@Nullable
@Override
protected LocalQuickFix createChangeTemplateDataFix(PsiFile file) {
if (file != TemplateLanguageUtil.getTemplateFile(file))
return null;
FileViewProvider vp = file.getViewProvider();
if (vp instanceof ConfigurableTemplateLanguageFileViewProvider) {
final TemplateLanguageFileViewProvider viewProvider = (TemplateLanguageFileViewProvider) vp;
final String text = LangBundle.message("quickfix.change.template.data.language.text", viewProvider.getTemplateDataLanguage().getDisplayName());
return new LocalQuickFixOnPsiElement(file) {
@NotNull
@Override
public String getText() {
return text;
}
@Override
public void invoke(@NotNull Project project, @NotNull PsiFile file, @NotNull PsiElement startElement, @NotNull PsiElement endElement) {
ChangeTemplateDataLanguageAction.editSettings(project, file.getVirtualFile());
}
@Nls
@NotNull
@Override
public String getFamilyName() {
return "Change template data language";
}
};
}
return null;
}
use of com.intellij.psi.FileViewProvider in project intellij-community by JetBrains.
the class HtmlSelectioner method select.
@Override
public List<TextRange> select(PsiElement e, @NotNull CharSequence editorText, int cursorOffset, @NotNull Editor editor) {
List<TextRange> result;
if (!(e instanceof XmlToken) || XmlTokenSelectioner.shouldSelectToken((XmlToken) e) || ((XmlToken) e).getTokenType() == XmlTokenType.XML_DATA_CHARACTERS) {
result = super.select(e, editorText, cursorOffset, editor);
} else {
result = ContainerUtil.newArrayList();
}
final PsiElement parent = e.getParent();
if (parent instanceof XmlComment) {
result.addAll(expandToWholeLine(editorText, parent.getTextRange(), true));
}
PsiFile psiFile = e.getContainingFile();
addAttributeSelection(result, editor, cursorOffset, editorText, e);
final FileViewProvider fileViewProvider = psiFile.getViewProvider();
for (Language lang : fileViewProvider.getLanguages()) {
final PsiFile langFile = fileViewProvider.getPsi(lang);
if (langFile != psiFile)
addAttributeSelection(result, editor, cursorOffset, editorText, fileViewProvider.findElementAt(cursorOffset, lang));
}
EditorHighlighter highlighter = HighlighterFactory.createHighlighter(e.getProject(), psiFile.getVirtualFile());
highlighter.setText(editorText);
addTagSelection2(e, result);
return result;
}
use of com.intellij.psi.FileViewProvider in project intellij-community by JetBrains.
the class FileBasedUserDataCache method compute.
public T compute(PsiFile file) {
final FileViewProvider fileViewProvider = file.getViewProvider();
final PsiFile baseFile = fileViewProvider.getPsi(fileViewProvider.getBaseLanguage());
// expand chameleon out of lock
baseFile.getFirstChild();
return get(getKey(), baseFile, null).getValue();
}
use of com.intellij.psi.FileViewProvider in project intellij-community by JetBrains.
the class HectorComponent method isModified.
private boolean isModified() {
final FileViewProvider viewProvider = myFile.getViewProvider();
for (Language language : mySliders.keySet()) {
JSlider slider = mySliders.get(language);
final PsiFile root = viewProvider.getPsi(language);
HighlightingLevelManager highlightingLevelManager = HighlightingLevelManager.getInstance(myFile.getProject());
if (root != null && getValue(highlightingLevelManager.shouldHighlight(root), highlightingLevelManager.shouldInspect(root)) != slider.getValue()) {
return true;
}
}
for (HectorComponentPanel panel : myAdditionalPanels) {
if (panel.isModified()) {
return true;
}
}
return false;
}
use of com.intellij.psi.FileViewProvider in project intellij-community by JetBrains.
the class HectorComponent method forceDaemonRestart.
private void forceDaemonRestart() {
final FileViewProvider viewProvider = myFile.getViewProvider();
for (Language language : mySliders.keySet()) {
JSlider slider = mySliders.get(language);
PsiElement root = viewProvider.getPsi(language);
assert root != null : "No root in " + viewProvider + " for " + language;
int value = slider.getValue();
if (value == 1) {
HighlightLevelUtil.forceRootHighlighting(root, FileHighlightingSetting.SKIP_HIGHLIGHTING);
} else if (value == 2) {
HighlightLevelUtil.forceRootHighlighting(root, FileHighlightingSetting.SKIP_INSPECTION);
} else {
HighlightLevelUtil.forceRootHighlighting(root, FileHighlightingSetting.FORCE_HIGHLIGHTING);
}
}
final DaemonCodeAnalyzer analyzer = DaemonCodeAnalyzer.getInstance(myFile.getProject());
analyzer.restart();
}
Aggregations