2 * Copyright 2000-2009 JetBrains s.r.o.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 package com
.intellij
.codeInsight
.daemon
;
19 import com
.intellij
.openapi
.application
.PathManager
;
20 import com
.intellij
.openapi
.components
.*;
21 import com
.intellij
.openapi
.diagnostic
.Logger
;
22 import com
.intellij
.openapi
.util
.DefaultJDOMExternalizer
;
23 import com
.intellij
.openapi
.util
.InvalidDataException
;
24 import com
.intellij
.openapi
.util
.JDOMUtil
;
25 import com
.intellij
.openapi
.util
.WriteExternalException
;
26 import com
.intellij
.profile
.codeInspection
.InspectionProfileManager
;
27 import org
.jdom
.Element
;
28 import org
.jetbrains
.annotations
.NonNls
;
29 import org
.jetbrains
.annotations
.NotNull
;
34 name
="DaemonCodeAnalyzerSettings",
38 file
= "$APP_CONFIG$/editor.codeinsight.xml"
41 public class DaemonCodeAnalyzerSettings
implements PersistentStateComponent
<Element
>, Cloneable
, ExportableComponent
{
42 private static final Logger LOG
= Logger
.getInstance("#com.intellij.codeInsight.daemon.DaemonCodeAnalyzerSettings");
43 @NonNls private static final String ROOT_TAG
= "root";
44 @NonNls private static final String PROFILE_ATT
= "profile";
45 @NonNls public static final String DEFAULT_PROFILE_ATT
= "Default";
46 @NonNls public static final String PROFILE_COPY_NAME
= "copy";
47 private final InspectionProfileManager myManager
;
50 public DaemonCodeAnalyzerSettings(InspectionProfileManager manager
) {
54 public static DaemonCodeAnalyzerSettings
getInstance() {
55 return ServiceManager
.getService(DaemonCodeAnalyzerSettings
.class);
59 public File
[] getExportFiles() {
60 return new File
[]{PathManager
.getOptionsFile("editor.codeinsight")};
64 public String
getPresentableName() {
65 return DaemonBundle
.message("error.highlighting.settings");
68 public boolean NEXT_ERROR_ACTION_GOES_TO_ERRORS_FIRST
= false;
69 public int AUTOREPARSE_DELAY
= 300;
70 public boolean SHOW_ADD_IMPORT_HINTS
= true;
71 @NonNls public String NO_AUTO_IMPORT_PATTERN
= "[a-z].?";
72 public boolean SUPPRESS_WARNINGS
= true;
73 public boolean SHOW_METHOD_SEPARATORS
= false;
74 public int ERROR_STRIPE_MARK_MIN_HEIGHT
= 3;
75 public boolean SHOW_SMALL_ICONS_IN_GUTTER
= true;
77 public boolean isCodeHighlightingChanged(DaemonCodeAnalyzerSettings oldSettings
) {
79 Element rootNew
= new Element(ROOT_TAG
);
80 writeExternal(rootNew
);
81 Element rootOld
= new Element(ROOT_TAG
);
82 oldSettings
.writeExternal(rootOld
);
84 return !JDOMUtil
.areElementsEqual(rootOld
, rootNew
);
86 catch (WriteExternalException e
) {
93 public Object
clone() {
94 DaemonCodeAnalyzerSettings settings
= new DaemonCodeAnalyzerSettings(myManager
);
95 settings
.AUTOREPARSE_DELAY
= AUTOREPARSE_DELAY
;
96 settings
.SHOW_ADD_IMPORT_HINTS
= SHOW_ADD_IMPORT_HINTS
;
97 settings
.SHOW_METHOD_SEPARATORS
= SHOW_METHOD_SEPARATORS
;
98 settings
.NO_AUTO_IMPORT_PATTERN
= NO_AUTO_IMPORT_PATTERN
;
99 settings
.SHOW_SMALL_ICONS_IN_GUTTER
= SHOW_SMALL_ICONS_IN_GUTTER
;
103 public Element
getState() {
104 Element e
= new Element("state");
108 catch (WriteExternalException ex
) {
114 public void loadState(final Element state
) {
118 catch (InvalidDataException e
) {
123 public void readExternal(Element element
) throws InvalidDataException
{
124 DefaultJDOMExternalizer
.readExternal(this, element
);
125 myManager
.getConverter().storeEditorHighlightingProfile(element
);
126 myManager
.setRootProfile(element
.getAttributeValue(PROFILE_ATT
));
129 public void writeExternal(Element element
) throws WriteExternalException
{
130 DefaultJDOMExternalizer
.writeExternal(this, element
);
131 element
.setAttribute(PROFILE_ATT
, myManager
.getRootProfile().getName());
134 public boolean isImportHintEnabled() {
135 return SHOW_ADD_IMPORT_HINTS
;
138 public void setImportHintEnabled(boolean isImportHintEnabled
) {
139 SHOW_ADD_IMPORT_HINTS
= isImportHintEnabled
;