From 131353bd3873484e0481cc22c19563baa54919be Mon Sep 17 00:00:00 2001 From: Alexander Zolotov Date: Fri, 11 Oct 2013 20:30:16 +0400 Subject: [PATCH] IDEA-112134 $SELECTION$ variable doesn't work as true variable, but as $END$ --- .../codeInsight/template/LiveTemplateBuilder.java | 14 +++++--------- .../template/emmet/ZenCodingTemplate.java | 10 ++++------ 2 files changed, 9 insertions(+), 15 deletions(-) diff --git a/platform/lang-impl/src/com/intellij/codeInsight/template/LiveTemplateBuilder.java b/platform/lang-impl/src/com/intellij/codeInsight/template/LiveTemplateBuilder.java index b2756647a745..592b6915cd36 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/template/LiveTemplateBuilder.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/template/LiveTemplateBuilder.java @@ -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 && diff --git a/xml/impl/src/com/intellij/codeInsight/template/emmet/ZenCodingTemplate.java b/xml/impl/src/com/intellij/codeInsight/template/emmet/ZenCodingTemplate.java index f259f1741cf4..6fc27d723a62 100644 --- a/xml/impl/src/com/intellij/codeInsight/template/emmet/ZenCodingTemplate.java +++ b/xml/impl/src/com/intellij/codeInsight/template/emmet/ZenCodingTemplate.java @@ -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); }