From: <dal...@us...> - 2007-01-17 04:26:36
|
Revision: 8602 http://svn.sourceforge.net/jedit/?rev=8602&view=rev Author: daleanson Date: 2007-01-16 20:26:35 -0800 (Tue, 16 Jan 2007) Log Message: ----------- fix for 1634163, completion for java.lang and other runtime classes Modified Paths: -------------- plugins/JavaSideKick/trunk/JavaSideKick.props plugins/JavaSideKick/trunk/src/sidekick/java/JavaCompletionFinder.java plugins/JavaSideKick/trunk/src/sidekick/java/JavaParser.java plugins/JavaSideKick/trunk/src/sidekick/java/PVHelper.java Modified: plugins/JavaSideKick/trunk/JavaSideKick.props =================================================================== --- plugins/JavaSideKick/trunk/JavaSideKick.props 2007-01-16 23:02:58 UTC (rev 8601) +++ plugins/JavaSideKick/trunk/JavaSideKick.props 2007-01-17 04:26:35 UTC (rev 8602) @@ -6,7 +6,7 @@ plugin.sidekick.java.JavaSideKickPlugin.activate=defer plugin.sidekick.java.JavaSideKickPlugin.name=JavaSideKick plugin.sidekick.java.JavaSideKickPlugin.author=Dale Anson, Andre Kaplan, George Latkiewicz -plugin.sidekick.java.JavaSideKickPlugin.version=2.3.2 +plugin.sidekick.java.JavaSideKickPlugin.version=2.3.3 # docs plugin.sidekick.java.JavaSideKickPlugin.docs=docs/index.html Modified: plugins/JavaSideKick/trunk/src/sidekick/java/JavaCompletionFinder.java =================================================================== --- plugins/JavaSideKick/trunk/src/sidekick/java/JavaCompletionFinder.java 2007-01-16 23:02:58 UTC (rev 8601) +++ plugins/JavaSideKick/trunk/src/sidekick/java/JavaCompletionFinder.java 2007-01-17 04:26:35 UTC (rev 8602) @@ -218,9 +218,9 @@ } // could have package.partialClass, e.g. javax.swing.tree.DefaultMu - List possibles = Locator.getClassPathClasses( word ); + List possibles = Locator.getInstance().getClassPathClasses( word ); if ( possibles == null || possibles.size() == 0 ) - possibles = Locator.getRuntimeClasses( word ); + possibles = Locator.getInstance().getRuntimeClasses( word ); if ( possibles != null && possibles.size() > 0 ) { if ( possibles.size() == 1 && possibles.get( 0 ).equals( word ) ) { return null; @@ -511,11 +511,11 @@ // check classpath /// TODO: use setting from pv option pane on whether or not to do this - String className = Locator.getClassPathClassName( type ); + String className = Locator.getInstance().getClassPathClassName( type ); Class c = validateClassName( className, type, filename ); if ( c == null ) { // check runtime - className = Locator.getRuntimeClassName( type ); + className = Locator.getInstance().getRuntimeClassName( type ); c = validateClassName( className, type, filename ); } Modified: plugins/JavaSideKick/trunk/src/sidekick/java/JavaParser.java =================================================================== --- plugins/JavaSideKick/trunk/src/sidekick/java/JavaParser.java 2007-01-16 23:02:58 UTC (rev 8601) +++ plugins/JavaSideKick/trunk/src/sidekick/java/JavaParser.java 2007-01-17 04:26:35 UTC (rev 8602) @@ -65,11 +65,22 @@ private DefaultErrorSource myErrorSource = JavaSideKickPlugin.ERROR_SOURCE; + /** + * Defaults to parsing java files. + + */ + public JavaParser() { this( JAVA_PARSER ); } + /** + + * @param type one of 'java' or 'javacc' + + */ + public JavaParser( int type ) { super( type == JAVA_PARSER ? "java" : "javacc" ); loadOptions(); @@ -117,27 +128,52 @@ super.deactivate( editPane ); } + /** + + * Reparse if the option settings have changed. + + */ + public void handleMessage( EBMessage msg ) { if ( ( msg instanceof PropertiesChanged ) && loadOptions() ) { parse(); } } + /** + + * Parse the current buffer in the current view. + + */ + public void parse() { if ( currentView != null ) { parse( currentView.getBuffer(), null ); } } + /** + + * Parse the given buffer. + + * TODO: can this be adapted to parse say java code from within a jsp file? + * @param buffer the buffer to parse. + + * @return a CUNode representing a java compilation unit. + */ + public CUNode parse( Buffer buffer ) { ByteArrayInputStream input = null; String filename = buffer.getPath(); TigerParser parser = null; CUNode compilationUnit = null; try { + // read the buffer input = new ByteArrayInputStream( buffer.getText( 0, buffer.getLength() ).getBytes() ); parser = new TigerParser( input ); int tab_size = buffer.getTabSize(); + + // do the parse switch ( parser_type ) { case JAVACC_PARSER: compilationUnit = parser.getJavaCCRootNode( tab_size ); @@ -146,6 +182,8 @@ compilationUnit = parser.getJavaRootNode( tab_size ); break; } + + // set some properties compilationUnit.setName( buffer.getName() ); compilationUnit.setResults( parser.getResults() ); compilationUnit.setStart( createStartPosition( buffer, compilationUnit ) ); @@ -248,20 +286,8 @@ } catch ( ParseException e ) { - // remove? I don't this the ever actually happens anymore, I think - // all ParseExceptions are now caught and accumulated in the parser. - // I think this is a hold-over from JBrowse. - /* - if ( displayOpt.getShowErrors() && errorSource != null ) { - ErrorNode eu = new ErrorNode( e ); - eu.setName( buffer.getName() ); - root.setUserObject( eu ); - String msg = e.getMessage(); - root.add( new DefaultMutableTreeNode( "<html><font color=red>" + msg ) ); - Range range = getExceptionLocation( e ); - errorSource.addError( ErrorSource.ERROR, buffer.getPath(), range.startLine, range.startColumn, range.endColumn, e.getMessage() ); - } - */ + // removed exception handling, all ParseExceptions are now caught + // and accumulated in the parser, then dealt with in handleErrors. } finally { try { @@ -286,7 +312,8 @@ /* only show errors for java files. If the default edit mode is "java" then by default, the parser will be invoked by SideKick. It's annoying to get parse error messages for files that aren't actually java files. Do parse buffers that have yet to be saved, they - might be java files eventually. Otherwise, require a ".java" extension on the file. */ + might be java or javacc files eventually. Otherwise, require a ".java" extension on + the file. */ if ( displayOpt.getShowErrors() && ( ( buffer.getPath() == null || buffer.getPath().endsWith( ".java" ) ) || buffer.getMode().getName().equals( "javacc" ) ) ) { for ( Iterator it = parser.getErrors().iterator(); it.hasNext(); ) { ErrorNode en = ( ErrorNode ) it.next(); Modified: plugins/JavaSideKick/trunk/src/sidekick/java/PVHelper.java =================================================================== --- plugins/JavaSideKick/trunk/src/sidekick/java/PVHelper.java 2007-01-16 23:02:58 UTC (rev 8601) +++ plugins/JavaSideKick/trunk/src/sidekick/java/PVHelper.java 2007-01-17 04:26:35 UTC (rev 8602) @@ -1,5 +1,34 @@ +/* +Copyright (c) 21st century, Dale Anson +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +* Redistributions of source code must retain the above copyright notice, +this list of conditions and the following disclaimer. +* Redistributions in binary form must reproduce the above copyright notice, +this list of conditions and the following disclaimer in the documentation +and/or other materials provided with the distribution. +* Neither the name of the <SOME OBSCURE ORGANIZATION> nor the names of its +contributors (whoever they may be) may be used to endorse or promote products +derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON +ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + package sidekick.java; +import java.io.File; import java.util.*; import org.gjt.sp.jedit.*; import projectviewer.*; @@ -9,6 +38,9 @@ public class PVHelper { + /** + * @return the name of the project containing the given filename + */ public static String getProjectNameForFile( String filename ) { if (!isProjectViewerAvailable()) return null; @@ -23,11 +55,17 @@ return null; } + /** + * @return true if the ProjectViewer plugin is loaded + */ public static boolean isProjectViewerAvailable() { EditPlugin pv = jEdit.getPlugin( "projectviewer.ProjectPlugin", false ); return pv != null; } + /** + * @return a Path containing the classpath as set in ProjectViewer for the given project + */ public static Path getClassPathForProject(String projectName) { boolean useJavaClasspath = jEdit.getBooleanProperty( "sidekick.java.pv." + projectName + ".useJavaClasspath" ); //System.out.println("+++++ useJavaClasspath = " + useJavaClasspath); @@ -40,10 +78,12 @@ return path; } + /** + * @return a Path containing the sourcepath as set in ProjectViewer for the given project + */ public static Path getSourcePathForProject(String projectName) { String sourcepath = jEdit.getProperty("sidekick.java.pv." + projectName + ".optionalSourcepath", ""); Path path = new Path(sourcepath); return path; } - } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |