mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
fix invalid .getProject() calls which crashed after "disable 'theOnlyProject' optimization after default project initialization"
This commit is contained in:
@@ -99,7 +99,16 @@ public class PsiTypeLookupItem extends LookupItem implements TypedLookupItem {
|
||||
|
||||
@Override
|
||||
public void handleInsert(@NotNull InsertionContext context) {
|
||||
SmartPsiElementPointer<PsiElement> pointer = null;
|
||||
if (getObject() instanceof PsiElement) {
|
||||
PsiElement psiElement = (PsiElement)getObject();
|
||||
pointer = SmartPointerManager.getInstance(context.getProject()).createSmartPsiElementPointer(psiElement);
|
||||
}
|
||||
myImportFixer.handleInsert(context, this);
|
||||
// restore PSI element tucked in this.myObject and possibly made invalid by import fixer
|
||||
if (pointer != null) {
|
||||
setObject(pointer.getElement());
|
||||
}
|
||||
|
||||
PsiElement position = context.getFile().findElementAt(context.getStartOffset());
|
||||
if (position != null) {
|
||||
|
||||
@@ -6,7 +6,6 @@ import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.openapi.ui.Messages;
|
||||
import com.intellij.openapi.util.Comparing;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.codeStyle.JavaCodeStyleManager;
|
||||
@@ -164,7 +163,6 @@ public class LambdaRefactoringUtil {
|
||||
final PsiElement resolveElement = resolveResult.getElement();
|
||||
|
||||
if (resolveElement instanceof PsiMember) {
|
||||
final PsiElementFactory elementFactory = JavaPsiFacade.getElementFactory(referenceExpression.getProject());
|
||||
buf.append("{");
|
||||
|
||||
if (!PsiType.VOID.equals(interfaceMethod.getReturnType())) {
|
||||
@@ -258,10 +256,7 @@ public class LambdaRefactoringUtil {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
if (qualifier instanceof PsiThisExpression && ((PsiThisExpression)qualifier).getQualifier() == null) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
return qualifier instanceof PsiThisExpression && ((PsiThisExpression)qualifier).getQualifier() == null;
|
||||
}
|
||||
|
||||
private static boolean isInferredSameTypeAfterConversion(PsiLambdaExpression lambdaExpression,
|
||||
@@ -276,9 +271,18 @@ public class LambdaRefactoringUtil {
|
||||
if (copyTopLevelCall != null) {
|
||||
PsiMethodReferenceExpression methodReferenceInCopy = (PsiMethodReferenceExpression)PsiTreeUtil.releaseMark(copyTopLevelCall, marker);
|
||||
if (methodReferenceInCopy != null) {
|
||||
PsiType functionalInterfaceType = methodReferenceInCopy.getFunctionalInterfaceType();
|
||||
PsiClassType functionalInterfaceType = (PsiClassType)methodReferenceInCopy.getFunctionalInterfaceType();
|
||||
PsiClassType.ClassResolveResult funcResult = functionalInterfaceType.resolveGenerics();
|
||||
PsiClass funcClass = funcResult.getElement();
|
||||
PsiSubstitutor funcSubstitutor = funcResult.getSubstitutor();
|
||||
PsiLambdaExpression lambdaCopy = (PsiLambdaExpression)methodReferenceInCopy.replace(lambdaExpression);
|
||||
return Comparing.equal(functionalInterfaceType, lambdaCopy.getFunctionalInterfaceType());
|
||||
|
||||
PsiClassType lambdaCopyType = (PsiClassType)lambdaCopy.getFunctionalInterfaceType();
|
||||
PsiClassType.ClassResolveResult lambdaCopyResult = lambdaCopyType.resolveGenerics();
|
||||
PsiClass lambdaCopyClass = lambdaCopyResult.getElement();
|
||||
PsiSubstitutor lambdaCopySubstitutor = lambdaCopyResult.getSubstitutor();
|
||||
return lambdaExpression.getManager().areElementsEquivalent(funcClass, lambdaCopyClass)
|
||||
&& funcSubstitutor.equals(lambdaCopySubstitutor);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
|
||||
Reference in New Issue
Block a user