Révision 1331
tmp/org.txm.translate.rcp/src/org/txm/rcp/translate/devtools/FindMessagesToBind.java (revision 1331) | ||
---|---|---|
25 | 25 |
|
26 | 26 |
File report; |
27 | 27 |
PrintWriter writer; |
28 |
boolean searchOnlyExternalized = true; |
|
28 | 29 |
|
29 | 30 |
public FindMessagesToBind(File report) { |
30 | 31 |
this.report = report; |
31 | 32 |
} |
32 | 33 |
|
33 |
private void processSourceFile(File sourceFile) {
|
|
34 |
private int processSourceFile(File sourceFile, boolean searchOnlyExternalized) {
|
|
34 | 35 |
|
36 |
|
|
35 | 37 |
//BufferedReader reader = IOUtils.getReader(sourceFile) |
36 | 38 |
//String line = reader.readLine(); |
39 |
this.searchOnlyExternalized = searchOnlyExternalized; |
|
37 | 40 |
boolean ignore = false; |
38 | 41 |
ArrayList<String> lines = IOUtils.getLines(sourceFile, "UTF-8"); |
39 | 42 |
ArrayList<String> toBind = new ArrayList<String>(); |
40 | 43 |
|
41 |
int n = 0; |
|
44 |
int nLine = 0;
|
|
42 | 45 |
for (String line : lines) { |
43 |
n++; |
|
46 |
nLine++;
|
|
44 | 47 |
//println ""+line |
45 | 48 |
String l = line.trim(); |
46 | 49 |
|
... | ... | |
62 | 65 |
|
63 | 66 |
Matcher m = p1.matcher(l); |
64 | 67 |
if (m.find()) { |
65 |
toBind.add(""+n+"\t"+l); |
|
68 |
toBind.add(""+nLine+"\t"+l);
|
|
66 | 69 |
// System.out.println(sourceFile.getAbsolutePath()+ " " + l); |
67 | 70 |
//System.out.println("1 "+m.group(1)); |
68 | 71 |
} else { |
69 | 72 |
m = p2.matcher(l); |
70 | 73 |
if (m.find()) { |
71 |
toBind.add(""+n+"\t"+l); |
|
74 |
toBind.add(""+nLine+"\t"+l);
|
|
72 | 75 |
// System.out.println(sourceFile.getAbsolutePath()+ " " + l); |
73 | 76 |
//System.out.println("2 "+m.group(2)); |
74 |
} else if (!l.contains("$NON-NLS-")) { |
|
77 |
} else if (!l.contains("$NON-NLS-") && !searchOnlyExternalized) {
|
|
75 | 78 |
m = p3.matcher(l); |
76 | 79 |
if (m.find()) { |
77 |
toBind.add(""+n+"\t"+l); |
|
80 |
toBind.add(""+nLine+"\t"+l);
|
|
78 | 81 |
//System.out.println(sourceFile.getAbsolutePath()+ " " + l); |
79 | 82 |
//System.out.println("2 "+m.group(2)); |
80 | 83 |
} else { |
... | ... | |
92 | 95 |
writer.println("\t"+l); |
93 | 96 |
} |
94 | 97 |
} |
98 |
|
|
99 |
return toBind.size(); |
|
95 | 100 |
} |
96 | 101 |
Pattern p1 = Pattern.compile("("+WorkspaceMessagesManager.KEY_REGEX.pattern()+")( ?\\+)"); |
97 | 102 |
Pattern p2 = Pattern.compile("( ?\\\\+)("+WorkspaceMessagesManager.KEY_REGEX.pattern()+")"); |
... | ... | |
133 | 138 |
LinkedHashMap<File, PluginMessagesManager> h = wmm.getPluginMessages(); |
134 | 139 |
|
135 | 140 |
writer = IOUtils.getWriter(report); |
136 |
|
|
141 |
int total = 0; |
|
137 | 142 |
for (File project : h.keySet()) { |
138 | 143 |
|
139 | 144 |
//System.out.println("Project: "+project); |
... | ... | |
149 | 154 |
if (javaFile.getName().endsWith("Messages.java")) continue; |
150 | 155 |
|
151 | 156 |
//System.out.println(" File: "+javaFile); |
152 |
processSourceFile(javaFile);
|
|
157 |
total += processSourceFile(javaFile, true);
|
|
153 | 158 |
} |
154 | 159 |
} |
155 | 160 |
|
156 | 161 |
writer.close(); |
162 |
|
|
163 |
if (total > 0) { |
|
164 |
System.out.println(""+total+" potential bindinds."); |
|
165 |
} else { |
|
166 |
System.out.println("You are the very best of the very best: nothing to do!"); |
|
167 |
} |
|
157 | 168 |
} |
158 | 169 |
|
159 | 170 |
public static void main(String[] args) throws UnsupportedEncodingException, FileNotFoundException, IOException { |
Formats disponibles : Unified diff