[prev in list] [next in list] [prev in thread] [next in thread] 

List:       jedit-cvs
Subject:    [ jEdit-commits ] SF.net SVN: jedit:[19516]
From:       daleanson () users ! sourceforge ! net
Date:       2011-04-20 18:11:55
Message-ID: E1QCbsZ-0001dp-8z () sfp-svn-3 ! v30 ! ch3 ! sourceforge ! com
[Download RAW message or body]

Revision: 19516
          http://jedit.svn.sourceforge.net/jedit/?rev=19516&view=rev
Author:   daleanson
Date:     2011-04-20 18:11:54 +0000 (Wed, 20 Apr 2011)

Log Message:
-----------
Switched out the input stream for a string reader and grabbing all the text at once. \
This helps keep asset offsets more accurate. Also did a little code clean up.

Modified Paths:
--------------
    plugins/JavaSideKick/trunk/src/sidekick/java/JavaParser.java

Modified: plugins/JavaSideKick/trunk/src/sidekick/java/JavaParser.java
===================================================================
--- plugins/JavaSideKick/trunk/src/sidekick/java/JavaParser.java	2011-04-20 17:59:59 \
                UTC (rev 19515)
+++ plugins/JavaSideKick/trunk/src/sidekick/java/JavaParser.java	2011-04-20 18:11:54 \
UTC (rev 19516) @@ -136,7 +136,7 @@
      * @param buffer the buffer to parse
      */
     public SideKickParsedData parse( Buffer buffer, DefaultErrorSource errorSource ) \
                {
-        ByteArrayInputStream input = null;
+        Reader input = null;
         String filename = buffer.getPath();
         SideKickParsedData parsedData = new JavaSideKickParsedData( filename );
         DefaultMutableTreeNode root = parsedData.root;
@@ -154,7 +154,8 @@
             // 1) a modifed buffer can be parsed without a save
             // 2) reading the buffer should be faster than reading from the file, \
                and
             // 3) jEdit has that 'gzip file on disk' option which won't parse.
-            input = new ByteArrayInputStream( buffer.getText( 0, buffer.getLength() \
).getBytes() ); +            String contents = buffer.getText(0, buffer.getLength());
+            input = new StringReader(contents);
             parser = new TigerParser( input );
             int tab_size = buffer.getTabSize();
             switch ( parser_type ) {
@@ -202,23 +203,6 @@
 
             // show constructors, fields, methods, etc
             addChildren( root, buffer, expansionModel );
-            /*
-            if ( compilationUnit.getChildren() != null ) {
-            Collections.sort( compilationUnit.getChildren(), nodeSorter );
-                for ( Iterator it = compilationUnit.getChildren().iterator(); \
                it.hasNext(); ) {
-                    TigerNode child = ( TigerNode ) it.next();
-
-                    if ( canShow( child ) ) {
-                        child.setStart( ElementUtil.createStartPosition( buffer, \
                child ) );
-                        child.setEnd( ElementUtil.createEndPosition( buffer, child ) \
                );
-                        DefaultMutableTreeNode cuChild = new DefaultMutableTreeNode( \
                child );
-                        root.add( cuChild );
-                        expansionModel.add();   // class node
-                        addChildren( buffer, cuChild, child, expansionModel );
-                    }
-                }
-                }
-                */
         }
         catch ( ParseException e ) {    // NOPMD
             // removed exception handling, all ParseExceptions are now caught
@@ -233,7 +217,7 @@
                 input.close();
             }
             catch ( Exception e ) {     // NOPMD
-                // not to worry
+                // not to worry, StringReader won't actually throw an exception.
             }
         }
 
@@ -275,14 +259,14 @@
 				// This is a fix for hard tabs
 				// Hard tabs mess up column counting, so this would occasionally cause \
out-of-index errors  int tab = (Integer) buffer.getMode().getProperty("tabSize");
-				String sub = "";
+				StringBuilder sub = new StringBuilder();
 				for (int i = 0; i < tab; i++) {
-					sub += " ";
+					sub.append(" ");
 				}
 				String startLineText = buffer.getLineText(range.startLine);
 				int index;
-				while ((index = startLineText.indexOf("\t")) != -1) {
-					startLineText = startLineText.replace("\t", sub);
+				while ((index = startLineText.indexOf('\t')) != -1) {
+					startLineText = startLineText.replace("\t", sub.toString());
 					if (range.startColumn > index) range.startColumn -= (tab-1);
 					if (range.endColumn > index) range.endColumn -= (tab-1);
 				}


This was sent by the SourceForge.net collaborative development platform, the world's \
largest Open Source development site.

------------------------------------------------------------------------------
Benefiting from Server Virtualization: Beyond Initial Workload 
Consolidation -- Increasing the use of server virtualization is a top
priority.Virtualization can reduce costs, simplify management, and improve 
application availability and disaster protection. Learn more about boosting 
the value of server virtualization. http://p.sf.net/sfu/vmware-sfdev2dev
_______________________________________________
jEdit-CVS mailing list
jEdit-CVS@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jedit-cvs


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic