Allow specifying patterns when registering file types in plugin.xml (IDEA-CR-47980)

GitOrigin-RevId: afc1dd7844ba0c7f03a64a234bdd99fde786f4a9
This commit is contained in:
Dmitry Jemerov
2019-06-13 03:28:08 +03:00
committed by intellij-monorepo-bot
parent 81021332bc
commit 66488e1a18
2 changed files with 12 additions and 3 deletions
@@ -50,6 +50,12 @@ public class FileTypeBean extends AbstractExtensionPointBean {
@Attribute("fileNames")
public String fileNames;
/**
* Semicolon-separated list of patterns (strings containing ? and * characters) to be associated with the file type.
*/
@Attribute("patterns")
public String patterns;
/**
* Semicolon-separated list of exact file names (case insensitive) to be associated with the file type.
*/
@@ -61,6 +61,7 @@ import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.annotations.TestOnly;
import org.jetbrains.ide.PooledThreadExecutor;
import org.jetbrains.jps.model.fileTypes.FileNameMatcherFactory;
import java.io.*;
import java.lang.reflect.Field;
@@ -351,9 +352,11 @@ public class FileTypeManagerImpl extends FileTypeManagerEx implements Persistent
final List<FileTypeBean> fileTypeBeans = EP_NAME.getExtensionList();
for (FileTypeBean bean : fileTypeBeans) {
bean.addMatchers(ContainerUtil.concat(parse(bean.extensions),
parse(bean.fileNames, (token) -> new ExactFileNameMatcher(token)),
parse(bean.fileNamesCaseInsensitive, (token) -> new ExactFileNameMatcher(token, true))));
bean.addMatchers(ContainerUtil.concat(
parse(bean.extensions),
parse(bean.fileNames, (token) -> new ExactFileNameMatcher(token)),
parse(bean.fileNamesCaseInsensitive, (token) -> new ExactFileNameMatcher(token, true)),
parse(bean.patterns, (token) -> FileNameMatcherFactory.getInstance().createMatcher(token))));
}
for (FileTypeBean bean : fileTypeBeans) {