extract CoreASTFactory

This commit is contained in:
Dmitry Jemerov
2011-09-09 16:12:03 +02:00
parent 0b2fa67b59
commit 1b33b69efa
2 changed files with 60 additions and 25 deletions
@@ -0,0 +1,55 @@
/*
* 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.core;
import com.intellij.lang.ASTFactory;
import com.intellij.lang.DefaultASTFactory;
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;
/**
* @author yole
*/
public class CoreASTFactory 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(IElementType type, CharSequence text) {
return new LeafPsiElement(type, text);
}
}
@@ -15,33 +15,13 @@
*/
package com.intellij.lang;
import com.intellij.psi.impl.source.tree.*;
import com.intellij.core.CoreASTFactory;
import com.intellij.psi.impl.source.tree.LeafElement;
import com.intellij.psi.impl.source.tree.PsiCommentImpl;
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);
}
public class DefaultASTFactoryImpl extends CoreASTFactory implements DefaultASTFactory {
@Override
@NotNull
public LeafElement createLeaf(final IElementType type, final CharSequence text) {
@@ -53,6 +33,6 @@ public class DefaultASTFactoryImpl extends ASTFactory implements DefaultASTFacto
}
}
return new LeafPsiElement(type, text);
return super.createLeaf(type, text);
}
}