use of com.intellij.lang.Language 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();
}
use of com.intellij.lang.Language in project intellij-community by JetBrains.
the class LocalInspectionsPass method appendDialects.
static void appendDialects(PsiElement element, Set<Language> outProcessedLanguages, Set<String> outDialectIds) {
Language language = element.getLanguage();
outDialectIds.add(language.getID());
if (outProcessedLanguages.add(language)) {
for (Language dialect : language.getDialects()) {
outDialectIds.add(dialect.getID());
}
}
}
use of com.intellij.lang.Language in project intellij-community by JetBrains.
the class ParameterNameHintsConfigurable method initLanguageCombo.
private void initLanguageCombo(Language selected, List<Language> languages) {
ListComboBoxModel<Language> model = new ListComboBoxModel<>(languages);
myCurrentLanguageCombo = new ComboBox<>(model);
myCurrentLanguageCombo.setSelectedItem(selected);
myCurrentLanguageCombo.setRenderer(new ListCellRendererWrapper<Language>() {
@Override
public void customize(JList list, Language value, int index, boolean selected, boolean hasFocus) {
setText(value.getDisplayName());
}
});
myCurrentLanguageCombo.addItemListener(new ItemListener() {
@Override
public void itemStateChanged(ItemEvent e) {
Language language = (Language) e.getItem();
if (e.getStateChange() == ItemEvent.SELECTED) {
showLanguagePanel(language);
}
}
});
}
use of com.intellij.lang.Language in project intellij-community by JetBrains.
the class ParameterNameHintsConfigurable method storeBlackListDiff.
private static void storeBlackListDiff(@NotNull Language language, @NotNull String text) {
Set<String> updatedBlackList = StringUtil.split(text, "\n").stream().filter((e) -> !e.trim().isEmpty()).collect(Collectors.toCollection(LinkedHashSet::new));
InlayParameterHintsProvider provider = InlayParameterHintsExtension.INSTANCE.forLanguage(language);
Set<String> defaultBlackList = provider.getDefaultBlackList();
Diff diff = Diff.Builder.build(defaultBlackList, updatedBlackList);
ParameterNameHintsSettings.getInstance().setBlackListDiff(language, diff);
}
use of com.intellij.lang.Language in project intellij-community by JetBrains.
the class QuickEditAction method getRangePair.
@Nullable
protected Pair<PsiElement, TextRange> getRangePair(final PsiFile file, final Editor editor) {
final int offset = editor.getCaretModel().getOffset();
final PsiLanguageInjectionHost host = PsiTreeUtil.getParentOfType(file.findElementAt(offset), PsiLanguageInjectionHost.class, false);
if (host == null || ElementManipulators.getManipulator(host) == null)
return null;
final List<Pair<PsiElement, TextRange>> injections = InjectedLanguageManager.getInstance(host.getProject()).getInjectedPsiFiles(host);
if (injections == null || injections.isEmpty())
return null;
final int offsetInElement = offset - host.getTextRange().getStartOffset();
final Pair<PsiElement, TextRange> rangePair = ContainerUtil.find(injections, pair -> pair.second.containsRange(offsetInElement, offsetInElement));
if (rangePair != null) {
final Language language = rangePair.first.getContainingFile().getLanguage();
final Object action = language.getUserData(EDIT_ACTION_AVAILABLE);
if (action != null && action.equals(false))
return null;
myLastLanguageName = language.getDisplayName();
}
return rangePair;
}
Aggregations