A massive organize imports and formatting of the sources using default Eclipse code...
[phpeclipse.git] / net.sourceforge.phpeclipse / src / net / sourceforge / phpdt / internal / codeassist / impl / AssistOptions.java
1 /*******************************************************************************
2  * Copyright (c) 2000, 2004 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials 
4  * are made available under the terms of the Common Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/cpl-v10.html
7  * 
8  * Contributors:
9  *     IBM Corporation - initial API and implementation
10  *******************************************************************************/
11 package net.sourceforge.phpdt.internal.codeassist.impl;
12
13 import java.util.Map;
14
15 import net.sourceforge.phpdt.core.compiler.CharOperation;
16
17 public class AssistOptions {
18         /**
19          * Option IDs
20          */
21         public static final String OPTION_PerformVisibilityCheck = "net.sourceforge.phpdt.core.codeComplete.visibilityCheck"; //$NON-NLS-1$
22
23         public static final String OPTION_ForceImplicitQualification = "net.sourceforge.phpdt.core.codeComplete.forceImplicitQualification"; //$NON-NLS-1$
24
25         public static final String OPTION_FieldPrefixes = "net.sourceforge.phpdt.core.codeComplete.fieldPrefixes"; //$NON-NLS-1$
26
27         public static final String OPTION_StaticFieldPrefixes = "net.sourceforge.phpdt.core.codeComplete.staticFieldPrefixes"; //$NON-NLS-1$
28
29         public static final String OPTION_LocalPrefixes = "net.sourceforge.phpdt.core.codeComplete.localPrefixes"; //$NON-NLS-1$
30
31         public static final String OPTION_ArgumentPrefixes = "net.sourceforge.phpdt.core.codeComplete.argumentPrefixes"; //$NON-NLS-1$
32
33         public static final String OPTION_FieldSuffixes = "net.sourceforge.phpdt.core.codeComplete.fieldSuffixes"; //$NON-NLS-1$
34
35         public static final String OPTION_StaticFieldSuffixes = "net.sourceforge.phpdt.core.codeComplete.staticFieldSuffixes"; //$NON-NLS-1$
36
37         public static final String OPTION_LocalSuffixes = "net.sourceforge.phpdt.core.codeComplete.localSuffixes"; //$NON-NLS-1$
38
39         public static final String OPTION_ArgumentSuffixes = "net.sourceforge.phpdt.core.codeComplete.argumentSuffixes"; //$NON-NLS-1$
40
41         public static final String ENABLED = "enabled"; //$NON-NLS-1$
42
43         public static final String DISABLED = "disabled"; //$NON-NLS-1$
44
45         public boolean checkVisibility = false;
46
47         public boolean forceImplicitQualification = false;
48
49         public char[][] fieldPrefixes = null;
50
51         public char[][] staticFieldPrefixes = null;
52
53         public char[][] localPrefixes = null;
54
55         public char[][] argumentPrefixes = null;
56
57         public char[][] fieldSuffixes = null;
58
59         public char[][] staticFieldSuffixes = null;
60
61         public char[][] localSuffixes = null;
62
63         public char[][] argumentSuffixes = null;
64
65         /**
66          * Initializing the assist options with default settings
67          */
68         public AssistOptions() {
69                 // Initializing the assist options with default settings
70         }
71
72         /**
73          * Initializing the assist options with external settings
74          */
75         public AssistOptions(Map settings) {
76                 if (settings == null)
77                         return;
78
79                 set(settings);
80         }
81
82         public void set(Map optionsMap) {
83
84                 Object optionValue;
85                 if ((optionValue = optionsMap.get(OPTION_PerformVisibilityCheck)) != null) {
86                         if (ENABLED.equals(optionValue)) {
87                                 this.checkVisibility = true;
88                         } else if (DISABLED.equals(optionValue)) {
89                                 this.checkVisibility = false;
90                         }
91                 }
92                 if ((optionValue = optionsMap.get(OPTION_ForceImplicitQualification)) != null) {
93                         if (ENABLED.equals(optionValue)) {
94                                 this.forceImplicitQualification = true;
95                         } else if (DISABLED.equals(optionValue)) {
96                                 this.forceImplicitQualification = false;
97                         }
98                 }
99                 if ((optionValue = optionsMap.get(OPTION_FieldPrefixes)) != null) {
100                         if (optionValue instanceof String) {
101                                 String stringValue = (String) optionValue;
102                                 if (stringValue.length() > 0) {
103                                         this.fieldPrefixes = CharOperation.splitAndTrimOn(',',
104                                                         stringValue.toCharArray());
105                                 } else {
106                                         this.fieldPrefixes = null;
107                                 }
108                         }
109                 }
110                 if ((optionValue = optionsMap.get(OPTION_StaticFieldPrefixes)) != null) {
111                         if (optionValue instanceof String) {
112                                 String stringValue = (String) optionValue;
113                                 if (stringValue.length() > 0) {
114                                         this.staticFieldPrefixes = CharOperation.splitAndTrimOn(
115                                                         ',', stringValue.toCharArray());
116                                 } else {
117                                         this.staticFieldPrefixes = null;
118                                 }
119                         }
120                 }
121                 if ((optionValue = optionsMap.get(OPTION_LocalPrefixes)) != null) {
122                         if (optionValue instanceof String) {
123                                 String stringValue = (String) optionValue;
124                                 if (stringValue.length() > 0) {
125                                         this.localPrefixes = CharOperation.splitAndTrimOn(',',
126                                                         stringValue.toCharArray());
127                                 } else {
128                                         this.localPrefixes = null;
129                                 }
130                         }
131                 }
132                 if ((optionValue = optionsMap.get(OPTION_ArgumentPrefixes)) != null) {
133                         if (optionValue instanceof String) {
134                                 String stringValue = (String) optionValue;
135                                 if (stringValue.length() > 0) {
136                                         this.argumentPrefixes = CharOperation.splitAndTrimOn(',',
137                                                         stringValue.toCharArray());
138                                 } else {
139                                         this.argumentPrefixes = null;
140                                 }
141                         }
142                 }
143                 if ((optionValue = optionsMap.get(OPTION_FieldSuffixes)) != null) {
144                         if (optionValue instanceof String) {
145                                 String stringValue = (String) optionValue;
146                                 if (stringValue.length() > 0) {
147                                         this.fieldSuffixes = CharOperation.splitAndTrimOn(',',
148                                                         stringValue.toCharArray());
149                                 } else {
150                                         this.fieldSuffixes = null;
151                                 }
152                         }
153                 }
154                 if ((optionValue = optionsMap.get(OPTION_StaticFieldSuffixes)) != null) {
155                         if (optionValue instanceof String) {
156                                 String stringValue = (String) optionValue;
157                                 if (stringValue.length() > 0) {
158                                         this.staticFieldSuffixes = CharOperation.splitAndTrimOn(
159                                                         ',', stringValue.toCharArray());
160                                 } else {
161                                         this.staticFieldSuffixes = null;
162                                 }
163                         }
164                 }
165                 if ((optionValue = optionsMap.get(OPTION_LocalSuffixes)) != null) {
166                         if (optionValue instanceof String) {
167                                 String stringValue = (String) optionValue;
168                                 if (stringValue.length() > 0) {
169                                         this.localSuffixes = CharOperation.splitAndTrimOn(',',
170                                                         stringValue.toCharArray());
171                                 } else {
172                                         this.localSuffixes = null;
173                                 }
174                         }
175                 }
176                 if ((optionValue = optionsMap.get(OPTION_ArgumentSuffixes)) != null) {
177                         if (optionValue instanceof String) {
178                                 String stringValue = (String) optionValue;
179                                 if (stringValue.length() > 0) {
180                                         this.argumentSuffixes = CharOperation.splitAndTrimOn(',',
181                                                         stringValue.toCharArray());
182                                 } else {
183                                         this.argumentSuffixes = null;
184                                 }
185                         }
186                 }
187         }
188 }