Bug 86277 - Format is not executed
Summary: Format is not executed
Status: RESOLVED DUPLICATE of bug 66452
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Text (show other bugs)
Version: 3.0   Edit
Hardware: PC Windows 2000
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: JDT-Text-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-02-23 11:00 EST by Helge Koch CLA
Modified: 2005-02-23 11:03 EST (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Helge Koch CLA 2005-02-23 11:00:06 EST
Version: 3.0.0
Build id: 200406251208

The following source isn't formatted when I select Source|Format. When 
the 'Index.class' expressions in printUsage are removed (or converted to 
Strings by introducing '"') the format works. I hope you are able to find it.

-------- begin source -------
package tms.intranet.search;

import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.Date;

import org.apache.lucene.analysis.standard.StandardAnalyzer;
import org.apache.lucene.demo.HTMLDocument;
import org.apache.lucene.document.Document;
import org.apache.lucene.index.IndexWriter;

/**
 * Creates index for static directory tree.
 * 
 * @author h.koch
 */
public class Index {
  
    
   

  public static void indexDocs(IndexWriter writer, File file)  throws 
IOException, InterruptedException {
    // do not try to index files that cannot be read
    if (file.canRead()) {
      if (file.isDirectory()) {
        String[] files = file.list();
        // an IO error could occur
        if (files != null) {
          for (int i = 0; i < files.length; i++) {
            indexDocs(writer, new File(file, files[i]));
          }
        }
      } else if(filter.accept(file)) {
        System.out.println("adding " + file);
        
        Document doc = null;
        try {
	        if(htmlFilter.accept(file)) {
	            doc = HTMLDocument.Document(file);
	        } else {
	            doc = MiscFileDocument.Document(file);
	        }
        
	        writer.addDocument(doc);
        } catch (FileNotFoundException fnfe) {
            // at least on windows, some temporary files raise this exception
            // with an "access denied" message
            // checking if the file can be read doesn't help
          ;
        }
      }
    }
  }

    
	private static void printUsage() {
	    System.out.println("Usage: " + Index.class + " <relative path to 
root dir> <path to index dir>");
	    System.out.println("Example:");
	    System.out.println("From a subdirectory of your htdocs dir call");
	    System.out.println("java " + Index.class 
+ " .. /usr/local/share/search/index");
	    System.out.println("to place an index 
in /usr/local/share/search/index (must exist)");
	}    
	
	private static final IndexFileFilter filter = new IndexFileFilter();
	private static final HTMLFileFilter htmlFilter = new HTMLFileFilter();
	
}

----- end source ------------
Comment 1 Dani Megert CLA 2005-02-23 11:03:40 EST

*** This bug has been marked as a duplicate of 66452 ***