Esempio n. 1
0
 private void cleanBundle(String bundle) {
   String scriptText = getText();
   Lexer lexer = getLexer();
   Iterable<Token> tokens = lexer.getTokens(scriptText);
   List<String> usedImages = new ArrayList<String>();
   boolean inString = false;
   String current;
   for (Token t : tokens) {
     current = t.getValue();
     if (t.getType() == TokenType.Comment) {
       cleanBundleCheckComments(lexer, t.getValue().substring(1), usedImages);
       continue;
     }
     if (t.getType() == TokenType.String_Doc) {
       cleanBundleCheckComments(
           lexer, t.getValue().substring(3, t.getValue().length() - 3), usedImages);
       continue;
     }
     if (!inString) {
       if (!current.isEmpty() && "'\"".contains(current)) {
         inString = true;
       }
       continue;
     }
     if (!current.isEmpty() && "'\"".contains(current)) {
       inString = false;
       continue;
     }
     cleanBundleIsImageUsed(current, usedImages);
   }
   if (usedImages.isEmpty()) {
     return;
   }
   FileManager.deleteNotUsedImages(bundle, usedImages);
 }
Esempio n. 2
0
 private void cleanBundleCheckComments(Lexer lexer, String comment, List<String> usedImages) {
   Iterable<Token> tokens = lexer.getTokens(comment);
   boolean inString = false;
   String current;
   for (Token t : tokens) {
     current = t.getValue();
     if (!inString) {
       if ("'\"".contains(current)) {
         inString = true;
       }
       continue;
     }
     if ("'\"".contains(current)) {
       inString = false;
       continue;
     }
     cleanBundleIsImageUsed(current, usedImages);
   }
 }