#431 Recognizers often ascribe wrong file type #455
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fix contentType for an empty YAML file, now it returns a more generic
YEdit editor.
Why this fix works
INDETERMINATE
as description. Notethat it's not the
VALID
which is returned when a content describeractually accepts the input. See
com.reprezen.swagedit.core.editor.TextContentDescriber.describe(InputStream, IContentDescription)
:All ContentDescriber for a given file extensions are equally
important.
Because all the ContentDescriber return
INDETERMINATE
, they aretreated equally important, see
org.eclipse.core.internal.content.ContentTypeCatalog.collectMatchingByContents(int, IContentType[], List<ContentType>, ILazySource, Map<String, Object>)
Then
IContentType
are sorted and the first one winsorg.eclipse.core.internal.content.ContentTypeCatalog.internalFindContentTypesFor(ILazySource, IContentType[][], Comparator<IContentType>, Comparator<IContentType>)
sorts the inputs. In case of
INDETERMINATE
,ContentTypeCatalog.policyConstantGeneralIsBetter
is used which is...where more generic content type means,
getDepth()
is based on thehierarchy defined by the
base-type
:By using YEdit as the
base-type
, we make the YEdit the more genericcontent type => it will be used in case of empty files.