mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
extract duplicate, cleanup
GitOrigin-RevId: 4e732dd8f2db9f6586f2a0b20fb377a597475888
This commit is contained in:
committed by
intellij-monorepo-bot
parent
f9f533440c
commit
8ee64025c2
+10
-9
@@ -328,12 +328,9 @@ public class AbstractFileType extends UserFileType<AbstractFileType> implements
|
||||
}
|
||||
|
||||
@Nullable
|
||||
static Element writeMapping(String typeName, @NotNull FileNameMatcher matcher, boolean specifyTypeName) {
|
||||
static Element writeMapping(@NotNull String typeName, @NotNull FileNameMatcher matcher, boolean specifyTypeName) {
|
||||
Element mapping = new Element(ELEMENT_MAPPING);
|
||||
if (matcher instanceof ExtensionFileNameMatcher) {
|
||||
mapping.setAttribute(ATTRIBUTE_EXT, ((ExtensionFileNameMatcher)matcher).getExtension());
|
||||
}
|
||||
else if (writePattern(matcher, mapping)) {
|
||||
if (!writePattern(matcher, mapping)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -344,17 +341,21 @@ public class AbstractFileType extends UserFileType<AbstractFileType> implements
|
||||
return mapping;
|
||||
}
|
||||
|
||||
static boolean writePattern(FileNameMatcher matcher, Element mapping) {
|
||||
if (matcher instanceof WildcardFileNameMatcher) {
|
||||
// returns true if written
|
||||
static boolean writePattern(@NotNull FileNameMatcher matcher, @NotNull Element mapping) {
|
||||
if (matcher instanceof ExtensionFileNameMatcher) {
|
||||
mapping.setAttribute(ATTRIBUTE_EXT, ((ExtensionFileNameMatcher)matcher).getExtension());
|
||||
}
|
||||
else if (matcher instanceof WildcardFileNameMatcher) {
|
||||
mapping.setAttribute(ATTRIBUTE_PATTERN, ((WildcardFileNameMatcher)matcher).getPattern());
|
||||
}
|
||||
else if (matcher instanceof ExactFileNameMatcher) {
|
||||
mapping.setAttribute(ATTRIBUTE_PATTERN, ((ExactFileNameMatcher)matcher).getFileName());
|
||||
}
|
||||
else {
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+1
-4
@@ -152,10 +152,7 @@ class RemovedMappingTracker {
|
||||
boolean specifyTypeName,
|
||||
boolean approved) {
|
||||
Element mapping = new Element(ELEMENT_REMOVED_MAPPING);
|
||||
if (matcher instanceof ExtensionFileNameMatcher) {
|
||||
mapping.setAttribute(AbstractFileType.ATTRIBUTE_EXT, ((ExtensionFileNameMatcher)matcher).getExtension());
|
||||
}
|
||||
else if (AbstractFileType.writePattern(matcher, mapping)) {
|
||||
if (!AbstractFileType.writePattern(matcher, mapping)) {
|
||||
return null;
|
||||
}
|
||||
if (approved) {
|
||||
|
||||
Reference in New Issue
Block a user