|
From: David C. <dc...@us...> - 2005-10-02 19:00:35
|
Update of /cvsroot/rubyeclipse/org.rubypeople.eclipse.shams/src/org/rubypeople/eclipse/shams/resources In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8707/src/org/rubypeople/eclipse/shams/resources Modified Files: ShamFile.java Log Message: Refactored RubyBuilder into several smaller classes. Wrote UTs for a few of them. Began work on a SymbolIndex. Index: ShamFile.java =================================================================== RCS file: /cvsroot/rubyeclipse/org.rubypeople.eclipse.shams/src/org/rubypeople/eclipse/shams/resources/ShamFile.java,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** ShamFile.java 13 Jul 2005 14:29:45 -0000 1.12 --- ShamFile.java 1 Oct 2005 23:00:50 -0000 1.13 *************** *** 4,10 **** --- 4,13 ---- import java.io.FileInputStream; import java.io.FileNotFoundException; + import java.io.IOException; import java.io.InputStream; import java.io.Reader; + import junit.framework.Assert; + import org.eclipse.core.resources.IContainer; import org.eclipse.core.resources.IFile; *************** *** 24,32 **** public class ShamFile extends ShamResource implements IFile { ! protected String contents = ""; protected boolean readContentFromFile; public void setCharset(String newCharset, IProgressMonitor monitor) ! throws CoreException { } --- 27,37 ---- public class ShamFile extends ShamResource implements IFile { ! ! protected String contents = ""; protected boolean readContentFromFile; + private InputStream inputStream; public void setCharset(String newCharset, IProgressMonitor monitor) ! throws CoreException { } *************** *** 70,82 **** if (readContentFromFile) { try { ! return new FileInputStream(this.path.toString()); } catch (FileNotFoundException e) { throw new RuntimeException(e.toString()); } } ! return new ByteArrayInputStream(contents.getBytes()); } ! public InputStream getContents(boolean force) throws CoreException { return getContents(); } --- 75,97 ---- if (readContentFromFile) { try { ! return openStream(new FileInputStream(this.path.toString())); } catch (FileNotFoundException e) { throw new RuntimeException(e.toString()); } } ! return openStream(new ByteArrayInputStream(contents.getBytes())); } ! private InputStream openStream(InputStream newStream) { ! Assert.assertNull("Unexpected second opening of stream", inputStream); ! inputStream = new MonitoredInputStream(newStream); ! return inputStream; ! } ! ! public void assertContentStreamClosed() { ! Assert.assertNull("Unexpected found open stream", inputStream); ! } ! ! public InputStream getContents(boolean force) throws CoreException { return getContents(); } *************** *** 324,326 **** --- 339,359 ---- } + + private class MonitoredInputStream extends InputStream { + + private final InputStream inputStream; + + public MonitoredInputStream(InputStream inputStream) { + this.inputStream = inputStream; + } + + public int read() throws IOException { + return inputStream.read(); + } + + public void close() throws IOException { + super.close(); + ShamFile.this.inputStream = null; + } + } } |