IDEA-112134 $SELECTION$ variable doesn't work as true variable, but as $END$

This commit is contained in:
Alexander Zolotov
2013-10-11 20:34:02 +04:00
parent cac9208ff7
commit 131353bd38
2 changed files with 9 additions and 15 deletions
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2010 JetBrains s.r.o.
* Copyright 2000-2013 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -50,10 +50,6 @@ public class LiveTemplateBuilder {
return name.startsWith(END_PREFIX);
}
public void insertVariableSegment(int offset, String name) {
myVariableOccurences.add(new VarOccurence(name, offset));
}
private static class VarOccurence {
String myName;
int myOffset;
@@ -262,7 +258,10 @@ public class LiveTemplateBuilder {
for (int i = 0; i < template.getSegmentsCount(); i++) {
String segmentName = template.getSegmentName(i);
int localOffset = template.getSegmentOffset(i);
if (!TemplateImpl.INTERNAL_VARS_SET.contains(segmentName)) {
if (TemplateImpl.END.equals(segmentName)) {
end = offset + localOffset;
}
else {
if (predefinedVarValues != null && predefinedVarValues.containsKey(segmentName)) {
String value = predefinedVarValues.get(segmentName);
insertText(offset + localOffset, value, false);
@@ -274,9 +273,6 @@ public class LiveTemplateBuilder {
}
myVariableOccurences.add(new VarOccurence(segmentName, offset + localOffset));
}
else if (TemplateImpl.END.equals(segmentName)) {
end = offset + localOffset;
}
}
int endOffset = end >= 0 ? end : offset + text.length();
if (endOffset > 0 &&
@@ -248,9 +248,7 @@ public class ZenCodingTemplate implements CustomLiveTemplate {
});
}
public void wrap(final String selection,
@NotNull final CustomTemplateCallback callback
) {
public void wrap(final String selection, @NotNull final CustomTemplateCallback callback) {
InputValidatorEx validator = new InputValidatorEx() {
public String getErrorText(String inputString) {
if (!checkTemplateKey(inputString, callback)) {
@@ -267,9 +265,9 @@ public class ZenCodingTemplate implements CustomLiveTemplate {
return checkInput(inputString);
}
};
final String abbreviation = Messages
.showInputDialog(callback.getProject(), XmlBundle.message("zen.coding.enter.abbreviation.dialog.label"),
XmlBundle.message("zen.coding.title"), Messages.getQuestionIcon(), "", validator);
final String abbreviation = Messages.showInputDialog(callback.getProject(),
XmlBundle.message("zen.coding.enter.abbreviation.dialog.label"),
XmlBundle.message("zen.coding.title"), Messages.getQuestionIcon(), "", validator);
if (abbreviation != null) {
doWrap(selection, abbreviation, callback);
}