Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
View | Details | Raw Unified | Return to bug 198544 | Differences between
and this patch

Collapse All | Expand All

(-)src/org/eclipse/core/internal/content/ContentTypeMatcher.java (-2 / +17 lines)
Lines 36-42 Link Here
36
	public IContentType findContentTypeFor(InputStream contents, String fileName) throws IOException {
36
	public IContentType findContentTypeFor(InputStream contents, String fileName) throws IOException {
37
		ContentTypeCatalog currentCatalog = getCatalog();
37
		ContentTypeCatalog currentCatalog = getCatalog();
38
		IContentType[] all = currentCatalog.findContentTypesFor(this, contents, fileName);
38
		IContentType[] all = currentCatalog.findContentTypesFor(this, contents, fileName);
39
		return all.length > 0 ? new ContentTypeHandler((ContentType) all[0], currentCatalog.getGeneration()) : null;
39
		return all.length > 0 ? new ContentTypeHandler((ContentType) getContentTypeWithTheHighestPriority(all), currentCatalog.getGeneration()) : null;
40
	}
41
	
42
	/*
43
	 * Returns a content type with the highest priority from the given list.
44
	 */
45
	private IContentType getContentTypeWithTheHighestPriority(IContentType[] contentTypes) {
46
		IContentType bestMatch = null;
47
		for (int i = 0; i < contentTypes.length; i++) {
48
			if (bestMatch == null || (((ContentType) bestMatch).getPriority() < ((ContentType) contentTypes[i]).getPriority())) {
49
				bestMatch = contentTypes[i];
50
				if (((ContentType) bestMatch).getPriority() == ContentType.PRIORITY_HIGH)
51
					break;
52
			}
53
		}
54
		return bestMatch;
40
	}
55
	}
41
56
42
	/**
57
	/**
Lines 58-64 Link Here
58
		IContentType[] result = new IContentType[types.length];
73
		IContentType[] result = new IContentType[types.length];
59
		int generation = currentCatalog.getGeneration();
74
		int generation = currentCatalog.getGeneration();
60
		for (int i = 0; i < result.length; i++)
75
		for (int i = 0; i < result.length; i++)
61
			result[i] = new ContentTypeHandler((ContentType) types[i], generation);
76
			result[i] = new ContentTypeHandler((ContentType) getContentTypeWithTheHighestPriority(types), generation);
62
		return result;
77
		return result;
63
	}
78
	}
64
79

Return to bug 198544