calculate prefix for path completion contributor properly
[fedora-idea.git] / platform / lang-impl / src / com / intellij / codeInsight / CodeInsightSettings.java
blob1debf36b3241090dd6e13a2515724beef2585d30
1 /*
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;
19 import com.intellij.openapi.application.PathManager;
20 import com.intellij.openapi.components.*;
21 import com.intellij.openapi.util.DefaultJDOMExternalizer;
22 import com.intellij.openapi.util.InvalidDataException;
23 import com.intellij.openapi.util.WriteExternalException;
24 import com.intellij.openapi.diagnostic.Logger;
25 import com.intellij.util.xmlb.annotations.AbstractCollection;
26 import com.intellij.util.xmlb.annotations.Property;
27 import org.jdom.Element;
28 import org.jetbrains.annotations.NonNls;
29 import org.jetbrains.annotations.NotNull;
30 import org.jetbrains.annotations.Nullable;
32 import java.io.File;
33 import java.util.List;
36 @State(
37 name = "CodeInsightSettings",
38 storages = {
39 @Storage(
40 id ="other",
41 file = "$APP_CONFIG$/editor.codeinsight.xml"
44 public class CodeInsightSettings implements PersistentStateComponent<Element>, Cloneable, ExportableComponent {
45 private static final Logger LOG = Logger.getInstance("#com.intellij.codeInsight.CodeInsightSettings");
47 @NonNls private static final String EXCLUDED_PACKAGE = "EXCLUDED_PACKAGE";
48 @NonNls private static final String ATTRIBUTE_NAME = "NAME";
49 @NonNls public static final String EXTERNAL_FILE_NAME = "editor.codeinsight";
51 public static CodeInsightSettings getInstance() {
52 return ServiceManager.getService(CodeInsightSettings.class);
55 @NotNull
56 public File[] getExportFiles() {
57 return new File[]{PathManager.getOptionsFile(EXTERNAL_FILE_NAME)};
60 @NotNull
61 public String getPresentableName() {
62 return CodeInsightBundle.message("codeinsight.settings");
65 @Nullable
66 public CodeInsightSettings clone() {
67 try {
68 return (CodeInsightSettings)super.clone();
70 catch (CloneNotSupportedException e) {
71 return null;
75 public boolean AUTO_POPUP_MEMBER_LOOKUP = true;
76 public int MEMBER_LOOKUP_DELAY = 1000;
77 public boolean AUTO_POPUP_XML_LOOKUP = true;
78 public int XML_LOOKUP_DELAY = 0;
79 public boolean AUTO_POPUP_PARAMETER_INFO = true;
80 public int PARAMETER_INFO_DELAY = 1000;
81 public boolean AUTO_POPUP_JAVADOC_INFO = false;
82 public int JAVADOC_INFO_DELAY = 1000;
83 public boolean AUTO_POPUP_JAVADOC_LOOKUP = true;
84 public int JAVADOC_LOOKUP_DELAY = 1000;
86 public int COMPLETION_CASE_SENSITIVE = FIRST_LETTER; // ALL, NONE or FIRST_LETTER
87 public static final int ALL = 1;
88 public static final int NONE = 2;
89 public static final int FIRST_LETTER = 3;
91 public boolean AUTOCOMPLETE_ON_CODE_COMPLETION = true;
92 public boolean AUTOCOMPLETE_ON_SMART_TYPE_COMPLETION = true;
93 public boolean AUTOCOMPLETE_ON_CLASS_NAME_COMPLETION = false;
94 public boolean AUTOCOMPLETE_COMMON_PREFIX = true;
95 public boolean SHOW_STATIC_AFTER_INSTANCE = false;
97 public boolean SHOW_FULL_SIGNATURES_IN_PARAMETER_INFO = false;
99 public boolean SMART_INDENT_ON_ENTER = true;
100 public boolean INSERT_BRACE_ON_ENTER = true;
101 public boolean INSERT_SCRIPTLET_END_ON_ENTER = true;
102 public boolean JAVADOC_STUB_ON_ENTER = true;
104 public boolean SMART_END_ACTION = true;
106 public boolean AUTOINSERT_PAIR_BRACKET = true;
107 public boolean AUTOINSERT_PAIR_QUOTE = true;
109 public int REFORMAT_ON_PASTE = INDENT_BLOCK;
110 public static final int NO_REFORMAT = 1;
111 public static final int INDENT_BLOCK = 2;
112 public static final int INDENT_EACH_LINE = 3;
113 public static final int REFORMAT_BLOCK = 4;
115 public int ADD_IMPORTS_ON_PASTE = ASK; // YES, NO or ASK
116 public static final int YES = 1;
117 public static final int NO = 2;
118 public static final int ASK = 3;
120 public boolean HIGHLIGHT_BRACES = true;
121 public boolean HIGHLIGHT_SCOPE = false;
123 public boolean USE_INSTANCEOF_ON_EQUALS_PARAMETER = false;
125 public boolean HIGHLIGHT_IDENTIFIER_UNDER_CARET = false;
127 public boolean OPTIMIZE_IMPORTS_ON_THE_FLY = false;
128 public boolean ADD_UNAMBIGIOUS_IMPORTS_ON_THE_FLY = false;
130 @Property(surroundWithTag = false)
131 @AbstractCollection(
132 surroundWithTag = false,
133 elementTag = "EXCLUDED_PACKAGE",
134 elementValueAttribute = "NAME"
136 public String[] EXCLUDED_PACKAGES = new String[0];
138 public void loadState(final Element state) {
139 try {
140 DefaultJDOMExternalizer.readExternal(this, state);
142 catch (InvalidDataException e) {
143 LOG.info(e);
145 final List list = state.getChildren(EXCLUDED_PACKAGE);
146 EXCLUDED_PACKAGES = new String[list.size()];
147 for(int i=0; i<list.size(); i++) {
148 EXCLUDED_PACKAGES [i] = ((Element) list.get(i)).getAttributeValue(ATTRIBUTE_NAME);
152 public Element getState() {
153 Element element = new Element("state");
154 writeExternal(element);
155 return element;
158 public void writeExternal(final Element element) {
159 try {
160 DefaultJDOMExternalizer.writeExternal(this, element);
162 catch (WriteExternalException e) {
163 LOG.info(e);
165 for(String s: EXCLUDED_PACKAGES) {
166 final Element child = new Element(EXCLUDED_PACKAGE);
167 child.setAttribute(ATTRIBUTE_NAME, s);
168 element.addContent(child);