use of com.intellij.lang.Language in project intellij-community by JetBrains.
the class CodeErrorReport method getErrorsForText.
@NotNull
private Collection<PsiErrorElement> getErrorsForText(@NotNull LanguageCodeStyleSettingsProvider provider, @NotNull String sample) {
PsiFile file = provider.createFileFromText(getProject(), sample);
if (file == null) {
Language language = provider.getLanguage();
LanguageFileType type = language.getAssociatedFileType();
if (type == null)
return ContainerUtil.newArrayList();
file = myFixture.configureByText(type, sample);
}
return PsiTreeUtil.collectElementsOfType(file, PsiErrorElement.class);
}
use of com.intellij.lang.Language in project intellij-community by JetBrains.
the class XDebuggerEvaluateActionHandler method showDialog.
private static void showDialog(@NotNull XDebugSession session, VirtualFile file, XDebuggerEditorsProvider editorsProvider, XStackFrame stackFrame, XDebuggerEvaluator evaluator, @NotNull XExpression expression) {
if (expression.getLanguage() == null) {
Language language = null;
if (stackFrame != null) {
XSourcePosition position = stackFrame.getSourcePosition();
if (position != null) {
language = LanguageUtil.getFileLanguage(position.getFile());
}
}
if (language == null && file != null) {
language = LanguageUtil.getFileTypeLanguage(file.getFileType());
}
expression = new XExpressionImpl(expression.getExpression(), language, expression.getCustomInfo(), expression.getMode());
}
new XDebuggerEvaluationDialog(session, editorsProvider, evaluator, expression, stackFrame == null ? null : stackFrame.getSourcePosition()).show();
}
use of com.intellij.lang.Language in project intellij-community by JetBrains.
the class JsonCodeStyleSettingsProvider method createSettingsPage.
@NotNull
@Override
public Configurable createSettingsPage(CodeStyleSettings settings, CodeStyleSettings originalSettings) {
return new CodeStyleAbstractConfigurable(settings, originalSettings, "JSON") {
@Override
protected CodeStyleAbstractPanel createPanel(CodeStyleSettings settings) {
final Language language = JsonLanguage.INSTANCE;
final CodeStyleSettings currentSettings = getCurrentSettings();
return new TabbedLanguageCodeStylePanel(language, currentSettings, settings) {
@Override
protected void initTabs(CodeStyleSettings settings) {
addIndentOptionsTab(settings);
addSpacesTab(settings);
addBlankLinesTab(settings);
addWrappingAndBracesTab(settings);
addTab(new JsonCodeStylePanel(settings));
}
};
}
@Nullable
@Override
public String getHelpTopic() {
return "reference.settingsdialog.codestyle.json";
}
};
}
use of com.intellij.lang.Language in project intellij-community by JetBrains.
the class DummyHolder method language.
protected static Language language(PsiElement context, Language defaultLanguage) {
if (context == null)
return defaultLanguage;
PsiFile file = context.getContainingFile();
if (file == null)
return defaultLanguage;
Language contextLanguage = context.getLanguage();
Language language = file.getLanguage();
if (language.isKindOf(contextLanguage))
return language;
return contextLanguage;
}
use of com.intellij.lang.Language in project intellij-community by JetBrains.
the class MultiplePsiFilesPerDocumentFileViewProvider method getAllFiles.
@Override
@NotNull
public List<PsiFile> getAllFiles() {
final List<PsiFile> roots = new ArrayList<>();
for (Language language : getLanguages()) {
PsiFile psi = getPsi(language);
if (psi != null)
roots.add(psi);
}
final PsiFile base = getPsi(getBaseLanguage());
if (!roots.isEmpty() && roots.get(0) != base) {
roots.remove(base);
roots.add(0, base);
}
return roots;
}
Aggregations