use of com.intellij.lang.Language in project intellij-community by JetBrains.
the class StudyUtils method showNoSdkNotification.
public static void showNoSdkNotification(@NotNull final Task currentTask, @NotNull final Project project) {
final Lesson lesson = currentTask.getLesson();
if (lesson == null)
return;
final Course course = lesson.getCourse();
if (course == null)
return;
final Language language = course.getLanguageById();
StudyExecutor.INSTANCE.forLanguage(language).showNoSdkNotification(project);
}
use of com.intellij.lang.Language in project intellij-community by JetBrains.
the class XmlDocumentationProvider method generateHtmlAdditionalDocTemplate.
static String generateHtmlAdditionalDocTemplate(@NotNull PsiElement element) {
StringBuilder buf = new StringBuilder();
final PsiFile containingFile = element.getContainingFile();
if (containingFile != null) {
final XmlTag tag = PsiTreeUtil.getParentOfType(element, XmlTag.class, false);
boolean append;
if (tag instanceof HtmlTag) {
append = true;
} else {
final FileViewProvider provider = containingFile.getViewProvider();
Language language;
if (provider instanceof TemplateLanguageFileViewProvider) {
language = ((TemplateLanguageFileViewProvider) provider).getTemplateDataLanguage();
} else {
language = provider.getBaseLanguage();
}
append = language == XHTMLLanguage.INSTANCE;
}
if (tag != null) {
EntityDescriptor descriptor = HtmlDescriptorsTable.getTagDescriptor(tag.getName());
if (descriptor != null && append) {
buf.append("<br>");
buf.append(XmlBundle.message("html.quickdoc.additional.template", descriptor.getHelpRef(), BASE_SITEPOINT_URL + tag.getName()));
}
}
}
return buf.toString();
}
use of com.intellij.lang.Language in project intellij-community by JetBrains.
the class XmlTagRenameHandler method getElement.
@Nullable
private static PsiElement getElement(@Nullable final DataContext context) {
if (context != null) {
final Editor editor = getEditor(context);
if (editor != null) {
final int offset = editor.getCaretModel().getOffset();
final PsiFile file = CommonDataKeys.PSI_FILE.getData(context);
if (file instanceof XmlFile) {
return file.getViewProvider().findElementAt(offset);
}
if (file != null) {
final Language language = PsiUtilCore.getLanguageAtOffset(file, offset);
if (language != file.getLanguage()) {
final PsiFile psiAtOffset = file.getViewProvider().getPsi(language);
if (psiAtOffset instanceof XmlFile) {
return psiAtOffset.findElementAt(offset);
}
}
}
}
}
return null;
}
use of com.intellij.lang.Language in project intellij-community by JetBrains.
the class XsltConfigImpl method initComponent.
@Override
@SuppressWarnings({ "StringEquality" })
public void initComponent() {
final Language xmlLang = StdFileTypes.XML.getLanguage();
// intentionManager.addAction(new DeleteUnusedParameterFix());
// intentionManager.addAction(new DeleteUnusedVariableFix());
final XsltFormattingModelBuilder builder = new XsltFormattingModelBuilder(LanguageFormatting.INSTANCE.forLanguage(xmlLang));
LanguageFormatting.INSTANCE.addExplicitExtension(xmlLang, builder);
try {
// TODO: put this into com.intellij.refactoring.actions.IntroduceParameterAction, just like IntroduceVariableAction
final AnAction introduceParameter = ActionManager.getInstance().getAction("IntroduceParameter");
if (introduceParameter != null) {
introduceParameter.setInjectedContext(true);
}
} catch (Exception e) {
Logger.getInstance(XsltConfigImpl.class.getName()).error(e);
}
}
use of com.intellij.lang.Language in project intellij-community by JetBrains.
the class PyInjectorBase method registerInjection.
protected PyInjectionUtil.InjectionResult registerInjection(@NotNull MultiHostRegistrar registrar, @NotNull PsiElement context) {
final Language language = getInjectedLanguage(context);
if (language != null) {
final PsiElement element = PyInjectionUtil.getLargestStringLiteral(context);
if (element != null) {
registrar.startInjecting(language);
final PyInjectionUtil.InjectionResult result = PyInjectionUtil.registerStringLiteralInjection(element, registrar);
if (result.isInjected()) {
registrar.doneInjecting();
}
return result;
}
}
return PyInjectionUtil.InjectionResult.EMPTY;
}
Aggregations