mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
assert GenerationInfo#getPsiMember must be not-null (IDEA-CR-16709)
This commit is contained in:
@@ -30,16 +30,12 @@ import org.jetbrains.annotations.Nullable;
|
||||
public abstract class GenerationInfoBase implements GenerationInfo {
|
||||
|
||||
@Override
|
||||
public abstract void insert(PsiClass aClass, PsiElement anchor, boolean before) throws IncorrectOperationException;
|
||||
public abstract void insert(@NotNull PsiClass aClass, PsiElement anchor, boolean before) throws IncorrectOperationException;
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public abstract PsiMember getPsiMember();
|
||||
|
||||
/**
|
||||
* @param aClass
|
||||
* @param leaf leaf element. Is guaranteed to be a tree descendant of aClass.
|
||||
* @return the value that will be passed to the {@link #insert(com.intellij.psi.PsiClass, com.intellij.psi.PsiElement, boolean)} method later.
|
||||
*/
|
||||
@Override
|
||||
@Nullable
|
||||
public PsiElement findInsertionAnchor(@NotNull PsiClass aClass, @NotNull PsiElement leaf) {
|
||||
@@ -64,7 +60,7 @@ public abstract class GenerationInfoBase implements GenerationInfo {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void positionCaret(Editor editor, boolean toEditMethodBody) {
|
||||
public void positionCaret(@NotNull Editor editor, boolean toEditMethodBody) {
|
||||
GenerateMembersUtil.positionCaret(editor, getPsiMember(), toEditMethodBody);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,6 +19,7 @@ import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.codeStyle.JavaCodeStyleManager;
|
||||
import com.intellij.util.IncorrectOperationException;
|
||||
import com.intellij.util.ObjectUtils;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@@ -43,9 +44,10 @@ public class PsiGenerationInfo<T extends PsiMember> extends GenerationInfoBase i
|
||||
myMember = SmartPointerManager.getInstance(member.getProject()).createSmartPsiElementPointer(member);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public final T getPsiMember() {
|
||||
return myMember.getElement();
|
||||
return ObjectUtils.assertNotNull(myMember.getElement());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -20,6 +20,8 @@ import com.intellij.codeInsight.template.Template;
|
||||
import com.intellij.codeInsight.template.TemplateBuilderImpl;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.util.IncorrectOperationException;
|
||||
import com.intellij.util.ObjectUtils;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public abstract class TemplateGenerationInfo extends GenerationInfoBase implements GenerationInfo {
|
||||
private final Expression myExpression;
|
||||
@@ -36,14 +38,15 @@ public abstract class TemplateGenerationInfo extends GenerationInfoBase implemen
|
||||
|
||||
protected abstract PsiElement getTemplateElement(PsiMethod method);
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public PsiMethod getPsiMember() {
|
||||
return myElement.getElement();
|
||||
return ObjectUtils.assertNotNull(myElement.getElement());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void insert(PsiClass aClass, PsiElement anchor, boolean before) throws IncorrectOperationException {
|
||||
setElement((PsiMethod)GenerateMembersUtil.insert(aClass, myElement.getElement(), anchor, before));
|
||||
public void insert(@NotNull PsiClass aClass, PsiElement anchor, boolean before) throws IncorrectOperationException {
|
||||
setElement((PsiMethod)GenerateMembersUtil.insert(aClass, getPsiMember(), anchor, before));
|
||||
}
|
||||
|
||||
public Template getTemplate() {
|
||||
|
||||
@@ -29,14 +29,14 @@ import org.jetbrains.annotations.Nullable;
|
||||
public interface GenerationInfo {
|
||||
GenerationInfo[] EMPTY_ARRAY = new GenerationInfo[0];
|
||||
|
||||
void insert(PsiClass aClass, PsiElement anchor, boolean before) throws IncorrectOperationException;
|
||||
void insert(@NotNull PsiClass aClass, @Nullable PsiElement anchor, boolean before) throws IncorrectOperationException;
|
||||
|
||||
@NotNull
|
||||
PsiMember getPsiMember();
|
||||
|
||||
/**
|
||||
* @param aClass
|
||||
* @param leaf leaf element. Is guaranteed to be a tree descendant of aClass.
|
||||
* @return the value that will be passed to the {@link #insert(com.intellij.psi.PsiClass, com.intellij.psi.PsiElement, boolean)} method later.
|
||||
* @return the value that will be passed to the {@link #insert(PsiClass, PsiElement, boolean)} method later.
|
||||
*/
|
||||
@Nullable
|
||||
PsiElement findInsertionAnchor(@NotNull PsiClass aClass, @NotNull PsiElement leaf);
|
||||
@@ -44,5 +44,5 @@ public interface GenerationInfo {
|
||||
/**
|
||||
* Position caret in generated element in correct way
|
||||
*/
|
||||
void positionCaret(Editor editor, boolean toEditMethodBody);
|
||||
void positionCaret(@NotNull Editor editor, boolean toEditMethodBody);
|
||||
}
|
||||
+1
-1
@@ -136,7 +136,7 @@ public class GroovyGenerationInfo<T extends PsiMember> extends PsiGenerationInfo
|
||||
}
|
||||
|
||||
@Override
|
||||
public void positionCaret(Editor editor, boolean toEditMethodBody) {
|
||||
public void positionCaret(@NotNull Editor editor, boolean toEditMethodBody) {
|
||||
final T firstMember = getPsiMember();
|
||||
LOG.assertTrue(firstMember.isValid());
|
||||
|
||||
|
||||
Reference in New Issue
Block a user