1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-06-08 10:16:03 +02:00

Fix for 194194, performance improvements for CModelManager.createBinaryFile().

This commit is contained in:
Markus Schorn 2007-07-12 09:18:00 +00:00
parent d122e22f3d
commit 3368b94eb8

View file

@ -69,8 +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.IContentType;
import org.eclipse.core.runtime.content.IContentTypeManager;
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;
@ -544,6 +544,11 @@ public class CModelManager implements IResourceChangeListener, ICDescriptorListe
} }
public IBinaryFile createBinaryFile(IFile file) { public IBinaryFile createBinaryFile(IFile file) {
BinaryParserConfig[] parsers = getBinaryParser(file.getProject());
if (parsers.length == 0) {
return null;
}
// Only if file has no extension, has an extension that is an integer // Only if file has no extension, has an extension that is an integer
// or is a binary file content type // or is a binary file content type
String ext = file.getFileExtension(); String ext = file.getFileExtension();
@ -556,15 +561,14 @@ public class CModelManager implements IResourceChangeListener, ICDescriptorListe
break; break;
} }
if (!isNumber) { if (!isNumber) {
try { boolean isBinary= false;
// make sure it's a binary file content type final IContentTypeManager ctm = Platform.getContentTypeManager();
IContentDescription contentDesc = file.getContentDescription(); final IContentType ctbin = ctm.getContentType(CCorePlugin.CONTENT_TYPE_BINARYFILE);
if (contentDesc == null) final IContentType[] cts= ctm.findContentTypesFor(file.getName());
return null; for (int i=0; !isBinary && i < cts.length; i++) {
IContentType contentType = contentDesc.getContentType(); isBinary= cts[i].isKindOf(ctbin);
if (!contentType.isKindOf(Platform.getContentTypeManager().getContentType(CCorePlugin.CONTENT_TYPE_BINARYFILE))) }
return null; if (!isBinary) {
} catch (CoreException e) {
return null; return null;
} }
} }
@ -582,7 +586,6 @@ public class CModelManager implements IResourceChangeListener, ICDescriptorListe
//return null; //return null;
} }
BinaryParserConfig[] parsers = getBinaryParser(file.getProject());
int hints = 0; int hints = 0;
for (int i = 0; i < parsers.length; i++) { for (int i = 0; i < parsers.length; i++) {