Project: JDT
Bug 88188 should use IContentType.isKindOf in PropertiesFileDocumentProvider
Reported: 2005-03-16 11:09:30 | Status: resolved fixed

Noticed there is an ad hoc implementation for the "isA" test for content types in PropertiesFileDocumentProvider. There is API for that in IContentType, so you would not need an ad-hoc implementation. Here is a patch rooted at org.eclipse.jdt.ui: Index: ui/org/eclipse/jdt/internal/ui/propertiesfileeditor/PropertiesFileDocumentProvider.java =================================================================== RCS file: /home/eclipse/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/propertiesfileeditor/PropertiesFileDocumentProvider.java,v retrieving revision 1.4 diff -u -r1.4 PropertiesFileDocumentProvider.java --- ui/org/eclipse/jdt/internal/ui/propertiesfileeditor/PropertiesFileDocumentProvider.java 25 Feb 2005 15:35:15 -0000 1.4 +++ ui/org/eclipse/jdt/internal/ui/propertiesfileeditor/PropertiesFileDocumentProvider.java 16 Mar 2005 16:03:36 -0000 @@ -61,8 +61,8 @@ if (file == null) return null; - IContentDescription description= file.getContentDescription(); - if (description == null || !isSubtype(description.getContentType(), JAVA_PROPERTIES_FILE_CONTENT_TYPE)) + IContentDescription description= file.getContentDescription(); + if (description == null || description.getContentType() == null || !description.getContentType().isKindOf(JAVA_PROPERTIES_FILE_CONTENT_TYPE)) return null; return super.createFileInfo(element); @@ -79,22 +79,4 @@ return super.createSaveOperation(element, document, overwrite); } - /** - * Returns <code>true</code> if the candidate content type is a - * subtype of the content type. - * - * @param candidateType the candidate content type - * @param contentType the content type - * @return <code>true</code> if the candidate content type is a - * subtype of the content type - */ - private boolean isSubtype(IContentType candidateType, IContentType contentType) { - if (candidateType == null) - return false; - - if (contentType.equals(candidateType)) - return true; - - return isSubtype(candidateType.getBaseType(), contentType); - } }

Files changed in fix:
org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/propertiesfileeditor/PropertiesFileDocumentProvider.java