mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-08-03 22:35:43 +02:00
Fixed Bug 88927 - Bug 88927 - EmptyCodeReaderCache ignores working copies
This commit is contained in:
parent
6d60a9e2dc
commit
6ad34a2f75
3 changed files with 29 additions and 6 deletions
|
@ -49,6 +49,20 @@ public class ParserUtil
|
|||
return scannerLogService;
|
||||
}
|
||||
|
||||
public static char [] findWorkingCopyBuffer( String path, Iterator workingCopies )
|
||||
{
|
||||
IResource resultingResource = getResourceForFilename(path);
|
||||
|
||||
if( resultingResource != null && resultingResource.getType() == IResource.FILE )
|
||||
{
|
||||
// this is the file for sure
|
||||
// check the working copy
|
||||
if( workingCopies.hasNext() )
|
||||
return findWorkingCopy( resultingResource, workingCopies );
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static CodeReader createReader( String finalPath, Iterator workingCopies )
|
||||
{
|
||||
// check to see if the file which this path points to points to an
|
||||
|
|
|
@ -12,13 +12,12 @@ package org.eclipse.cdt.internal.core.dom;
|
|||
|
||||
import java.util.Arrays;
|
||||
import java.util.Iterator;
|
||||
|
||||
import org.eclipse.cdt.core.browser.IWorkingCopyProvider;
|
||||
import org.eclipse.cdt.core.dom.CDOM;
|
||||
import org.eclipse.cdt.core.dom.ICodeReaderFactory;
|
||||
import org.eclipse.cdt.core.parser.CodeReader;
|
||||
import org.eclipse.cdt.core.parser.ICodeReaderCache;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.EmptyCodeReaderCache;
|
||||
import org.eclipse.cdt.core.parser.ParserUtil;
|
||||
import org.eclipse.cdt.internal.core.parser.ast.EmptyIterator;
|
||||
|
||||
/**
|
||||
|
@ -35,7 +34,7 @@ public class PartialWorkingCopyCodeReaderFactory
|
|||
*/
|
||||
public PartialWorkingCopyCodeReaderFactory(IWorkingCopyProvider provider) {
|
||||
this.provider = provider;
|
||||
cache = new EmptyCodeReaderCache();
|
||||
cache = SavedCodeReaderFactory.getInstance().getCodeReaderCache();
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
|
@ -49,7 +48,18 @@ public class PartialWorkingCopyCodeReaderFactory
|
|||
* @see org.eclipse.cdt.core.dom.ICodeReaderFactory#createCodeReaderForTranslationUnit(java.lang.String)
|
||||
*/
|
||||
public CodeReader createCodeReaderForTranslationUnit(String path) {
|
||||
return ((EmptyCodeReaderCache)cache).createReader( path, createWorkingCopyIterator() );
|
||||
return checkWorkingCopyThenCache(path);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param path
|
||||
* @return
|
||||
*/
|
||||
protected CodeReader checkWorkingCopyThenCache(String path) {
|
||||
char [] buffer = ParserUtil.findWorkingCopyBuffer( path, createWorkingCopyIterator() );
|
||||
if( buffer != null )
|
||||
return new CodeReader(path, buffer);
|
||||
return cache.get( path );
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
|
|
|
@ -14,7 +14,6 @@ import org.eclipse.cdt.core.browser.IWorkingCopyProvider;
|
|||
import org.eclipse.cdt.core.dom.CDOM;
|
||||
import org.eclipse.cdt.core.dom.ICodeReaderFactory;
|
||||
import org.eclipse.cdt.core.parser.CodeReader;
|
||||
import org.eclipse.cdt.core.parser.ParserUtil;
|
||||
|
||||
/**
|
||||
* @author jcamelon
|
||||
|
@ -40,7 +39,7 @@ public class WorkingCopyCodeReaderFactory extends
|
|||
* @see org.eclipse.cdt.core.dom.ICodeReaderFactory#createCodeReaderForInclusion(java.lang.String)
|
||||
*/
|
||||
public CodeReader createCodeReaderForInclusion(String path) {
|
||||
return ParserUtil.createReader(path, createWorkingCopyIterator());
|
||||
return checkWorkingCopyThenCache(path);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue