mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
PredefinedCodeStyle is extension point now
This commit is contained in:
+2
-1
@@ -109,9 +109,10 @@ public abstract class LanguageCodeStyleSettingsProvider {
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Array of predefined code styles (empty array by default).
|
||||
* @deprecated use PredefinedCodeStyle extension point instead
|
||||
*/
|
||||
@NotNull
|
||||
@Deprecated
|
||||
public PredefinedCodeStyle[] getPredefinedCodeStyles() {
|
||||
return PredefinedCodeStyle.EMPTY_ARRAY;
|
||||
}
|
||||
|
||||
@@ -17,12 +17,15 @@ package com.intellij.psi.codeStyle;
|
||||
|
||||
|
||||
import com.intellij.lang.Language;
|
||||
import com.intellij.openapi.extensions.ExtensionPointName;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* @author Rustam Vishnyakov
|
||||
*/
|
||||
public abstract class PredefinedCodeStyle {
|
||||
public static final ExtensionPointName<PredefinedCodeStyle> EP_NAME =
|
||||
ExtensionPointName.create("com.intellij.predefinedCodeStyle");
|
||||
|
||||
public final static PredefinedCodeStyle[] EMPTY_ARRAY = new PredefinedCodeStyle[]{};
|
||||
private final String myName;
|
||||
@@ -46,9 +49,17 @@ public abstract class PredefinedCodeStyle {
|
||||
public boolean equals(Object obj) {
|
||||
if (!(obj instanceof PredefinedCodeStyle)) return false;
|
||||
PredefinedCodeStyle otherStyle = (PredefinedCodeStyle)obj;
|
||||
return myName.equals(otherStyle.getName());
|
||||
return myName.equals(otherStyle.getName()) &&
|
||||
myLanguage.equals(otherStyle.getLanguage());
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int result = myName.hashCode();
|
||||
result = 31 * result + myLanguage.hashCode();
|
||||
return result;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return myName;
|
||||
}
|
||||
@@ -57,7 +68,8 @@ public abstract class PredefinedCodeStyle {
|
||||
public String toString() {
|
||||
return myName;
|
||||
}
|
||||
|
||||
|
||||
@NotNull
|
||||
public Language getLanguage() {
|
||||
return myLanguage;
|
||||
}
|
||||
|
||||
+15
-6
@@ -40,9 +40,7 @@ import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.*;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@@ -357,9 +355,20 @@ public abstract class TabbedLanguageCodeStylePanel extends CodeStyleAbstractPane
|
||||
}
|
||||
|
||||
private PredefinedCodeStyle[] getPredefinedStyles() {
|
||||
LanguageCodeStyleSettingsProvider provider = LanguageCodeStyleSettingsProvider.forLanguage(getDefaultLanguage());
|
||||
if (provider == null) return new PredefinedCodeStyle[0];
|
||||
return provider.getPredefinedCodeStyles();
|
||||
final Language language = getDefaultLanguage();
|
||||
final List<PredefinedCodeStyle> result = new ArrayList<PredefinedCodeStyle>();
|
||||
|
||||
for (PredefinedCodeStyle codeStyle : PredefinedCodeStyle.EP_NAME.getExtensions()) {
|
||||
if (codeStyle.getLanguage().equals(language)) {
|
||||
result.add(codeStyle);
|
||||
}
|
||||
}
|
||||
final LanguageCodeStyleSettingsProvider provider = LanguageCodeStyleSettingsProvider.forLanguage(getDefaultLanguage());
|
||||
|
||||
if (provider != null) {
|
||||
result.addAll(Arrays.asList(provider.getPredefinedCodeStyles()));
|
||||
}
|
||||
return result.toArray(new PredefinedCodeStyle[result.size()]);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -515,6 +515,8 @@
|
||||
|
||||
<extensionPoint name="langCodeStyleSettingsProvider" interface="com.intellij.psi.codeStyle.LanguageCodeStyleSettingsProvider"/>
|
||||
|
||||
<extensionPoint name="predefinedCodeStyle" interface="com.intellij.psi.codeStyle.PredefinedCodeStyle"/>
|
||||
|
||||
<extensionPoint name="semContributor"
|
||||
beanClass="com.intellij.semantic.SemContributorEP" area="IDEA_PROJECT"/>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user