Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlain Magloire2006-12-17 00:57:22 +0000
committerAlain Magloire2006-12-17 00:57:22 +0000
commit23ad32e88a128c37ed5029e2e38ddfc7a4997bd4 (patch)
treeb251612f3a7a3e5518b462191a278fe6824161cc
parent66948345f02c12d4e7920c3ced4e223e86d4d30d (diff)
downloadorg.eclipse.cdt-23ad32e88a128c37ed5029e2e38ddfc7a4997bd4.tar.gz
org.eclipse.cdt-23ad32e88a128c37ed5029e2e38ddfc7a4997bd4.tar.xz
org.eclipse.cdt-23ad32e88a128c37ed5029e2e38ddfc7a4997bd4.zip
Based on suggestion/patch from James Blackburn we also add more verbosity when going through the folders, this is more reassuring to the user then to see a blank "Binary Thread search"
fixes for PR:149428 PR74387
-rw-r--r--core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/BinaryRunner.java48
-rw-r--r--core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/CModelManager.java20
-rw-r--r--core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/Util.java30
3 files changed, 64 insertions, 34 deletions
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 08d503e7ae1..5aabac2c3df 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
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2005 QNX Software Systems and others.
+ * Copyright (c) 2000, 2005, 2006 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
@@ -83,6 +83,7 @@ public class BinaryRunner {
public void start() {
String taskName = CCorePlugin.getResourceString("CoreModel.BinaryRunner.Binary_Search_Thread"); //$NON-NLS-1$
+ taskName += " (" + cproject.getElementName() + ")";
runner = new Job(taskName) {
/*
@@ -91,29 +92,30 @@ public class BinaryRunner {
* @see org.eclipse.core.runtime.jobs.Job#run(org.eclipse.core.runtime.IProgressMonitor)
*/
protected IStatus run(IProgressMonitor monitor) {
+ IStatus status = Status.OK_STATUS;
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(monitor), IContainer.INCLUDE_PHANTOMS);
-
- CModelOperation op = new BinaryRunnerOperation(cproject);
- op.runOperation(monitor);
-
- monitor.done();
- } catch (CoreException e) {
- return e.getStatus();
+ status = Status.CANCEL_STATUS;
+ } else {
+ 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(monitor), IContainer.INCLUDE_PHANTOMS);
+
+ CModelOperation op = new BinaryRunnerOperation(cproject);
+ op.runOperation(monitor);
+
+ } catch (CoreException e) {
+ status = e.getStatus();
+ }
}
- return Status.OK_STATUS;
+ monitor.done();
+ return status;
}
};
runner.schedule();
@@ -172,6 +174,8 @@ public class BinaryRunner {
// check against known content types
String name = proxy.getName();
+ vMonitor.subTask(name); // give a hint to the user of what we are doing
+
IContentType contentType = CCorePlugin.getContentType(project, name);
if (contentType != null && textContentType != null) {
if (contentType != null && contentType.isKindOf(textContentType)) {
diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/CModelManager.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/CModelManager.java
index 1e5cc002cff..115dd47f9af 100644
--- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/CModelManager.java
+++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/CModelManager.java
@@ -13,7 +13,6 @@
package org.eclipse.cdt.internal.core.model;
-import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
@@ -408,8 +407,7 @@ public class CModelManager implements IResourceChangeListener, ICDescriptorListe
return null;
}
if (path.isAbsolute()) {
- File file = path.toFile();
- if (file == null || !file.isFile()) {
+ if (! Util.isNonZeroLengthFile(path)) {
return null;
}
try {
@@ -434,8 +432,7 @@ public class CModelManager implements IResourceChangeListener, ICDescriptorListe
IIncludeReference[] includeReferences = cproject.getIncludeReferences();
for (int i = 0; i < includeReferences.length; i++) {
IPath includePath = includeReferences[i].getPath().append(path);
- File file = includePath.toFile();
- if (file != null && file.isFile()) {
+ if (Util.isNonZeroLengthFile(includePath)) {
String id = CoreModel.getRegistedContentTypeId(cproject.getProject(), includePath.lastSegment());
if (id == null) {
// fallbakc to C Header
@@ -567,11 +564,9 @@ public class CModelManager implements IResourceChangeListener, ICDescriptorListe
public IBinaryFile createBinaryFile(IFile file) {
//Avoid name special devices, empty files and the like
- File f = new File(file.getLocationURI());
- if (!f.isFile() || f.length() == 0) {
+ if (! Util.isNonZeroLengthFile(file.getLocationURI())) {
return null;
}
-
BinaryParserConfig[] parsers = getBinaryParser(file.getProject());
int hints = 0;
@@ -659,13 +654,14 @@ public class CModelManager implements IResourceChangeListener, ICDescriptorListe
}
}
- public BinaryRunner getBinaryRunner(ICProject project, boolean start) {
+ public BinaryRunner getBinaryRunner(ICProject cproject, boolean start) {
BinaryRunner runner = null;
synchronized (binaryRunners) {
- runner = (BinaryRunner)binaryRunners.get(project.getProject());
+ IProject project = cproject.getProject();
+ runner = (BinaryRunner)binaryRunners.get(project);
if (runner == null) {
- runner = new BinaryRunner(project.getProject());
- binaryRunners.put(project.getProject(), runner);
+ runner = new BinaryRunner(project);
+ binaryRunners.put(project, runner);
if (start) {
runner.start();
}
diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/Util.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/Util.java
index dfc78b04b50..981339f4cb2 100644
--- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/Util.java
+++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/Util.java
@@ -17,6 +17,7 @@ import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
+import java.net.URI;
import java.text.MessageFormat;
import org.eclipse.cdt.core.CCorePlugin;
@@ -25,8 +26,12 @@ import org.eclipse.cdt.core.model.CModelException;
import org.eclipse.cdt.core.model.ICModelStatusConstants;
import org.eclipse.cdt.internal.core.model.IDebugLogConstants.DebugLogConstant;
import org.eclipse.cdt.internal.core.util.CharArrayBuffer;
+import org.eclipse.core.filesystem.EFS;
+import org.eclipse.core.filesystem.IFileInfo;
+import org.eclipse.core.filesystem.URIUtil;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
@@ -423,5 +428,30 @@ public class Util implements ICLogConstants {
return null;
}
+ /**
+ * Return true if the file is not a directory and has length > 0
+ * @param path
+ * @return
+ */
+ public static boolean isNonZeroLengthFile(IPath path) {
+ return isNonZeroLengthFile(URIUtil.toURI(path));
+ }
+ /**
+ * Return true if the file is not a directory and has length > 0
+ * @param path
+ * @return
+ */
+ public static boolean isNonZeroLengthFile(URI uri) {
+ try {
+ IFileInfo file = EFS.getStore(uri).fetchInfo();
+ if (file.getLength() == EFS.NONE) {
+ return false;
+ }
+ return true;
+ } catch (CoreException e) {
+ // ignore
+ }
+ return false;
+ }
}

Back to the top