code review

This commit is contained in:
Dmitry Jemerov
2015-01-20 16:43:28 +01:00
parent 100b8c2c4d
commit 31f5441f6b
@@ -18,18 +18,19 @@ package org.jetbrains.kotlin.kdoc.parser;
import com.intellij.lang.ASTNode;
import com.intellij.psi.tree.IElementType;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.kotlin.idea.JetLanguage;
import org.jetbrains.kotlin.kdoc.psi.impl.KDocElementImpl;
import java.lang.reflect.Constructor;
public class KDocElementType extends IElementType {
private final Constructor<? extends KDocElementImpl> myPsiFactory;
private final Constructor<? extends KDocElementImpl> psiFactory;
public KDocElementType(String debugName, Class<? extends KDocElementImpl> psiClass) {
public KDocElementType(String debugName, @NotNull Class<? extends KDocElementImpl> psiClass) {
super(debugName, JetLanguage.INSTANCE);
try {
myPsiFactory = psiClass != null ? psiClass.getConstructor(ASTNode.class) : null;
psiFactory = psiClass != null ? psiClass.getConstructor(ASTNode.class) : null;
} catch (NoSuchMethodException e) {
throw new RuntimeException("Must have a constructor with ASTNode");
}
@@ -39,7 +40,7 @@ public class KDocElementType extends IElementType {
assert node.getElementType() == this;
try {
return myPsiFactory.newInstance(node);
return psiFactory.newInstance(node);
} catch (Exception e) {
throw new RuntimeException("Error creating psi element for node", e);
}