code review
This commit is contained in:
@@ -18,18 +18,19 @@ package org.jetbrains.kotlin.kdoc.parser;
|
|||||||
|
|
||||||
import com.intellij.lang.ASTNode;
|
import com.intellij.lang.ASTNode;
|
||||||
import com.intellij.psi.tree.IElementType;
|
import com.intellij.psi.tree.IElementType;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.kotlin.idea.JetLanguage;
|
import org.jetbrains.kotlin.idea.JetLanguage;
|
||||||
import org.jetbrains.kotlin.kdoc.psi.impl.KDocElementImpl;
|
import org.jetbrains.kotlin.kdoc.psi.impl.KDocElementImpl;
|
||||||
|
|
||||||
import java.lang.reflect.Constructor;
|
import java.lang.reflect.Constructor;
|
||||||
|
|
||||||
public class KDocElementType extends IElementType {
|
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);
|
super(debugName, JetLanguage.INSTANCE);
|
||||||
try {
|
try {
|
||||||
myPsiFactory = psiClass != null ? psiClass.getConstructor(ASTNode.class) : null;
|
psiFactory = psiClass != null ? psiClass.getConstructor(ASTNode.class) : null;
|
||||||
} catch (NoSuchMethodException e) {
|
} catch (NoSuchMethodException e) {
|
||||||
throw new RuntimeException("Must have a constructor with ASTNode");
|
throw new RuntimeException("Must have a constructor with ASTNode");
|
||||||
}
|
}
|
||||||
@@ -39,7 +40,7 @@ public class KDocElementType extends IElementType {
|
|||||||
assert node.getElementType() == this;
|
assert node.getElementType() == this;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
return myPsiFactory.newInstance(node);
|
return psiFactory.newInstance(node);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
throw new RuntimeException("Error creating psi element for node", e);
|
throw new RuntimeException("Error creating psi element for node", e);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user