no need to commit documents in live template macros => no need to calculate their lookup items in EDT (IDEA-92139)

This commit is contained in:
peter
2012-10-01 18:50:17 +02:00
parent f318b5f344
commit 9e271e1887
13 changed files with 0 additions and 17 deletions
@@ -37,7 +37,6 @@ public class ArrayVariableMacro extends VariableTypeMacroBase {
Project project = context.getProject();
final int offset = context.getStartOffset();
PsiDocumentManager.getInstance(project).commitAllDocuments();
final ArrayList<PsiVariable> array = new ArrayList<PsiVariable>();
PsiFile file = PsiDocumentManager.getInstance(project).getPsiFile(context.getEditor().getDocument());
PsiElement place = file.findElementAt(offset);
@@ -43,7 +43,6 @@ public class CastToLeftSideTypeMacro extends Macro {
public Result calculateResult(@NotNull Expression[] params, ExpressionContext context) {
int offset = context.getStartOffset();
Project project = context.getProject();
PsiDocumentManager.getInstance(project).commitAllDocuments();
PsiFile file = PsiDocumentManager.getInstance(project).getPsiFile(context.getEditor().getDocument());
PsiElement element = file.findElementAt(offset);
element = PsiTreeUtil.getParentOfType(element, PsiAssignmentExpression.class, PsiVariable.class);
@@ -61,7 +61,6 @@ public class ComponentTypeOfMacro extends Macro {
final Result result = params[0].calculateResult(context);
if (result == null) return null;
PsiDocumentManager.getInstance(context.getProject()).commitAllDocuments();
if (result instanceof PsiTypeResult) {
PsiType type = ((PsiTypeResult) result).getType();
if (type instanceof PsiArrayType) {
@@ -44,7 +44,6 @@ class CurrentPackageMacro extends Macro {
Project project = context.getProject();
PsiFile file = PsiDocumentManager.getInstance(project).getPsiFile(context.getEditor().getDocument());
if (!(file instanceof PsiJavaFile)) return new TextResult ("");
PsiDocumentManager.getInstance(project).commitDocument(context.getEditor().getDocument());
return new TextResult (((PsiJavaFile)file).getPackageName());
}
@@ -69,7 +69,6 @@ public class ExpectedTypeMacro extends Macro {
if (params.length != 0) return null;
final Project project = context.getProject();
PsiDocumentManager.getInstance(project).commitAllDocuments();
PsiType[] types = null;
final int offset = context.getTemplateStartOffset();
@@ -23,7 +23,6 @@ import com.intellij.codeInsight.template.*;
import com.intellij.codeInsight.template.impl.JavaTemplateUtil;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.TextRange;
import com.intellij.psi.PsiDocumentManager;
import com.intellij.psi.PsiExpression;
import com.intellij.psi.PsiType;
import com.intellij.psi.PsiWildcardType;
@@ -70,7 +69,6 @@ public class GuessElementTypeMacro extends Macro {
if (result == null) return null;
Project project = context.getProject();
PsiDocumentManager.getInstance(project).commitAllDocuments();
PsiExpression expr = MacroUtil.resultToPsiExpression(result, context);
if (expr == null) return null;
@@ -45,7 +45,6 @@ public class IterableComponentTypeMacro extends Macro {
if (result == null) return null;
Project project = context.getProject();
PsiDocumentManager.getInstance(project).commitAllDocuments();
PsiExpression expr = MacroUtil.resultToPsiExpression(result, context);
if (expr == null) return null;
@@ -53,7 +53,6 @@ public class IterableVariableMacro extends VariableTypeMacroBase {
Project project = context.getProject();
final int offset = context.getStartOffset();
PsiDocumentManager.getInstance(project).commitAllDocuments();
PsiFile file = PsiDocumentManager.getInstance(project).getPsiFile(context.getEditor().getDocument());
assert file != null;
PsiElement place = file.findElementAt(offset);
@@ -44,7 +44,6 @@ public class MacroUtil {
String text = result.toString();
if (text == null) return null;
PsiManager manager = PsiManager.getInstance(project);
PsiDocumentManager.getInstance(project).commitAllDocuments();
PsiFile file = PsiDocumentManager.getInstance(project).getPsiFile(context.getEditor().getDocument());
//-1: Hack to deal with stupid resolve
PsiElement place = file != null ? file.findElementAt(context.getStartOffset()) : null;
@@ -72,7 +71,6 @@ public class MacroUtil {
String text = result.toString();
if (text == null) return null;
PsiManager manager = PsiManager.getInstance(project);
PsiDocumentManager.getInstance(project).commitAllDocuments();
PsiFile file = PsiDocumentManager.getInstance(project).getPsiFile(context.getEditor().getDocument());
//-1: Hack to deal with resolve algorithm
PsiElement place = file != null ? file.findElementAt(context.getStartOffset()) : null;
@@ -39,7 +39,6 @@ public class RightSideTypeMacro extends Macro {
public Result calculateResult(@NotNull Expression[] params, ExpressionContext context) {
int offset = context.getStartOffset();
Project project = context.getProject();
PsiDocumentManager.getInstance(project).commitAllDocuments();
PsiFile file = PsiDocumentManager.getInstance(project).getPsiFile(context.getEditor().getDocument());
PsiElement element = file.findElementAt(offset);
element = PsiTreeUtil.getParentOfType(element, PsiAssignmentExpression.class, PsiVariable.class);
@@ -42,8 +42,6 @@ public class SuggestIndexNameMacro extends Macro {
final Project project = context.getProject();
final int offset = context.getStartOffset();
PsiDocumentManager.getInstance(project).commitAllDocuments();
PsiFile file = PsiDocumentManager.getInstance(project).getPsiFile(context.getEditor().getDocument());
PsiElement place = file.findElementAt(offset);
PsiVariable[] vars = MacroUtil.getVariablesVisibleAt(place, "");
@@ -41,7 +41,6 @@ public class TypeOfVariableMacro extends Macro {
if (params.length == 0) return null;
final Project project = context.getProject();
PsiDocumentManager.getInstance(project).commitAllDocuments();
Result result = params[0].calculateQuickResult(context);
if (result instanceof PsiElementResult) {
final PsiElement element = ((PsiElementResult)result).getElement();
@@ -72,8 +72,6 @@ public class VariableOfTypeMacro extends Macro {
Project project = context.getProject();
final int offset = context.getStartOffset();
PsiDocumentManager.getInstance(project).commitAllDocuments();
final ArrayList<PsiElement> array = new ArrayList<PsiElement>();
PsiType type = MacroUtil.resultToPsiType(result, context);
PsiFile file = PsiDocumentManager.getInstance(project).getPsiFile(context.getEditor().getDocument());