From f070a52e9361e43cce55cdb26841b325c4d856bf Mon Sep 17 00:00:00 2001 From: John Camelon Date: Wed, 25 Feb 2004 22:18:51 +0000 Subject: [PATCH] org.eclipse.cdt.core Fixed Bug 43051 : Search: cannot specify relative search paths Fixed Bug 45140 : refactor IScanner to allow use of Readers of IResource org.eclipse.cdt.core.tests org.eclipse.cdt.ui Updates for new ISourceElementRequestor interface updates. --- core/org.eclipse.cdt.core.tests/ChangeLog | 3 + .../parser/tests/CompleteParseBaseTest.java | 9 ++ .../cdt/core/parser/tests/ExprEvalTest.java | 4 +- .../indexing/SourceIndexerRequestor.java | 8 ++ .../parser/ChangeLog-parser | 4 + .../eclipse/cdt/core/parser/CodeReader.java | 38 ++++++ .../core/parser/ISourceElementRequestor.java | 8 ++ .../parser/NullSourceElementRequestor.java | 12 +- ...erFactory.java => InternalParserUtil.java} | 24 +++- .../internal/core/parser/scanner/Scanner.java | 121 ++++++++++-------- .../core/search/matching/MatchLocator.java | 7 + .../eclipse/cdt/core/parser/ParserUtil.java | 39 ++++++ core/org.eclipse.cdt.ui/ChangeLog | 3 + .../SourceElementRequestorAdapter.java | 10 ++ 14 files changed, 233 insertions(+), 57 deletions(-) create mode 100644 core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/CodeReader.java rename core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/{InternalParserFactory.java => InternalParserUtil.java} (72%) diff --git a/core/org.eclipse.cdt.core.tests/ChangeLog b/core/org.eclipse.cdt.core.tests/ChangeLog index 1dce28d7eb8..08c49f12831 100644 --- a/core/org.eclipse.cdt.core.tests/ChangeLog +++ b/core/org.eclipse.cdt.core.tests/ChangeLog @@ -1,3 +1,6 @@ +2004-02-25 John Camelon + Updates for new ISourceElementRequestor interface updates. + 2004-02-25 John Camelon Added ScannerTestCase::testGerman(). diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/CompleteParseBaseTest.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/CompleteParseBaseTest.java index 6c3ff56e896..202120d27f3 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/CompleteParseBaseTest.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/CompleteParseBaseTest.java @@ -10,6 +10,7 @@ ***********************************************************************/ package org.eclipse.cdt.core.parser.tests; +import java.io.Reader; import java.io.StringReader; import java.util.ArrayList; import java.util.HashSet; @@ -30,6 +31,7 @@ import org.eclipse.cdt.core.parser.ParserFactory; import org.eclipse.cdt.core.parser.ParserFactoryError; import org.eclipse.cdt.core.parser.ParserLanguage; import org.eclipse.cdt.core.parser.ParserMode; +import org.eclipse.cdt.core.parser.ParserUtil; import org.eclipse.cdt.core.parser.ScannerInfo; import org.eclipse.cdt.core.parser.ast.IASTASMDefinition; import org.eclipse.cdt.core.parser.ast.IASTAbstractTypeSpecifierDeclaration; @@ -671,6 +673,13 @@ public class CompleteParseBaseTest extends TestCase { processReference( reference ); } + + /* (non-Javadoc) + * @see org.eclipse.cdt.core.parser.ISourceElementRequestor#createReader(java.lang.String) + */ + public Reader createReader(String finalPath) { + return ParserUtil.createReader(finalPath); + } } diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ExprEvalTest.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ExprEvalTest.java index 5695ffa599e..ad795483fa5 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ExprEvalTest.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ExprEvalTest.java @@ -13,7 +13,7 @@ import org.eclipse.cdt.core.parser.ParserLanguage; import org.eclipse.cdt.core.parser.ScannerInfo; import org.eclipse.cdt.core.parser.ast.IASTExpression; import org.eclipse.cdt.internal.core.parser.IExpressionParser; -import org.eclipse.cdt.internal.core.parser.InternalParserFactory; +import org.eclipse.cdt.internal.core.parser.InternalParserUtil; public class ExprEvalTest extends TestCase { @@ -28,7 +28,7 @@ public class ExprEvalTest extends TestCase { public void runTest(String code, int expectedValue) throws Exception { final NullSourceElementRequestor nullCallback = new NullSourceElementRequestor(); - IExpressionParser parser = InternalParserFactory.createExpressionParser(ParserFactory.createScanner( new StringReader( code ), getClass().getName(), new ScannerInfo(), null, ParserLanguage.CPP, nullCallback, new NullLogService() ), ParserLanguage.CPP, null ); + IExpressionParser parser = InternalParserUtil.createExpressionParser(ParserFactory.createScanner( new StringReader( code ), getClass().getName(), new ScannerInfo(), null, ParserLanguage.CPP, nullCallback, new NullLogService() ), ParserLanguage.CPP, null ); IASTExpression expression = parser.expression(null); assertEquals(expectedValue, expression.evaluateExpression()); } diff --git a/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/search/indexing/SourceIndexerRequestor.java b/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/search/indexing/SourceIndexerRequestor.java index 346dc341bf6..f4c273c1e7a 100644 --- a/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/search/indexing/SourceIndexerRequestor.java +++ b/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/search/indexing/SourceIndexerRequestor.java @@ -15,12 +15,14 @@ package org.eclipse.cdt.internal.core.search.indexing; * @author bgheorgh */ +import java.io.Reader; import java.util.LinkedList; import org.eclipse.cdt.core.parser.DefaultProblemHandler; import org.eclipse.cdt.core.parser.IProblem; import org.eclipse.cdt.core.parser.ISourceElementRequestor; import org.eclipse.cdt.core.parser.ParserMode; +import org.eclipse.cdt.core.parser.ParserUtil; import org.eclipse.cdt.core.parser.ast.IASTASMDefinition; import org.eclipse.cdt.core.parser.ast.IASTAbstractTypeSpecifierDeclaration; import org.eclipse.cdt.core.parser.ast.IASTClassReference; @@ -476,4 +478,10 @@ public class SourceIndexerRequestor implements ISourceElementRequestor, IIndexCo private IASTInclusion peekInclude(){ return currentInclude; } + /* (non-Javadoc) + * @see org.eclipse.cdt.core.parser.ISourceElementRequestor#createReader(java.lang.String) + */ + public Reader createReader(String finalPath) { + return ParserUtil.createReader(finalPath); + } } diff --git a/core/org.eclipse.cdt.core/parser/ChangeLog-parser b/core/org.eclipse.cdt.core/parser/ChangeLog-parser index 4bc2de2e4f9..a28a4b86f9c 100644 --- a/core/org.eclipse.cdt.core/parser/ChangeLog-parser +++ b/core/org.eclipse.cdt.core/parser/ChangeLog-parser @@ -1,3 +1,7 @@ +2004-02-25 John Camelon + Fixed Bug 43051 : Search: cannot specify relative search paths + Fixed Bug 45140 : refactor IScanner to allow use of Readers of IResource + 2004-02-25 John Camelon Updated Scanner to allow for invalid identifier names despite C++'s best efforts at maintaining its honour. diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/CodeReader.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/CodeReader.java new file mode 100644 index 00000000000..66e990663e6 --- /dev/null +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/CodeReader.java @@ -0,0 +1,38 @@ +/********************************************************************** + * Copyright (c) 2002-2004 IBM Canada and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Common Public License v0.5 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/cpl-v05.html + * + * Contributors: + * IBM Rational Software - Initial API and implementation +***********************************************************************/ +package org.eclipse.cdt.core.parser; + +import java.io.Reader; + +/** + * @author jcamelon + */ +public class CodeReader { + + public CodeReader( String filename, Reader reader ) + { + this.reader = reader; + this.filename = filename; + } + + private final Reader reader; + private final String filename; + + public String getFilename() + { + return filename; + } + + public Reader getUnderlyingReader() + { + return reader; + } +} diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/ISourceElementRequestor.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/ISourceElementRequestor.java index 068437a4770..34310316ae6 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/ISourceElementRequestor.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/ISourceElementRequestor.java @@ -10,6 +10,8 @@ ***********************************************************************/ package org.eclipse.cdt.core.parser; +import java.io.Reader; + import org.eclipse.cdt.core.parser.ast.IASTASMDefinition; import org.eclipse.cdt.core.parser.ast.IASTAbstractTypeSpecifierDeclaration; import org.eclipse.cdt.core.parser.ast.IASTClassReference; @@ -102,4 +104,10 @@ public interface ISourceElementRequestor { public void exitNamespaceDefinition( IASTNamespaceDefinition namespaceDefinition ); public void exitInclusion( IASTInclusion inclusion ); public void exitCompilationUnit( IASTCompilationUnit compilationUnit ); + + /** + * @param finalPath + * @return + */ + public Reader createReader(String finalPath); } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/NullSourceElementRequestor.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/NullSourceElementRequestor.java index 7cc60547d39..a2531e329fb 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/NullSourceElementRequestor.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/NullSourceElementRequestor.java @@ -1,5 +1,7 @@ package org.eclipse.cdt.core.parser; +import java.io.Reader; + import org.eclipse.cdt.core.parser.ast.IASTASMDefinition; import org.eclipse.cdt.core.parser.ast.IASTAbstractTypeSpecifierDeclaration; import org.eclipse.cdt.core.parser.ast.IASTClassReference; @@ -31,6 +33,7 @@ import org.eclipse.cdt.core.parser.ast.IASTUsingDeclaration; import org.eclipse.cdt.core.parser.ast.IASTUsingDirective; import org.eclipse.cdt.core.parser.ast.IASTVariable; import org.eclipse.cdt.core.parser.ast.IASTVariableReference; +import org.eclipse.cdt.internal.core.parser.InternalParserUtil; public class NullSourceElementRequestor implements ISourceElementRequestor @@ -448,5 +451,12 @@ public class NullSourceElementRequestor implements ISourceElementRequestor { // TODO Auto-generated method stub - } + } + + /* (non-Javadoc) + * @see org.eclipse.cdt.core.parser.ISourceElementRequestor#createReader(java.lang.String) + */ + public Reader createReader(String finalPath) { + return InternalParserUtil.createFileReader( finalPath ); + } } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/InternalParserFactory.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/InternalParserUtil.java similarity index 72% rename from core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/InternalParserFactory.java rename to core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/InternalParserUtil.java index 83b4ba6cebb..c85b67d06cc 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/InternalParserFactory.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/InternalParserUtil.java @@ -10,6 +10,11 @@ *******************************************************************************/ package org.eclipse.cdt.internal.core.parser; +import java.io.File; +import java.io.FileNotFoundException; +import java.io.FileReader; +import java.io.Reader; + import org.eclipse.cdt.core.parser.IParserLogService; import org.eclipse.cdt.core.parser.IScanner; import org.eclipse.cdt.core.parser.ParserFactory; @@ -19,7 +24,7 @@ import org.eclipse.cdt.core.parser.ParserLanguage; /** * @author jcamelon */ -public class InternalParserFactory extends ParserFactory { +public class InternalParserUtil extends ParserFactory { public static IExpressionParser createExpressionParser( IScanner scanner, ParserLanguage language, IParserLogService log ) throws ParserFactoryError { @@ -29,4 +34,21 @@ public class InternalParserFactory extends ParserFactory { return new ExpressionParser( scanner, language, logService ); } + /** + * @param finalPath + * @return + */ + public static Reader createFileReader(String finalPath) { + File includeFile = new File(finalPath); + if (includeFile.exists() && includeFile.isFile()) + { + //check and see + try { + return new FileReader( includeFile); + } catch (FileNotFoundException fnf) { + + } + } + return null; + } } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner/Scanner.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner/Scanner.java index b5ad423a7ee..4fefeb94e3c 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner/Scanner.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner/Scanner.java @@ -11,8 +11,6 @@ package org.eclipse.cdt.internal.core.parser.scanner; import java.io.File; -import java.io.FileNotFoundException; -import java.io.FileReader; import java.io.IOException; import java.io.Reader; import java.io.StringReader; @@ -28,6 +26,7 @@ import java.util.StringTokenizer; import java.util.Vector; import org.eclipse.cdt.core.parser.BacktrackException; +import org.eclipse.cdt.core.parser.CodeReader; import org.eclipse.cdt.core.parser.Directives; import org.eclipse.cdt.core.parser.EndOfFileException; import org.eclipse.cdt.core.parser.IMacroDescriptor; @@ -54,8 +53,8 @@ import org.eclipse.cdt.core.parser.ast.IASTExpression; import org.eclipse.cdt.core.parser.ast.IASTFactory; import org.eclipse.cdt.core.parser.ast.IASTInclusion; import org.eclipse.cdt.core.parser.extension.IScannerExtension; -import org.eclipse.cdt.internal.core.parser.*; -import org.eclipse.cdt.internal.core.parser.InternalParserFactory; +import org.eclipse.cdt.internal.core.parser.IExpressionParser; +import org.eclipse.cdt.internal.core.parser.InternalParserUtil; import org.eclipse.cdt.internal.core.parser.ast.ASTCompletionNode; import org.eclipse.cdt.internal.core.parser.token.KeywordSets; import org.eclipse.cdt.internal.core.parser.token.Token; @@ -309,6 +308,7 @@ public class Scanner implements IScanner { buffer.append( tokenizer.nextToken() ); } file = new File( buffer.toString() ); + path = buffer.toString(); } if( file.exists() && file.isDirectory() ) @@ -496,9 +496,7 @@ public class Scanner implements IScanner { protected void handleInclusion(String fileName, boolean useIncludePaths, int beginOffset, int startLine, int nameOffset, int nameLine, int endOffset, int endLine ) throws ScannerException { - FileReader inclusionReader = null; - String newPath = null; - + CodeReader duple = null; totalLoop: for( int i = 0; i < 2; ++i ) { if( useIncludePaths ) // search include paths for this file @@ -509,65 +507,33 @@ public class Scanner implements IScanner { while (iter.hasNext()) { String path = (String)iter.next(); - File pathFile = new File(path); - //TODO assert pathFile.isDirectory(); - StringBuffer buffer = new StringBuffer( pathFile.getPath() ); - buffer.append( File.separatorChar ); - buffer.append( fileName ); - newPath = buffer.toString(); - //TODO remove ".." and "." segments - File includeFile = new File(newPath); - if (includeFile.exists() && includeFile.isFile()) { - try { - inclusionReader = new FileReader(includeFile); - break totalLoop; - } catch (FileNotFoundException fnf) { - continue; - } - } + duple = createReaderDuple( path, fileName ); + if( duple != null ) + break totalLoop; } - if (inclusionReader == null ) + if (duple == null ) handleProblem( IProblem.PREPROCESSOR_INCLUSION_NOT_FOUND, fileName, beginOffset, false, true ); } else // local inclusion { - String currentFilename = scannerData.getContextStack().getCurrentContext().getFilename(); - File currentIncludeFile = new File( currentFilename ); - String parentDirectory = currentIncludeFile.getParentFile().getAbsolutePath(); - currentIncludeFile = null; - - StringBuffer buffer = new StringBuffer( parentDirectory ); - buffer.append( File.separatorChar ); - buffer.append( fileName ); - newPath = buffer.toString(); - //TODO remove ".." and "." segments - File includeFile = new File( newPath ); - if (includeFile.exists() && includeFile.isFile()) { - try { - inclusionReader = new FileReader(includeFile); - break totalLoop; - } catch (FileNotFoundException fnf) { - useIncludePaths = true; - continue totalLoop; - } - } - else - { - useIncludePaths = true; - continue totalLoop; - } + duple = createReaderDuple( new File( scannerData.getContextStack().getCurrentContext().getFilename() ).getParentFile().getAbsolutePath(), fileName ); + if( duple != null ) + break totalLoop; + useIncludePaths = true; + continue totalLoop; } } - if (inclusionReader != null) { + + if (duple!= null) { IASTInclusion inclusion = null; try { inclusion = scannerData.getASTFactory().createInclusion( fileName, - newPath, + duple.getFilename(), !useIncludePaths, beginOffset, startLine, @@ -581,7 +547,7 @@ public class Scanner implements IScanner { try { - scannerData.getContextStack().updateContext(inclusionReader, newPath, ScannerContext.ContextKind.INCLUSION, inclusion, scannerData.getClientRequestor() ); + scannerData.getContextStack().updateContext(duple.getUnderlyingReader(), duple.getFilename(), ScannerContext.ContextKind.INCLUSION, inclusion, scannerData.getClientRequestor() ); } catch (ContextException e1) { @@ -2283,7 +2249,7 @@ public class Scanner implements IScanner { EXPRESSION, new ScannerInfo( scannerData.getDefinitions(), scannerData.getOriginalConfig().getIncludePaths()), ParserMode.QUICK_PARSE, scannerData.getLanguage(), new NullSourceElementRequestor(), nullLogService ); - parser = InternalParserFactory.createExpressionParser(trial, scannerData.getLanguage(), nullLogService); + parser = InternalParserUtil.createExpressionParser(trial, scannerData.getLanguage(), nullLogService); } catch( ParserFactoryError pfe ) { handleInternalError(); @@ -3129,4 +3095,53 @@ public class Scanner implements IScanner { return ( scannerData.getContextStack().getCurrentContext() == scannerData.getContextStack().getTopContext() ); } + protected CodeReader createReaderDuple( String path, String fileName ) + { + File pathFile = new File(path); + //TODO assert pathFile.isDirectory(); + StringBuffer newPathBuffer = new StringBuffer( pathFile.getPath() ); + newPathBuffer.append( File.separatorChar ); + newPathBuffer.append( fileName ); + //remove ".." and "." segments + String finalPath = reconcilePath( newPathBuffer.toString() ); + Reader r = scannerData.getClientRequestor().createReader( finalPath ); + if( r != null ) + return new CodeReader( finalPath, r ); + return null; + + } + + /** + * @param string + * @return + */ + private String reconcilePath(String originalPath ) { + if( originalPath == null ) return null; + String [] segments = originalPath.split( "[/\\\\]" ); + if( segments.length == 1 ) return originalPath; + Vector results = new Vector(); + for( int i = 0; i < segments.length; ++i ) + { + String segment = segments[i]; + if( segment.equals( ".") ) continue; + if( segment.equals("..") ) + { + if( results.size() > 0 ) + results.removeElementAt( results.size() - 1 ); + } + else + results.add( segment ); + } + StringBuffer buffer = new StringBuffer(); + Iterator i = results.iterator(); + while( i.hasNext() ) + { + buffer.append( (String)i.next() ); + if( i.hasNext() ) + buffer.append( File.separatorChar ); + } + scannerData.getLogService().traceLog( "Path has been reduced to " + buffer.toString()); + return buffer.toString(); + } + } diff --git a/core/org.eclipse.cdt.core/search/org/eclipse/cdt/internal/core/search/matching/MatchLocator.java b/core/org.eclipse.cdt.core/search/org/eclipse/cdt/internal/core/search/matching/MatchLocator.java index 53efa1227c3..4edb6d4fb4e 100644 --- a/core/org.eclipse.cdt.core/search/org/eclipse/cdt/internal/core/search/matching/MatchLocator.java +++ b/core/org.eclipse.cdt.core/search/org/eclipse/cdt/internal/core/search/matching/MatchLocator.java @@ -593,4 +593,11 @@ public class MatchLocator implements ISourceElementRequestor, ICSearchConstants public static void verbose(String log) { System.out.println("(" + Thread.currentThread() + ") " + log); } + + /* (non-Javadoc) + * @see org.eclipse.cdt.core.parser.ISourceElementRequestor#createReader(java.lang.String) + */ + public Reader createReader(String finalPath) { + return ParserUtil.createReader(finalPath); + } } diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/parser/ParserUtil.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/parser/ParserUtil.java index 1ef34e7e21a..324b63a460d 100644 --- a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/parser/ParserUtil.java +++ b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/parser/ParserUtil.java @@ -10,8 +10,20 @@ ***********************************************************************/ package org.eclipse.cdt.core.parser; +import java.io.BufferedInputStream; +import java.io.InputStreamReader; +import java.io.Reader; + import org.eclipse.cdt.internal.core.model.IDebugLogConstants; +import org.eclipse.cdt.internal.core.parser.InternalParserUtil; import org.eclipse.cdt.internal.core.parser.ParserLogService; +import org.eclipse.core.resources.IFile; +import org.eclipse.core.resources.IResource; +import org.eclipse.core.resources.IWorkspace; +import org.eclipse.core.resources.ResourcesPlugin; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IPath; +import org.eclipse.core.runtime.Path; /** * @author jcamelon @@ -34,4 +46,31 @@ public class ParserUtil public static IParserLogService getScannerLogService() { return scannerLogService; } + + public static Reader createReader( String finalPath ) + { + // check to see if the file which this path points to points to an + // IResource in the workspace + try + { + IWorkspace workspace = ResourcesPlugin.getWorkspace(); + IPath path = new Path( finalPath ); + + if( workspace.getRoot().getLocation().isPrefixOf( path ) ) + path = path.removeFirstSegments(workspace.getRoot().getLocation().segmentCount() ); + + IResource result = workspace.getRoot().findMember(path); + + if( result != null && result.getType() == IResource.FILE ) + { + BufferedInputStream bufferedStream = new BufferedInputStream( ((IFile) result).getContents() ); + InputStreamReader reader = new InputStreamReader( bufferedStream ); + return reader; + } + } + catch( CoreException ce ) + { + } + return InternalParserUtil.createFileReader(finalPath); + } } diff --git a/core/org.eclipse.cdt.ui/ChangeLog b/core/org.eclipse.cdt.ui/ChangeLog index 3ea5a95cb6a..7b13bbed4d9 100644 --- a/core/org.eclipse.cdt.ui/ChangeLog +++ b/core/org.eclipse.cdt.ui/ChangeLog @@ -1,3 +1,6 @@ +2004-02-25 John Camelon + Updates for new ISourceElementRequestor interface updates. + 2004-02-24 Alain Magloire New constructor for ShowInCView. diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/compare/SourceElementRequestorAdapter.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/compare/SourceElementRequestorAdapter.java index cf2836c9dba..81ca43f9950 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/compare/SourceElementRequestorAdapter.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/compare/SourceElementRequestorAdapter.java @@ -11,10 +11,13 @@ package org.eclipse.cdt.internal.ui.compare; +import java.io.Reader; + import org.eclipse.cdt.core.parser.DefaultProblemHandler; import org.eclipse.cdt.core.parser.IProblem; import org.eclipse.cdt.core.parser.ISourceElementRequestor; import org.eclipse.cdt.core.parser.ParserMode; +import org.eclipse.cdt.core.parser.ParserUtil; import org.eclipse.cdt.core.parser.ast.IASTASMDefinition; import org.eclipse.cdt.core.parser.ast.IASTAbstractTypeSpecifierDeclaration; import org.eclipse.cdt.core.parser.ast.IASTClassReference; @@ -331,4 +334,11 @@ public class SourceElementRequestorAdapter implements ISourceElementRequestor { // TODO Auto-generated method stub } + /* (non-Javadoc) + * @see org.eclipse.cdt.core.parser.ISourceElementRequestor#createReader(java.lang.String) + */ + public Reader createReader(String finalPath) { + return ParserUtil.createReader(finalPath); + } + }