コード例 #1
0
 private void insertDocs(File file) {
   try {
     char[] contents = Util.getFileCharContent(file, null);
     String raw = new String(contents);
     StringBuffer modified = new StringBuffer(raw);
     Pattern p =
         Pattern.compile("class (\\w+)"); // FIXME This is picking up code samples and stuff!
     Matcher m = p.matcher(raw);
     while (m.find()) {
       String className = m.group(1);
       if (Character.isLowerCase(className.charAt(0))) continue;
       String originalName = file.getName().substring(0, file.getName().length() - 3);
       if (!className.toLowerCase().equals(originalName)) continue;
       int offset = m.start();
       String before = raw.substring(0, offset).trim();
       if (before.endsWith("=end")) continue; // Already has docs for type
       String docs = getRI(className);
       modified.insert(offset, "=begin\n" + docs + "=end\n");
       //				System.out.println(docs);
     }
     if (modified.length() != raw.length()) write(file, modified);
   } catch (IOException e) {
     // TODO Auto-generated catch block
     e.printStackTrace();
   }
 }
コード例 #2
0
ファイル: IndexManager.java プロジェクト: aptana/rdt
 private char[][] readIndexState(String dirOSString) {
   try {
     char[] savedIndexNames =
         org.rubypeople.rdt.core.util.Util.getFileCharContent(savedIndexNamesFile, null);
     if (savedIndexNames.length > 0) {
       char[][] names = CharOperation.splitOn('\n', savedIndexNames);
       if (names.length > 1) {
         // First line is DiskIndex signature + saved plugin working location (see
         // writeSavedIndexNamesFile())
         String savedSignature = DiskIndex.SIGNATURE + "+" + dirOSString; // $NON-NLS-1$
         if (savedSignature.equals(new String(names[0]))) return names;
       }
     }
   } catch (IOException ignored) {
     if (VERBOSE) Util.verbose("Failed to read saved index file names"); // $NON-NLS-1$
   }
   return null;
 }