2626import java .util .ResourceBundle ;
2727
2828/**
29- * @author patrick (4/3/13)
29+ * Loads and extracts all information of Mathematica built-in symbols that are used for completion and intelligent
30+ * code insight.
31+ * @author hal (4/3/13)
3032 */
3133public class SymbolInformationProvider {
3234
33- private static HashMap <String , SymbolInformation > ourSymbols ;
35+ private final static String ourSymbolInformationFile = "/de/halirutan/mathematica/codeinsight/completion/symbolInformationV10_3_1" ;
36+ private final static HashMap <String , SymbolInformation > ourSymbols ;
3437
35- private SymbolInformationProvider () {
36- }
37-
38- private static void initialize () {
38+ private SymbolInformationProvider () {}
3939
40- ResourceBundle info = ResourceBundle . getBundle ( "/de/halirutan/mathematica/codeinsight/completion/symbolInformationV10_0_2" );
40+ static {
4141
42+ ResourceBundle info = ResourceBundle .getBundle (ourSymbolInformationFile );
4243 ourSymbols = new HashMap <String , SymbolInformation >(6000 );
4344
4445 Enumeration <String > names = info .getKeys ();
4546 while (names .hasMoreElements ()) {
4647 String name = names .nextElement ();
48+ String context = name .split ("`" )[0 ] + "`" ;
49+ String nameWithoutContext = name .substring (context .length ());
4750 String parts [] = info .getString (name ).split (";" );
4851
4952 boolean isFunction = false ;
5053 int importance = 0 ;
5154 String attributes [] = {};
52- String shortName = "" ;
5355 String pattern = "" ;
5456 String options [] = {};
5557
@@ -67,10 +69,8 @@ private static void initialize() {
6769 attributes = parts [1 ].trim ().split (" " );
6870 }
6971
70- if (parts .length > 2 ) {
71- shortName = parts [2 ];
72-
73- }
72+ // part 2 is missing because it was used as "ShortName" until everything was refactored and the short name is
73+ // now extracted from the full context name of a symbol
7474
7575 if (parts .length > 3 ) {
7676 pattern = parts [3 ].trim ();
@@ -84,58 +84,37 @@ private static void initialize() {
8484 isFunction = true ;
8585 }
8686
87- ourSymbols .put (name , new SymbolInformation (name , shortName , importance , pattern , isFunction , attributes , options ));
87+ ourSymbols .put (name , new SymbolInformation (name , nameWithoutContext , context , importance , pattern , isFunction , attributes , options ));
8888 }
8989
9090 }
9191
9292 public static HashMap <String , SymbolInformation > getSymbolNames () {
93- if (ourSymbols == null ) {
94- initialize ();
95- }
9693 return ourSymbols ;
9794 }
9895
96+ @ SuppressWarnings ("InstanceVariableNamingConvention" )
9997 public static class SymbolInformation {
10098 public final String name ;
10199 public final int importance ;
102- public final String shortName ;
103100 public final String callPattern ;
104101 public final boolean function ;
105102 public final String attributes [];
106103 public final String options [];
107- public String context = "System" ;
104+ public String context ;
108105 public String nameWithoutContext ;
109106
110- public SymbolInformation (String name , String shortName , int importance , String callPattern , boolean function , String [] attributes , String [] options ) {
111- this .name = name ;
112- this .nameWithoutContext = name ;
113- this .shortName = shortName .length () == 0 ? name : shortName ;
114- this .importance = importance ;
115- this .callPattern = callPattern ;
116- this .function = function ;
117- this .attributes = attributes ;
118- this .options = options ;
119-
120- if (name .contains ("`" )) {
121- context = name .split ("`" )[0 ];
122- nameWithoutContext = name .substring (context .length () + 1 );
123- }
124-
125-
107+ public SymbolInformation (String nameIn , String nameWithoutContextIn , String contextIn , int importanceIn , String callPatternIn , boolean functionIn , String [] attributesIn , String [] optionsIn ) {
108+ this .name = nameIn ;
109+ this .nameWithoutContext = nameWithoutContextIn ;
110+ this .context = contextIn ;
111+ this .importance = importanceIn ;
112+ this .callPattern = callPatternIn ;
113+ this .function = functionIn ;
114+ this .attributes = attributesIn ;
115+ this .options = optionsIn ;
126116 }
127117
128- public SymbolInformation (String name ) {
129- this .name = name ;
130- shortName = name ;
131- importance = 0 ;
132- callPattern = "" ;
133- function = false ;
134- attributes = new String [0 ];
135- options = new String [0 ];
136- }
137-
138-
139118 }
140119
141120}
0 commit comments