mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-28 19:35:36 +02:00
Fix for 150075, progress indication for indexer
This commit is contained in:
parent
0132200353
commit
2d8f966f3b
33 changed files with 453 additions and 213 deletions
|
@ -99,7 +99,7 @@ public abstract class AbstractGCCBOPConsoleParserUtility {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected IPath convertCygpath(IPath path) {
|
public static IPath convertCygpath(IPath path) {
|
||||||
if (path.segmentCount() > 1 && path.segment(0).equals("cygdrive")) { //$NON-NLS-1$
|
if (path.segmentCount() > 1 && path.segment(0).equals("cygdrive")) { //$NON-NLS-1$
|
||||||
StringBuffer buf = new StringBuffer(2);
|
StringBuffer buf = new StringBuffer(2);
|
||||||
buf.append(Character.toUpperCase(path.segment(1).charAt(0)));
|
buf.append(Character.toUpperCase(path.segment(1).charAt(0)));
|
||||||
|
|
|
@ -25,6 +25,7 @@ import org.eclipse.cdt.make.internal.core.scannerconfig.util.TraceUtil;
|
||||||
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.IPath;
|
import org.eclipse.core.runtime.IPath;
|
||||||
|
import org.eclipse.core.runtime.Path;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Parses gcc and g++ output for -I and -D parameters.
|
* Parses gcc and g++ output for -I and -D parameters.
|
||||||
|
@ -126,6 +127,10 @@ public class GCCScannerInfoConsoleParser extends AbstractGCCBOPConsoleParser {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (fileName != null && fileName.startsWith("/cygdrive/")) { //$NON-NLS-1$
|
||||||
|
fileName= AbstractGCCBOPConsoleParserUtility.convertCygpath(new Path(fileName)).toOSString();
|
||||||
|
}
|
||||||
|
|
||||||
IProject project = getProject();
|
IProject project = getProject();
|
||||||
IFile file = null;
|
IFile file = null;
|
||||||
List translatedIncludes = includes;
|
List translatedIncludes = includes;
|
||||||
|
@ -221,7 +226,7 @@ public class GCCScannerInfoConsoleParser extends AbstractGCCBOPConsoleParser {
|
||||||
if (postfix.charAt(0) == '-') { // empty -I
|
if (postfix.charAt(0) == '-') { // empty -I
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (postfix.startsWith(SINGLE_QUOTE_STRING) || postfix.startsWith(DOUBLE_QUOTE_STRING)) { //$NON-NLS-1$ //$NON-NLS-2$
|
if (postfix.startsWith(SINGLE_QUOTE_STRING) || postfix.startsWith(DOUBLE_QUOTE_STRING)) {
|
||||||
delimiter = postfix.substring(0, 1);
|
delimiter = postfix.substring(0, 1);
|
||||||
}
|
}
|
||||||
String[] tokens = postfix.split(delimiter);
|
String[] tokens = postfix.split(delimiter);
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2004, 2005 IBM Corporation and others.
|
* Copyright (c) 2004, 2006 IBM Corporation and others.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
@ -7,6 +7,7 @@
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* IBM - Initial API and implementation
|
* IBM - Initial API and implementation
|
||||||
|
* Markus Schorn (Wind River Systems)
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.make.internal.core.scannerconfig2;
|
package org.eclipse.cdt.make.internal.core.scannerconfig2;
|
||||||
|
|
||||||
|
@ -83,22 +84,22 @@ public class PerFileSICollector implements IScannerInfoCollector2, IScannerInfoC
|
||||||
Integer commandId = (Integer) i.next();
|
Integer commandId = (Integer) i.next();
|
||||||
CCommandDSC command = (CCommandDSC) commandIdCommandMap.get(commandId);
|
CCommandDSC command = (CCommandDSC) commandIdCommandMap.get(commandId);
|
||||||
|
|
||||||
Element cmdElem = doc.createElement(CC_ELEM); //$NON-NLS-1$
|
Element cmdElem = doc.createElement(CC_ELEM);
|
||||||
collectorElem.appendChild(cmdElem);
|
collectorElem.appendChild(cmdElem);
|
||||||
cmdElem.setAttribute(ID_ATTR, commandId.toString()); //$NON-NLS-1$
|
cmdElem.setAttribute(ID_ATTR, commandId.toString());
|
||||||
cmdElem.setAttribute(FILE_TYPE_ATTR, command.appliesToCPPFileType() ? "c++" : "c"); //$NON-NLS-1$ //$NON-NLS-2$
|
cmdElem.setAttribute(FILE_TYPE_ATTR, command.appliesToCPPFileType() ? "c++" : "c"); //$NON-NLS-1$ //$NON-NLS-2$
|
||||||
// write command and scanner info
|
// write command and scanner info
|
||||||
command.serialize(cmdElem);
|
command.serialize(cmdElem);
|
||||||
// write files command applies to
|
// write files command applies to
|
||||||
Element filesElem = doc.createElement(APPLIES_TO_ATTR); //$NON-NLS-1$
|
Element filesElem = doc.createElement(APPLIES_TO_ATTR);
|
||||||
cmdElem.appendChild(filesElem);
|
cmdElem.appendChild(filesElem);
|
||||||
Set files = (Set) commandIdToFilesMap.get(commandId);
|
Set files = (Set) commandIdToFilesMap.get(commandId);
|
||||||
if (files != null) {
|
if (files != null) {
|
||||||
for (Iterator j = files.iterator(); j.hasNext(); ) {
|
for (Iterator j = files.iterator(); j.hasNext(); ) {
|
||||||
Element fileElem = doc.createElement(FILE_ELEM); //$NON-NLS-1$
|
Element fileElem = doc.createElement(FILE_ELEM);
|
||||||
IFile file = (IFile) j.next();
|
IFile file = (IFile) j.next();
|
||||||
IPath path = file.getProjectRelativePath();
|
IPath path = file.getProjectRelativePath();
|
||||||
fileElem.setAttribute(PATH_ATTR, path.toString()); //$NON-NLS-1$
|
fileElem.setAttribute(PATH_ATTR, path.toString());
|
||||||
filesElem.appendChild(fileElem);
|
filesElem.appendChild(fileElem);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -110,7 +111,7 @@ public class PerFileSICollector implements IScannerInfoCollector2, IScannerInfoC
|
||||||
*/
|
*/
|
||||||
public void deserialize(Element collectorElem) {
|
public void deserialize(Element collectorElem) {
|
||||||
for (Node child = collectorElem.getFirstChild(); child != null; child = child.getNextSibling()) {
|
for (Node child = collectorElem.getFirstChild(); child != null; child = child.getNextSibling()) {
|
||||||
if (child.getNodeName().equals(CC_ELEM)) { //$NON-NLS-1$
|
if (child.getNodeName().equals(CC_ELEM)) {
|
||||||
Element cmdElem = (Element) child;
|
Element cmdElem = (Element) child;
|
||||||
boolean cppFileType = cmdElem.getAttribute(FILE_TYPE_ATTR).equals("c++"); //$NON-NLS-1$
|
boolean cppFileType = cmdElem.getAttribute(FILE_TYPE_ATTR).equals("c++"); //$NON-NLS-1$
|
||||||
CCommandDSC command = new CCommandDSC(cppFileType);
|
CCommandDSC command = new CCommandDSC(cppFileType);
|
||||||
|
|
|
@ -23,7 +23,9 @@ import org.eclipse.cdt.core.index.IIndexBinding;
|
||||||
import org.eclipse.cdt.core.index.IIndexFile;
|
import org.eclipse.cdt.core.index.IIndexFile;
|
||||||
import org.eclipse.cdt.core.index.IIndexInclude;
|
import org.eclipse.cdt.core.index.IIndexInclude;
|
||||||
import org.eclipse.cdt.core.index.IndexFilter;
|
import org.eclipse.cdt.core.index.IndexFilter;
|
||||||
|
import org.eclipse.cdt.core.model.CoreModel;
|
||||||
import org.eclipse.cdt.core.model.ICProject;
|
import org.eclipse.cdt.core.model.ICProject;
|
||||||
|
import org.eclipse.cdt.core.model.IPathEntry;
|
||||||
import org.eclipse.cdt.core.testplugin.CProjectHelper;
|
import org.eclipse.cdt.core.testplugin.CProjectHelper;
|
||||||
import org.eclipse.cdt.core.testplugin.TestScannerProvider;
|
import org.eclipse.cdt.core.testplugin.TestScannerProvider;
|
||||||
import org.eclipse.cdt.core.testplugin.util.TestSourceReader;
|
import org.eclipse.cdt.core.testplugin.util.TestSourceReader;
|
||||||
|
@ -56,6 +58,10 @@ public class IndexIncludeTest extends IndexTestBase {
|
||||||
super.setUp();
|
super.setUp();
|
||||||
if (fProject == null) {
|
if (fProject == null) {
|
||||||
fProject= createProject(true, "resources/indexTests/includes");
|
fProject= createProject(true, "resources/indexTests/includes");
|
||||||
|
IPathEntry[] entries= new IPathEntry[] {
|
||||||
|
CoreModel.newIncludeEntry(fProject.getPath(),
|
||||||
|
null, fProject.getResource().getLocation())};
|
||||||
|
fProject.setRawPathEntries(entries, NPM);
|
||||||
}
|
}
|
||||||
fIndex= CCorePlugin.getIndexManager().getIndex(fProject);
|
fIndex= CCorePlugin.getIndexManager().getIndex(fProject);
|
||||||
}
|
}
|
||||||
|
|
|
@ -92,6 +92,7 @@ public class CProjectHelper {
|
||||||
}
|
}
|
||||||
newProject[0] = CCorePlugin.getDefault().getCoreModel().create(project);
|
newProject[0] = CCorePlugin.getDefault().getCoreModel().create(project);
|
||||||
if (indexerID != null) {
|
if (indexerID != null) {
|
||||||
|
CCoreInternals.getPDOMManager().setIndexAllFiles(newProject[0], true);
|
||||||
CCoreInternals.getPDOMManager().setIndexerId(newProject[0], indexerID);
|
CCoreInternals.getPDOMManager().setIndexerId(newProject[0], indexerID);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,3 +35,7 @@ org.eclipse.cdt.core/debug/typeresolver=false
|
||||||
|
|
||||||
# Reports timings for PDOM
|
# Reports timings for PDOM
|
||||||
org.eclipse.cdt.core/debug/pdomtimings=false
|
org.eclipse.cdt.core/debug/pdomtimings=false
|
||||||
|
|
||||||
|
# Reports sequence of files indexed
|
||||||
|
org.eclipse.cdt.core/debug/indexer=false
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
#Tue Oct 10 16:32:29 CEST 2006
|
#Thu Nov 09 15:08:09 CET 2006
|
||||||
eclipse.preferences.version=1
|
eclipse.preferences.version=1
|
||||||
encoding//parser/org/eclipse/cdt/internal/core/index/messages.properties=8859_1
|
encoding//parser/org/eclipse/cdt/internal/core/index/messages.properties=8859_1
|
||||||
encoding//parser/org/eclipse/cdt/internal/core/pdom/db/messages.properties=8859_1
|
encoding//parser/org/eclipse/cdt/internal/core/pdom/db/messages.properties=8859_1
|
||||||
|
encoding//parser/org/eclipse/cdt/internal/core/pdom/indexer/messages.properties=8859_1
|
||||||
encoding//parser/org/eclipse/cdt/internal/core/pdom/messages.properties=8859_1
|
encoding//parser/org/eclipse/cdt/internal/core/pdom/messages.properties=8859_1
|
||||||
|
|
|
@ -21,6 +21,7 @@ import org.eclipse.cdt.core.dom.ICodeReaderFactory;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
|
import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
|
||||||
import org.eclipse.cdt.core.index.IIndex;
|
import org.eclipse.cdt.core.index.IIndex;
|
||||||
import org.eclipse.cdt.core.model.CModelException;
|
import org.eclipse.cdt.core.model.CModelException;
|
||||||
|
import org.eclipse.cdt.core.model.CoreModel;
|
||||||
import org.eclipse.cdt.core.model.IBuffer;
|
import org.eclipse.cdt.core.model.IBuffer;
|
||||||
import org.eclipse.cdt.core.model.ICElement;
|
import org.eclipse.cdt.core.model.ICElement;
|
||||||
import org.eclipse.cdt.core.model.ICProject;
|
import org.eclipse.cdt.core.model.ICProject;
|
||||||
|
@ -796,12 +797,14 @@ public class TranslationUnit extends Openable implements ITranslationUnit {
|
||||||
ICProject project = getCProject();
|
ICProject project = getCProject();
|
||||||
IProject rproject = project.getProject();
|
IProject rproject = project.getProject();
|
||||||
|
|
||||||
IScannerInfoProvider provider = CCorePlugin.getDefault()
|
if (!force && CoreModel.isScannerInformationEmpty(resource)) {
|
||||||
.getScannerInfoProvider(rproject);
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
IScannerInfoProvider provider = CCorePlugin.getDefault().getScannerInfoProvider(rproject);
|
||||||
if (provider != null) {
|
if (provider != null) {
|
||||||
IResource infoResource = resource != null ? resource : rproject;
|
IResource infoResource = resource != null ? resource : rproject;
|
||||||
IScannerInfo scanInfo = provider
|
IScannerInfo scanInfo = provider.getScannerInformation(infoResource);
|
||||||
.getScannerInformation(infoResource);
|
|
||||||
if (scanInfo != null)
|
if (scanInfo != null)
|
||||||
return scanInfo;
|
return scanInfo;
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,6 +7,7 @@
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* QNX Software Systems - initial API and implementation
|
* QNX Software Systems - initial API and implementation
|
||||||
|
* Markus Schorn (Wind River Systems)
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
@ -31,6 +32,23 @@ public interface IPDOMIndexerTask {
|
||||||
|
|
||||||
public IPDOMIndexer getIndexer();
|
public IPDOMIndexer getIndexer();
|
||||||
|
|
||||||
public int getFilesToIndexCount();
|
/**
|
||||||
|
* Returns the remaining subtasks. The count may increase over the time.
|
||||||
|
* Used by the framework to report progress.
|
||||||
|
* @since 4.0
|
||||||
|
*/
|
||||||
|
public int getRemainingSubtaskCount();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Used by the framework to report progress.
|
||||||
|
* @since 4.0
|
||||||
|
*/
|
||||||
|
public int getCompletedSubtaskCount();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns information about the current subtask.
|
||||||
|
* Used by the framework to report progress.
|
||||||
|
* @since 4.0
|
||||||
|
*/
|
||||||
|
public String getMonitorMessageDetail();
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,7 +36,6 @@ public class ASTInternal {
|
||||||
if (scope instanceof IASTInternalScope) {
|
if (scope instanceof IASTInternalScope) {
|
||||||
return ((IASTInternalScope) scope).getPhysicalNode();
|
return ((IASTInternalScope) scope).getPhysicalNode();
|
||||||
}
|
}
|
||||||
assert false;
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -14,6 +14,7 @@ package org.eclipse.cdt.internal.core.index;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collection;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.LinkedHashSet;
|
import java.util.LinkedHashSet;
|
||||||
|
@ -45,6 +46,7 @@ public class IndexBasedCodeReaderFactory implements ICodeReaderFactory {
|
||||||
private final IIndex index;
|
private final IIndex index;
|
||||||
private Map fileInfoCache = new HashMap(); // filename, fileInfo
|
private Map fileInfoCache = new HashMap(); // filename, fileInfo
|
||||||
private List usedMacros = new ArrayList();
|
private List usedMacros = new ArrayList();
|
||||||
|
private Collection fPathCollector;
|
||||||
|
|
||||||
private static final char[] EMPTY_CHARS = new char[0];
|
private static final char[] EMPTY_CHARS = new char[0];
|
||||||
|
|
||||||
|
@ -65,6 +67,9 @@ public class IndexBasedCodeReaderFactory implements ICodeReaderFactory {
|
||||||
}
|
}
|
||||||
|
|
||||||
public CodeReader createCodeReaderForTranslationUnit(String path) {
|
public CodeReader createCodeReaderForTranslationUnit(String path) {
|
||||||
|
if (fPathCollector != null) {
|
||||||
|
fPathCollector.add(path);
|
||||||
|
}
|
||||||
return ParserUtil.createReader(path, null);
|
return ParserUtil.createReader(path, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -113,6 +118,9 @@ public class IndexBasedCodeReaderFactory implements ICodeReaderFactory {
|
||||||
// still try to parse the file.
|
// still try to parse the file.
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (fPathCollector != null) {
|
||||||
|
fPathCollector.add(canonicalPath);
|
||||||
|
}
|
||||||
return ParserUtil.createReader(canonicalPath, null);
|
return ParserUtil.createReader(canonicalPath, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -171,4 +179,8 @@ public class IndexBasedCodeReaderFactory implements ICodeReaderFactory {
|
||||||
public FileInfo createFileInfo(ITranslationUnit tu) throws CoreException {
|
public FileInfo createFileInfo(ITranslationUnit tu) throws CoreException {
|
||||||
return createInfo(tu.getLocation().toOSString(), null);
|
return createInfo(tu.getLocation().toOSString(), null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setPathCollector(Collection paths) {
|
||||||
|
fPathCollector= paths;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1132,7 +1132,6 @@ public class LocationMap implements ILocationResolver, IScannerPreprocessorLog {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (subC instanceof _CompositeContext) {
|
if (subC instanceof _CompositeContext) {
|
||||||
assert !subC.containsInContext(globalOffset);
|
|
||||||
externalCount+= subC.getContextLength();
|
externalCount+= subC.getContextLength();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,7 +15,6 @@ import org.eclipse.osgi.util.NLS;
|
||||||
|
|
||||||
public class Messages extends NLS {
|
public class Messages extends NLS {
|
||||||
private static final String BUNDLE_NAME = "org.eclipse.cdt.internal.core.pdom.messages"; //$NON-NLS-1$
|
private static final String BUNDLE_NAME = "org.eclipse.cdt.internal.core.pdom.messages"; //$NON-NLS-1$
|
||||||
public static String PDOMManager_FilesToIndexSubtask;
|
|
||||||
public static String PDOMManager_JoinIndexerTask;
|
public static String PDOMManager_JoinIndexerTask;
|
||||||
public static String PDOMManager_notifyJob_label;
|
public static String PDOMManager_notifyJob_label;
|
||||||
public static String PDOMManager_notifyTask_message;
|
public static String PDOMManager_notifyTask_message;
|
||||||
|
|
|
@ -79,6 +79,9 @@ public class PDOM extends PlatformObject implements IIndexFragment, IPDOM {
|
||||||
// 11 - changed how members work
|
// 11 - changed how members work
|
||||||
// 12 - one more change for members (is-a list -> has-a list)
|
// 12 - one more change for members (is-a list -> has-a list)
|
||||||
// 13 - CV-qualifiers, storage class specifiers, function/method annotations
|
// 13 - CV-qualifiers, storage class specifiers, function/method annotations
|
||||||
|
// 14 - added timestamps for files (bug 149571)
|
||||||
|
// 15 - fixed offsets for pointer types and qualifier types and PDOMCPPVariable (bug 160540).
|
||||||
|
|
||||||
|
|
||||||
public static final int LINKAGES = Database.DATA_AREA;
|
public static final int LINKAGES = Database.DATA_AREA;
|
||||||
public static final int FILE_INDEX = Database.DATA_AREA + 4;
|
public static final int FILE_INDEX = Database.DATA_AREA + 4;
|
||||||
|
|
|
@ -11,6 +11,8 @@
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.internal.core.pdom;
|
package org.eclipse.cdt.internal.core.pdom;
|
||||||
|
|
||||||
|
import java.text.MessageFormat;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.CCorePlugin;
|
import org.eclipse.cdt.core.CCorePlugin;
|
||||||
import org.eclipse.cdt.core.dom.IPDOMIndexer;
|
import org.eclipse.cdt.core.dom.IPDOMIndexer;
|
||||||
import org.eclipse.cdt.core.dom.IPDOMIndexerTask;
|
import org.eclipse.cdt.core.dom.IPDOMIndexerTask;
|
||||||
|
@ -27,13 +29,15 @@ import org.eclipse.core.runtime.jobs.Job;
|
||||||
public class PDOMIndexerJob extends Job {
|
public class PDOMIndexerJob extends Job {
|
||||||
|
|
||||||
private final PDOMManager pdomManager;
|
private final PDOMManager pdomManager;
|
||||||
|
private int fCompletedSubtaskCount= 0;
|
||||||
private IPDOMIndexerTask currentTask;
|
private IPDOMIndexerTask currentTask;
|
||||||
private boolean cancelledByManager= false;
|
private boolean cancelledByManager= false;
|
||||||
private Object taskMutex = new Object();
|
private Object taskMutex = new Object();
|
||||||
|
|
||||||
private IProgressMonitor monitor;
|
private IProgressMonitor monitor;
|
||||||
|
|
||||||
|
private Job fMonitorJob;
|
||||||
|
|
||||||
public PDOMIndexerJob(PDOMManager manager) {
|
public PDOMIndexerJob(PDOMManager manager) {
|
||||||
super(CCorePlugin.getResourceString("pdom.indexer.name")); //$NON-NLS-1$
|
super(CCorePlugin.getResourceString("pdom.indexer.name")); //$NON-NLS-1$
|
||||||
this.pdomManager = manager;
|
this.pdomManager = manager;
|
||||||
|
@ -46,10 +50,13 @@ public class PDOMIndexerJob extends Job {
|
||||||
|
|
||||||
String taskName = CCorePlugin.getResourceString("pdom.indexer.task"); //$NON-NLS-1$
|
String taskName = CCorePlugin.getResourceString("pdom.indexer.task"); //$NON-NLS-1$
|
||||||
monitor.beginTask(taskName, IProgressMonitor.UNKNOWN);
|
monitor.beginTask(taskName, IProgressMonitor.UNKNOWN);
|
||||||
|
startMonitorJob(monitor);
|
||||||
try {
|
try {
|
||||||
do {
|
do {
|
||||||
synchronized(taskMutex) {
|
synchronized(taskMutex) {
|
||||||
|
if (currentTask != null) {
|
||||||
|
fCompletedSubtaskCount+= currentTask.getCompletedSubtaskCount();
|
||||||
|
}
|
||||||
currentTask= null;
|
currentTask= null;
|
||||||
taskMutex.notify();
|
taskMutex.notify();
|
||||||
|
|
||||||
|
@ -69,7 +76,7 @@ public class PDOMIndexerJob extends Job {
|
||||||
}
|
}
|
||||||
catch (Exception e) {
|
catch (Exception e) {
|
||||||
CCorePlugin.log(e);
|
CCorePlugin.log(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
while (currentTask != null);
|
while (currentTask != null);
|
||||||
|
@ -99,8 +106,50 @@ public class PDOMIndexerJob extends Job {
|
||||||
}
|
}
|
||||||
throw e;
|
throw e;
|
||||||
}
|
}
|
||||||
|
finally {
|
||||||
|
stopMonitorJob();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void stopMonitorJob() {
|
||||||
|
if (fMonitorJob != null) {
|
||||||
|
fMonitorJob.cancel();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void startMonitorJob(final IProgressMonitor monitor) {
|
||||||
|
fMonitorJob= new Job("cdt indexer monitor job") { //$NON-NLS-1$
|
||||||
|
protected IStatus run(IProgressMonitor m) {
|
||||||
|
while(!m.isCanceled()) {
|
||||||
|
updateMonitor(monitor);
|
||||||
|
try {
|
||||||
|
Thread.sleep(350);
|
||||||
|
} catch (InterruptedException e) {
|
||||||
|
return Status.CANCEL_STATUS;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return Status.OK_STATUS;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
fMonitorJob.setSystem(true);
|
||||||
|
fMonitorJob.schedule();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void updateMonitor(IProgressMonitor monitor) {
|
||||||
|
String detail= null;
|
||||||
|
synchronized(taskMutex) {
|
||||||
|
if (currentTask != null) {
|
||||||
|
detail= currentTask.getMonitorMessageDetail();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
String msg= pdomManager.getMonitorMessage();
|
||||||
|
if (detail != null) {
|
||||||
|
msg= MessageFormat.format("{0}: {1}", new Object[] {msg, detail}); //$NON-NLS-1$
|
||||||
|
}
|
||||||
|
|
||||||
|
monitor.subTask(msg);
|
||||||
|
}
|
||||||
|
|
||||||
public void cancelJobs(IPDOMIndexer indexer) {
|
public void cancelJobs(IPDOMIndexer indexer) {
|
||||||
synchronized (taskMutex) {
|
synchronized (taskMutex) {
|
||||||
if (currentTask != null && currentTask.getIndexer() == indexer) {
|
if (currentTask != null && currentTask.getIndexer() == indexer) {
|
||||||
|
@ -116,4 +165,13 @@ public class PDOMIndexerJob extends Job {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int getCompletedSubtaskCount() {
|
||||||
|
synchronized (taskMutex) {
|
||||||
|
if (currentTask != null) {
|
||||||
|
return currentTask.getCompletedSubtaskCount() + fCompletedSubtaskCount;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return fCompletedSubtaskCount;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -92,10 +92,10 @@ public class PDOMManager implements IPDOMManager, IWritableIndexManager, IListen
|
||||||
/**
|
/**
|
||||||
* Protects indexerJob, currentTask and taskQueue.
|
* Protects indexerJob, currentTask and taskQueue.
|
||||||
*/
|
*/
|
||||||
private Object taskQueueMutex = new Object();
|
private Object fTaskQueueMutex = new Object();
|
||||||
private PDOMIndexerJob indexerJob;
|
private PDOMIndexerJob fIndexerJob;
|
||||||
private IPDOMIndexerTask currentTask;
|
private IPDOMIndexerTask fCurrentTask;
|
||||||
private LinkedList taskQueue = new LinkedList();
|
private LinkedList fTaskQueue = new LinkedList();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Stores mapping from pdom to project, used to serialize\ creation of new pdoms.
|
* Stores mapping from pdom to project, used to serialize\ creation of new pdoms.
|
||||||
|
@ -420,11 +420,11 @@ public class PDOMManager implements IPDOMManager, IWritableIndexManager, IListen
|
||||||
|
|
||||||
public void enqueue(IPDOMIndexerTask subjob) {
|
public void enqueue(IPDOMIndexerTask subjob) {
|
||||||
boolean notifyBusy= false;
|
boolean notifyBusy= false;
|
||||||
synchronized (taskQueueMutex) {
|
synchronized (fTaskQueueMutex) {
|
||||||
taskQueue.addLast(subjob);
|
fTaskQueue.addLast(subjob);
|
||||||
if (indexerJob == null) {
|
if (fIndexerJob == null) {
|
||||||
indexerJob = new PDOMIndexerJob(this);
|
fIndexerJob = new PDOMIndexerJob(this);
|
||||||
indexerJob.schedule();
|
fIndexerJob.schedule();
|
||||||
notifyBusy= true;
|
notifyBusy= true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -436,14 +436,14 @@ public class PDOMManager implements IPDOMManager, IWritableIndexManager, IListen
|
||||||
IPDOMIndexerTask getNextTask() {
|
IPDOMIndexerTask getNextTask() {
|
||||||
boolean idle= false;
|
boolean idle= false;
|
||||||
IPDOMIndexerTask result= null;
|
IPDOMIndexerTask result= null;
|
||||||
synchronized (taskQueueMutex) {
|
synchronized (fTaskQueueMutex) {
|
||||||
if (taskQueue.isEmpty()) {
|
if (fTaskQueue.isEmpty()) {
|
||||||
currentTask= null;
|
fCurrentTask= null;
|
||||||
indexerJob= null;
|
fIndexerJob= null;
|
||||||
idle= true;
|
idle= true;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
result= currentTask= (IPDOMIndexerTask)taskQueue.removeFirst();
|
result= fCurrentTask= (IPDOMIndexerTask)fTaskQueue.removeFirst();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (idle) {
|
if (idle) {
|
||||||
|
@ -454,18 +454,18 @@ public class PDOMManager implements IPDOMManager, IWritableIndexManager, IListen
|
||||||
|
|
||||||
void cancelledJob(boolean byManager) {
|
void cancelledJob(boolean byManager) {
|
||||||
boolean idle= false;
|
boolean idle= false;
|
||||||
synchronized (taskQueueMutex) {
|
synchronized (fTaskQueueMutex) {
|
||||||
currentTask= null;
|
fCurrentTask= null;
|
||||||
if (!byManager) {
|
if (!byManager) {
|
||||||
taskQueue.clear();
|
fTaskQueue.clear();
|
||||||
}
|
}
|
||||||
idle= taskQueue.isEmpty();
|
idle= fTaskQueue.isEmpty();
|
||||||
if (idle) {
|
if (idle) {
|
||||||
indexerJob= null;
|
fIndexerJob= null;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
indexerJob = new PDOMIndexerJob(this);
|
fIndexerJob = new PDOMIndexerJob(this);
|
||||||
indexerJob.schedule();
|
fIndexerJob.schedule();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (idle) {
|
if (idle) {
|
||||||
|
@ -474,25 +474,11 @@ public class PDOMManager implements IPDOMManager, IWritableIndexManager, IListen
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isIndexerIdle() {
|
private boolean isIndexerIdle() {
|
||||||
synchronized (taskQueueMutex) {
|
synchronized (fTaskQueueMutex) {
|
||||||
return currentTask == null && taskQueue.isEmpty();
|
return fCurrentTask == null && fTaskQueue.isEmpty();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private int getFilesToIndexCount() {
|
|
||||||
int count= 0;
|
|
||||||
synchronized (taskQueueMutex) {
|
|
||||||
if (currentTask != null) {
|
|
||||||
count= currentTask.getFilesToIndexCount();
|
|
||||||
}
|
|
||||||
for (Iterator iter = taskQueue.iterator(); iter.hasNext();) {
|
|
||||||
IPDOMIndexerTask task= (IPDOMIndexerTask) iter.next();
|
|
||||||
count+= task.getFilesToIndexCount();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return count;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void addProject(ICProject project, ICElementDelta delta) {
|
public void addProject(ICProject project, ICElementDelta delta) {
|
||||||
getIndexer(project, true); // if the indexer is new this triggers a rebuild
|
getIndexer(project, true); // if the indexer is new this triggers a rebuild
|
||||||
}
|
}
|
||||||
|
@ -551,18 +537,18 @@ public class PDOMManager implements IPDOMManager, IWritableIndexManager, IListen
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
PDOMIndexerJob jobToCancel= null;
|
PDOMIndexerJob jobToCancel= null;
|
||||||
synchronized (taskQueueMutex) {
|
synchronized (fTaskQueueMutex) {
|
||||||
for (Iterator iter = taskQueue.iterator(); iter.hasNext();) {
|
for (Iterator iter = fTaskQueue.iterator(); iter.hasNext();) {
|
||||||
IPDOMIndexerTask task= (IPDOMIndexerTask) iter.next();
|
IPDOMIndexerTask task= (IPDOMIndexerTask) iter.next();
|
||||||
if (task.getIndexer() == indexer) {
|
if (task.getIndexer() == indexer) {
|
||||||
iter.remove();
|
iter.remove();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
jobToCancel= indexerJob;
|
jobToCancel= fIndexerJob;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (jobToCancel != null) {
|
if (jobToCancel != null) {
|
||||||
assert !Thread.holdsLock(taskQueueMutex);
|
assert !Thread.holdsLock(fTaskQueueMutex);
|
||||||
jobToCancel.cancelJobs(indexer);
|
jobToCancel.cancelJobs(indexer);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -584,10 +570,10 @@ public class PDOMManager implements IPDOMManager, IWritableIndexManager, IListen
|
||||||
}
|
}
|
||||||
|
|
||||||
private void notifyState(final int state) {
|
private void notifyState(final int state) {
|
||||||
assert !Thread.holdsLock(taskQueueMutex);
|
assert !Thread.holdsLock(fTaskQueueMutex);
|
||||||
if (state == IndexerStateEvent.STATE_IDLE) {
|
if (state == IndexerStateEvent.STATE_IDLE) {
|
||||||
synchronized(taskQueueMutex) {
|
synchronized(fTaskQueueMutex) {
|
||||||
taskQueueMutex.notifyAll();
|
fTaskQueueMutex.notifyAll();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -665,7 +651,8 @@ public class PDOMManager implements IPDOMManager, IWritableIndexManager, IListen
|
||||||
if (monitor.isCanceled()) {
|
if (monitor.isCanceled()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
synchronized(taskQueueMutex) {
|
monitor.subTask(getMonitorMessage());
|
||||||
|
synchronized(fTaskQueueMutex) {
|
||||||
if (isIndexerIdle()) {
|
if (isIndexerIdle()) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -680,9 +667,8 @@ public class PDOMManager implements IPDOMManager, IWritableIndexManager, IListen
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
monitor.subTask(MessageFormat.format(Messages.PDOMManager_FilesToIndexSubtask, new Object[] {new Integer(getFilesToIndexCount())}));
|
|
||||||
try {
|
try {
|
||||||
taskQueueMutex.wait(wait);
|
fTaskQueueMutex.wait(wait);
|
||||||
} catch (InterruptedException e) {
|
} catch (InterruptedException e) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -693,6 +679,32 @@ public class PDOMManager implements IPDOMManager, IWritableIndexManager, IListen
|
||||||
monitor.done();
|
monitor.done();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
String getMonitorMessage() {
|
||||||
|
assert !Thread.holdsLock(fTaskQueueMutex);
|
||||||
|
int remainingCount= 0;
|
||||||
|
int completedCount= 0;
|
||||||
|
IPDOMIndexerTask currentTask= null;
|
||||||
|
PDOMIndexerJob currentJob= null;
|
||||||
|
synchronized (fTaskQueueMutex) {
|
||||||
|
for (Iterator iter = fTaskQueue.iterator(); iter.hasNext();) {
|
||||||
|
IPDOMIndexerTask task = (IPDOMIndexerTask) iter.next();
|
||||||
|
remainingCount+= task.getRemainingSubtaskCount();
|
||||||
|
}
|
||||||
|
currentTask= fCurrentTask;
|
||||||
|
currentJob= fIndexerJob;
|
||||||
|
}
|
||||||
|
if (currentTask != null) {
|
||||||
|
remainingCount += currentTask.getRemainingSubtaskCount();
|
||||||
|
}
|
||||||
|
if (currentJob != null) {
|
||||||
|
completedCount= currentJob.getCompletedSubtaskCount();
|
||||||
|
}
|
||||||
|
return MessageFormat.format("{0}/{1}", new Object[] { //$NON-NLS-1$
|
||||||
|
new Integer(completedCount), new Integer(remainingCount+completedCount)
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public IWritableIndex getWritableIndex(ICProject project) throws CoreException {
|
public IWritableIndex getWritableIndex(ICProject project) throws CoreException {
|
||||||
return fIndexFactory.getWritableIndex(project);
|
return fIndexFactory.getWritableIndex(project);
|
||||||
|
|
|
@ -0,0 +1,27 @@
|
||||||
|
/*******************************************************************************
|
||||||
|
* Copyright (c) 2006 Wind River Systems, Inc. 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:
|
||||||
|
* Markus Schorn - initial API and implementation
|
||||||
|
*******************************************************************************/
|
||||||
|
|
||||||
|
package org.eclipse.cdt.internal.core.pdom.indexer;
|
||||||
|
|
||||||
|
import org.eclipse.osgi.util.NLS;
|
||||||
|
|
||||||
|
public class Messages extends NLS {
|
||||||
|
private static final String BUNDLE_NAME = "org.eclipse.cdt.internal.core.pdom.indexer.messages"; //$NON-NLS-1$
|
||||||
|
public static String PDOMIndexerTask_collectingFilesTask;
|
||||||
|
public static String PDOMIndexerTask_parsingFileTask;
|
||||||
|
static {
|
||||||
|
// initialize resource bundle
|
||||||
|
NLS.initializeMessages(BUNDLE_NAME, Messages.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
private Messages() {
|
||||||
|
}
|
||||||
|
}
|
|
@ -11,6 +11,7 @@
|
||||||
|
|
||||||
package org.eclipse.cdt.internal.core.pdom.indexer;
|
package org.eclipse.cdt.internal.core.pdom.indexer;
|
||||||
|
|
||||||
|
import java.text.MessageFormat;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
@ -34,14 +35,18 @@ import org.eclipse.cdt.internal.core.index.IWritableIndex;
|
||||||
import org.eclipse.core.resources.IFile;
|
import org.eclipse.core.resources.IFile;
|
||||||
import org.eclipse.core.runtime.CoreException;
|
import org.eclipse.core.runtime.CoreException;
|
||||||
import org.eclipse.core.runtime.IPath;
|
import org.eclipse.core.runtime.IPath;
|
||||||
|
import org.eclipse.core.runtime.IProgressMonitor;
|
||||||
import org.eclipse.core.runtime.Path;
|
import org.eclipse.core.runtime.Path;
|
||||||
|
|
||||||
public abstract class PDOMIndexerTask implements IPDOMIndexerTask {
|
public abstract class PDOMIndexerTask implements IPDOMIndexerTask {
|
||||||
private static final Object NO_CONTEXT = new Object();
|
private static final Object NO_CONTEXT = new Object();
|
||||||
protected static final int MAX_ERRORS = 10;
|
protected static final int MAX_ERRORS = 10;
|
||||||
|
|
||||||
|
protected volatile int fTotalTasks= 0;
|
||||||
|
protected volatile int fCompletedTasks= 0;
|
||||||
protected int fErrorCount;
|
protected int fErrorCount;
|
||||||
protected Map fContextMap= new HashMap();
|
protected Map fContextMap= new HashMap();
|
||||||
|
protected volatile String fMessage;
|
||||||
|
|
||||||
protected void processDelta(ICElementDelta delta, Collection added, Collection changed, Collection removed) throws CoreException {
|
protected void processDelta(ICElementDelta delta, Collection added, Collection changed, Collection removed) throws CoreException {
|
||||||
int flags = delta.getFlags();
|
int flags = delta.getFlags();
|
||||||
|
@ -75,16 +80,19 @@ public abstract class PDOMIndexerTask implements IPDOMIndexerTask {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void collectSources(ICProject project, final Collection sources, final Collection headers) throws CoreException {
|
protected void collectSources(ICProject project, final Collection sources, final Collection headers, final boolean allFiles) throws CoreException {
|
||||||
|
fMessage= Messages.PDOMIndexerTask_collectingFilesTask;
|
||||||
project.accept(new ICElementVisitor() {
|
project.accept(new ICElementVisitor() {
|
||||||
public boolean visit(ICElement element) throws CoreException {
|
public boolean visit(ICElement element) throws CoreException {
|
||||||
switch (element.getElementType()) {
|
switch (element.getElementType()) {
|
||||||
case ICElement.C_UNIT:
|
case ICElement.C_UNIT:
|
||||||
ITranslationUnit tu = (ITranslationUnit)element;
|
ITranslationUnit tu = (ITranslationUnit)element;
|
||||||
if (tu.isSourceUnit()) {
|
if (tu.isSourceUnit()) {
|
||||||
sources.add(tu);
|
if (allFiles || !CoreModel.isScannerInformationEmpty(tu.getResource())) {
|
||||||
|
sources.add(tu);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if (tu.isHeaderUnit()) {
|
else if (headers != null && tu.isHeaderUnit()) {
|
||||||
headers.add(tu);
|
headers.add(tu);
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
@ -109,9 +117,12 @@ public abstract class PDOMIndexerTask implements IPDOMIndexerTask {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void parseTU(ITranslationUnit tu) throws CoreException, InterruptedException {
|
protected void parseTU(ITranslationUnit tu, IProgressMonitor pm) throws CoreException, InterruptedException {
|
||||||
try {
|
try {
|
||||||
doParseTU(tu);
|
IPath path= tu.getPath();
|
||||||
|
fMessage= MessageFormat.format(Messages.PDOMIndexerTask_parsingFileTask,
|
||||||
|
new Object[]{path.lastSegment(), path.removeLastSegments(1).toString()});
|
||||||
|
doParseTU(tu, pm);
|
||||||
}
|
}
|
||||||
catch (CoreException e) {
|
catch (CoreException e) {
|
||||||
if (++fErrorCount <= MAX_ERRORS) {
|
if (++fErrorCount <= MAX_ERRORS) {
|
||||||
|
@ -123,7 +134,7 @@ public abstract class PDOMIndexerTask implements IPDOMIndexerTask {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
abstract protected void doParseTU(ITranslationUnit tu) throws CoreException, InterruptedException;
|
abstract protected void doParseTU(ITranslationUnit tu, IProgressMonitor pm) throws CoreException, InterruptedException;
|
||||||
|
|
||||||
protected void clearIndex(IWritableIndex index) throws InterruptedException, CoreException {
|
protected void clearIndex(IWritableIndex index) throws InterruptedException, CoreException {
|
||||||
// reset error count
|
// reset error count
|
||||||
|
@ -183,4 +194,16 @@ public abstract class PDOMIndexerTask implements IPDOMIndexerTask {
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getMonitorMessageDetail() {
|
||||||
|
return fMessage;
|
||||||
|
}
|
||||||
|
|
||||||
|
final public int getRemainingSubtaskCount() {
|
||||||
|
return fTotalTasks-fCompletedTasks;
|
||||||
|
}
|
||||||
|
|
||||||
|
final public int getCompletedSubtaskCount() {
|
||||||
|
return fCompletedTasks;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,7 +31,7 @@ class PDOMFastHandleDelta extends PDOMFastIndexerJob {
|
||||||
public PDOMFastHandleDelta(PDOMFastIndexer indexer, ICElementDelta delta) throws CoreException {
|
public PDOMFastHandleDelta(PDOMFastIndexer indexer, ICElementDelta delta) throws CoreException {
|
||||||
super(indexer);
|
super(indexer);
|
||||||
processDelta(delta, changed, changed, removed);
|
processDelta(delta, changed, changed, removed);
|
||||||
fFilesToIndex= changed.size() + removed.size();
|
fTotalTasks= changed.size() + removed.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void run(IProgressMonitor monitor) {
|
public void run(IProgressMonitor monitor) {
|
||||||
|
@ -41,20 +41,20 @@ class PDOMFastHandleDelta extends PDOMFastIndexerJob {
|
||||||
setupIndexAndReaderFactory();
|
setupIndexAndReaderFactory();
|
||||||
registerTUsInReaderFactory(changed);
|
registerTUsInReaderFactory(changed);
|
||||||
|
|
||||||
parseTUs(changed, monitor);
|
|
||||||
if (monitor.isCanceled()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
Iterator i= removed.iterator();
|
Iterator i= removed.iterator();
|
||||||
while (i.hasNext()) {
|
while (i.hasNext()) {
|
||||||
if (monitor.isCanceled())
|
if (monitor.isCanceled())
|
||||||
return;
|
return;
|
||||||
ITranslationUnit tu = (ITranslationUnit)i.next();
|
ITranslationUnit tu = (ITranslationUnit)i.next();
|
||||||
removeTU(index, tu);
|
removeTU(index, tu);
|
||||||
fFilesToIndex--;
|
fCompletedTasks++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
parseTUs(changed, monitor);
|
||||||
|
if (monitor.isCanceled()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
String showTimings = Platform.getDebugOption(CCorePlugin.PLUGIN_ID + "/debug/pdomtimings"); //$NON-NLS-1$
|
String showTimings = Platform.getDebugOption(CCorePlugin.PLUGIN_ID + "/debug/pdomtimings"); //$NON-NLS-1$
|
||||||
if (showTimings != null && showTimings.equalsIgnoreCase("true")) //$NON-NLS-1$
|
if (showTimings != null && showTimings.equalsIgnoreCase("true")) //$NON-NLS-1$
|
||||||
System.out.println("PDOM Fast Delta Time: " + (System.currentTimeMillis() - start)); //$NON-NLS-1$
|
System.out.println("PDOM Fast Delta Time: " + (System.currentTimeMillis() - start)); //$NON-NLS-1$
|
||||||
|
|
|
@ -46,7 +46,7 @@ public class PDOMFastIndexer implements IPDOMIndexer {
|
||||||
|
|
||||||
public void handleDelta(ICElementDelta delta) throws CoreException {
|
public void handleDelta(ICElementDelta delta) throws CoreException {
|
||||||
PDOMFastHandleDelta fhd= new PDOMFastHandleDelta(this, delta);
|
PDOMFastHandleDelta fhd= new PDOMFastHandleDelta(this, delta);
|
||||||
if (fhd.getFilesToIndexCount() > 0) {
|
if (fhd.getRemainingSubtaskCount() > 0) {
|
||||||
CCoreInternals.getPDOMManager().enqueue(fhd);
|
CCoreInternals.getPDOMManager().enqueue(fhd);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,7 +16,7 @@ import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.LinkedHashMap;
|
import java.util.LinkedHashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
@ -43,6 +43,7 @@ import org.eclipse.core.runtime.CoreException;
|
||||||
import org.eclipse.core.runtime.IPath;
|
import org.eclipse.core.runtime.IPath;
|
||||||
import org.eclipse.core.runtime.IProgressMonitor;
|
import org.eclipse.core.runtime.IProgressMonitor;
|
||||||
import org.eclipse.core.runtime.Path;
|
import org.eclipse.core.runtime.Path;
|
||||||
|
import org.eclipse.core.runtime.Platform;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Doug Schaefer
|
* @author Doug Schaefer
|
||||||
|
@ -53,10 +54,14 @@ abstract class PDOMFastIndexerJob extends PDOMIndexerTask implements IPDOMIndexe
|
||||||
protected final PDOMFastIndexer indexer;
|
protected final PDOMFastIndexer indexer;
|
||||||
protected IWritableIndex index;
|
protected IWritableIndex index;
|
||||||
protected IndexBasedCodeReaderFactory codeReaderFactory;
|
protected IndexBasedCodeReaderFactory codeReaderFactory;
|
||||||
protected volatile int fFilesToIndex= 0;
|
private boolean fTrace= false;
|
||||||
|
|
||||||
public PDOMFastIndexerJob(PDOMFastIndexer indexer) throws CoreException {
|
public PDOMFastIndexerJob(PDOMFastIndexer indexer) throws CoreException {
|
||||||
this.indexer = indexer;
|
this.indexer = indexer;
|
||||||
|
String trace = Platform.getDebugOption(CCorePlugin.PLUGIN_ID + "/debug/indexer"); //$NON-NLS-1$
|
||||||
|
if (trace != null && trace.equalsIgnoreCase("true")) { //$NON-NLS-1$
|
||||||
|
fTrace= true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void setupIndexAndReaderFactory() throws CoreException {
|
protected void setupIndexAndReaderFactory() throws CoreException {
|
||||||
|
@ -76,7 +81,7 @@ abstract class PDOMFastIndexerJob extends PDOMIndexerTask implements IPDOMIndexe
|
||||||
return indexer;
|
return indexer;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void doParseTU(ITranslationUnit tu) throws CoreException, InterruptedException {
|
protected void doParseTU(ITranslationUnit tu, IProgressMonitor pm) throws CoreException, InterruptedException {
|
||||||
IPath path = tu.getLocation();
|
IPath path = tu.getLocation();
|
||||||
if (path == null) {
|
if (path == null) {
|
||||||
return;
|
return;
|
||||||
|
@ -95,30 +100,31 @@ abstract class PDOMFastIndexerJob extends PDOMIndexerTask implements IPDOMIndexe
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
LinkedHashSet paths= new LinkedHashSet();
|
||||||
|
paths.add(path.toOSString());
|
||||||
|
codeReaderFactory.setPathCollector(paths);
|
||||||
index.acquireReadLock();
|
index.acquireReadLock();
|
||||||
try {
|
try {
|
||||||
// get the AST in a "Fast" way
|
// get the AST in a "Fast" way
|
||||||
IASTTranslationUnit ast= language.getASTTranslationUnit(codeReader, scanner, codeReaderFactory, index);
|
IASTTranslationUnit ast= language.getASTTranslationUnit(codeReader, scanner, codeReaderFactory, index);
|
||||||
|
if (pm.isCanceled()) {
|
||||||
index.acquireWriteLock(1);
|
return;
|
||||||
try {
|
|
||||||
// Clear the macros
|
|
||||||
codeReaderFactory.clearMacroAttachements();
|
|
||||||
|
|
||||||
// Add the new symbols
|
|
||||||
addSymbols(ast);
|
|
||||||
} finally {
|
|
||||||
index.releaseWriteLock(1);
|
|
||||||
}
|
}
|
||||||
|
// Clear the macros
|
||||||
|
codeReaderFactory.clearMacroAttachements();
|
||||||
|
|
||||||
|
// Add the new symbols
|
||||||
|
addSymbols(paths, ast, pm);
|
||||||
}
|
}
|
||||||
finally {
|
finally {
|
||||||
index.releaseReadLock();
|
index.releaseReadLock();
|
||||||
|
codeReaderFactory.setPathCollector(null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void addSymbols(IASTTranslationUnit ast) throws InterruptedException, CoreException {
|
protected void addSymbols(Collection paths, IASTTranslationUnit ast, IProgressMonitor pm) throws InterruptedException, CoreException {
|
||||||
// Add in the includes
|
// Add in the includes
|
||||||
final LinkedHashMap symbolMap= new LinkedHashMap(); // makes bugs reproducible
|
final HashMap symbolMap= new HashMap();
|
||||||
|
|
||||||
// includes
|
// includes
|
||||||
IASTPreprocessorIncludeStatement[] includes = ast.getIncludeDirectives();
|
IASTPreprocessorIncludeStatement[] includes = ast.getIncludeDirectives();
|
||||||
|
@ -162,9 +168,15 @@ abstract class PDOMFastIndexerJob extends PDOMIndexerTask implements IPDOMIndexe
|
||||||
|
|
||||||
for (Iterator iter = symbolMap.entrySet().iterator(); iter.hasNext();) {
|
for (Iterator iter = symbolMap.entrySet().iterator(); iter.hasNext();) {
|
||||||
Map.Entry entry = (Map.Entry) iter.next();
|
Map.Entry entry = (Map.Entry) iter.next();
|
||||||
|
if (pm.isCanceled()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
String path= (String) entry.getKey();
|
String path= (String) entry.getKey();
|
||||||
FileInfo info= codeReaderFactory.createFileInfo(path);
|
FileInfo info= codeReaderFactory.createFileInfo(path);
|
||||||
if (!info.fNeedToIndex && info.fFile != null) {
|
if (!info.fNeedToIndex && info.fFile != null) {
|
||||||
|
if (fTrace) {
|
||||||
|
System.out.println("Indexer: skipping " + path); //$NON-NLS-1$
|
||||||
|
}
|
||||||
iter.remove();
|
iter.remove();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -176,12 +188,26 @@ abstract class PDOMFastIndexerJob extends PDOMIndexerTask implements IPDOMIndexe
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (Iterator iter = symbolMap.entrySet().iterator(); iter.hasNext();) {
|
index.acquireWriteLock(1);
|
||||||
Map.Entry entry = (Map.Entry) iter.next();
|
try {
|
||||||
String path= (String) entry.getKey();
|
for (Iterator iter = paths.iterator(); iter.hasNext();) {
|
||||||
FileInfo info= codeReaderFactory.createFileInfo(path);
|
String path = (String) iter.next();
|
||||||
info.fNeedToIndex= false;
|
FileInfo info= codeReaderFactory.createFileInfo(path);
|
||||||
addToIndex(path, info, (ArrayList[]) entry.getValue());
|
if (!info.fNeedToIndex) {
|
||||||
|
fTotalTasks++;
|
||||||
|
}
|
||||||
|
info.fNeedToIndex= false;
|
||||||
|
if (fTrace) {
|
||||||
|
System.out.println("Indexer: adding " + path); //$NON-NLS-1$
|
||||||
|
}
|
||||||
|
addToIndex(path, info, (ArrayList[]) symbolMap.get(path));
|
||||||
|
fCompletedTasks++;
|
||||||
|
if (pm.isCanceled()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} finally {
|
||||||
|
index.releaseWriteLock(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -207,25 +233,27 @@ abstract class PDOMFastIndexerJob extends PDOMIndexerTask implements IPDOMIndexe
|
||||||
}
|
}
|
||||||
file.setTimestamp(path.toFile().lastModified());
|
file.setTimestamp(path.toFile().lastModified());
|
||||||
|
|
||||||
// includes
|
if (lists != null) {
|
||||||
ArrayList list= lists[0];
|
// includes
|
||||||
for (int i = 0; i < list.size(); i++) {
|
ArrayList list= lists[0];
|
||||||
IASTPreprocessorIncludeStatement include= (IASTPreprocessorIncludeStatement) list.get(i);
|
for (int i = 0; i < list.size(); i++) {
|
||||||
IIndexFragmentFile destFile= createIndexFile(include.getPath());
|
IASTPreprocessorIncludeStatement include= (IASTPreprocessorIncludeStatement) list.get(i);
|
||||||
index.addInclude(file, destFile, include);
|
IIndexFragmentFile destFile= createIndexFile(include.getPath());
|
||||||
}
|
index.addInclude(file, destFile, include);
|
||||||
|
}
|
||||||
|
|
||||||
// macros
|
// macros
|
||||||
list= lists[1];
|
list= lists[1];
|
||||||
for (int i = 0; i < list.size(); i++) {
|
for (int i = 0; i < list.size(); i++) {
|
||||||
index.addMacro(file, (IASTPreprocessorMacroDefinition) list.get(i));
|
index.addMacro(file, (IASTPreprocessorMacroDefinition) list.get(i));
|
||||||
}
|
}
|
||||||
|
|
||||||
// symbols
|
// symbols
|
||||||
list= lists[2];
|
list= lists[2];
|
||||||
for (int i = 0; i < list.size(); i++) {
|
for (int i = 0; i < list.size(); i++) {
|
||||||
index.addName(file, (IASTName) list.get(i));
|
index.addName(file, (IASTName) list.get(i));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private IIndexFragmentFile createIndexFile(String path) throws CoreException {
|
private IIndexFragmentFile createIndexFile(String path) throws CoreException {
|
||||||
|
@ -244,9 +272,9 @@ abstract class PDOMFastIndexerJob extends PDOMIndexerTask implements IPDOMIndexe
|
||||||
return;
|
return;
|
||||||
ITranslationUnit tu = (ITranslationUnit)i.next();
|
ITranslationUnit tu = (ITranslationUnit)i.next();
|
||||||
if (tu.isSourceUnit()) {
|
if (tu.isSourceUnit()) {
|
||||||
parseTU(tu);
|
parseTU(tu, monitor);
|
||||||
i.remove();
|
i.remove();
|
||||||
fFilesToIndex--;
|
fCompletedTasks++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -259,12 +287,11 @@ abstract class PDOMFastIndexerJob extends PDOMIndexerTask implements IPDOMIndexe
|
||||||
FileInfo info= codeReaderFactory.createFileInfo(tu);
|
FileInfo info= codeReaderFactory.createFileInfo(tu);
|
||||||
if (!info.fNeedToIndex) {
|
if (!info.fNeedToIndex) {
|
||||||
i.remove();
|
i.remove();
|
||||||
fFilesToIndex--;
|
|
||||||
}
|
}
|
||||||
else if (info.fFile != null) {
|
else if (info.fFile != null) {
|
||||||
ITranslationUnit context= findContext(index, info.fFile.getLocation());
|
ITranslationUnit context= findContext(index, info.fFile.getLocation());
|
||||||
if (context != null) {
|
if (context != null) {
|
||||||
parseTU(context);
|
parseTU(context, monitor);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -281,14 +308,9 @@ abstract class PDOMFastIndexerJob extends PDOMIndexerTask implements IPDOMIndexe
|
||||||
i.remove();
|
i.remove();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
parseTU(tu);
|
parseTU(tu, monitor);
|
||||||
}
|
}
|
||||||
fFilesToIndex--;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
final public int getFilesToIndexCount() {
|
|
||||||
return fFilesToIndex;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,6 +13,7 @@
|
||||||
package org.eclipse.cdt.internal.core.pdom.indexer.fast;
|
package org.eclipse.cdt.internal.core.pdom.indexer.fast;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collection;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.CCorePlugin;
|
import org.eclipse.cdt.core.CCorePlugin;
|
||||||
import org.eclipse.core.runtime.CoreException;
|
import org.eclipse.core.runtime.CoreException;
|
||||||
|
@ -28,23 +29,27 @@ class PDOMFastReindex extends PDOMFastIndexerJob {
|
||||||
|
|
||||||
public PDOMFastReindex(PDOMFastIndexer indexer) throws CoreException {
|
public PDOMFastReindex(PDOMFastIndexer indexer) throws CoreException {
|
||||||
super(indexer);
|
super(indexer);
|
||||||
fFilesToIndex= 1;
|
fTotalTasks= 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void run(final IProgressMonitor monitor) {
|
public void run(final IProgressMonitor monitor) {
|
||||||
try {
|
try {
|
||||||
long start = System.currentTimeMillis();
|
long start = System.currentTimeMillis();
|
||||||
collectSources(indexer.getProject(), fTUs, fTUs);
|
boolean allFiles= getIndexAllFiles();
|
||||||
fFilesToIndex= fTUs.size()+1;
|
Collection headers= allFiles ? fTUs : null;
|
||||||
|
collectSources(indexer.getProject(), fTUs, headers, allFiles);
|
||||||
|
fTotalTasks+= fTUs.size()+1;
|
||||||
|
fCompletedTasks+= 1;
|
||||||
|
|
||||||
if (fFilesToIndex == 1 || monitor.isCanceled()) {
|
setupIndexAndReaderFactory();
|
||||||
|
clearIndex(index);
|
||||||
|
|
||||||
|
if (getRemainingSubtaskCount() == 1 || monitor.isCanceled()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
setupIndexAndReaderFactory();
|
|
||||||
clearIndex(index);
|
|
||||||
registerTUsInReaderFactory(fTUs);
|
registerTUsInReaderFactory(fTUs);
|
||||||
fFilesToIndex--;
|
fCompletedTasks++;
|
||||||
|
|
||||||
parseTUs(fTUs, monitor);
|
parseTUs(fTUs, monitor);
|
||||||
|
|
||||||
|
|
|
@ -13,6 +13,7 @@
|
||||||
package org.eclipse.cdt.internal.core.pdom.indexer.full;
|
package org.eclipse.cdt.internal.core.pdom.indexer.full;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collections;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
@ -35,27 +36,27 @@ class PDOMFullHandleDelta extends PDOMFullIndexerJob {
|
||||||
public PDOMFullHandleDelta(PDOMFullIndexer indexer, ICElementDelta delta) throws CoreException {
|
public PDOMFullHandleDelta(PDOMFullIndexer indexer, ICElementDelta delta) throws CoreException {
|
||||||
super(indexer);
|
super(indexer);
|
||||||
processDelta(delta, changed, changed, removed);
|
processDelta(delta, changed, changed, removed);
|
||||||
fFilesToIndex= changed.size() + removed.size();
|
fTotalTasks= changed.size() + removed.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void run(IProgressMonitor monitor) {
|
public void run(IProgressMonitor monitor) {
|
||||||
try {
|
try {
|
||||||
long start = System.currentTimeMillis();
|
long start = System.currentTimeMillis();
|
||||||
setupIndexAndReaderFactory();
|
setupIndexAndReaderFactory();
|
||||||
registerTUsInReaderFactory(changed);
|
registerTUsInReaderFactory(changed, Collections.EMPTY_LIST);
|
||||||
|
|
||||||
parseTUs(changed, monitor);
|
|
||||||
if (monitor.isCanceled()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
Iterator i= removed.iterator();
|
Iterator i= removed.iterator();
|
||||||
while (i.hasNext()) {
|
while (i.hasNext()) {
|
||||||
if (monitor.isCanceled())
|
if (monitor.isCanceled())
|
||||||
return;
|
return;
|
||||||
ITranslationUnit tu = (ITranslationUnit)i.next();
|
ITranslationUnit tu = (ITranslationUnit)i.next();
|
||||||
removeTU(index, tu);
|
removeTU(index, tu);
|
||||||
fFilesToIndex--;
|
fCompletedTasks++;
|
||||||
|
}
|
||||||
|
|
||||||
|
parseTUs(changed, monitor);
|
||||||
|
if (monitor.isCanceled()) {
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
String showTimings = Platform.getDebugOption(CCorePlugin.PLUGIN_ID
|
String showTimings = Platform.getDebugOption(CCorePlugin.PLUGIN_ID
|
||||||
|
|
|
@ -42,7 +42,7 @@ public class PDOMFullIndexer implements IPDOMIndexer {
|
||||||
|
|
||||||
public void handleDelta(ICElementDelta delta) throws CoreException {
|
public void handleDelta(ICElementDelta delta) throws CoreException {
|
||||||
PDOMFullHandleDelta task = new PDOMFullHandleDelta(this, delta);
|
PDOMFullHandleDelta task = new PDOMFullHandleDelta(this, delta);
|
||||||
if (task.getFilesToIndexCount() > 0) {
|
if (task.getRemainingSubtaskCount() > 0) {
|
||||||
CCoreInternals.getPDOMManager().enqueue(task);
|
CCoreInternals.getPDOMManager().enqueue(task);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,12 +15,10 @@ package org.eclipse.cdt.internal.core.pdom.indexer.full;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.LinkedHashMap;
|
import java.util.LinkedHashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
import org.eclipse.cdt.core.CCorePlugin;
|
import org.eclipse.cdt.core.CCorePlugin;
|
||||||
import org.eclipse.cdt.core.dom.IPDOMIndexer;
|
import org.eclipse.cdt.core.dom.IPDOMIndexer;
|
||||||
|
@ -49,8 +47,7 @@ abstract class PDOMFullIndexerJob extends PDOMIndexerTask implements IPDOMIndexe
|
||||||
|
|
||||||
protected final PDOMFullIndexer indexer;
|
protected final PDOMFullIndexer indexer;
|
||||||
protected IWritableIndex index= null;
|
protected IWritableIndex index= null;
|
||||||
private Set filePathsToParse= null;
|
private Map filePathsToParse= null;
|
||||||
protected volatile int fFilesToIndex= 0;
|
|
||||||
|
|
||||||
public PDOMFullIndexerJob(PDOMFullIndexer indexer) throws CoreException {
|
public PDOMFullIndexerJob(PDOMFullIndexer indexer) throws CoreException {
|
||||||
this.indexer = indexer;
|
this.indexer = indexer;
|
||||||
|
@ -64,12 +61,16 @@ abstract class PDOMFullIndexerJob extends PDOMIndexerTask implements IPDOMIndexe
|
||||||
this.index = ((IWritableIndexManager) CCorePlugin.getIndexManager()).getWritableIndex(indexer.getProject());
|
this.index = ((IWritableIndexManager) CCorePlugin.getIndexManager()).getWritableIndex(indexer.getProject());
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void registerTUsInReaderFactory(Collection tus) throws CoreException {
|
protected void registerTUsInReaderFactory(Collection required, Collection optional) throws CoreException {
|
||||||
filePathsToParse= new HashSet();
|
filePathsToParse= new HashMap();
|
||||||
|
|
||||||
for (Iterator iter = tus.iterator(); iter.hasNext();) {
|
for (Iterator iter = required.iterator(); iter.hasNext();) {
|
||||||
ITranslationUnit tu = (ITranslationUnit) iter.next();
|
ITranslationUnit tu = (ITranslationUnit) iter.next();
|
||||||
filePathsToParse.add(tu.getLocation().toOSString());
|
filePathsToParse.put(tu.getLocation().toOSString(), Boolean.TRUE);
|
||||||
|
}
|
||||||
|
for (Iterator iter = optional.iterator(); iter.hasNext();) {
|
||||||
|
ITranslationUnit tu = (ITranslationUnit) iter.next();
|
||||||
|
filePathsToParse.put(tu.getLocation().toOSString(), Boolean.FALSE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -81,11 +82,11 @@ abstract class PDOMFullIndexerJob extends PDOMIndexerTask implements IPDOMIndexe
|
||||||
return;
|
return;
|
||||||
ITranslationUnit tu = (ITranslationUnit)i.next();
|
ITranslationUnit tu = (ITranslationUnit)i.next();
|
||||||
String path = tu.getLocation().toOSString();
|
String path = tu.getLocation().toOSString();
|
||||||
if (!filePathsToParse.contains(path)) {
|
if (filePathsToParse.get(path) == null) {
|
||||||
i.remove();
|
i.remove();
|
||||||
}
|
}
|
||||||
else if (tu.isSourceUnit()) {
|
else if (tu.isSourceUnit()) {
|
||||||
parseTU(tu);
|
parseTU(tu, monitor);
|
||||||
i.remove();
|
i.remove();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -97,13 +98,13 @@ abstract class PDOMFullIndexerJob extends PDOMIndexerTask implements IPDOMIndexe
|
||||||
return;
|
return;
|
||||||
ITranslationUnit tu = (ITranslationUnit)i.next();
|
ITranslationUnit tu = (ITranslationUnit)i.next();
|
||||||
String path = tu.getLocation().toOSString();
|
String path = tu.getLocation().toOSString();
|
||||||
if (!filePathsToParse.contains(path)) {
|
if (filePathsToParse.get(path)==null) {
|
||||||
i.remove();
|
i.remove();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
ITranslationUnit context= findContext(index, path);
|
ITranslationUnit context= findContext(index, path);
|
||||||
if (context != null) {
|
if (context != null) {
|
||||||
parseTU(context);
|
parseTU(context, monitor);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -114,17 +115,17 @@ abstract class PDOMFullIndexerJob extends PDOMIndexerTask implements IPDOMIndexe
|
||||||
while (i.hasNext()) {
|
while (i.hasNext()) {
|
||||||
ITranslationUnit tu = (ITranslationUnit)i.next();
|
ITranslationUnit tu = (ITranslationUnit)i.next();
|
||||||
String path = tu.getLocation().toOSString();
|
String path = tu.getLocation().toOSString();
|
||||||
if (!filePathsToParse.contains(path)) {
|
if (filePathsToParse.get(path)==null) {
|
||||||
i.remove();
|
i.remove();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
parseTU(tu);
|
parseTU(tu, monitor);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void doParseTU(ITranslationUnit tu) throws CoreException, InterruptedException {
|
protected void doParseTU(ITranslationUnit tu, IProgressMonitor pm) throws CoreException, InterruptedException {
|
||||||
IPath path = tu.getLocation();
|
IPath path = tu.getLocation();
|
||||||
if (path == null) {
|
if (path == null) {
|
||||||
return;
|
return;
|
||||||
|
@ -134,34 +135,11 @@ abstract class PDOMFullIndexerJob extends PDOMIndexerTask implements IPDOMIndexe
|
||||||
options |= ITranslationUnit.AST_SKIP_IF_NO_BUILD_INFO;
|
options |= ITranslationUnit.AST_SKIP_IF_NO_BUILD_INFO;
|
||||||
}
|
}
|
||||||
IASTTranslationUnit ast= tu.getAST(null, options);
|
IASTTranslationUnit ast= tu.getAST(null, options);
|
||||||
if (ast == null)
|
if (ast != null)
|
||||||
return;
|
addSymbols(ast, pm);
|
||||||
System.out.println(path.toOSString());
|
|
||||||
index.acquireWriteLock(0);
|
|
||||||
|
|
||||||
try {
|
|
||||||
// Remove the old symbols in the tu
|
|
||||||
IIndexFragmentFile file = (IIndexFragmentFile) index.getFile(path);
|
|
||||||
if (file != null)
|
|
||||||
index.clearFile(file);
|
|
||||||
|
|
||||||
// Clear out the symbols in the includes
|
|
||||||
IASTPreprocessorIncludeStatement[] includes = ast.getIncludeDirectives();
|
|
||||||
for (int i = 0; i < includes.length; ++i) {
|
|
||||||
String incname = includes[i].getPath();
|
|
||||||
IIndexFragmentFile incfile = (IIndexFragmentFile) index.getFile(new Path(incname));
|
|
||||||
if (incfile != null) {
|
|
||||||
index.clearFile(incfile);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
addSymbols(ast);
|
|
||||||
} finally {
|
|
||||||
index.releaseWriteLock(0);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void addSymbols(IASTTranslationUnit ast) throws InterruptedException, CoreException {
|
protected void addSymbols(IASTTranslationUnit ast, IProgressMonitor pm) throws InterruptedException, CoreException {
|
||||||
// Add in the includes
|
// Add in the includes
|
||||||
final LinkedHashMap symbolMap= new LinkedHashMap(); // makes bugs reproducible
|
final LinkedHashMap symbolMap= new LinkedHashMap(); // makes bugs reproducible
|
||||||
|
|
||||||
|
@ -206,6 +184,9 @@ abstract class PDOMFullIndexerJob extends PDOMIndexerTask implements IPDOMIndexe
|
||||||
});
|
});
|
||||||
|
|
||||||
for (Iterator iter = symbolMap.values().iterator(); iter.hasNext();) {
|
for (Iterator iter = symbolMap.values().iterator(); iter.hasNext();) {
|
||||||
|
if (pm.isCanceled()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
// resolve the names
|
// resolve the names
|
||||||
ArrayList names= ((ArrayList[]) iter.next())[2];
|
ArrayList names= ((ArrayList[]) iter.next())[2];
|
||||||
for (int i=0; i<names.size(); i++) {
|
for (int i=0; i<names.size(); i++) {
|
||||||
|
@ -213,15 +194,23 @@ abstract class PDOMFullIndexerJob extends PDOMIndexerTask implements IPDOMIndexe
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (Iterator iter = symbolMap.entrySet().iterator(); iter.hasNext();) {
|
index.acquireWriteLock(0);
|
||||||
Map.Entry entry = (Map.Entry) iter.next();
|
try {
|
||||||
String path= (String) entry.getKey();
|
for (Iterator iter = symbolMap.entrySet().iterator(); iter.hasNext();) {
|
||||||
addToIndex(path, (ArrayList[]) entry.getValue());
|
if (pm.isCanceled()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Map.Entry entry = (Map.Entry) iter.next();
|
||||||
|
String path= (String) entry.getKey();
|
||||||
|
addToIndex(path, (ArrayList[]) entry.getValue());
|
||||||
|
}
|
||||||
|
} finally {
|
||||||
|
index.releaseWriteLock(0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addToMap(HashMap map, int idx, String path, Object thing) {
|
private void addToMap(HashMap map, int idx, String path, Object thing) {
|
||||||
if (filePathsToParse.contains(path)) {
|
if (filePathsToParse.get(path) != null) {
|
||||||
List[] lists= (List[]) map.get(path);
|
List[] lists= (List[]) map.get(path);
|
||||||
if (lists == null) {
|
if (lists == null) {
|
||||||
lists= new ArrayList[]{new ArrayList(), new ArrayList(), new ArrayList()};
|
lists= new ArrayList[]{new ArrayList(), new ArrayList(), new ArrayList()};
|
||||||
|
@ -232,10 +221,13 @@ abstract class PDOMFullIndexerJob extends PDOMIndexerTask implements IPDOMIndexe
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addToIndex(String location, ArrayList[] lists) throws CoreException {
|
private void addToIndex(String location, ArrayList[] lists) throws CoreException {
|
||||||
if (!filePathsToParse.remove(location)) {
|
Boolean required= (Boolean) filePathsToParse.remove(location);
|
||||||
|
if (required == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
fFilesToIndex--;
|
if (!required.booleanValue()) {
|
||||||
|
fTotalTasks++;
|
||||||
|
}
|
||||||
|
|
||||||
// Remove the old symbols in the tu
|
// Remove the old symbols in the tu
|
||||||
Path path= new Path(location);
|
Path path= new Path(location);
|
||||||
|
@ -267,9 +259,6 @@ abstract class PDOMFullIndexerJob extends PDOMIndexerTask implements IPDOMIndexe
|
||||||
for (int i = 0; i < list.size(); i++) {
|
for (int i = 0; i < list.size(); i++) {
|
||||||
index.addName(file, (IASTName) list.get(i));
|
index.addName(file, (IASTName) list.get(i));
|
||||||
}
|
}
|
||||||
}
|
fCompletedTasks++;
|
||||||
|
|
||||||
final public int getFilesToIndexCount() {
|
|
||||||
return fFilesToIndex;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,6 +13,7 @@
|
||||||
package org.eclipse.cdt.internal.core.pdom.indexer.full;
|
package org.eclipse.cdt.internal.core.pdom.indexer.full;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.CCorePlugin;
|
import org.eclipse.cdt.core.CCorePlugin;
|
||||||
import org.eclipse.core.runtime.CoreException;
|
import org.eclipse.core.runtime.CoreException;
|
||||||
|
@ -30,23 +31,33 @@ class PDOMFullReindex extends PDOMFullIndexerJob {
|
||||||
|
|
||||||
public PDOMFullReindex(PDOMFullIndexer indexer) throws CoreException {
|
public PDOMFullReindex(PDOMFullIndexer indexer) throws CoreException {
|
||||||
super(indexer);
|
super(indexer);
|
||||||
fFilesToIndex= 1;
|
fTotalTasks= 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void run(final IProgressMonitor monitor) {
|
public void run(final IProgressMonitor monitor) {
|
||||||
try {
|
try {
|
||||||
long start = System.currentTimeMillis();
|
long start = System.currentTimeMillis();
|
||||||
collectSources(indexer.getProject(), fTUs, fTUs);
|
boolean allfiles= getIndexAllFiles();
|
||||||
fFilesToIndex= fTUs.size()+1;
|
List optional= new ArrayList();
|
||||||
|
|
||||||
if (fFilesToIndex == 1 || monitor.isCanceled()) {
|
collectSources(indexer.getProject(), fTUs, optional, allfiles);
|
||||||
return;
|
if (allfiles) {
|
||||||
|
fTUs.addAll(optional);
|
||||||
|
optional.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fTotalTasks+= fTUs.size()+1;
|
||||||
|
fCompletedTasks++;
|
||||||
|
|
||||||
setupIndexAndReaderFactory();
|
setupIndexAndReaderFactory();
|
||||||
clearIndex(index);
|
clearIndex(index);
|
||||||
registerTUsInReaderFactory(fTUs);
|
|
||||||
fFilesToIndex--;
|
if (getRemainingSubtaskCount() == 1 || monitor.isCanceled()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
registerTUsInReaderFactory(fTUs, optional);
|
||||||
|
fCompletedTasks++;
|
||||||
|
|
||||||
parseTUs(fTUs, monitor);
|
parseTUs(fTUs, monitor);
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,2 @@
|
||||||
|
PDOMIndexerTask_collectingFilesTask=Collecting files to parse
|
||||||
|
PDOMIndexerTask_parsingFileTask=parsing {0} ({1})
|
|
@ -69,8 +69,16 @@ public class PDOMNullIndexer implements IPDOMIndexer {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getFilesToIndexCount() {
|
public String getMonitorMessageDetail() {
|
||||||
return 1;
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getCompletedSubtaskCount() {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getRemainingSubtaskCount() {
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -3,4 +3,3 @@ PDOMManager_notifyJob_label=Notify Index Change Listeners
|
||||||
PDOMManager_JoinIndexerTask=Join Indexer
|
PDOMManager_JoinIndexerTask=Join Indexer
|
||||||
PDOMManager_savePrefsJob=Save Project Preferences
|
PDOMManager_savePrefsJob=Save Project Preferences
|
||||||
PDOMManager_notifyTask_message=Notify Listeners
|
PDOMManager_notifyTask_message=Notify Listeners
|
||||||
PDOMManager_FilesToIndexSubtask={0} files to index
|
|
||||||
|
|
|
@ -0,0 +1,26 @@
|
||||||
|
/*******************************************************************************
|
||||||
|
* Copyright (c) 2006 Wind River Systems, Inc. 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:
|
||||||
|
* Markus Schorn - initial API and implementation
|
||||||
|
*******************************************************************************/
|
||||||
|
|
||||||
|
package org.eclipse.cdt.internal.core;
|
||||||
|
|
||||||
|
import org.eclipse.osgi.util.NLS;
|
||||||
|
|
||||||
|
public class Messages extends NLS {
|
||||||
|
private static final String BUNDLE_NAME = "org.eclipse.cdt.internal.core.messages"; //$NON-NLS-1$
|
||||||
|
public static String Util_unexpectedError;
|
||||||
|
static {
|
||||||
|
// initialize resource bundle
|
||||||
|
NLS.initializeMessages(BUNDLE_NAME, Messages.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
private Messages() {
|
||||||
|
}
|
||||||
|
}
|
|
@ -376,7 +376,11 @@ public class Util {
|
||||||
* @return an IStatus object based on the given Throwable.
|
* @return an IStatus object based on the given Throwable.
|
||||||
*/
|
*/
|
||||||
public static IStatus createStatus(Throwable t) {
|
public static IStatus createStatus(Throwable t) {
|
||||||
return new Status(IStatus.ERROR, CCorePlugin.PLUGIN_ID, 0, t.getMessage(), t);
|
String msg= t.getMessage();
|
||||||
|
if (msg == null) {
|
||||||
|
msg= Messages.Util_unexpectedError;
|
||||||
|
}
|
||||||
|
return new Status(IStatus.ERROR, CCorePlugin.PLUGIN_ID, 0, msg, t);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -55,3 +55,4 @@ convention.enum.dollarName= Enum name has $
|
||||||
convention.enum.leadingUnderscore= Enum name starts with underscore
|
convention.enum.leadingUnderscore= Enum name starts with underscore
|
||||||
convention.enum.lowercaseName= Enum name starts with lower case
|
convention.enum.lowercaseName= Enum name starts with lower case
|
||||||
convention.enum.invalidName= Enum name is invalid
|
convention.enum.invalidName= Enum name is invalid
|
||||||
|
Util_unexpectedError=Unexpected error
|
||||||
|
|
|
@ -284,6 +284,7 @@ public class IBViewPart extends ViewPart
|
||||||
fContentProvider= new IBContentProvider(display);
|
fContentProvider= new IBContentProvider(display);
|
||||||
fLabelProvider= new IBLabelProvider(display, fContentProvider);
|
fLabelProvider= new IBLabelProvider(display, fContentProvider);
|
||||||
fTreeViewer= new ExtendedTreeViewer(fViewerPage);
|
fTreeViewer= new ExtendedTreeViewer(fViewerPage);
|
||||||
|
fTreeViewer.setUseHashlookup(true);
|
||||||
fTreeViewer.setContentProvider(fContentProvider);
|
fTreeViewer.setContentProvider(fContentProvider);
|
||||||
fTreeViewer.setLabelProvider(fLabelProvider);
|
fTreeViewer.setLabelProvider(fLabelProvider);
|
||||||
fTreeViewer.setAutoExpandLevel(2);
|
fTreeViewer.setAutoExpandLevel(2);
|
||||||
|
|
Loading…
Add table
Reference in a new issue