From 72947a1a2eb22c93a25c3531ac71d9f3d8338d63 Mon Sep 17 00:00:00 2001 From: Doug Schaefer Date: Tue, 17 Apr 2007 22:57:42 +0000 Subject: [PATCH] Bug 152041 - Filter out running of the binary parser to only parse if the file has no extension, the extension is a number (e.g. libc.so.1), or the file is a binaryFile content type. Much faster now... --- .../plugin.xml | 28 +++++++++++++------ .../internal/core/model/CModelManager.java | 28 +++++++++++++++++++ core/org.eclipse.cdt.core/plugin.properties | 1 + core/org.eclipse.cdt.core/plugin.xml | 5 ++++ .../src/org/eclipse/cdt/core/CCorePlugin.java | 6 +++- 5 files changed, 59 insertions(+), 9 deletions(-) diff --git a/build/org.eclipse.cdt.managedbuilder.core/plugin.xml b/build/org.eclipse.cdt.managedbuilder.core/plugin.xml index 62be9649bad..c08b4ba1539 100644 --- a/build/org.eclipse.cdt.managedbuilder.core/plugin.xml +++ b/build/org.eclipse.cdt.managedbuilder.core/plugin.xml @@ -173,17 +173,29 @@ - + - + - + - + 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 24092979df6..0d0e73fc81e 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 @@ -69,6 +69,8 @@ import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.ISafeRunnable; import org.eclipse.core.runtime.Platform; import org.eclipse.core.runtime.SafeRunner; +import org.eclipse.core.runtime.content.IContentDescription; +import org.eclipse.core.runtime.content.IContentType; import org.eclipse.core.runtime.content.IContentTypeManager.ContentTypeChangeEvent; import org.eclipse.core.runtime.content.IContentTypeManager.IContentTypeChangeListener; @@ -574,6 +576,32 @@ public class CModelManager implements IResourceChangeListener, ICDescriptorListe } public IBinaryFile createBinaryFile(IFile file) { + // Only if file has no extension, has an extension that is an integer + // or is a binary file content type + String ext = file.getFileExtension(); + if (ext != null) { + // shared libraries often have a version number + boolean isNumber = true; + for (int i = 0; i < ext.length(); ++i) + if (!Character.isDigit(ext.charAt(i))) { + isNumber = false; + break; + } + if (!isNumber) { + try { + // make sure it's a binary file content type + IContentDescription contentDesc = file.getContentDescription(); + if (contentDesc == null) + return null; + IContentType contentType = contentDesc.getContentType(); + if (!contentType.isKindOf(Platform.getContentTypeManager().getContentType(CCorePlugin.CONTENT_TYPE_BINARYFILE))) + return null; + } catch (CoreException e) { + return null; + } + } + } + //Avoid name special devices, empty files and the like if (! Util.isNonZeroLengthFile(file.getLocationURI())) { // PR:xxx the EFS does not seem to work for newly created file diff --git a/core/org.eclipse.cdt.core/plugin.properties b/core/org.eclipse.cdt.core/plugin.properties index 218c86eb392..6f3f84c3c35 100644 --- a/core/org.eclipse.cdt.core/plugin.properties +++ b/core/org.eclipse.cdt.core/plugin.properties @@ -77,6 +77,7 @@ cHeaderName=C Header File cxxSourceName=C++ Source File cxxHeaderName=C++ Header File asmSourceName=Assembly Source File +binaryFileName=Binary File cdt_pathentry_var.description=CDT PathEntry Variable diff --git a/core/org.eclipse.cdt.core/plugin.xml b/core/org.eclipse.cdt.core/plugin.xml index eaddf64dbfe..ddf8beb379f 100644 --- a/core/org.eclipse.cdt.core/plugin.xml +++ b/core/org.eclipse.cdt.core/plugin.xml @@ -503,6 +503,11 @@ base-type="org.eclipse.core.runtime.text" file-extensions="s,asm" priority="high"/> + + diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/CCorePlugin.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/CCorePlugin.java index be865101187..423eeb5d3a5 100644 --- a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/CCorePlugin.java +++ b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/CCorePlugin.java @@ -159,7 +159,11 @@ public class CCorePlugin extends Plugin { * IContentType id for ASM Unit */ public final static String CONTENT_TYPE_ASMSOURCE = "org.eclipse.cdt.core.asmSource"; //$NON-NLS-1$ - + /** + * IContentType id for Binary Files + */ + public final static String CONTENT_TYPE_BINARYFILE = "org.eclipse.cdt.core.binaryFile"; //$NON-NLS-1$ + /** * Possible configurable option value. * @see #getDefaultOptions()