diff --git a/platform/lang-impl/src/com/intellij/lang/ASTFactory.java b/platform/lang-impl/src/com/intellij/lang/ASTFactory.java
index e9ce34b542a0..f22d3612a96e 100644
--- a/platform/lang-impl/src/com/intellij/lang/ASTFactory.java
+++ b/platform/lang-impl/src/com/intellij/lang/ASTFactory.java
@@ -15,6 +15,7 @@
*/
package com.intellij.lang;
+import com.intellij.openapi.components.ServiceManager;
import com.intellij.psi.TokenType;
import com.intellij.psi.impl.source.CharTableImpl;
import com.intellij.psi.impl.source.CodeFragmentElement;
@@ -30,7 +31,7 @@ import org.jetbrains.annotations.Nullable;
* @author max
*/
public abstract class ASTFactory {
- public static final DefaultFactory DEFAULT = new DefaultFactory();
+ public static final ASTFactory DEFAULT = (ASTFactory) ServiceManager.getService(DefaultASTFactory.class);
private static final CharTable WHITESPACES = new CharTableImpl();
@@ -103,42 +104,4 @@ public abstract class ASTFactory {
CodeEditUtil.setNodeGenerated(w, true);
return w;
}
-
- // default implementation
-
- private static class DefaultFactory extends ASTFactory {
- @Override
- @NotNull
- public LazyParseableElement createLazy(final ILazyParseableElementType type, final CharSequence text) {
- if (type instanceof IFileElementType) {
- return new FileElement(type, text);
- }
-
- return new LazyParseableElement(type, text);
- }
-
- @Override
- @NotNull
- public CompositeElement createComposite(final IElementType type) {
- if (type instanceof IFileElementType) {
- return new FileElement(type, null);
- }
-
- return new CompositeElement(type);
- }
-
- @Override
- @NotNull
- public LeafElement createLeaf(final IElementType type, final CharSequence text) {
- final Language lang = type.getLanguage();
- final ParserDefinition parserDefinition = LanguageParserDefinitions.INSTANCE.forLanguage(lang);
- if (parserDefinition != null) {
- if (parserDefinition.getCommentTokens().contains(type)) {
- return new PsiCommentImpl(type, text);
- }
- }
-
- return new LeafPsiElement(type, text);
- }
- }
}
diff --git a/platform/lang-impl/src/com/intellij/lang/DefaultASTFactory.java b/platform/lang-impl/src/com/intellij/lang/DefaultASTFactory.java
new file mode 100644
index 000000000000..5ebf75ce2bdd
--- /dev/null
+++ b/platform/lang-impl/src/com/intellij/lang/DefaultASTFactory.java
@@ -0,0 +1,24 @@
+/*
+ * Copyright 2000-2011 JetBrains s.r.o.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.intellij.lang;
+
+/**
+ * Marker interface for retrieving the service which provides a default implementation of ASTFactory.
+ *
+ * @author yole
+ */
+public interface DefaultASTFactory {
+}
diff --git a/platform/lang-impl/src/com/intellij/lang/DefaultASTFactoryImpl.java b/platform/lang-impl/src/com/intellij/lang/DefaultASTFactoryImpl.java
new file mode 100644
index 000000000000..0dca57b12d7c
--- /dev/null
+++ b/platform/lang-impl/src/com/intellij/lang/DefaultASTFactoryImpl.java
@@ -0,0 +1,58 @@
+/*
+ * Copyright 2000-2011 JetBrains s.r.o.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.intellij.lang;
+
+import com.intellij.psi.impl.source.tree.*;
+import com.intellij.psi.tree.IElementType;
+import com.intellij.psi.tree.IFileElementType;
+import com.intellij.psi.tree.ILazyParseableElementType;
+import org.jetbrains.annotations.NotNull;
+
+public class DefaultASTFactoryImpl extends ASTFactory implements DefaultASTFactory {
+ @Override
+ @NotNull
+ public LazyParseableElement createLazy(final ILazyParseableElementType type, final CharSequence text) {
+ if (type instanceof IFileElementType) {
+ return new FileElement(type, text);
+ }
+
+ return new LazyParseableElement(type, text);
+ }
+
+ @Override
+ @NotNull
+ public CompositeElement createComposite(final IElementType type) {
+ if (type instanceof IFileElementType) {
+ return new FileElement(type, null);
+ }
+
+ return new CompositeElement(type);
+ }
+
+ @Override
+ @NotNull
+ public LeafElement createLeaf(final IElementType type, final CharSequence text) {
+ final Language lang = type.getLanguage();
+ final ParserDefinition parserDefinition = LanguageParserDefinitions.INSTANCE.forLanguage(lang);
+ if (parserDefinition != null) {
+ if (parserDefinition.getCommentTokens().contains(type)) {
+ return new PsiCommentImpl(type, text);
+ }
+ }
+
+ return new LeafPsiElement(type, text);
+ }
+}
diff --git a/platform/platform-resources/src/META-INF/LangExtensions.xml b/platform/platform-resources/src/META-INF/LangExtensions.xml
index cae0f842f0aa..e572924f71fb 100644
--- a/platform/platform-resources/src/META-INF/LangExtensions.xml
+++ b/platform/platform-resources/src/META-INF/LangExtensions.xml
@@ -156,6 +156,9 @@
+
+