Révision 1242
tmp/org.txm.translate.rcp/src/org/txm/rcp/translate/i18n/PluginMessages.java (revision 1242) | ||
---|---|---|
166 | 166 |
this.usedKeysIndex.put(key, files); |
167 | 167 |
|
168 | 168 |
if(debug) { |
169 |
System.out.println("PluginMessages.createUsedKeysIndex(): cheking key " + key + "...");
|
|
169 |
System.out.println("PluginMessages.createUsedKeysIndex(): looking for key " + this.getKeyFullName(key) + " in project source files...");
|
|
170 | 170 |
} |
171 | 171 |
|
172 | 172 |
for (File file : this.srcFiles) { |
... | ... | |
204 | 204 |
} |
205 | 205 |
} |
206 | 206 |
|
207 |
// /*** |
|
208 |
// * Returns all source files using the specified message key (except the main Java message file). |
|
209 |
// * @param key |
|
210 |
// * @return |
|
211 |
// */ |
|
212 |
// public HashMap<File, String> getFilesUsingKey(String key) { |
|
213 |
// |
|
214 |
// HashMap<File, String> files = new HashMap<File, String>(); |
|
215 |
// |
|
216 |
// for (File file : this.srcFiles) { |
|
217 |
// ArrayList<String> lines = IOUtils.getLines(file, PluginMessages.ENCODING); |
|
218 |
// |
|
219 |
// for (String line : lines) { |
|
220 |
// if(line.contains(key)) { |
|
221 |
// files.put(file, key); |
|
222 |
// }; |
|
223 |
// |
|
224 |
// } |
|
225 |
// } |
|
226 |
// |
|
227 |
// return files; |
|
228 |
// } |
|
229 |
// |
|
230 |
// |
|
207 |
/*** |
|
208 |
* Returns all source files using the specified message key (except the main Java message file). |
|
209 |
* @param key |
|
210 |
* @return |
|
211 |
*/ |
|
212 |
public TreeSet<File> getFilesUsingKey(String key) { |
|
213 |
return this.usedKeysIndex.get(key); |
|
214 |
} |
|
215 |
|
|
216 |
|
|
231 | 217 |
/** |
232 | 218 |
* Returns the keys of all messages that are not used in the project itself. |
233 | 219 |
* @return a sorted list containing all unused keys |
234 | 220 |
*/ |
235 |
public ArrayList<String> findUnusedKeys() {
|
|
221 |
public ArrayList<String> getUnusedKeys() {
|
|
236 | 222 |
ArrayList<String> unusedKeys = new ArrayList<String>(); |
237 | 223 |
for (Map.Entry<String, TreeSet<File>> entry : this.usedKeysIndex.entrySet()) { |
238 | 224 |
if(entry.getValue().isEmpty()) { |
... | ... | |
511 | 497 |
PluginMessages pmManager = new PluginMessages(projectFile, messageFile); |
512 | 498 |
|
513 | 499 |
// test to find files using the specified key |
514 |
// HashMap<File, String> files = pmManager.getFilesUsingKey("Base_5"); |
|
515 |
// for (Map.Entry<File, String> entry : files.entrySet()) { |
|
516 |
// System.out.println("find files using key: file " + entry.getKey() + " contains key " + entry.getValue()); |
|
517 |
// } |
|
518 |
// |
|
500 |
String key = "Base_0"; |
|
501 |
TreeSet<File> files = pmManager.getFilesUsingKey(key); |
|
502 |
System.out.println("getFilesUsingKey: files using key: " + key); |
|
503 |
for(File file : files) { |
|
504 |
System.out.println(" file(s): " + file); |
|
505 |
} |
|
506 |
key = "common_frequency"; |
|
507 |
files = pmManager.getFilesUsingKey(key); |
|
508 |
System.out.println("getFilesUsingKey: files using key: " + key); |
|
509 |
for(File file : files) { |
|
510 |
System.out.println(" file(s): " + file); |
|
511 |
} |
|
512 |
|
|
513 |
|
|
519 | 514 |
// test to find unused keys |
520 |
ArrayList<String> unusedKeys = pmManager.findUnusedKeys();
|
|
515 |
ArrayList<String> unusedKeys = pmManager.getUnusedKeys();
|
|
521 | 516 |
for (int i = 0; i < unusedKeys.size(); i++) { |
522 | 517 |
System.out.println("findUnusedKeys: key " + unusedKeys.get(i) + " is unused in project " + pmManager.getProjectDirectory() + " (main language value = " + pmManager.getMessagesForLang("").get(unusedKeys.get(i)) + ")"); |
523 | 518 |
} |
Formats disponibles : Unified diff