additional api
authorEugene Kudelevsky <Eugene.Kudelevsky@jetbrains.com>
Sat, 13 Feb 2010 15:04:55 +0000 (13 18:04 +0300)
committerEugene Kudelevsky <Eugene.Kudelevsky@jetbrains.com>
Sat, 13 Feb 2010 15:04:55 +0000 (13 18:04 +0300)
platform/lang-impl/src/com/intellij/codeInsight/template/CustomTemplateCallback.java

index 21d30a1..2b70ac7 100644 (file)
@@ -146,12 +146,24 @@ public class CustomTemplateCallback {
   }
 
   public void gotoEndOfTemplate(@NotNull Object key) {
+    myEditor.getCaretModel().moveToOffset(getEndOfTemplate(key));
+  }
+
+  public int getEndOfTemplate(@NotNull Object key) {
     MyCheckpoint checkpoint = myCheckpoints.get(key);
     if (checkpoint == null) {
       throw new IllegalArgumentException();
     }
     int length = myEditor.getDocument().getTextLength();
-    myEditor.getCaretModel().moveToOffset(checkpoint.myFixedOffset + length - checkpoint.myFixedLength);
+    return checkpoint.myFixedOffset + length - checkpoint.myFixedLength;
+  }
+
+  public int getStartOfTemplate(@NotNull Object key) {
+    MyCheckpoint checkpoint = myCheckpoints.get(key);
+    if (checkpoint == null) {
+      throw new IllegalArgumentException();
+    }
+    return checkpoint.myFixedOffset;
   }
 
   private static List<TemplateImpl> getMatchingTemplates(@NotNull String templateKey) {
@@ -164,6 +176,10 @@ public class CustomTemplateCallback {
     return myEditor;
   }
 
+  public int getOffset() {
+    return myEditor.getCaretModel().getOffset();
+  }
+
   public PsiFile getFile() {
     return myFile;
   }