Lines 901-912
Link Here
|
901 |
} |
901 |
} |
902 |
return (String[]) tmp.toArray(new String[tmp.size()]); |
902 |
return (String[]) tmp.toArray(new String[tmp.size()]); |
903 |
} |
903 |
} |
904 |
|
904 |
|
905 |
private static IContentType getContentType(ITypedElement element) { |
905 |
/* |
|
|
906 |
* Returns the first content-type for the given element that defines |
907 |
* a binding on both a ContentMergeViewer and a StructureMergeViewer |
908 |
*/ |
909 |
private IContentType getContentType(ITypedElement element) { |
906 |
if (element == null) |
910 |
if (element == null) |
907 |
return null; |
911 |
return null; |
908 |
String name= element.getName(); |
912 |
String name= element.getName(); |
909 |
IContentType ct= null; |
913 |
IContentType[] ct= null; |
910 |
if (element instanceof IStreamContentAccessor) { |
914 |
if (element instanceof IStreamContentAccessor) { |
911 |
IStreamContentAccessor isa= (IStreamContentAccessor) element; |
915 |
IStreamContentAccessor isa= (IStreamContentAccessor) element; |
912 |
try { |
916 |
try { |
Lines 914-920
Link Here
|
914 |
if (is != null) { |
918 |
if (is != null) { |
915 |
InputStream bis= new BufferedInputStream(is); |
919 |
InputStream bis= new BufferedInputStream(is); |
916 |
try { |
920 |
try { |
917 |
ct= fgContentTypeManager.findContentTypeFor(is, name); |
921 |
ct= fgContentTypeManager.findContentTypesFor(is, name); |
918 |
} catch (IOException e) { |
922 |
} catch (IOException e) { |
919 |
// silently ignored |
923 |
// silently ignored |
920 |
} finally { |
924 |
} finally { |
Lines 930-937
Link Here
|
930 |
} |
934 |
} |
931 |
} |
935 |
} |
932 |
if (ct == null) |
936 |
if (ct == null) |
933 |
ct= fgContentTypeManager.findContentTypeFor(name); |
937 |
ct= fgContentTypeManager.findContentTypesFor(name); |
934 |
return ct; |
938 |
// We found more than a single content-type for this file. |
|
|
939 |
// Seeks out a content-type on which a viewer is defined. |
940 |
if (ct.length > 0) { |
941 |
initializeRegistries(); |
942 |
IContentType best = ct[0]; |
943 |
for (int i= 0; i < ct.length; i++) { |
944 |
final Object structureViewer = fStructureMergeViewers.search(ct[i]); |
945 |
final Object contentViewer = fContentMergeViewers.search(ct[i]); |
946 |
if (structureViewer != null && contentViewer != null) |
947 |
/* |
948 |
* This loop could be broken now, but what should be do when more |
949 |
* than one content-type defines both a structureViewer and a |
950 |
* contentViewer? The best option would be to put a "priority" |
951 |
* attribute to the org.eclipse.compare.ContentMergeViewers and |
952 |
* org.eclipse.compare.StructureMergeViewers extension points. |
953 |
*/ |
954 |
best = ct[i]; |
955 |
} |
956 |
return best; |
957 |
} |
958 |
return ct[0]; |
935 |
} |
959 |
} |
936 |
|
960 |
|
937 |
/* |
961 |
/* |
Lines 950-958
Link Here
|
950 |
} |
974 |
} |
951 |
|
975 |
|
952 |
/* |
976 |
/* |
953 |
* Returns the most specific content type that is common to the given inputs or null. |
977 |
* Returns the most common content type that defines a binding on both |
|
|
978 |
* a ContentMergeViewer and a StructureMergeViewer |
954 |
*/ |
979 |
*/ |
955 |
private static IContentType getCommonType(ICompareInput input) { |
980 |
private IContentType getCommonType(ICompareInput input) { |
956 |
|
981 |
|
957 |
ITypedElement ancestor= input.getAncestor(); |
982 |
ITypedElement ancestor= input.getAncestor(); |
958 |
ITypedElement left= input.getLeft(); |
983 |
ITypedElement left= input.getLeft(); |