mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
fix ASTFactory registration in ParsingTestCase
This commit is contained in:
@@ -31,8 +31,6 @@ import org.jetbrains.annotations.Nullable;
|
||||
* @author max
|
||||
*/
|
||||
public abstract class ASTFactory {
|
||||
public static final ASTFactory DEFAULT = (ASTFactory) ServiceManager.getService(DefaultASTFactory.class);
|
||||
|
||||
private static final CharTable WHITESPACES = new CharTableImpl();
|
||||
|
||||
// interface methods
|
||||
@@ -67,7 +65,7 @@ public abstract class ASTFactory {
|
||||
}
|
||||
|
||||
final LazyParseableElement customLazy = factory(type).createLazy(type, text);
|
||||
return customLazy != null ? customLazy : DEFAULT.createLazy(type, text);
|
||||
return customLazy != null ? customLazy : DefaultFactoryHolder.DEFAULT.createLazy(type, text);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@@ -77,7 +75,7 @@ public abstract class ASTFactory {
|
||||
}
|
||||
|
||||
final CompositeElement customComposite = factory(type).createComposite(type);
|
||||
return customComposite != null ? customComposite : DEFAULT.createComposite(type);
|
||||
return customComposite != null ? customComposite : DefaultFactoryHolder.DEFAULT.createComposite(type);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@@ -91,7 +89,7 @@ public abstract class ASTFactory {
|
||||
}
|
||||
|
||||
final LeafElement customLeaf = factory(type).createLeaf(type, text);
|
||||
return customLeaf != null ? customLeaf : DEFAULT.createLeaf(type, text);
|
||||
return customLeaf != null ? customLeaf : DefaultFactoryHolder.DEFAULT.createLeaf(type, text);
|
||||
}
|
||||
|
||||
private static ASTFactory factory(final IElementType type) {
|
||||
@@ -104,4 +102,15 @@ public abstract class ASTFactory {
|
||||
CodeEditUtil.setNodeGenerated(w, true);
|
||||
return w;
|
||||
}
|
||||
|
||||
public static class DefaultFactoryHolder {
|
||||
public static final ASTFactory DEFAULT = def();
|
||||
|
||||
private static ASTFactory def() {
|
||||
return (ASTFactory)ServiceManager.getService(DefaultASTFactory.class);
|
||||
}
|
||||
|
||||
private DefaultFactoryHolder() {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,6 +23,6 @@ public class LanguageASTFactory extends LanguageExtension<ASTFactory> {
|
||||
public static final LanguageASTFactory INSTANCE = new LanguageASTFactory();
|
||||
|
||||
private LanguageASTFactory() {
|
||||
super("com.intellij.lang.ast.factory", ASTFactory.DEFAULT);
|
||||
super("com.intellij.lang.ast.factory", ASTFactory.DefaultFactoryHolder.DEFAULT);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -97,6 +97,7 @@ public abstract class ParsingTestCase extends PlatformLiteFixture {
|
||||
myLanguage = myLanguage == null && myDefinitions != null && myDefinitions.length > 0? myDefinitions[0].getFileNodeType().getLanguage() : myLanguage;
|
||||
registerComponentInstance(appContainer, FileTypeManager.class, new MockFileTypeManager(new MockLanguageFileType(myLanguage, myFileExt)));
|
||||
registerApplicationService(PsiBuilderFactory.class, new PsiBuilderFactoryImpl());
|
||||
registerApplicationService(DefaultASTFactory.class, new DefaultASTFactoryImpl());
|
||||
myProject.registerService(CachedValuesManager.class, new CachedValuesManagerImpl(myProject, new PsiCachedValuesFactory(myPsiManager)));
|
||||
myProject.registerService(PsiManager.class, myPsiManager);
|
||||
myProject.registerService(StartupManager.class, new StartupManagerImpl(myProject));
|
||||
|
||||
Reference in New Issue
Block a user