mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
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
This commit is contained in:
parent
66948345f0
commit
23ad32e88a
3 changed files with 64 additions and 34 deletions
|
@ -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;
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
||||
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();
|
||||
}
|
||||
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)) {
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue