1 package com
.intellij
.codeInsight
.daemon
;
3 import com
.intellij
.openapi
.application
.PathManager
;
4 import com
.intellij
.openapi
.components
.*;
5 import com
.intellij
.openapi
.diagnostic
.Logger
;
6 import com
.intellij
.openapi
.util
.DefaultJDOMExternalizer
;
7 import com
.intellij
.openapi
.util
.InvalidDataException
;
8 import com
.intellij
.openapi
.util
.JDOMUtil
;
9 import com
.intellij
.openapi
.util
.WriteExternalException
;
10 import com
.intellij
.profile
.codeInspection
.InspectionProfileManager
;
11 import org
.jdom
.Element
;
12 import org
.jetbrains
.annotations
.NonNls
;
13 import org
.jetbrains
.annotations
.NotNull
;
18 name
="DaemonCodeAnalyzerSettings",
22 file
= "$APP_CONFIG$/editor.codeinsight.xml"
25 public class DaemonCodeAnalyzerSettings
implements PersistentStateComponent
<Element
>, Cloneable
, ExportableComponent
{
26 private static final Logger LOG
= Logger
.getInstance("#com.intellij.codeInsight.daemon.DaemonCodeAnalyzerSettings");
27 @NonNls private static final String ROOT_TAG
= "root";
28 @NonNls private static final String PROFILE_ATT
= "profile";
29 @NonNls public static final String DEFAULT_PROFILE_ATT
= "Default";
30 @NonNls public static final String PROFILE_COPY_NAME
= "copy";
31 private final InspectionProfileManager myManager
;
34 public DaemonCodeAnalyzerSettings(InspectionProfileManager manager
) {
38 public static DaemonCodeAnalyzerSettings
getInstance() {
39 return ServiceManager
.getService(DaemonCodeAnalyzerSettings
.class);
43 public File
[] getExportFiles() {
44 return new File
[]{PathManager
.getOptionsFile("editor.codeinsight")};
48 public String
getPresentableName() {
49 return DaemonBundle
.message("error.highlighting.settings");
52 public boolean NEXT_ERROR_ACTION_GOES_TO_ERRORS_FIRST
= false;
53 public int AUTOREPARSE_DELAY
= 300;
54 public boolean SHOW_ADD_IMPORT_HINTS
= true;
55 @NonNls public String NO_AUTO_IMPORT_PATTERN
= "[a-z].?";
56 public boolean SUPPRESS_WARNINGS
= true;
57 public boolean SHOW_METHOD_SEPARATORS
= false;
58 public int ERROR_STRIPE_MARK_MIN_HEIGHT
= 3;
59 public boolean SHOW_SMALL_ICONS_IN_GUTTER
= true;
61 public boolean isCodeHighlightingChanged(DaemonCodeAnalyzerSettings oldSettings
) {
63 Element rootNew
= new Element(ROOT_TAG
);
64 writeExternal(rootNew
);
65 Element rootOld
= new Element(ROOT_TAG
);
66 oldSettings
.writeExternal(rootOld
);
68 return !JDOMUtil
.areElementsEqual(rootOld
, rootNew
);
70 catch (WriteExternalException e
) {
77 public Object
clone() {
78 DaemonCodeAnalyzerSettings settings
= new DaemonCodeAnalyzerSettings(myManager
);
79 settings
.AUTOREPARSE_DELAY
= AUTOREPARSE_DELAY
;
80 settings
.SHOW_ADD_IMPORT_HINTS
= SHOW_ADD_IMPORT_HINTS
;
81 settings
.SHOW_METHOD_SEPARATORS
= SHOW_METHOD_SEPARATORS
;
82 settings
.NO_AUTO_IMPORT_PATTERN
= NO_AUTO_IMPORT_PATTERN
;
83 settings
.SHOW_SMALL_ICONS_IN_GUTTER
= SHOW_SMALL_ICONS_IN_GUTTER
;
87 public Element
getState() {
88 Element e
= new Element("state");
92 catch (WriteExternalException ex
) {
98 public void loadState(final Element state
) {
102 catch (InvalidDataException e
) {
107 public void readExternal(Element element
) throws InvalidDataException
{
108 DefaultJDOMExternalizer
.readExternal(this, element
);
109 myManager
.getConverter().storeEditorHighlightingProfile(element
);
110 myManager
.setRootProfile(element
.getAttributeValue(PROFILE_ATT
));
113 public void writeExternal(Element element
) throws WriteExternalException
{
114 DefaultJDOMExternalizer
.writeExternal(this, element
);
115 element
.setAttribute(PROFILE_ATT
, myManager
.getRootProfile().getName());
118 public boolean isImportHintEnabled() {
119 return SHOW_ADD_IMPORT_HINTS
;
122 public void setImportHintEnabled(boolean isImportHintEnabled
) {
123 SHOW_ADD_IMPORT_HINTS
= isImportHintEnabled
;