-
- if (shortcutChar == templateSettings.getDefaultShortcutChar()) {
- for (final CustomLiveTemplate customLiveTemplate : CustomLiveTemplate.EP_NAME.getExtensions()) {
- int caretOffset = editor.getCaretModel().getOffset();
- if (customLiveTemplate.isApplicable(file, caretOffset, false)) {
- final CustomTemplateCallback callback = new CustomTemplateCallback(editor, file);
- String key = customLiveTemplate.computeTemplateKey(callback);
- if (key != null) {
- int offsetBeforeKey = caretOffset - key.length();
- CharSequence text = editor.getDocument().getCharsSequence();
- if (template2argument == null || !containsTemplateStartingBefore(template2argument, offsetBeforeKey, caretOffset, text)) {
- callback.getEditor().getDocument().deleteString(offsetBeforeKey, caretOffset);
- callback.fixInitialState();
- customLiveTemplate.expand(key, callback, new TemplateInvokationListener() {
- public void finished(boolean inSeparateEvent) {
- callback.finish();
- }
- });
- return true;
- }
- }
- }
- }
- }