use of com.intellij.lang.Language in project intellij-plugins by JetBrains.
the class CfmlCommenter method getCfmlElementAtOffset.
private static PsiElement getCfmlElementAtOffset(int offset, PsiFile file) {
final FileViewProvider fileViewProvider = file.getViewProvider();
file = fileViewProvider.getPsi(fileViewProvider.getBaseLanguage());
final Language cfmlLanguage = file.getLanguage();
return fileViewProvider.findElementAt(offset, cfmlLanguage);
}
use of com.intellij.lang.Language in project intellij-plugins by JetBrains.
the class AngularJSErrorFilter method shouldHighlightErrorElement.
@Override
public boolean shouldHighlightErrorElement(@NotNull PsiErrorElement error) {
final Project project = error.getProject();
final Language language = error.getLanguage();
if ("CSS".equals(language.getID()) && PsiTreeUtil.getParentOfType(error, XmlAttribute.class) != null && AngularIndexUtil.hasAngularJS(project)) {
final PsiFile file = error.getContainingFile();
PsiErrorElement nextError = error;
while (nextError != null) {
if (hasAngularInjectionAt(project, file, nextError.getTextOffset()))
return false;
nextError = PsiTreeUtil.getNextSiblingOfType(nextError, PsiErrorElement.class);
}
}
if (HTMLLanguage.INSTANCE.is(language) && error.getErrorDescription().endsWith("not closed")) {
final PsiElement parent = error.getParent();
final XmlElementDescriptor descriptor = parent instanceof XmlTag ? ((XmlTag) parent).getDescriptor() : null;
return !(descriptor instanceof AngularJSTagDescriptor);
}
if (XMLLanguage.INSTANCE.is(language) && error.getErrorDescription().equals(XmlErrorMessages.message("xml.parsing.unexpected.tokens"))) {
return !error.getParent().getLanguage().is(Angular2HTMLLanguage.INSTANCE);
}
return true;
}
use of com.intellij.lang.Language in project intellij-plugins by JetBrains.
the class AngularJSBracesUtil method hasConflicts.
public static boolean hasConflicts(String start, String end, PsiElement element) {
final Language elementLanguage = element.getLanguage();
// JSP contains two roots that contain XmlText, don't inject anything in JSP root to prevent double injections
if ("JSP".equals(elementLanguage.getDisplayName())) {
return true;
}
PsiFile file = element.getContainingFile();
if (DEFAULT_START.equals(start) || DEFAULT_END.equals(end)) {
// JSX attributes don't contain AngularJS injections, {{}} is JSX injection with object inside
if (elementLanguage.isKindOf(JavascriptLanguage.INSTANCE))
return true;
for (Language language : file.getViewProvider().getLanguages()) {
if (DEFAULT_CONFLICTS.contains(language.getDisplayName())) {
return true;
}
}
}
return false;
}
use of com.intellij.lang.Language in project intellij-community by JetBrains.
the class TailType method getLocalCodeStyleSettings.
protected static CommonCodeStyleSettings getLocalCodeStyleSettings(Editor editor, int tailOffset) {
final PsiFile psiFile = getFile(editor);
Language language = PsiUtilCore.getLanguageAtOffset(psiFile, tailOffset);
final Project project = editor.getProject();
assert project != null;
return CodeStyleSettingsManager.getSettings(project).getCommonSettings(language);
}
use of com.intellij.lang.Language in project intellij-community by JetBrains.
the class TabbedLanguageCodeStylePanel method applyLanguageSettings.
private void applyLanguageSettings(Language lang) {
final Project currProject = ProjectUtil.guessCurrentProject(getPanel());
CodeStyleSettings rootSettings = CodeStyleSettingsManager.getSettings(currProject);
CommonCodeStyleSettings sourceSettings = rootSettings.getCommonSettings(lang);
CommonCodeStyleSettings targetSettings = getSettings().getCommonSettings(getDefaultLanguage());
if (sourceSettings == null || targetSettings == null)
return;
if (!(targetSettings instanceof CodeStyleSettings)) {
CommonCodeStyleSettingsManager.copy(sourceSettings, targetSettings);
} else {
Language targetLang = getDefaultLanguage();
LOG.error((targetLang != null ? targetLang.getDisplayName() : "Unknown") + " language plug-in either uses an outdated API or does not initialize" + " its own code style settings in LanguageCodeStyleSettingsProvider.getDefaultSettings()." + " The operation can not be applied in this case.");
}
reset(getSettings());
onSomethingChanged();
}
Aggregations