mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
Moved TimeOut to parser public package in src/ and renamed it to ParserTimeOut. See resolution description in the defect for more details.
This commit is contained in:
parent
f24c20f55c
commit
a17096c97e
16 changed files with 64 additions and 88 deletions
|
@ -751,14 +751,6 @@ public class CompleteParseBaseTest extends TestCase
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.eclipse.cdt.core.parser.ISourceElementRequestor#parserTimeout()
|
|
||||||
*/
|
|
||||||
public boolean parserTimeout() {
|
|
||||||
// TODO Auto-generated method stub
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.cdt.core.parser.ISourceElementRequestor#acceptFriendDeclaration(org.eclipse.cdt.core.parser.ast.IASTDeclaration)
|
* @see org.eclipse.cdt.core.parser.ISourceElementRequestor#acceptFriendDeclaration(org.eclipse.cdt.core.parser.ast.IASTDeclaration)
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -902,6 +902,8 @@ public class TypeParser implements ISourceElementRequestor {
|
||||||
* @see org.eclipse.cdt.core.parser.ISourceElementRequestor#parserTimeout()
|
* @see org.eclipse.cdt.core.parser.ISourceElementRequestor#parserTimeout()
|
||||||
*/
|
*/
|
||||||
public boolean parserTimeout() {
|
public boolean parserTimeout() {
|
||||||
|
//TODO - Chris Wiebe - Need to resturcture how you cancel the parser now that
|
||||||
|
//IParser.cancel() is available, this method is no longer being called.
|
||||||
if (fFoundType || fProgressMonitor.isCanceled())
|
if (fFoundType || fProgressMonitor.isCanceled())
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
|
|
|
@ -29,6 +29,7 @@ import org.eclipse.cdt.core.ICLogConstants;
|
||||||
import org.eclipse.cdt.core.index.IIndexChangeListener;
|
import org.eclipse.cdt.core.index.IIndexChangeListener;
|
||||||
import org.eclipse.cdt.core.index.IndexChangeEvent;
|
import org.eclipse.cdt.core.index.IndexChangeEvent;
|
||||||
import org.eclipse.cdt.core.model.ICModelMarker;
|
import org.eclipse.cdt.core.model.ICModelMarker;
|
||||||
|
import org.eclipse.cdt.core.parser.ParserTimeOut;
|
||||||
import org.eclipse.cdt.internal.core.CharOperation;
|
import org.eclipse.cdt.internal.core.CharOperation;
|
||||||
import org.eclipse.cdt.internal.core.Util;
|
import org.eclipse.cdt.internal.core.Util;
|
||||||
import org.eclipse.cdt.internal.core.index.IIndex;
|
import org.eclipse.cdt.internal.core.index.IIndex;
|
||||||
|
@ -40,7 +41,6 @@ import org.eclipse.cdt.internal.core.search.SimpleLookupTable;
|
||||||
import org.eclipse.cdt.internal.core.search.processing.IJob;
|
import org.eclipse.cdt.internal.core.search.processing.IJob;
|
||||||
import org.eclipse.cdt.internal.core.search.processing.JobManager;
|
import org.eclipse.cdt.internal.core.search.processing.JobManager;
|
||||||
import org.eclipse.cdt.internal.core.sourcedependency.UpdateDependency;
|
import org.eclipse.cdt.internal.core.sourcedependency.UpdateDependency;
|
||||||
import org.eclipse.cdt.utils.TimeOut;
|
|
||||||
import org.eclipse.core.resources.IFile;
|
import org.eclipse.core.resources.IFile;
|
||||||
import org.eclipse.core.resources.IProject;
|
import org.eclipse.core.resources.IProject;
|
||||||
import org.eclipse.core.resources.IResource;
|
import org.eclipse.core.resources.IResource;
|
||||||
|
@ -87,7 +87,7 @@ public class IndexManager extends JobManager implements IIndexConstants {
|
||||||
|
|
||||||
public static boolean VERBOSE = false;
|
public static boolean VERBOSE = false;
|
||||||
|
|
||||||
private TimeOut timeoutThread = null;
|
private ParserTimeOut timeoutThread = null;
|
||||||
|
|
||||||
private IndexerModelListener indexModelListener = null;
|
private IndexerModelListener indexModelListener = null;
|
||||||
|
|
||||||
|
@ -564,7 +564,7 @@ public class IndexManager extends JobManager implements IIndexConstants {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.timeoutThread == null){
|
if (this.timeoutThread == null){
|
||||||
this.timeoutThread = new TimeOut("Indexer TimeOut Thread"); //$NON-NLS-1$
|
this.timeoutThread = new ParserTimeOut("Indexer TimeOut Thread"); //$NON-NLS-1$
|
||||||
this.timeoutThread.setThreadPriority(Thread.MAX_PRIORITY);
|
this.timeoutThread.setThreadPriority(Thread.MAX_PRIORITY);
|
||||||
|
|
||||||
Preferences prefs = CCorePlugin.getDefault().getPluginPreferences();
|
Preferences prefs = CCorePlugin.getDefault().getPluginPreferences();
|
||||||
|
@ -744,7 +744,7 @@ public class IndexManager extends JobManager implements IIndexConstants {
|
||||||
/**
|
/**
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public TimeOut getTimeout() {
|
public ParserTimeOut getTimeout() {
|
||||||
// TODO Auto-generated method stub
|
// TODO Auto-generated method stub
|
||||||
return this.timeoutThread ;
|
return this.timeoutThread ;
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,11 +31,11 @@ import org.eclipse.cdt.core.parser.ParserFactory;
|
||||||
import org.eclipse.cdt.core.parser.ParserFactoryError;
|
import org.eclipse.cdt.core.parser.ParserFactoryError;
|
||||||
import org.eclipse.cdt.core.parser.ParserLanguage;
|
import org.eclipse.cdt.core.parser.ParserLanguage;
|
||||||
import org.eclipse.cdt.core.parser.ParserMode;
|
import org.eclipse.cdt.core.parser.ParserMode;
|
||||||
|
import org.eclipse.cdt.core.parser.ParserTimeOut;
|
||||||
import org.eclipse.cdt.core.parser.ParserUtil;
|
import org.eclipse.cdt.core.parser.ParserUtil;
|
||||||
import org.eclipse.cdt.core.parser.ScannerInfo;
|
import org.eclipse.cdt.core.parser.ScannerInfo;
|
||||||
import org.eclipse.cdt.internal.core.index.IDocument;
|
import org.eclipse.cdt.internal.core.index.IDocument;
|
||||||
import org.eclipse.cdt.internal.core.index.impl.IndexDelta;
|
import org.eclipse.cdt.internal.core.index.impl.IndexDelta;
|
||||||
import org.eclipse.cdt.utils.TimeOut;
|
|
||||||
import org.eclipse.core.resources.IFile;
|
import org.eclipse.core.resources.IFile;
|
||||||
import org.eclipse.core.resources.IProject;
|
import org.eclipse.core.resources.IProject;
|
||||||
import org.eclipse.core.runtime.CoreException;
|
import org.eclipse.core.runtime.CoreException;
|
||||||
|
@ -62,13 +62,13 @@ public class SourceIndexer extends AbstractIndexer {
|
||||||
public static final String CDT_INDEXER_TIMEOUT= "CDT_INDEXER_TIMEOUT"; //$NON-NLS-1$
|
public static final String CDT_INDEXER_TIMEOUT= "CDT_INDEXER_TIMEOUT"; //$NON-NLS-1$
|
||||||
|
|
||||||
IFile resourceFile;
|
IFile resourceFile;
|
||||||
TimeOut timeOut = null;
|
ParserTimeOut timeOut = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param resource
|
* @param resource
|
||||||
* @param out
|
* @param out
|
||||||
*/
|
*/
|
||||||
public SourceIndexer(IFile resource, TimeOut timeOut) {
|
public SourceIndexer(IFile resource, ParserTimeOut timeOut) {
|
||||||
this.resourceFile = resource;
|
this.resourceFile = resource;
|
||||||
this.timeOut = timeOut;
|
this.timeOut = timeOut;
|
||||||
}
|
}
|
||||||
|
@ -107,6 +107,7 @@ public class SourceIndexer extends AbstractIndexer {
|
||||||
parser = ParserFactory.createParser(
|
parser = ParserFactory.createParser(
|
||||||
ParserFactory.createScanner(reader, scanInfo, ParserMode.COMPLETE_PARSE, language, requestor, ParserUtil.getScannerLogService(), null ),
|
ParserFactory.createScanner(reader, scanInfo, ParserMode.COMPLETE_PARSE, language, requestor, ParserUtil.getScannerLogService(), null ),
|
||||||
requestor, ParserMode.COMPLETE_PARSE, language, ParserUtil.getParserLogService() );
|
requestor, ParserMode.COMPLETE_PARSE, language, ParserUtil.getParserLogService() );
|
||||||
|
requestor.setParser(parser);
|
||||||
} catch( ParserFactoryError pfe ){
|
} catch( ParserFactoryError pfe ){
|
||||||
} catch (CoreException e) {
|
} catch (CoreException e) {
|
||||||
} finally {
|
} finally {
|
||||||
|
|
|
@ -26,9 +26,11 @@ import java.util.Map;
|
||||||
import org.eclipse.cdt.core.CCorePlugin;
|
import org.eclipse.cdt.core.CCorePlugin;
|
||||||
import org.eclipse.cdt.core.model.ICModelMarker;
|
import org.eclipse.cdt.core.model.ICModelMarker;
|
||||||
import org.eclipse.cdt.core.parser.CodeReader;
|
import org.eclipse.cdt.core.parser.CodeReader;
|
||||||
|
import org.eclipse.cdt.core.parser.IParser;
|
||||||
import org.eclipse.cdt.core.parser.IProblem;
|
import org.eclipse.cdt.core.parser.IProblem;
|
||||||
import org.eclipse.cdt.core.parser.ISourceElementRequestor;
|
import org.eclipse.cdt.core.parser.ISourceElementRequestor;
|
||||||
import org.eclipse.cdt.core.parser.ParserMode;
|
import org.eclipse.cdt.core.parser.ParserMode;
|
||||||
|
import org.eclipse.cdt.core.parser.ParserTimeOut;
|
||||||
import org.eclipse.cdt.core.parser.ParserUtil;
|
import org.eclipse.cdt.core.parser.ParserUtil;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTASMDefinition;
|
import org.eclipse.cdt.core.parser.ast.IASTASMDefinition;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTAbstractTypeSpecifierDeclaration;
|
import org.eclipse.cdt.core.parser.ast.IASTAbstractTypeSpecifierDeclaration;
|
||||||
|
@ -67,7 +69,6 @@ import org.eclipse.cdt.core.parser.ast.IASTUsingDirective;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTVariable;
|
import org.eclipse.cdt.core.parser.ast.IASTVariable;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTVariableReference;
|
import org.eclipse.cdt.core.parser.ast.IASTVariableReference;
|
||||||
import org.eclipse.cdt.internal.core.Util;
|
import org.eclipse.cdt.internal.core.Util;
|
||||||
import org.eclipse.cdt.utils.TimeOut;
|
|
||||||
import org.eclipse.core.resources.IFile;
|
import org.eclipse.core.resources.IFile;
|
||||||
import org.eclipse.core.resources.IMarker;
|
import org.eclipse.core.resources.IMarker;
|
||||||
import org.eclipse.core.resources.IResource;
|
import org.eclipse.core.resources.IResource;
|
||||||
|
@ -104,15 +105,16 @@ public class SourceIndexerRequestor implements ISourceElementRequestor, IIndexCo
|
||||||
private Map problemsMap = null;
|
private Map problemsMap = null;
|
||||||
|
|
||||||
private IProgressMonitor pm = new NullProgressMonitor();
|
private IProgressMonitor pm = new NullProgressMonitor();
|
||||||
private TimeOut timeoutThread = null;
|
private ParserTimeOut timeoutThread = null;
|
||||||
|
|
||||||
private static final String INDEXER_MARKER_ORIGINATOR = ICModelMarker.INDEXER_MARKER + ".originator"; //$NON-NLS-1$
|
private static final String INDEXER_MARKER_ORIGINATOR = ICModelMarker.INDEXER_MARKER + ".originator"; //$NON-NLS-1$
|
||||||
private static final String INDEXER_MARKER_PREFIX = Util.bind("indexerMarker.prefix" ) + " "; //$NON-NLS-1$ //$NON-NLS-2$
|
private static final String INDEXER_MARKER_PREFIX = Util.bind("indexerMarker.prefix" ) + " "; //$NON-NLS-1$ //$NON-NLS-2$
|
||||||
private static final String INDEXER_MARKER_PROCESSING = Util.bind( "indexerMarker.processing" ); //$NON-NLS-1$
|
private static final String INDEXER_MARKER_PROCESSING = Util.bind( "indexerMarker.processing" ); //$NON-NLS-1$
|
||||||
|
|
||||||
private ArrayList filesTraversed = null;
|
private ArrayList filesTraversed = null;
|
||||||
|
private IParser parser;
|
||||||
|
|
||||||
public SourceIndexerRequestor(SourceIndexer indexer, IFile resourceFile, TimeOut timeOut) {
|
public SourceIndexerRequestor(SourceIndexer indexer, IFile resourceFile, ParserTimeOut timeOut) {
|
||||||
super();
|
super();
|
||||||
this.indexer = indexer;
|
this.indexer = indexer;
|
||||||
this.resourceFile = resourceFile;
|
this.resourceFile = resourceFile;
|
||||||
|
@ -660,6 +662,10 @@ public class SourceIndexerRequestor implements ISourceElementRequestor, IIndexCo
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setParser( IParser parser )
|
||||||
|
{
|
||||||
|
this.parser = parser;
|
||||||
|
}
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.cdt.internal.ui.text.contentassist.ITimeoutThreadOwner#setTimeout(int)
|
* @see org.eclipse.cdt.internal.ui.text.contentassist.ITimeoutThreadOwner#setTimeout(int)
|
||||||
*/
|
*/
|
||||||
|
@ -670,7 +676,7 @@ public class SourceIndexerRequestor implements ISourceElementRequestor, IIndexCo
|
||||||
* @see org.eclipse.cdt.internal.ui.text.contentassist.ITimeoutThreadOwner#startTimer()
|
* @see org.eclipse.cdt.internal.ui.text.contentassist.ITimeoutThreadOwner#startTimer()
|
||||||
*/
|
*/
|
||||||
public void startTimer() {
|
public void startTimer() {
|
||||||
createProgressMonitor();
|
createProgressMonitor(parser);
|
||||||
while (!timeoutThread.isReadyToRun()){
|
while (!timeoutThread.isReadyToRun()){
|
||||||
try {
|
try {
|
||||||
Thread.sleep(20);
|
Thread.sleep(20);
|
||||||
|
@ -700,9 +706,9 @@ public class SourceIndexerRequestor implements ISourceElementRequestor, IIndexCo
|
||||||
/*
|
/*
|
||||||
* Creates a new progress monitor with each start timer
|
* Creates a new progress monitor with each start timer
|
||||||
*/
|
*/
|
||||||
private void createProgressMonitor() {
|
private void createProgressMonitor( IParser parser ) {
|
||||||
pm.setCanceled(false);
|
pm.setCanceled(false);
|
||||||
timeoutThread.setProgressMonitor(pm);
|
timeoutThread.setParser(parser);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -50,6 +50,9 @@ public interface IParser {
|
||||||
*/
|
*/
|
||||||
public ISelectionParseResult parse( int startingOffset, int endingOffset ) throws ParseError;
|
public ISelectionParseResult parse( int startingOffset, int endingOffset ) throws ParseError;
|
||||||
|
|
||||||
|
public void cancel();
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* If an error was encountered, give us the offset of the token that caused the error.
|
* If an error was encountered, give us the offset of the token that caused the error.
|
||||||
*
|
*
|
||||||
|
|
|
@ -114,10 +114,5 @@ public interface ISourceElementRequestor {
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public CodeReader createReader(String finalPath, Iterator workingCopies );
|
public CodeReader createReader(String finalPath, Iterator workingCopies );
|
||||||
/**
|
|
||||||
* The parser asks the client if it wishes to time out
|
|
||||||
* in case it is taking more than the expected time.
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public boolean parserTimeout();
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -481,13 +481,6 @@ public class NullSourceElementRequestor implements ISourceElementRequestor
|
||||||
// TODO Auto-generated method stub
|
// TODO Auto-generated method stub
|
||||||
|
|
||||||
}
|
}
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.eclipse.cdt.core.parser.ISourceElementRequestor#parserTimeout()
|
|
||||||
*/
|
|
||||||
public boolean parserTimeout() {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.cdt.core.parser.ISourceElementRequestor#acceptFriendDeclaration(org.eclipse.cdt.core.parser.ast.IASTDeclaration)
|
* @see org.eclipse.cdt.core.parser.ISourceElementRequestor#acceptFriendDeclaration(org.eclipse.cdt.core.parser.ast.IASTDeclaration)
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -30,7 +30,7 @@ public class ParseError extends Error {
|
||||||
// semantic context cannot be provided in this case
|
// semantic context cannot be provided in this case
|
||||||
public static final ParseErrorKind OFFSET_RANGE_NOT_NAME = new ParseErrorKind( 2 );
|
public static final ParseErrorKind OFFSET_RANGE_NOT_NAME = new ParseErrorKind( 2 );
|
||||||
|
|
||||||
public static final ParseErrorKind TIMEOUT = new ParseErrorKind( 3 );
|
public static final ParseErrorKind TIMEOUT_OR_CANCELLED = new ParseErrorKind( 3 );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param enumValue
|
* @param enumValue
|
||||||
|
|
|
@ -105,8 +105,8 @@ public class ExpressionParser implements IExpressionParser, IParserData {
|
||||||
*/
|
*/
|
||||||
public IToken LA(int i) throws EndOfFileException {
|
public IToken LA(int i) throws EndOfFileException {
|
||||||
|
|
||||||
if (parserTimeout()) {
|
if (isCancelled) {
|
||||||
throw new ParseError(ParseError.ParseErrorKind.TIMEOUT);
|
throw new ParseError(ParseError.ParseErrorKind.TIMEOUT_OR_CANCELLED);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (i < 1) // can't go backwards
|
if (i < 1) // can't go backwards
|
||||||
|
@ -2764,10 +2764,9 @@ public class ExpressionParser implements IExpressionParser, IParserData {
|
||||||
public char[] getCurrentFilename() {
|
public char[] getCurrentFilename() {
|
||||||
return scanner.getCurrentFilename();
|
return scanner.getCurrentFilename();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected boolean isCancelled = false;
|
||||||
|
|
||||||
protected boolean parserTimeout() {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.cdt.internal.core.parser.IParserData#getLastToken()
|
* @see org.eclipse.cdt.internal.core.parser.IParserData#getLastToken()
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -3341,14 +3341,7 @@ public abstract class Parser extends ExpressionParser implements IParser
|
||||||
// do nothing as of yet
|
// do nothing as of yet
|
||||||
// subclasses will need to implement this method
|
// subclasses will need to implement this method
|
||||||
}
|
}
|
||||||
/*
|
|
||||||
* (non-Javadoc)
|
|
||||||
*
|
|
||||||
* @see org.eclipse.cdt.internal.core.parser.ExpressionParser#parserTimeout()
|
|
||||||
*/
|
|
||||||
protected final boolean parserTimeout() {
|
|
||||||
return requestor.parserTimeout();
|
|
||||||
}
|
|
||||||
/*
|
/*
|
||||||
* (non-Javadoc)
|
* (non-Javadoc)
|
||||||
*
|
*
|
||||||
|
@ -3399,5 +3392,12 @@ public abstract class Parser extends ExpressionParser implements IParser
|
||||||
*/
|
*/
|
||||||
protected void handleOffsetableNamedElement(IASTOffsetableNamedElement node) {
|
protected void handleOffsetableNamedElement(IASTOffsetableNamedElement node) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.parser.IParser#cancel()
|
||||||
|
*/
|
||||||
|
public synchronized void cancel() {
|
||||||
|
isCancelled = true;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -671,14 +671,6 @@ public class MatchLocator implements IMatchLocator{
|
||||||
public CodeReader createReader(String finalPath, Iterator workingCopies) {
|
public CodeReader createReader(String finalPath, Iterator workingCopies) {
|
||||||
return ParserUtil.createReader(finalPath,workingCopies);
|
return ParserUtil.createReader(finalPath,workingCopies);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.eclipse.cdt.core.parser.ISourceElementRequestor#parserTimeout()
|
|
||||||
*/
|
|
||||||
public boolean parserTimeout() {
|
|
||||||
// TODO Auto-generated method stub
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.cdt.core.search.IMatchLocator#setProgressMonitor(org.eclipse.core.runtime.IProgressMonitor)
|
* @see org.eclipse.cdt.core.search.IMatchLocator#setProgressMonitor(org.eclipse.core.runtime.IProgressMonitor)
|
||||||
|
|
|
@ -8,33 +8,31 @@
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* IBM Rational Software - Initial API and implementation
|
* IBM Rational Software - Initial API and implementation
|
||||||
***********************************************************************/
|
***********************************************************************/
|
||||||
package org.eclipse.cdt.utils;
|
package org.eclipse.cdt.core.parser;
|
||||||
|
|
||||||
import org.eclipse.core.runtime.IProgressMonitor;
|
import org.eclipse.cdt.core.parser.IParser;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author bgheorgh
|
* @author bgheorgh
|
||||||
*
|
*
|
||||||
* To change the template for this generated type comment go to
|
|
||||||
* Window - Preferences - Java - Code Generation - Code and Comments
|
|
||||||
*/
|
*/
|
||||||
public class TimeOut implements Runnable {
|
public class ParserTimeOut implements Runnable {
|
||||||
|
|
||||||
|
|
||||||
protected Thread thread;
|
protected Thread thread;
|
||||||
protected boolean enabled;
|
protected boolean enabled;
|
||||||
protected IProgressMonitor pm = null;
|
protected IParser cancellable;
|
||||||
private int timeout = 0;
|
private int timeout = 0;
|
||||||
private int threadPriority = Thread.MIN_PRIORITY + 1;
|
private int threadPriority = Thread.MIN_PRIORITY + 1;
|
||||||
boolean debug = false;
|
boolean debug = false;
|
||||||
private String threadName = null;
|
private String threadName = null;
|
||||||
boolean readyToRun = true;
|
boolean readyToRun = true;
|
||||||
|
|
||||||
public TimeOut(){
|
public ParserTimeOut(){
|
||||||
reset();
|
reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
public TimeOut(String threadName){
|
public ParserTimeOut(String threadName){
|
||||||
this.threadName = threadName;
|
this.threadName = threadName;
|
||||||
reset();
|
reset();
|
||||||
}
|
}
|
||||||
|
@ -47,8 +45,8 @@ public class TimeOut implements Runnable {
|
||||||
readyToRun = false;
|
readyToRun = false;
|
||||||
wait(timeout);
|
wait(timeout);
|
||||||
if (enabled){
|
if (enabled){
|
||||||
if(pm != null)
|
if(cancellable != null)
|
||||||
pm.setCanceled(true);
|
cancellable.cancel();
|
||||||
enabled = false;
|
enabled = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -102,17 +100,12 @@ public class TimeOut implements Runnable {
|
||||||
public void setThreadPriority(int threadPriority) {
|
public void setThreadPriority(int threadPriority) {
|
||||||
this.threadPriority = threadPriority;
|
this.threadPriority = threadPriority;
|
||||||
}
|
}
|
||||||
/**
|
|
||||||
* @return Returns the pm.
|
|
||||||
*/
|
|
||||||
public IProgressMonitor getProgressMonitor() {
|
|
||||||
return pm;
|
|
||||||
}
|
|
||||||
/**
|
/**
|
||||||
* @param pm The pm to set.
|
* @param pm The pm to set.
|
||||||
*/
|
*/
|
||||||
public void setProgressMonitor(IProgressMonitor pm) {
|
public void setParser(IParser c) {
|
||||||
this.pm = pm;
|
this.cancellable = c;
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* @return Returns the timeout.
|
* @return Returns the timeout.
|
|
@ -353,14 +353,6 @@ public class SourceElementRequestorAdapter implements ISourceElementRequestor {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.eclipse.cdt.core.parser.ISourceElementRequestor#parserTimeout()
|
|
||||||
*/
|
|
||||||
public boolean parserTimeout() {
|
|
||||||
// TODO Auto-generated method stub
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.cdt.core.parser.ISourceElementRequestor#acceptFriendDeclaration(org.eclipse.cdt.core.parser.ast.IASTDeclaration)
|
* @see org.eclipse.cdt.core.parser.ISourceElementRequestor#acceptFriendDeclaration(org.eclipse.cdt.core.parser.ast.IASTDeclaration)
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -170,6 +170,7 @@ public class CompletionEngine implements RelevanceConstants {
|
||||||
{
|
{
|
||||||
scanner = ParserFactory.createScanner( reader, scanInfo, ParserMode.COMPLETION_PARSE, language, elementRequestor, ParserUtil.getScannerLogService(), Arrays.asList(CUIPlugin.getSharedWorkingCopies()) );
|
scanner = ParserFactory.createScanner( reader, scanInfo, ParserMode.COMPLETION_PARSE, language, elementRequestor, ParserUtil.getScannerLogService(), Arrays.asList(CUIPlugin.getSharedWorkingCopies()) );
|
||||||
parser = ParserFactory.createParser( scanner, elementRequestor, ParserMode.COMPLETION_PARSE, language, ParserUtil.getParserLogService() );
|
parser = ParserFactory.createParser( scanner, elementRequestor, ParserMode.COMPLETION_PARSE, language, ParserUtil.getParserLogService() );
|
||||||
|
elementRequestor.setParser(parser);
|
||||||
}
|
}
|
||||||
catch( ParserFactoryError pfe )
|
catch( ParserFactoryError pfe )
|
||||||
{
|
{
|
||||||
|
@ -193,7 +194,7 @@ public class CompletionEngine implements RelevanceConstants {
|
||||||
|
|
||||||
macroMap = scanner.getDefinitions();
|
macroMap = scanner.getDefinitions();
|
||||||
} catch (ParseError e ) {
|
} catch (ParseError e ) {
|
||||||
if(e.getErrorKind() == ParseError.ParseErrorKind.TIMEOUT){
|
if(e.getErrorKind() == ParseError.ParseErrorKind.TIMEOUT_OR_CANCELLED){
|
||||||
log("Timeout received !!!!!! "); //$NON-NLS-1$;
|
log("Timeout received !!!!!! "); //$NON-NLS-1$;
|
||||||
requestor.acceptError(new Problem(CUIMessages.getString("CEditor.contentassist.timeout"))); //$NON-NLS-1$;
|
requestor.acceptError(new Problem(CUIMessages.getString("CEditor.contentassist.timeout"))); //$NON-NLS-1$;
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,9 +13,10 @@ package org.eclipse.cdt.internal.ui.text.contentassist;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.parser.CodeReader;
|
import org.eclipse.cdt.core.parser.CodeReader;
|
||||||
|
import org.eclipse.cdt.core.parser.IParser;
|
||||||
import org.eclipse.cdt.core.parser.NullSourceElementRequestor;
|
import org.eclipse.cdt.core.parser.NullSourceElementRequestor;
|
||||||
|
import org.eclipse.cdt.core.parser.ParserTimeOut;
|
||||||
import org.eclipse.cdt.core.parser.ParserUtil;
|
import org.eclipse.cdt.core.parser.ParserUtil;
|
||||||
import org.eclipse.cdt.utils.TimeOut;
|
|
||||||
import org.eclipse.core.runtime.IProgressMonitor;
|
import org.eclipse.core.runtime.IProgressMonitor;
|
||||||
import org.eclipse.core.runtime.NullProgressMonitor;
|
import org.eclipse.core.runtime.NullProgressMonitor;
|
||||||
|
|
||||||
|
@ -25,8 +26,9 @@ import org.eclipse.core.runtime.NullProgressMonitor;
|
||||||
*/
|
*/
|
||||||
public class ContentAssistElementRequestor extends NullSourceElementRequestor implements ITimeoutThreadOwner{
|
public class ContentAssistElementRequestor extends NullSourceElementRequestor implements ITimeoutThreadOwner{
|
||||||
// a static timer thread
|
// a static timer thread
|
||||||
private static TimeOut timeoutThread = new TimeOut();
|
private static ParserTimeOut timeoutThread = new ParserTimeOut();
|
||||||
private IProgressMonitor pm = new NullProgressMonitor();
|
private IProgressMonitor pm = new NullProgressMonitor();
|
||||||
|
private IParser parser;
|
||||||
|
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
|
@ -45,6 +47,11 @@ public class ContentAssistElementRequestor extends NullSourceElementRequestor im
|
||||||
timeoutThread.setThreadPriority(Thread.MAX_PRIORITY);
|
timeoutThread.setThreadPriority(Thread.MAX_PRIORITY);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void setParser( IParser parser )
|
||||||
|
{
|
||||||
|
this.parser = parser;
|
||||||
|
}
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.cdt.internal.ui.text.contentassist.ITimeoutThreadOwner#setTimeout(int)
|
* @see org.eclipse.cdt.internal.ui.text.contentassist.ITimeoutThreadOwner#setTimeout(int)
|
||||||
*/
|
*/
|
||||||
|
@ -55,7 +62,7 @@ public class ContentAssistElementRequestor extends NullSourceElementRequestor im
|
||||||
* @see org.eclipse.cdt.internal.ui.text.contentassist.ITimeoutThreadOwner#startTimer()
|
* @see org.eclipse.cdt.internal.ui.text.contentassist.ITimeoutThreadOwner#startTimer()
|
||||||
*/
|
*/
|
||||||
public void startTimer() {
|
public void startTimer() {
|
||||||
createProgressMonitor();
|
createProgressMonitor(parser);
|
||||||
timeoutThread.startTimer();
|
timeoutThread.startTimer();
|
||||||
}
|
}
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
|
@ -76,9 +83,9 @@ public class ContentAssistElementRequestor extends NullSourceElementRequestor im
|
||||||
/*
|
/*
|
||||||
* Creates a new progress monitor with each start timer
|
* Creates a new progress monitor with each start timer
|
||||||
*/
|
*/
|
||||||
private void createProgressMonitor() {
|
private void createProgressMonitor(IParser parser) {
|
||||||
pm.setCanceled(false);
|
pm.setCanceled(false);
|
||||||
timeoutThread.setProgressMonitor(pm);
|
timeoutThread.setParser(parser);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue