Bug 298218 and 298219 - run the remote indexer in a separate thread and make it cancelable
diff --git a/rdt/org.eclipse.ptp.rdt.core/miners/org/eclipse/ptp/internal/rdt/core/miners/CDTMiner.java b/rdt/org.eclipse.ptp.rdt.core/miners/org/eclipse/ptp/internal/rdt/core/miners/CDTMiner.java
index 97bf2a2..7bc3a05 100755
--- a/rdt/org.eclipse.ptp.rdt.core/miners/org/eclipse/ptp/internal/rdt/core/miners/CDTMiner.java
+++ b/rdt/org.eclipse.ptp.rdt.core/miners/org/eclipse/ptp/internal/rdt/core/miners/CDTMiner.java
@@ -50,6 +50,7 @@
import org.eclipse.dstore.core.model.DataElement;
import org.eclipse.dstore.core.model.DataStore;
import org.eclipse.dstore.core.model.DataStoreResources;
+import org.eclipse.dstore.core.model.DataStoreSchema;
import org.eclipse.ptp.internal.rdt.core.IRemoteIndexerInfoProvider;
import org.eclipse.ptp.internal.rdt.core.Serializer;
import org.eclipse.ptp.internal.rdt.core.callhierarchy.CalledByResult;
@@ -80,7 +81,6 @@
public class CDTMiner extends Miner {
// index management
- public static final String C_INDEX_START = "C_INDEX_START"; //$NON-NLS-1$
public static final String C_INDEX_REINDEX = "C_INDEX_REINDEX"; //$NON-NLS-1$
public static final String C_INDEX_DELTA = "C_INDEX_DELTA"; //$NON-NLS-1$
public static final String T_INDEX_STATUS_DESCRIPTOR = "Type.Index.Status"; //$NON-NLS-1$
@@ -153,6 +153,8 @@
public static final String LOG_TAG = "CDTMiner"; //$NON-NLS-1$
+ private IndexerThread indexerThread = null;
+
/* (non-Javadoc)
* @see org.eclipse.dstore.core.miners.Miner#getVersion()
@@ -213,21 +215,6 @@
DataElement scopeName = getCommandArgument(theCommand, 1);
handleIndexFileRemove(scopeName, status);
}
-
- else if (name.equals(C_INDEX_START)) {
- try {
- String scopeName = getString(theCommand, 1);
- IRemoteIndexerInfoProvider provider = (IRemoteIndexerInfoProvider) Serializer.deserialize(getString(theCommand, 2));
- UniversalServerUtilities.logDebugMessage(LOG_TAG, "Indexing scope " + scopeName, _dataStore); //$NON-NLS-1$
- handleIndexStart(scopeName, provider, status);
- UniversalServerUtilities.logDebugMessage(LOG_TAG, "Indexing complete", _dataStore); //$NON-NLS-1$
-
- } catch (IOException e) {
- UniversalServerUtilities.logError(LOG_TAG, e.toString(), e, _dataStore);
- } catch (ClassNotFoundException e) {
- UniversalServerUtilities.logError(LOG_TAG, e.toString(), e, _dataStore);
- }
- }
else if(name.equals(C_INDEX_DELTA)) {
String scopeName = getString(theCommand, 1);
@@ -296,6 +283,20 @@
}
+ else if(name.equals(DataStoreSchema.C_CANCEL)) {
+ DataElement subject = getCommandArgument(theCommand, 0);
+ DataElement cancelStatus = getCommandStatus(subject);
+
+ // get the name of the command that is to be canceled
+ // Note for now only the indexer can be canceled, but we check the name anyway
+ String commandName = subject.getName().trim();
+
+ if(C_INDEX_REINDEX.equals(commandName) || C_INDEX_DELTA.equals(commandName)) {
+ handleIndexCancel(cancelStatus);
+ }
+ // add more cancelable commands here
+ }
+
else if(name.equals(C_MOVE_INDEX_FILE)) {
try {
String scopeName = getString(theCommand, 1);
@@ -1169,7 +1170,7 @@
index.acquireReadLock();
try {
- query.runWithIndex(index, getLocationConverter(hostName), getProgressMonitor());
+ query.runWithIndex(index, getLocationConverter(hostName), new StdoutProgressMonitor());
List<RemoteSearchMatch> matches = query.getMatches();
UniversalServerUtilities.logDebugMessage(LOG_TAG, "Found " + matches.size() + " match(es)", _dataStore); //$NON-NLS-1$ //$NON-NLS-2$
@@ -1206,52 +1207,6 @@
return Integer.parseInt(element.getName());
}
- protected void handleIndexDelta(String scopeName, List<String> addedFiles,
- List<String> changedFiles, List<String> removedFiles, IRemoteIndexerInfoProvider provider, DataElement status) {
- try {
-// statusWorking(status);
-
- StandaloneFastIndexer indexer = RemoteIndexManager.getInstance().getIndexerForScope(scopeName, provider, _dataStore, status);
- ScopeManager scopeManager = ScopeManager.getInstance();
-
- // update the scope if required
- for(String file : addedFiles) {
- scopeManager.addFileToScope(scopeName, file);
- }
-
- for(String file : changedFiles) {
- scopeManager.addFileToScope(scopeName, file);
- }
-
- for(String file : removedFiles) {
- scopeManager.removeFileFromScope(scopeName, file);
- }
-
- try {
- indexer.setTraceStatistics(true);
- indexer.setShowProblems(true);
- indexer.setShowActivity(true);
- indexer.handleDelta(addedFiles, changedFiles, removedFiles, getProgressMonitor(indexer, status));
- } catch (IOException e) {
- UniversalServerUtilities.logError(LOG_TAG, e.toString(), e, _dataStore);
- }
- } catch (Exception e) {
- UniversalServerUtilities.logError(LOG_TAG, e.toString(), e, _dataStore);
- }
-
- finally {
- statusDone(status);
- }
-
- }
-
- private IProgressMonitor getProgressMonitor(StandaloneFastIndexer indexer, DataElement status) {
- return new RemoteIndexProgressMonitor(indexer, status, _dataStore);
- }
-
- private IProgressMonitor getProgressMonitor() {
- return new StdoutProgressMonitor();
- }
/* (non-Javadoc)
* @see org.eclipse.dstore.core.model.ISchemaExtender#extendSchema(org.eclipse.dstore.core.model.DataElement)
@@ -1260,16 +1215,17 @@
UniversalServerUtilities.logInfo(LOG_TAG, "Extended schema from CDTMiner", _dataStore); //$NON-NLS-1$
+ DataElement cancellable = _dataStore.findObjectDescriptor(DataStoreResources.model_Cancellable);
+
// scope management
createCommandDescriptor(schemaRoot, "Register Scope", C_SCOPE_REGISTER, false); //$NON-NLS-1$
createCommandDescriptor(schemaRoot, "Unregister Scope", C_SCOPE_UNREGISTER, false); //$NON-NLS-1$
// index management
- createCommandDescriptor(schemaRoot, "Start Index", C_INDEX_START, false); //$NON-NLS-1$
- createCommandDescriptor(schemaRoot, "Reindex", C_INDEX_REINDEX, false); //$NON-NLS-1$
- createCommandDescriptor(schemaRoot, "Index Delta", C_INDEX_DELTA, false); //$NON-NLS-1$
- createCommandDescriptor(schemaRoot, "Remove Index File", C_REMOVE_INDEX_FILE, false); //$NON-NLS-1$
- createCommandDescriptor(schemaRoot, "Move Index File", C_MOVE_INDEX_FILE, false); //$NON-NLS-1$
+ DataElement rcmd = createCommandDescriptor(schemaRoot, "Reindex", C_INDEX_REINDEX, false); //$NON-NLS-1$
+ _dataStore.createReference(cancellable, rcmd, DataStoreResources.model_abstracts, DataStoreResources.model_abstracted_by);
+ DataElement dcmd = createCommandDescriptor(schemaRoot, "Index Delta", C_INDEX_DELTA, false); //$NON-NLS-1$
+ _dataStore.createReference(cancellable, dcmd, DataStoreResources.model_abstracts, DataStoreResources.model_abstracted_by);
// call hierarchy
createCommandDescriptor(schemaRoot, "Get Callers", C_CALL_HIERARCHY_GET_CALLERS, false); //$NON-NLS-1$
@@ -1573,26 +1529,37 @@
}
}
- protected void handleIndexStart(String scopeName, IRemoteIndexerInfoProvider provider, DataElement status) {
- try {
- StandaloneFastIndexer indexer = RemoteIndexManager.getInstance().getIndexerForScope(scopeName, provider, _dataStore, status);
- Set<String> sources = ScopeManager.getInstance().getFilesForScope(scopeName);
- List<String> sourcesList = new LinkedList<String>(sources);
+ protected void handleIndexDelta(String scopeName, List<String> addedFiles, List<String> changedFiles, List<String> removedFiles,
+ IRemoteIndexerInfoProvider provider, DataElement status) {
+ StandaloneFastIndexer indexer = RemoteIndexManager.getInstance().getIndexerForScope(scopeName, provider, _dataStore, status);
+ ScopeManager scopeManager = ScopeManager.getInstance();
+
+ // update the scope if required
+ for(String file : addedFiles)
+ scopeManager.addFileToScope(scopeName, file);
+ for(String file : changedFiles)
+ scopeManager.addFileToScope(scopeName, file);
+ for(String file : removedFiles)
+ scopeManager.removeFileFromScope(scopeName, file);
+
+ // if there is already an indexer thread running wait for it (highly unlikely since indexer tasks are only executed one at a time on the client)
+ if(indexerThread != null) {
try {
- indexer.rebuild(sourcesList, getProgressMonitor());
- } catch (IOException e) {
- UniversalServerUtilities.logError(LOG_TAG, e.toString(), e, _dataStore);
+ indexerThread.join();
+ } catch (InterruptedException e) {
+ UniversalServerUtilities.logError(LOG_TAG, "Indexer thread got interrupted", e, _dataStore); //$NON-NLS-1$
+ } catch (NullPointerException e) {
+
}
- } catch (Exception e) {
- UniversalServerUtilities.logError(LOG_TAG, e.toString(), e, _dataStore);
+
}
- finally {
- statusDone(status);
- }
+ indexerThread = IndexerThread.createIndexDeltaThread(indexer, addedFiles, changedFiles, removedFiles, status, this);
+ indexerThread.start();
}
+
protected void handleReindex(String scopeName, String newIndexLocation, IRemoteIndexerInfoProvider provider, DataElement status) {
RemoteIndexManager indexManager = RemoteIndexManager.getInstance();
indexManager.setIndexFileLocation(scopeName, newIndexLocation);
@@ -1600,16 +1567,25 @@
Set<String> sources = ScopeManager.getInstance().getFilesForScope(scopeName);
List<String> sourcesList = new LinkedList<String>(sources);
-
- try {
- indexer.setTraceStatistics(true);
- indexer.setShowProblems(true);
- indexer.setShowActivity(true);
- indexer.rebuild(sourcesList, getProgressMonitor(indexer, status));
- } catch (IOException e) {
- UniversalServerUtilities.logError(LOG_TAG, "I/O Exception while reindexing", e, _dataStore); //$NON-NLS-1$
+
+ // if there is already an indexer thread running wait for it (highly unlikely since indexer tasks are only executed one at a time on the client)
+ if(indexerThread != null) {
+ try {
+ indexerThread.join();
+ } catch (InterruptedException e) {
+ UniversalServerUtilities.logError(LOG_TAG, "Indexer thread got interrupted", e, _dataStore); //$NON-NLS-1$
+ }
}
+ indexerThread = IndexerThread.createReindexThread(indexer, sourcesList, status, this);
+ indexerThread.start();
+ }
+
+
+ protected void handleIndexCancel(DataElement status) {
+ if(indexerThread != null)
+ indexerThread.cancel();
+
statusDone(status);
}
diff --git a/rdt/org.eclipse.ptp.rdt.core/miners/org/eclipse/ptp/internal/rdt/core/miners/IndexerThread.java b/rdt/org.eclipse.ptp.rdt.core/miners/org/eclipse/ptp/internal/rdt/core/miners/IndexerThread.java
new file mode 100644
index 0000000..a41b77c
--- /dev/null
+++ b/rdt/org.eclipse.ptp.rdt.core/miners/org/eclipse/ptp/internal/rdt/core/miners/IndexerThread.java
@@ -0,0 +1,86 @@
+/*******************************************************************************
+ * Copyright (c) 2009 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.ptp.internal.rdt.core.miners;
+
+import java.io.IOException;
+import java.util.List;
+
+import org.eclipse.cdt.internal.core.indexer.StandaloneFastIndexer;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.dstore.core.model.DataElement;
+import org.eclipse.rse.dstore.universal.miners.UniversalServerUtilities;
+
+
+public abstract class IndexerThread extends Thread {
+
+ private static final String LOG_TAG = "CDTMiner - IndexerThread"; //$NON-NLS-1$
+
+ private final StandaloneFastIndexer indexer;
+ private final DataElement status;
+ private final CDTMiner miner;
+
+ private IProgressMonitor progressMonitor;
+
+
+ protected abstract void runIndexer(StandaloneFastIndexer indexer, IProgressMonitor progressMonitor) throws IOException;
+
+
+ private IndexerThread(StandaloneFastIndexer indexer, DataElement status, CDTMiner miner) {
+ super("Remote Indexer"); //$NON-NLS-1$
+ this.indexer = indexer;
+ this.status = status;
+ this.miner = miner;
+ }
+
+
+ public static IndexerThread createReindexThread(StandaloneFastIndexer indexer, final List<String> sourcesList, DataElement status, CDTMiner miner) {
+ return new IndexerThread(indexer, status, miner) {
+ protected void runIndexer(StandaloneFastIndexer indexer, IProgressMonitor progressMonitor) throws IOException {
+ indexer.rebuild(sourcesList, progressMonitor);
+ }
+ };
+ }
+
+ public static IndexerThread createIndexDeltaThread(StandaloneFastIndexer indexer, final List<String> added, final List<String> changed, final List<String> removed, DataElement status, CDTMiner miner) {
+ return new IndexerThread(indexer, status, miner) {
+ protected void runIndexer(StandaloneFastIndexer indexer, IProgressMonitor progressMonitor) throws IOException {
+ indexer.handleDelta(added, changed, removed, progressMonitor);
+ }
+ };
+ }
+
+
+ @Override
+ public void run() {
+ progressMonitor = new RemoteIndexProgressMonitor(indexer, status, miner._dataStore);
+
+ try {
+ indexer.setTraceStatistics(true);
+ indexer.setShowProblems(true);
+ indexer.setShowActivity(true);
+
+ runIndexer(indexer, progressMonitor);
+
+ } catch (IOException e) {
+ UniversalServerUtilities.logError(LOG_TAG, "I/O Exception while reindexing", e, miner._dataStore); //$NON-NLS-1$
+ }
+
+ CDTMiner.statusDone(status);
+ }
+
+
+ public void cancel() {
+ // the indexer will notice this and stop running allowing the run() method to return
+ progressMonitor.setCanceled(true);
+ UniversalServerUtilities.logDebugMessage(LOG_TAG, "Indexer Thread Cancelled", miner._dataStore); //$NON-NLS-1$
+ }
+}
diff --git a/rdt/org.eclipse.ptp.rdt.core/src/org/eclipse/ptp/internal/rdt/core/subsystems/ICIndexSubsystem.java b/rdt/org.eclipse.ptp.rdt.core/src/org/eclipse/ptp/internal/rdt/core/subsystems/ICIndexSubsystem.java
index 5873efd..b7b8a36 100755
--- a/rdt/org.eclipse.ptp.rdt.core/src/org/eclipse/ptp/internal/rdt/core/subsystems/ICIndexSubsystem.java
+++ b/rdt/org.eclipse.ptp.rdt.core/src/org/eclipse/ptp/internal/rdt/core/subsystems/ICIndexSubsystem.java
@@ -63,14 +63,6 @@
public void checkAllProjects(IProgressMonitor monitor);
// index management
- /**
- * Incrementally indexes the given scope
- *
- * @param scopeName
- * @param monitor
- * @return IStatus indicating success or failure
- */
- public IStatus startIndexOfScope(Scope scope, IRemoteIndexerInfoProvider provider, IProgressMonitor monitor);
/**
* Re-indexes the given scope.
diff --git a/rdt/org.eclipse.ptp.rdt.ui/plugin.properties b/rdt/org.eclipse.ptp.rdt.ui/plugin.properties
index d2bb2db..1f187d1 100755
--- a/rdt/org.eclipse.ptp.rdt.ui/plugin.properties
+++ b/rdt/org.eclipse.ptp.rdt.ui/plugin.properties
@@ -36,6 +36,7 @@
RemoteEnvironment=Remote Environment
page.remote = Remote Development
Environment = Environment
+RemoteProposals.name=Remote Parsing-based Proposals
export.name = C/C++ Project Settings
import.name = C/C++ Project Settings
diff --git a/rdt/org.eclipse.ptp.rdt.ui/plugin.xml b/rdt/org.eclipse.ptp.rdt.ui/plugin.xml
index c0f741e..d577ddd 100755
--- a/rdt/org.eclipse.ptp.rdt.ui/plugin.xml
+++ b/rdt/org.eclipse.ptp.rdt.ui/plugin.xml
@@ -50,16 +50,16 @@
<extension
point="org.eclipse.cdt.ui.completionProposalComputer"
id="remoteParserProposalCategory"
- name="Remote Proposals">
+ name="%RemoteProposals.name">
<proposalCategory
icon="$nl$/icons/elcl16/codeassist_co.gif"/>
</extension>
<extension
- id="LocalCompletionProposalAdapter"
+ id="RemoteCompletionProposalAdapter"
point="org.eclipse.cdt.ui.completionProposalComputer">
<completionProposalComputer
activate="true"
- categoryId="remoteParserProposalCategory"
+ categoryId="org.eclipse.ptp.rdt.ui.remoteParserProposalCategory"
class="org.eclipse.ptp.internal.rdt.ui.contentassist.RemoteCompletionProposalAdapter">
<partition type="__dftl_partition_content_type" />
<partition type="__c_preprocessor" />
diff --git a/rdt/org.eclipse.ptp.rdt.ui/src/org/eclipse/ptp/internal/rdt/ui/contentassist/AbstractCompletionProposalAdapter.java b/rdt/org.eclipse.ptp.rdt.ui/src/org/eclipse/ptp/internal/rdt/ui/contentassist/AbstractCompletionProposalAdapter.java
index 630f6fc..8b0182f 100755
--- a/rdt/org.eclipse.ptp.rdt.ui/src/org/eclipse/ptp/internal/rdt/ui/contentassist/AbstractCompletionProposalAdapter.java
+++ b/rdt/org.eclipse.ptp.rdt.ui/src/org/eclipse/ptp/internal/rdt/ui/contentassist/AbstractCompletionProposalAdapter.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007, 2008 QNX Software Systems and others.
+ * Copyright (c) 2007, 2009 QNX Software Systems and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -40,11 +40,13 @@
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.jface.text.ITextViewer;
+import org.eclipse.jface.text.contentassist.ICompletionProposal;
import org.eclipse.ptp.internal.rdt.core.contentassist.CompletionType;
import org.eclipse.ptp.internal.rdt.core.contentassist.Proposal;
import org.eclipse.ptp.internal.rdt.core.contentassist.RemoteProposalContextInformation;
import org.eclipse.ptp.internal.rdt.core.contentassist.Visibility;
import org.eclipse.ptp.internal.rdt.core.model.Scope;
+import org.eclipse.ptp.rdt.ui.UIPlugin;
import org.eclipse.swt.graphics.Image;
/**
@@ -56,21 +58,21 @@
protected abstract IContentAssistService getService(IProject project);
@Override
- public List computeCompletionProposals(ContentAssistInvocationContext context, IProgressMonitor monitor) {
+ public List<ICompletionProposal> computeCompletionProposals(ContentAssistInvocationContext context, IProgressMonitor monitor) {
try {
if (context instanceof CContentAssistInvocationContext) {
CContentAssistInvocationContext cContext = (CContentAssistInvocationContext) context;
return computeCompletionProposals(cContext, null, null);
}
} catch (Exception e) {
- CUIPlugin.log(e);
+ UIPlugin.log(e);
}
- return Collections.EMPTY_LIST;
+ return Collections.emptyList();
}
@Override
- protected List computeCompletionProposals(CContentAssistInvocationContext context, IASTCompletionNode node, String prefix) throws CoreException {
+ protected List<ICompletionProposal> computeCompletionProposals(CContentAssistInvocationContext context, IASTCompletionNode node, String prefix) throws CoreException {
IProject project = ((CContentAssistInvocationContext) context).getProject().getProject();
IContentAssistService service = getService(project);
if (service == null) {
@@ -78,12 +80,13 @@
}
ITranslationUnit unit = context.getTranslationUnit();
Scope scope = Scope.WORKSPACE_ROOT_SCOPE; // TODO: Use local scope
- List<CCompletionProposal> proposals = adaptProposals(context, service.computeCompletionProposals(scope, context, unit)); // TODO: Provide IScope
+ List<Proposal> rawProposals = service.computeCompletionProposals(scope, context, unit);
+ List<ICompletionProposal> proposals = adaptProposals(context, rawProposals); // TODO: Provide IScope
return proposals;
}
- private List<CCompletionProposal> adaptProposals(CContentAssistInvocationContext context, List<Proposal> proposals) {
- List<CCompletionProposal> result = new LinkedList<CCompletionProposal>();
+ private List<ICompletionProposal> adaptProposals(CContentAssistInvocationContext context, List<Proposal> proposals) {
+ List<ICompletionProposal> result = new LinkedList<ICompletionProposal>();
for (Proposal proposal : proposals) {
String replacement = proposal.getReplacementText();
diff --git a/rdt/org.eclipse.ptp.rdt.ui/src/org/eclipse/ptp/rdt/ui/subsystems/RemoteCIndexSubsystem.java b/rdt/org.eclipse.ptp.rdt.ui/src/org/eclipse/ptp/rdt/ui/subsystems/RemoteCIndexSubsystem.java
index f88cca0..a02ce98 100755
--- a/rdt/org.eclipse.ptp.rdt.ui/src/org/eclipse/ptp/rdt/ui/subsystems/RemoteCIndexSubsystem.java
+++ b/rdt/org.eclipse.ptp.rdt.ui/src/org/eclipse/ptp/rdt/ui/subsystems/RemoteCIndexSubsystem.java
@@ -16,7 +16,6 @@
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashSet;
-import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import java.util.Set;
@@ -145,170 +144,90 @@
fInitializedProjects = null;
}
- /* (non-Javadoc)
- * @see org.eclipse.ptp.internal.rdt.core.subsystems.ICIndexSubsystem#startIndexOfScope(org.eclipse.ptp.internal.rdt.core.model.Scope, org.eclipse.core.runtime.IProgressMonitor)
- */
- public IStatus startIndexOfScope(Scope scope, IRemoteIndexerInfoProvider provider, IProgressMonitor monitor)
- {
- DataStore dataStore = getDataStore();
-
- if (dataStore != null)
- {
-
- StatusMonitor smonitor = StatusMonitorFactory.getInstance().getStatusMonitorFor(getConnectorService(), dataStore);
-
-
- monitor.beginTask(Messages.getString("RemoteCIndexSubsystem.0"), 100); //$NON-NLS-1$
-
- DataElement queryCmd = dataStore.localDescriptorQuery(dataStore.getDescriptorRoot(), CDTMiner.C_INDEX_START);
- if (queryCmd != null)
- {
-
- ArrayList<Object> args = new ArrayList<Object>();
-
- // need to know the scope
- DataElement scopeElement = dataStore.createObject(null, CDTMiner.T_SCOPE_SCOPENAME_DESCRIPTOR, scope.getName());
- args.add(scopeElement);
-
- String serializedProvider = null;
- try {
- serializedProvider = Serializer.serialize(provider);
- } catch (IOException e) {
- RDTLog.logError(e);
- }
-
- DataElement providerElement = dataStore.createObject(null, CDTMiner.T_INDEX_SCANNER_INFO_PROVIDER, serializedProvider);
- args.add(providerElement);
-
-
- // execute the command
- //DataElement status = dataStore.command(queryCmd, dataStore.getDescriptorRoot(), true);
- DataElement status = dataStore.command(queryCmd, args, dataStore.getDescriptorRoot());
-
- try
- {
- smonitor.waitForUpdate(status, monitor);
- if (monitor.isCanceled())
- {
- cancelOperation(monitor, status.getParent());
- }
- }
- catch (Exception e)
- {
- }
-
- }
-
- }
-
- return Status.OK_STATUS;
-
- }
-
+
/*
* (non-Javadoc)
* @see org.eclipse.ptp.internal.rdt.core.subsystems.ICIndexSubsystem#reindexScope(org.eclipse.ptp.internal.rdt.core.model.Scope, org.eclipse.ptp.internal.rdt.core.IRemoteIndexerInfoProvider, org.eclipse.core.runtime.IProgressMonitor, org.eclipse.ptp.internal.rdt.core.index.RemoteIndexerTask)
*/
- public IStatus reindexScope(Scope scope, IRemoteIndexerInfoProvider provider, String indexLocation, IProgressMonitor monitor, RemoteIndexerTask task)
- {
+ public IStatus reindexScope(Scope scope, IRemoteIndexerInfoProvider provider, String indexLocation, IProgressMonitor monitor, RemoteIndexerTask task) {
removeProblems(scope);
DataStore dataStore = getDataStore();
-
- if (dataStore != null)
- {
-
- DataElement result = getDataStore().createObject(null, CDTMiner.T_INDEX_STATUS_DESCRIPTOR, "index"); //$NON-NLS-1$
- StatusMonitor smonitor = StatusMonitorFactory.getInstance().getStatusMonitorFor(getConnectorService(), dataStore);
-
-// int count = 0;
-// DataElement countCmd = dataStore.localDescriptorQuery(datastore.getDescriptorRoot(), CDTMiner.C_SCOPE_COUNT_ELEMENTS);
-// if (countCmd != null)
-// {
-// DataElement countStatus = dataStore.command(countCmd, result, true);
-// try
-// {
-// smonitor.waitForUpdate(countStatus, monitor, 5000);
-// if (monitor.isCanceled())
-// {
-// cancelOperation(monitor, countStatus.getParent());
-// }
-// }
-// catch (Exception e)
-// {
-// }
-// count = Integer.parseInt(countStatus.getSource());
-// }
-//
-// monitor.beginTask(Messages.getString("RemoteCIndexSubsystem.1"), count); //$NON-NLS-1$
-
- monitor.beginTask("Rebuilding indexing...", 100); //$NON-NLS-1$
-
- DataElement queryCmd = dataStore.localDescriptorQuery(dataStore.getDescriptorRoot(), CDTMiner.C_INDEX_REINDEX);
- if (queryCmd != null)
- {
-
- ArrayList<Object> args = new ArrayList<Object>();
-
- // need to know the scope
- DataElement scopeElement = dataStore.createObject(null, CDTMiner.T_SCOPE_SCOPENAME_DESCRIPTOR, scope.getName());
- args.add(scopeElement);
-
- String serializedProvider = null;
+ if(dataStore == null)
+ return Status.OK_STATUS;
+
+ DataElement result = getDataStore().createObject(null, CDTMiner.T_INDEX_STATUS_DESCRIPTOR, "index"); //$NON-NLS-1$
+ StatusMonitor smonitor = StatusMonitorFactory.getInstance().getStatusMonitorFor(getConnectorService(), dataStore);
+ monitor.beginTask("Rebuilding indexing...", 100); //$NON-NLS-1$
+
+ DataElement queryCmd = dataStore.localDescriptorQuery(dataStore.getDescriptorRoot(), CDTMiner.C_INDEX_REINDEX);
+ if (queryCmd != null) {
+ ArrayList<Object> args = new ArrayList<Object>();
+
+ args.add(dataStore.createObject(null, CDTMiner.T_SCOPE_SCOPENAME_DESCRIPTOR, scope.getName()));
+
+ String serializedProvider = null;
+ try {
+ serializedProvider = Serializer.serialize(provider);
+ } catch (IOException e) {
+ RDTLog.logError(e);
+ }
+
+ args.add(dataStore.createObject(null, CDTMiner.T_INDEX_SCANNER_INFO_PROVIDER, serializedProvider));
+ args.add(dataStore.createObject(null, CDTMiner.T_SCOPE_CONFIG_LOCATION, indexLocation));
+
+ DataElement status = dataStore.command(queryCmd, args, result);
+
+ //poll for progress information until the operation is done or canceled
+ while (!status.getName().equals("done") && !status.getName().equals("cancelled") && !monitor.isCanceled()) { //$NON-NLS-1$ //$NON-NLS-2$
+ RemoteIndexerProgress progress = getIndexerProgress(status);
+ task.updateProgressInformation(progress);
try {
- serializedProvider = Serializer.serialize(provider);
- } catch (IOException e) {
- RDTLog.logError(e);
- }
-
- DataElement providerElement = dataStore.createObject(null, CDTMiner.T_INDEX_SCANNER_INFO_PROVIDER, serializedProvider);
- args.add(providerElement);
-
- // need to know the scope config location
- DataElement indexLocationElement = dataStore.createObject(null, CDTMiner.T_SCOPE_CONFIG_LOCATION, indexLocation);
- args.add(indexLocationElement);
-
- DataElement status = dataStore.command(queryCmd, args, result);
-
- //poll for progress information until the operation is done or canceled
- while (!status.getName().equals("done") && !status.getName().equals("cancelled") && !monitor.isCanceled()) { //$NON-NLS-1$ //$NON-NLS-2$
-
- RemoteIndexerProgress progress = getIndexerProgress(status);
- task.updateProgressInformation(progress);
- try {
- Thread.sleep(100);
- } catch (InterruptedException e) {
- RDTLog.logError(e);
- }
- }
-
- try {
- smonitor.waitForUpdate(status, monitor);
- if (monitor.isCanceled())
- cancelOperation(monitor, status.getParent());
- } catch (Exception e) {
+ Thread.sleep(100);
+ } catch (InterruptedException e) {
RDTLog.logError(e);
}
-
- if (status.getName().equals("done") || status.getName().equals("cancelled") || monitor.isCanceled()) { //$NON-NLS-1$//$NON-NLS-2$
- for (int i = 0; i < status.getNestedSize(); i ++ ){
- DataElement element = status.get(i);
- if (element != null && CDTMiner.T_INDEXING_ERROR.equals(element.getType())) { // Error occurred on the server
- String message = element.getAttribute(DE.A_NAME)+ ". " + Messages.getString("RemoteCIndexSubsystem.11"); //$NON-NLS-1$//$NON-NLS-2$
- for (int j = 0; j < fErrorMessages.size(); j++) {
- if (message.indexOf(fErrorMessages.get(j)) > 0) {
- RDTLog.logWarning(message);
- reportProblem(scope, message);
- }
- }
- }
- }
- }
- monitor.done();
}
- }
+
+ try {
+ try {
+ smonitor.waitForUpdate(status, monitor);
+ } catch (InterruptedException e) { // Canceled
+ if (monitor.isCanceled())
+ cancelOperation(status.getParent());
+ }
+ } catch (Exception e) {
+ RDTLog.logError(e);
+ }
+
+ if (status.getName().equals("done") || status.getName().equals("cancelled") || monitor.isCanceled()) { //$NON-NLS-1$//$NON-NLS-2$
+ for (int i = 0; i < status.getNestedSize(); i ++ ){
+ DataElement element = status.get(i);
+ if (element != null && CDTMiner.T_INDEXING_ERROR.equals(element.getType())) { // Error occurred on the server
+ String message = element.getAttribute(DE.A_NAME)+ ". " + Messages.getString("RemoteCIndexSubsystem.11"); //$NON-NLS-1$//$NON-NLS-2$
+ for (int j = 0; j < fErrorMessages.size(); j++) {
+ if (message.indexOf(fErrorMessages.get(j)) > 0) {
+ RDTLog.logWarning(message);
+ reportProblem(scope, message);
+ }
+ }
+ }
+ }
+ }
+ monitor.done();
+ }
return Status.OK_STATUS;
-
+ }
+
+
+ protected void cancelOperation(DataElement command) {
+ // send cancel command
+ DataStore dataStore = command.getDataStore();
+ DataElement cmdDescriptor = command.getDescriptor();
+ DataElement cancelDescriptor = dataStore.localDescriptorQuery(cmdDescriptor, DataStoreSchema.C_CANCEL);
+ if (cancelDescriptor != null) {
+ dataStore.command(cancelDescriptor, command);
+ }
}
@@ -338,17 +257,23 @@
int lineEnd = message.indexOf(". Please", lineStart); //$NON-NLS-1$
String lineNumber = message.substring(lineStart + 1, lineEnd);
+ IFile file = null;
String projectLocation = project.getLocationURI().getPath();
fileStart = fileName.indexOf(projectLocation);
- fileName = fileName.substring(fileStart + projectLocation.length() + 1);
+ if(fileStart == -1) {
+ fileName = null;
+ }
+ else {
+ fileName = fileName.substring(fileStart + projectLocation.length() + 1);
+ IPath path = new Path(fileName);
+ file = project.getFile(path);
+ }
- IPath path = new Path(fileName);
- IFile file = project.getFile(path);
if (file != null) {
try {
IMarker marker = file.createMarker("org.eclipse.ptp.rdt.ui.indexerproblemmarker"); //$NON-NLS-1$
- marker.setAttribute(IMarker.LINE_NUMBER, Integer.parseInt(lineNumber));
+ marker.setAttribute(IMarker.LINE_NUMBER, Integer.parseInt(lineNumber.replace(",", ""))); //$NON-NLS-1$ //$NON-NLS-2$
marker.setAttribute(IMarker.MESSAGE, message);
marker.setAttribute(IMarker.SEVERITY, IMarker.SEVERITY_WARNING);
return;
@@ -366,133 +291,99 @@
}
}
+
/* (non-Javadoc)
* @see org.eclipse.ptp.internal.rdt.core.subsystems.ICIndexSubsystem#indexDelta(org.eclipse.ptp.internal.rdt.core.model.Scope, java.util.List, java.util.List, java.util.List, org.eclipse.core.runtime.IProgressMonitor)
*/
- public IStatus indexDelta(Scope scope,
- IRemoteIndexerInfoProvider provider,
- List<ICElement> newElements, List<ICElement> changedElements,
- List<ICElement> deletedElements, IProgressMonitor monitor,
- RemoteIndexerTask task) {
- removeProblems(scope);
+ public IStatus indexDelta(Scope scope, IRemoteIndexerInfoProvider provider, List<ICElement> newElements,
+ List<ICElement> changedElements, List<ICElement> deletedElements, IProgressMonitor monitor, RemoteIndexerTask task) {
+ removeProblems(scope);
DataStore dataStore = getDataStore();
-
- if (dataStore != null)
- {
-
- DataElement result = getDataStore().createObject(null, CDTMiner.T_INDEX_STATUS_DESCRIPTOR, "index"); //$NON-NLS-1$
- StatusMonitor smonitor = StatusMonitorFactory.getInstance().getStatusMonitorFor(_connectorService, dataStore);
-
- int workCount = newElements.size() + changedElements.size();
-
- monitor.beginTask("Incrementally Indexing...", workCount); //$NON-NLS-1$
-
- DataElement queryCmd = dataStore.localDescriptorQuery(dataStore.getDescriptorRoot(), CDTMiner.C_INDEX_DELTA);
- if (queryCmd != null)
- {
-
- ArrayList<Object> args = new ArrayList<Object>();
-
- // need to know the scope
- DataElement scopeElement = dataStore.createObject(null, CDTMiner.T_SCOPE_SCOPENAME_DESCRIPTOR, scope.getName());
- args.add(scopeElement);
-
-
- String serializedProvider = null;
- try {
- serializedProvider = Serializer.serialize(provider);
- } catch (IOException e) {
- RDTLog.logError(e);
- }
-
- DataElement providerElement = dataStore.createObject(null, CDTMiner.T_INDEX_SCANNER_INFO_PROVIDER, serializedProvider);
- args.add(providerElement);
-
-
- // iterate through the additions and create an object for each addition
- Iterator<ICElement> iterator = newElements.iterator();
-
- while(iterator.hasNext()) {
- ICElement element = iterator.next();
-
- // figure out the path to the element on the remote machine
- String remotePath = convertURIToRemotePath(element.getLocationURI());
-
- DataElement addedElement = dataStore.createObject(null, CDTMiner.T_INDEX_DELTA_ADDED, remotePath);
- args.add(addedElement);
- }
-
- // iterate through the changed elements and create an object for each change
- iterator = changedElements.iterator();
-
- while(iterator.hasNext()) {
- ICElement element = iterator.next();
-
- // figure out the path to the element on the remote machine
- String remotePath = convertURIToRemotePath(element.getLocationURI());
-
- DataElement changedElement = dataStore.createObject(null, CDTMiner.T_INDEX_DELTA_CHANGED, remotePath);
- args.add(changedElement);
- }
-
- // iterate through the deleted elements and create an object for each change
- iterator = deletedElements.iterator();
-
- while(iterator.hasNext()) {
- ICElement element = iterator.next();
-
- // figure out the path to the element on the remote machine
- String remotePath = convertURIToRemotePath(element.getLocationURI());
-
- DataElement deletedElement = dataStore.createObject(null, CDTMiner.T_INDEX_DELTA_REMOVED, remotePath);
- args.add(deletedElement);
- }
-
- DataElement status = dataStore.command(queryCmd, args, result);
-
- //poll for progress information until the operation is done or canceled
- while (!status.getName().equals("done") && !status.getName().equals("cancelled") && !monitor.isCanceled()) { //$NON-NLS-1$ //$NON-NLS-2$
+ if(dataStore == null)
+ return Status.OK_STATUS;
- RemoteIndexerProgress progress = getIndexerProgress(status);
- task.updateProgressInformation(progress);
- try {
- Thread.sleep(100);
- } catch (InterruptedException e) {
- RDTLog.logError(e);
- }
- }
-
- try {
- smonitor.waitForUpdate(status, monitor);
- if (monitor.isCanceled())
- cancelOperation(monitor, status.getParent());
- } catch (Exception e) {
+ DataElement result = getDataStore().createObject(null, CDTMiner.T_INDEX_STATUS_DESCRIPTOR, "index"); //$NON-NLS-1$
+ StatusMonitor smonitor = StatusMonitorFactory.getInstance().getStatusMonitorFor(_connectorService, dataStore);
+ int workCount = newElements.size() + changedElements.size();
+ monitor.beginTask("Incrementally Indexing...", workCount); //$NON-NLS-1$
+
+ DataElement queryCmd = dataStore.localDescriptorQuery(dataStore.getDescriptorRoot(), CDTMiner.C_INDEX_DELTA);
+ if (queryCmd != null) {
+ ArrayList<Object> args = new ArrayList<Object>();
+
+ args.add(dataStore.createObject(null, CDTMiner.T_SCOPE_SCOPENAME_DESCRIPTOR, scope.getName()));
+
+ String serializedProvider = null;
+ try {
+ serializedProvider = Serializer.serialize(provider);
+ } catch (IOException e) {
+ RDTLog.logError(e);
+ }
+
+ args.add(dataStore.createObject(null, CDTMiner.T_INDEX_SCANNER_INFO_PROVIDER, serializedProvider));
+
+ for(ICElement element : newElements) {
+ String remotePath = convertURIToRemotePath(element.getLocationURI());
+ args.add(dataStore.createObject(null, CDTMiner.T_INDEX_DELTA_ADDED, remotePath));
+ }
+
+ for(ICElement element : changedElements) {
+ String remotePath = convertURIToRemotePath(element.getLocationURI());
+ args.add(dataStore.createObject(null, CDTMiner.T_INDEX_DELTA_CHANGED, remotePath));
+ }
+
+ for(ICElement element : deletedElements) {
+ String remotePath = convertURIToRemotePath(element.getLocationURI());
+ args.add(dataStore.createObject(null, CDTMiner.T_INDEX_DELTA_REMOVED, remotePath));
+ }
+
+ DataElement status = dataStore.command(queryCmd, args, result);
+
+ //poll for progress information until the operation is done or canceled
+ while (!status.getName().equals("done") && !status.getName().equals("cancelled") && !monitor.isCanceled()) { //$NON-NLS-1$ //$NON-NLS-2$
+ RemoteIndexerProgress progress = getIndexerProgress(status);
+ task.updateProgressInformation(progress);
+ try {
+ Thread.sleep(100);
+ } catch (InterruptedException e) {
RDTLog.logError(e);
}
-
- if (status.getName().equals("done") || status.getName().equals("cancelled") || monitor.isCanceled()) { //$NON-NLS-1$//$NON-NLS-2$
- for (int i = 0; i < status.getNestedSize(); i ++ ){
- DataElement element = status.get(i);
- if (element != null && CDTMiner.T_INDEXING_ERROR.equals(element.getType())) { // Error occurred on the server
- String message = element.getAttribute(DE.A_NAME)+ ". " + Messages.getString("RemoteCIndexSubsystem.11"); //$NON-NLS-1$//$NON-NLS-2$
- for (int j = 0; j < fErrorMessages.size(); j++) {
- if (message.indexOf(fErrorMessages.get(j)) > 0) {
- RDTLog.logWarning(message);
- reportProblem(scope, message);
- }
- }
- }
- }
+ }
+
+ try {
+ try {
+ smonitor.waitForUpdate(status, monitor);
+ } catch (InterruptedException e) { // Canceled
+ if (monitor.isCanceled())
+ cancelOperation(status.getParent());
}
-
- monitor.done();
+ } catch(Exception e) {
+ RDTLog.logError(e);
+ }
+
+ if (status.getName().equals("done") || status.getName().equals("cancelled") || monitor.isCanceled()) { //$NON-NLS-1$//$NON-NLS-2$
+ for (int i = 0; i < status.getNestedSize(); i ++ ){
+ DataElement element = status.get(i);
+ if (element != null && CDTMiner.T_INDEXING_ERROR.equals(element.getType())) { // Error occurred on the server
+ String message = element.getAttribute(DE.A_NAME)+ ". " + Messages.getString("RemoteCIndexSubsystem.11"); //$NON-NLS-1$//$NON-NLS-2$
+ for (int j = 0; j < fErrorMessages.size(); j++) {
+ if (message.indexOf(fErrorMessages.get(j)) > 0) {
+ RDTLog.logWarning(message);
+ reportProblem(scope, message);
+ }
+ }
+ }
+ }
}
+
+ monitor.done();
}
return Status.OK_STATUS;
}
-
+
+
private RemoteIndexerProgress getIndexerProgress(DataElement status) {
int num = status.getNestedSize();
if (num > 0) {
@@ -569,20 +460,12 @@
try
{
smonitor.waitForUpdate(status, monitor);
- if (monitor.isCanceled())
- {
- cancelOperation(monitor, status.getParent());
- }
}
catch (Exception e)
{
+ RDTLog.logError(e);
}
-
- int i=0;
- i++;
}
-
-
}
return Status.OK_STATUS;
@@ -685,19 +568,12 @@
try
{
smonitor.waitForUpdate(status, monitor);
- if (monitor.isCanceled())
- {
- cancelOperation(monitor, status.getParent());
- }
}
catch (Exception e)
- {
+ {
+ RDTLog.logError(e);
}
-
-
- }
-
-
+ }
}
return Status.OK_STATUS;
@@ -814,10 +690,6 @@
try
{
smonitor.waitForUpdate(status, monitor);
- if (monitor.isCanceled())
- {
- cancelOperation(monitor, status.getParent());
- }
}
catch (Exception e)
{
@@ -918,9 +790,6 @@
{
monitor = monitor == null ? new NullProgressMonitor() : monitor;
statusMonitor.waitForUpdate(status, monitor);
- if (monitor.isCanceled()) {
- cancelOperation(monitor, status.getParent());
- }
}
catch (Exception e) {
RDTLog.logError(e);
@@ -973,16 +842,6 @@
return null;
}
- protected void cancelOperation(IProgressMonitor monitor, DataElement cmd) throws java.lang.reflect.InvocationTargetException, java.lang.InterruptedException
- {
- DataStore dataStore = cmd.getDataStore();
- DataElement commandDescriptor = dataStore.findCommandDescriptor(DataStoreSchema.C_CANCEL);
- if (commandDescriptor != null)
- {
- dataStore.command(commandDescriptor, cmd, false, true);
- }
- }
-
public void checkAllProjects(IProgressMonitor monitor) {
IWorkspace workspace = ResourcesPlugin.getWorkspace();
IWorkspaceRoot workspaceRoot = workspace.getRoot();
diff --git a/rdt/org.eclipse.ptp.rdt.ui/src/org/eclipse/ptp/rdt/ui/subsystems/RemoteCIndexSubsystem2.java b/rdt/org.eclipse.ptp.rdt.ui/src/org/eclipse/ptp/rdt/ui/subsystems/RemoteCIndexSubsystem2.java
index b5ecbd7..d6e870f 100644
--- a/rdt/org.eclipse.ptp.rdt.ui/src/org/eclipse/ptp/rdt/ui/subsystems/RemoteCIndexSubsystem2.java
+++ b/rdt/org.eclipse.ptp.rdt.ui/src/org/eclipse/ptp/rdt/ui/subsystems/RemoteCIndexSubsystem2.java
@@ -730,64 +730,6 @@
return (String) sendRequest(requestType, arguments, monitor, false);
}
- /* (non-Javadoc)
- * @see org.eclipse.ptp.internal.rdt.core.subsystems.ICIndexSubsystem#startIndexOfScope(org.eclipse.ptp.internal.rdt.core.model.Scope, org.eclipse.core.runtime.IProgressMonitor)
- */
- public IStatus startIndexOfScope(Scope scope, IRemoteIndexerInfoProvider provider, IProgressMonitor monitor)
- {
- DataStore dataStore = getDataStore();
-
- if (dataStore != null)
- {
-
- StatusMonitor smonitor = StatusMonitor.getStatusMonitorFor(fProvider.getRemoteConnection(), dataStore);
-
- monitor.beginTask(Messages.getString("RemoteCIndexSubsystem.0"), 100); //$NON-NLS-1$
-
- DataElement queryCmd = dataStore.localDescriptorQuery(dataStore.getDescriptorRoot(), CDTMiner.C_INDEX_START);
- if (queryCmd != null)
- {
-
- ArrayList<Object> args = new ArrayList<Object>();
-
- // need to know the scope
- DataElement scopeElement = dataStore.createObject(null, CDTMiner.T_SCOPE_SCOPENAME_DESCRIPTOR, scope.getName());
- args.add(scopeElement);
-
- String serializedProvider = null;
- try {
- serializedProvider = Serializer.serialize(provider);
- } catch (IOException e) {
- RDTLog.logError(e);
- }
-
- DataElement providerElement = dataStore.createObject(null, CDTMiner.T_INDEX_SCANNER_INFO_PROVIDER, serializedProvider);
- args.add(providerElement);
-
-
- // execute the command
- //DataElement status = dataStore.command(queryCmd, dataStore.getDescriptorRoot(), true);
- DataElement status = dataStore.command(queryCmd, args, dataStore.getDescriptorRoot());
-
- try
- {
- smonitor.waitForUpdate(status, monitor);
- if (monitor.isCanceled())
- {
- cancelOperation(monitor, status.getParent());
- }
- }
- catch (Exception e)
- {
- }
-
- }
-
- }
-
- return Status.OK_STATUS;
-
- }
/* (non-Javadoc)
* @see org.eclipse.ptp.internal.rdt.core.subsystems.ICIndexSubsystem#unregisterScope(org.eclipse.ptp.internal.rdt.core.model.Scope, org.eclipse.core.runtime.IProgressMonitor)