Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlain Magloire2005-06-25 19:33:42 +0000
committerAlain Magloire2005-06-25 19:33:42 +0000
commit59725982d0a0340f83843299f1bd738b83c8d847 (patch)
treefd306c42cfaacc61ca303b884bdb61b7b07949af
parent939eb01a27a1e2538a45ee98130d3e9a872bd24c (diff)
downloadorg.eclipse.cdt-59725982d0a0340f83843299f1bd738b83c8d847.tar.gz
org.eclipse.cdt-59725982d0a0340f83843299f1bd738b83c8d847.tar.xz
org.eclipse.cdt-59725982d0a0340f83843299f1bd738b83c8d847.zip
2005-06-25 Alain Magloire
Fix PR 91069: BinaryRunner search improvements from Chris Wiebe. * model/org/eclipse/cdt/internal/core/model/BinaryRunner.java
-rw-r--r--core/org.eclipse.cdt.core/ChangeLog4
-rw-r--r--core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/BinaryRunner.java98
-rw-r--r--core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/ContentTypeProcessor.java2
3 files changed, 75 insertions, 29 deletions
diff --git a/core/org.eclipse.cdt.core/ChangeLog b/core/org.eclipse.cdt.core/ChangeLog
index d7d9465015a..8a6fd5475c7 100644
--- a/core/org.eclipse.cdt.core/ChangeLog
+++ b/core/org.eclipse.cdt.core/ChangeLog
@@ -1,4 +1,8 @@
2005-06-25 Alain Magloire
+ Fix PR 91069: BinaryRunner search improvements from Chris Wiebe.
+ * model/org/eclipse/cdt/internal/core/model/BinaryRunner.java
+
+2005-06-25 Alain Magloire
Fix PR 98788: Dealing with templates
* model/org/eclipse/cdt/core/model/ICElement.java
+ model/org/eclipse/cdt/core/model/IFunctionTemplate.java
diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/BinaryRunner.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/BinaryRunner.java
index 39f15581fba..4a5a900267c 100644
--- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/BinaryRunner.java
+++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/BinaryRunner.java
@@ -14,18 +14,25 @@ package org.eclipse.cdt.internal.core.model;
import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.IBinaryParser.IBinaryFile;
import org.eclipse.cdt.core.model.CModelException;
-import org.eclipse.cdt.core.model.CoreModel;
+import org.eclipse.cdt.core.model.CoreModelUtil;
import org.eclipse.cdt.core.model.ElementChangedEvent;
import org.eclipse.cdt.core.model.ICElement;
import org.eclipse.cdt.core.model.ICProject;
+import org.eclipse.cdt.core.model.IOutputEntry;
+import org.eclipse.core.resources.IContainer;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
-import org.eclipse.core.resources.IResourceVisitor;
+import org.eclipse.core.resources.IResourceProxy;
+import org.eclipse.core.resources.IResourceProxyVisitor;
import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.content.IContentType;
+import org.eclipse.core.runtime.content.IContentTypeManager;
import org.eclipse.core.runtime.jobs.Job;
public class BinaryRunner {
@@ -50,15 +57,21 @@ public class BinaryRunner {
if (cproject == null || monitor.isCanceled()) {
return Status.CANCEL_STATUS;
}
+
try {
+ monitor.beginTask(getName(), IProgressMonitor.UNKNOWN);
+
BinaryContainer vbin = (BinaryContainer) cproject.getBinaryContainer();
ArchiveContainer vlib = (ArchiveContainer) cproject.getArchiveContainer();
vlib.removeChildren();
vbin.removeChildren();
- cproject.getProject().accept(new Visitor(BinaryRunner.this, monitor));
+
+ cproject.getProject().accept(new Visitor(monitor), IContainer.INCLUDE_PHANTOMS);
fireEvents(cproject, vbin);
fireEvents(cproject, vlib);
+
+ monitor.done();
} catch (CoreException e) {
return e.getStatus();
}
@@ -108,42 +121,73 @@ public class BinaryRunner {
}
}
- void addChildIfBinary(IFile file) {
- CModelManager factory = CModelManager.getDefault();
- // Attempt to speed things up by rejecting up front
- // Things we know should not be Binary files.
- if (!CoreModel.isTranslationUnit(file)) {
- IBinaryFile bin = factory.createBinaryFile(file);
- if (bin != null) {
- // Create the file will add it to the {Archive,Binary}Containery.
- factory.create(file, bin, null);
- }
- }
- }
-
- class Visitor implements IResourceVisitor {
-
- private BinaryRunner vRunner;
+ private class Visitor implements IResourceProxyVisitor {
private IProgressMonitor vMonitor;
+ private IProject project;
+ private IOutputEntry[] entries = new IOutputEntry[0];
+ private IContentType textContentType;
- public Visitor(BinaryRunner r, IProgressMonitor monitor) {
- vRunner = r;
+ public Visitor(IProgressMonitor monitor) {
vMonitor = monitor;
+ this.project = cproject.getProject();
+ try {
+ entries = cproject.getOutputEntries();
+ } catch (CModelException e) {
+ }
+ IContentTypeManager mgr = Platform.getContentTypeManager();
+ textContentType = mgr.getContentType("org.eclipse.core.runtime.text"); //$NON-NLS-1$
}
- public boolean visit(IResource res) throws CoreException {
+ public boolean visit(IResourceProxy proxy) throws CoreException {
if (vMonitor.isCanceled()) {
return false;
}
- if (cproject.isOnOutputEntry(res)) {
- if (res instanceof IFile) {
- if (vRunner != null) {
- vRunner.addChildIfBinary((IFile) res);
+ vMonitor.worked(1);
+
+ // Attempt to speed things up by rejecting up front
+ // Things we know should not be Binary files.
+
+ // check if it's a file resource
+ // and bail out early
+ if (proxy.getType() != IResource.FILE) {
+ return true;
+ }
+
+ // check against known content types
+ String name = proxy.getName();
+ IContentType contentType = CCorePlugin.getContentType(project, name);
+ if (contentType != null && textContentType != null) {
+ if (contentType != null && contentType.isKindOf(textContentType)) {
+ return true;
+ } else if (textContentType.isAssociatedWith(name)) {
+ return true;
+ }
+ }
+
+ // we have a candidate
+ IPath path = proxy.requestFullPath();
+ if (path != null) {
+ for (int i = 0; i < entries.length; ++i) {
+ if (isOnOutputEntry(entries[i], path)) {
+ IFile file = (IFile) proxy.requestResource();
+ CModelManager factory = CModelManager.getDefault();
+ IBinaryFile bin = factory.createBinaryFile(file);
+ if (bin != null) {
+ // Create the file will add it to the {Archive,Binary}Containery.
+ factory.create(file, bin, cproject);
+ return true;
+ }
}
- return false;
}
}
return true;
}
+
+ private boolean isOnOutputEntry(IOutputEntry entry, IPath path) {
+ if (entry.getPath().isPrefixOf(path) && !CoreModelUtil.isExcluded(path, entry.fullExclusionPatternChars())) {
+ return true;
+ }
+ return false;
+ }
}
}
diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/ContentTypeProcessor.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/ContentTypeProcessor.java
index 21c65b43c72..6abeb8c59be 100644
--- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/ContentTypeProcessor.java
+++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/ContentTypeProcessor.java
@@ -102,10 +102,8 @@ public class ContentTypeProcessor {
for (int i = 0; i < members.length; ++i) {
if (members[i] instanceof IFile) {
IFile file = (IFile) members[i];
- //if (contentType.isAssociatedWith(file.getName(), context)) {
IContentType cType = CCorePlugin.getContentType(file.getProject(), file.getName());
if (cType != null && cType.equals(contentType)) {
-// if (CoreModel.isValidTranslationUnitName(file.getProject(), file.getName())) {
ICElement newElement = CoreModel.getDefault().create(file);
if (newElement != null) {
elementAdded(newElement, celement);

Back to the top