Java 类com.intellij.lang.LanguageExtensionPoint 实例源码

项目:intellij-ce-playground    文件:DocumentMarkupModelTest.java   
public void testInfoTestAttributes() throws Exception {
  LanguageExtensionPoint<Annotator> extension = new LanguageExtensionPoint<Annotator>();
  extension.language="TEXT";
  extension.implementationClass = TestAnnotator.class.getName();
  PlatformTestUtil.registerExtension(ExtensionPointName.create(LanguageAnnotators.EP_NAME), extension, getTestRootDisposable());
  myFixture.configureByText(PlainTextFileType.INSTANCE, "foo");
  EditorColorsScheme scheme = new EditorColorsSchemeImpl(new DefaultColorsScheme()){{initFonts();}};
  scheme.setAttributes(HighlighterColors.TEXT, new TextAttributes(Color.black, Color.white, null, null, Font.PLAIN));
  ((EditorEx)myFixture.getEditor()).setColorsScheme(scheme);
  myFixture.doHighlighting();
  MarkupModel model = DocumentMarkupModel.forDocument(myFixture.getEditor().getDocument(), getProject(), false);
  RangeHighlighter[] highlighters = model.getAllHighlighters();
  assertEquals(1, highlighters.length);
  TextAttributes attributes = highlighters[0].getTextAttributes();
  assertNotNull(attributes);
  assertNull(attributes.getBackgroundColor());
  assertNull(attributes.getForegroundColor());
}
项目:educational-plugin    文件:StudyProjectGenerator.java   
@Nullable
public List<Course> getBundledCourses() {
  final ArrayList<Course> courses = new ArrayList<>();
  final LanguageExtensionPoint<EduPluginConfigurator>[] extensions = Extensions.getExtensions(EduPluginConfigurator.EP_NAME, null);
  for (LanguageExtensionPoint<EduPluginConfigurator> extension : extensions) {
    final EduPluginConfigurator configurator = extension.getInstance();
    final List<String> paths = configurator.getBundledCoursePaths();
    for (String path : paths) {
      courses.add(getCourse(path));
    }
  }
  return courses;
}
项目:educational-plugin    文件:EduStepicConnector.java   
static boolean canBeOpened(RemoteCourse courseInfo) {
  final ArrayList<String> supportedLanguages = new ArrayList<>();
  final LanguageExtensionPoint[] extensions = Extensions.getExtensions(EduPluginConfigurator.EP_NAME, null);
  for (LanguageExtensionPoint extension : extensions) {
    String languageId = extension.getKey();
    supportedLanguages.add(languageId);
  }

  if (courseInfo.isAdaptive()) {
    return supportedLanguages.contains(courseInfo.getLanguageID());
  }

  String courseType = courseInfo.getType();
  final List<String> typeLanguage = StringUtil.split(courseType, " ");
  String prefix = typeLanguage.get(0);
  if (!supportedLanguages.contains(courseInfo.getLanguageID())) return false;
  if (typeLanguage.size() < 2 || !prefix.startsWith(PYCHARM_PREFIX)) {
    return false;
  }
  String versionString = prefix.substring(PYCHARM_PREFIX.length());
  if (versionString.isEmpty()) {
    return true;
  }
  try {
    Integer version = Integer.valueOf(versionString);
    return version <= CURRENT_VERSION;
  }
  catch (NumberFormatException e) {
    LOG.info("Wrong version format", e);
    return false;
  }
}
项目:educational-plugin    文件:EduCCModuleBuilder.java   
@Nullable
@Override
public ModuleWizardStep modifySettingsStep(@NotNull SettingsStep settingsStep) {
  ModuleWizardStep javaSettingsStep =
    ProjectWizardStepFactory.getInstance().createJavaSettingsStep(settingsStep, this, Conditions.alwaysTrue());
  Function<JTextField, String> getValue = JTextComponent::getText;
  getWizardInputField("ccname", "", "Name:", myPanel.getNameField(), getValue).addToSettings(settingsStep);
  getWizardInputField("ccauthor", "", "Author:", myPanel.getAuthorField(), getValue).addToSettings(settingsStep);

  myLanguageComboBox.removeAllItems();
  for (LanguageExtensionPoint extension : Extensions.<LanguageExtensionPoint>getExtensions(EduPluginConfigurator.EP_NAME, null)) {
    String languageId = extension.getKey();
    Language language = Language.findLanguageByID(languageId);
    if (language == null) {
      LOG.info("Language with id " + languageId + " not found");
      continue;
    }
    myLanguageComboBox.addItem(new LanguageWrapper(language));
  }
  getWizardInputField("cclang", "", "Language:", myLanguageComboBox, comboBox -> (String) comboBox.getSelectedItem())
    .addToSettings(settingsStep);
  JTextArea descriptionField = myPanel.getDescriptionField();
  descriptionField.setRows(4);
  descriptionField.setBorder(null);
  descriptionField.invalidate();
  JBScrollPane scrollPane = new JBScrollPane(descriptionField);
  scrollPane.setMinimumSize(scrollPane.getUI().getPreferredSize(descriptionField));
  getWizardInputField("ccdescr", "", "Description:", scrollPane, pane -> descriptionField.getText()).addToSettings(settingsStep);
  return javaSettingsStep;
}
项目:intellij-ce-playground    文件:PostfixTemplatesUtils.java   
@NotNull
public static String getLangForProvider(@NotNull PostfixTemplateProvider provider) {
  LanguageExtensionPoint[] extensions = new ExtensionPointName<LanguageExtensionPoint>(LanguagePostfixTemplate.EP_NAME).getExtensions();

  for (LanguageExtensionPoint extension : extensions) {
    if (provider.equals(extension.getInstance())) {
      return extension.getKey();
    }
  }

  return Language.ANY.getID();
}
项目:intellij-ce-playground    文件:PostfixTemplatesConfigurable.java   
@SuppressWarnings("unchecked")
public PostfixTemplatesConfigurable() {
  PostfixTemplatesSettings settings = PostfixTemplatesSettings.getInstance();
  if (settings == null) {
    throw new RuntimeException("Can't retrieve postfix template settings");
  }

  myTemplatesSettings = settings;

  LanguageExtensionPoint[] extensions = new ExtensionPointName<LanguageExtensionPoint>(LanguagePostfixTemplate.EP_NAME).getExtensions();


  templateMultiMap = MultiMap.create();
  for (LanguageExtensionPoint extension : extensions) {
    List<PostfixTemplate> postfixTemplates =
      ContainerUtil.newArrayList(((PostfixTemplateProvider)extension.getInstance()).getTemplates());
    if (postfixTemplates.isEmpty()) {
      continue;
    }

    ContainerUtil.sort(postfixTemplates, TEMPLATE_COMPARATOR);

    templateMultiMap.putValues(extension.getKey(), postfixTemplates);
  }

  myPostfixTemplatesEnabled.addChangeListener(new ChangeListener() {
    @Override
    public void stateChanged(ChangeEvent e) {
      updateComponents();
    }
  });
  myShortcutComboBox.addItem(TAB);
  myShortcutComboBox.addItem(SPACE);
  myShortcutComboBox.addItem(ENTER);

  myDescriptionPanel.setLayout(new BorderLayout());
}
项目:intellij    文件:ServiceHelper.java   
/** Unregister all extensions of the given class, for the given extension point. */
public static <T> void unregisterLanguageExtensionPoint(
    String extensionPointKey, Class<T> clazz, Disposable parentDisposable) {
  ExtensionPoint<LanguageExtensionPoint<T>> ep =
      Extensions.getRootArea().getExtensionPoint(extensionPointKey);
  LanguageExtensionPoint<T>[] existingExtensions = ep.getExtensions();
  for (LanguageExtensionPoint<T> ext : existingExtensions) {
    if (clazz.getName().equals(ext.implementationClass)) {
      ep.unregisterExtension(ext);
      Disposer.register(parentDisposable, () -> ep.registerExtension(ext));
    }
  }
}
项目:consulo    文件:PostfixTemplatesUtils.java   
@Nonnull
public static String getLangForProvider(@Nonnull PostfixTemplateProvider provider) {
  LanguageExtensionPoint[] extensions = new ExtensionPointName<LanguageExtensionPoint>(LanguagePostfixTemplate.EP_NAME).getExtensions();

  for (LanguageExtensionPoint extension : extensions) {
    if (provider.equals(extension.getInstance())) {
      return extension.getKey();
    }
  }

  return Language.ANY.getID();
}
项目:consulo    文件:PostfixTemplatesConfigurable.java   
@Override
protected Configurable[] buildConfigurables() {
  LanguageExtensionPoint[] extensions = new ExtensionPointName<LanguageExtensionPoint>(LanguagePostfixTemplate.EP_NAME).getExtensions();
  List<Configurable> list = new ArrayList<Configurable>(extensions.length);
  for (LanguageExtensionPoint extensionPoint : extensions) {
    list.add(new PostfixTemplatesChildConfigurable(extensionPoint));
  }
  Collections.sort(list, new Comparator<Configurable>() {
    @Override
    public int compare(Configurable o1, Configurable o2) {
      return StringUtil.compare(o1.getDisplayName(), o2.getDisplayName(), true);
    }
  });
  return list.toArray(new Configurable[list.size()]);
}
项目:consulo    文件:PostfixTemplatesChildConfigurable.java   
@SuppressWarnings("unchecked")
public PostfixTemplatesChildConfigurable(LanguageExtensionPoint extensionPoint) {
  myExtensionPoint = extensionPoint;
  myTemplatesSettings = PostfixTemplatesSettings.getInstance();
}