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:
parent
42cc1b5978
commit
72947a1a2e
5 changed files with 59 additions and 9 deletions
|
@ -173,17 +173,29 @@
|
||||||
<!-- =================================================================================== -->
|
<!-- =================================================================================== -->
|
||||||
<extension point="org.eclipse.core.runtime.contentTypes">
|
<extension point="org.eclipse.core.runtime.contentTypes">
|
||||||
<!-- declares a content type for object files -->
|
<!-- declares a content type for object files -->
|
||||||
<content-type id="compiledObjectFile" name="%objectFileName"
|
<content-type
|
||||||
priority="high"/>
|
base-type="org.eclipse.cdt.core.binaryFile"
|
||||||
|
id="compiledObjectFile"
|
||||||
|
name="%objectFileName"
|
||||||
|
priority="high"/>
|
||||||
<!-- declares a content type for executable files -->
|
<!-- declares a content type for executable files -->
|
||||||
<content-type id="executableFile" name="%executableName"
|
<content-type
|
||||||
priority="high"/>
|
base-type="org.eclipse.cdt.core.binaryFile"
|
||||||
|
id="executableFile"
|
||||||
|
name="%executableName"
|
||||||
|
priority="high"/>
|
||||||
<!-- declares a content type for static libraries -->
|
<!-- declares a content type for static libraries -->
|
||||||
<content-type id="staticLibrary" name="%staticLibraryName"
|
<content-type
|
||||||
priority="high"/>
|
base-type="org.eclipse.cdt.core.binaryFile"
|
||||||
|
id="staticLibrary"
|
||||||
|
name="%staticLibraryName"
|
||||||
|
priority="high"/>
|
||||||
<!-- declares a content type for shared libraries -->
|
<!-- declares a content type for shared libraries -->
|
||||||
<content-type id="sharedLibrary" name="%sharedLibraryName"
|
<content-type
|
||||||
priority="high"/>
|
base-type="org.eclipse.cdt.core.binaryFile"
|
||||||
|
id="sharedLibrary"
|
||||||
|
name="%sharedLibraryName"
|
||||||
|
priority="high"/>
|
||||||
</extension>
|
</extension>
|
||||||
|
|
||||||
<extension point="org.eclipse.core.runtime.contentTypes">
|
<extension point="org.eclipse.core.runtime.contentTypes">
|
||||||
|
|
|
@ -69,6 +69,8 @@ import org.eclipse.core.runtime.IPath;
|
||||||
import org.eclipse.core.runtime.ISafeRunnable;
|
import org.eclipse.core.runtime.ISafeRunnable;
|
||||||
import org.eclipse.core.runtime.Platform;
|
import org.eclipse.core.runtime.Platform;
|
||||||
import org.eclipse.core.runtime.SafeRunner;
|
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.ContentTypeChangeEvent;
|
||||||
import org.eclipse.core.runtime.content.IContentTypeManager.IContentTypeChangeListener;
|
import org.eclipse.core.runtime.content.IContentTypeManager.IContentTypeChangeListener;
|
||||||
|
|
||||||
|
@ -574,6 +576,32 @@ public class CModelManager implements IResourceChangeListener, ICDescriptorListe
|
||||||
}
|
}
|
||||||
|
|
||||||
public IBinaryFile createBinaryFile(IFile file) {
|
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
|
//Avoid name special devices, empty files and the like
|
||||||
if (! Util.isNonZeroLengthFile(file.getLocationURI())) {
|
if (! Util.isNonZeroLengthFile(file.getLocationURI())) {
|
||||||
// PR:xxx the EFS does not seem to work for newly created file
|
// PR:xxx the EFS does not seem to work for newly created file
|
||||||
|
|
|
@ -77,6 +77,7 @@ cHeaderName=C Header File
|
||||||
cxxSourceName=C++ Source File
|
cxxSourceName=C++ Source File
|
||||||
cxxHeaderName=C++ Header File
|
cxxHeaderName=C++ Header File
|
||||||
asmSourceName=Assembly Source File
|
asmSourceName=Assembly Source File
|
||||||
|
binaryFileName=Binary File
|
||||||
|
|
||||||
cdt_pathentry_var.description=CDT PathEntry Variable
|
cdt_pathentry_var.description=CDT PathEntry Variable
|
||||||
|
|
||||||
|
|
|
@ -503,6 +503,11 @@
|
||||||
base-type="org.eclipse.core.runtime.text"
|
base-type="org.eclipse.core.runtime.text"
|
||||||
file-extensions="s,asm"
|
file-extensions="s,asm"
|
||||||
priority="high"/>
|
priority="high"/>
|
||||||
|
<content-type
|
||||||
|
id="binaryFile"
|
||||||
|
name="%binaryFileName"
|
||||||
|
priority="high">
|
||||||
|
</content-type>
|
||||||
</extension>
|
</extension>
|
||||||
|
|
||||||
<!-- the reserved filenames by the C++ standard -->
|
<!-- the reserved filenames by the C++ standard -->
|
||||||
|
|
|
@ -159,7 +159,11 @@ public class CCorePlugin extends Plugin {
|
||||||
* IContentType id for ASM Unit
|
* IContentType id for ASM Unit
|
||||||
*/
|
*/
|
||||||
public final static String CONTENT_TYPE_ASMSOURCE = "org.eclipse.cdt.core.asmSource"; //$NON-NLS-1$
|
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.
|
* Possible configurable option value.
|
||||||
* @see #getDefaultOptions()
|
* @see #getDefaultOptions()
|
||||||
|
|
Loading…
Add table
Reference in a new issue