Update of /cvsroot/rubyeclipse/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/runtime
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13347/src/org/rubypeople/rdt/core/runtime
Added Files:
RubyContentDescriber.java
Log Message:
add a RubyContentDescriber which describes ruby source files. Add OSGi Bundling stuff (like MANIFEST.MF) to support the content describer (which must be able to be loaded without auto-loading the entire plugin)
--- NEW FILE: RubyContentDescriber.java ---
package org.rubypeople.rdt.core.runtime;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.Reader;
import org.eclipse.core.runtime.QualifiedName;
import org.eclipse.core.runtime.content.IContentDescription;
import org.eclipse.core.runtime.content.ITextContentDescriber;
public class RubyContentDescriber implements ITextContentDescriber {
/*
* (non-Javadoc)
* @see org.eclipse.core.runtime.content.ITextContentDescriber#describe(java.io.Reader, org.eclipse.core.runtime.content.IContentDescription)
*/
public int describe(Reader contents, IContentDescription description) throws IOException {
BufferedReader reader = new BufferedReader(contents);
// Skip all empty lines and find first line with characters
String firstLine = "";
while(firstLine.trim().length() == 0) {
firstLine = reader.readLine();
if (firstLine == null) return ITextContentDescriber.INVALID;
}
if (firstLine.indexOf("ruby") > -1 && firstLine.indexOf("#!") > -1)
return ITextContentDescriber.VALID;
return ITextContentDescriber.INVALID;
}
/*
* (non-Javadoc)
* @see org.eclipse.core.runtime.content.IContentDescriber#describe(java.io.InputStream, org.eclipse.core.runtime.content.IContentDescription)
*/
public int describe(InputStream contents, IContentDescription description) throws IOException {
Reader reader = new InputStreamReader(contents);
return describe(reader, description);
}
/*
* (non-Javadoc)
* @see org.eclipse.core.runtime.content.IContentDescriber#getSupportedOptions()
*/
public QualifiedName[] getSupportedOptions() {
// TODO Auto-generated method stub
return null;
}
}
|