summaryrefslogtreecommitdiff
path: root/java/java-impl/src/com/intellij/codeInsight/template/postfix/templates/ForIndexedPostfixTemplate.java
diff options
context:
space:
mode:
Diffstat (limited to 'java/java-impl/src/com/intellij/codeInsight/template/postfix/templates/ForIndexedPostfixTemplate.java')
-rw-r--r--java/java-impl/src/com/intellij/codeInsight/template/postfix/templates/ForIndexedPostfixTemplate.java27
1 files changed, 15 insertions, 12 deletions
diff --git a/java/java-impl/src/com/intellij/codeInsight/template/postfix/templates/ForIndexedPostfixTemplate.java b/java/java-impl/src/com/intellij/codeInsight/template/postfix/templates/ForIndexedPostfixTemplate.java
index 38ea87df927f..922a8bbfec30 100644
--- a/java/java-impl/src/com/intellij/codeInsight/template/postfix/templates/ForIndexedPostfixTemplate.java
+++ b/java/java-impl/src/com/intellij/codeInsight/template/postfix/templates/ForIndexedPostfixTemplate.java
@@ -43,22 +43,20 @@ public abstract class ForIndexedPostfixTemplate extends StringBasedPostfixTempla
}
@Override
- public void expandWithTemplateManager(TemplateManager manager, PsiElement expression, Editor editor) {
- PsiExpression expr = (PsiExpression)expression;
+ public void setVariables(@NotNull Template template, @NotNull PsiElement element) {
+ MacroCallNode index = new MacroCallNode(new SuggestVariableNameMacro());
+ template.addVariable("index", index, index, true);
+ }
+
+ @Override
+ public final String getTemplateString(@NotNull PsiElement element) {
+ PsiExpression expr = (PsiExpression)element;
String bound = getExpressionBound(expr);
if (bound == null) {
- PostfixTemplatesUtils.showErrorHint(expr.getProject(), editor);
- return;
+ return null;
}
- String templateWithMacro = getStringTemplate(expr).replace("$bound$", bound).replace("$type$", suggestIndexType(expr));
-
- Template template = manager.createTemplate("", "", templateWithMacro);
-
- template.setToReformat(true);
- MacroCallNode index = new MacroCallNode(new SuggestVariableNameMacro());
- template.addVariable("index", index, index, true);
- manager.startTemplate(editor, template);
+ return getStringTemplate(expr).replace("$bound$", bound).replace("$type$", suggestIndexType(expr));
}
@NotNull
@@ -87,4 +85,9 @@ public abstract class ForIndexedPostfixTemplate extends StringBasedPostfixTempla
}
return "int";
}
+
+ @Override
+ protected boolean shouldAddExpressionToContext() {
+ return false;
+ }
} \ No newline at end of file