1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-29 11:55:40 +02:00

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...

This commit is contained in:
Doug Schaefer 2007-04-17 22:57:42 +00:00
parent 42cc1b5978
commit 72947a1a2e
5 changed files with 59 additions and 9 deletions

View file

@ -173,17 +173,29 @@
<!-- =================================================================================== -->
<extension point="org.eclipse.core.runtime.contentTypes">
<!-- declares a content type for object files -->
<content-type id="compiledObjectFile" name="%objectFileName"
priority="high"/>
<content-type
base-type="org.eclipse.cdt.core.binaryFile"
id="compiledObjectFile"
name="%objectFileName"
priority="high"/>
<!-- declares a content type for executable files -->
<content-type id="executableFile" name="%executableName"
priority="high"/>
<content-type
base-type="org.eclipse.cdt.core.binaryFile"
id="executableFile"
name="%executableName"
priority="high"/>
<!-- declares a content type for static libraries -->
<content-type id="staticLibrary" name="%staticLibraryName"
priority="high"/>
<content-type
base-type="org.eclipse.cdt.core.binaryFile"
id="staticLibrary"
name="%staticLibraryName"
priority="high"/>
<!-- declares a content type for shared libraries -->
<content-type id="sharedLibrary" name="%sharedLibraryName"
priority="high"/>
<content-type
base-type="org.eclipse.cdt.core.binaryFile"
id="sharedLibrary"
name="%sharedLibraryName"
priority="high"/>
</extension>
<extension point="org.eclipse.core.runtime.contentTypes">

View file

@ -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

View file

@ -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

View file

@ -503,6 +503,11 @@
base-type="org.eclipse.core.runtime.text"
file-extensions="s,asm"
priority="high"/>
<content-type
id="binaryFile"
name="%binaryFileName"
priority="high">
</content-type>
</extension>
<!-- the reserved filenames by the C++ standard -->

View file

@ -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()