void (Document oldDocument, Project project, @Messages.YesNoResult int exitCode, @NlsContexts.Command String commandName) { PsiFile file = PsiDocumentManager.getInstance(project).getPsiFile(oldDocument); if (file != null) { VirtualFile virtualFile = file.getVirtualFile(); if (virtualFile instanceof VirtualFileWindow) { virtualFile = ((VirtualFileWindow)virtualFile).getDelegate(); } if (virtualFile != null) { FileEditor[] editors = FileEditorManager.getInstance(project).getEditors(virtualFile); for (FileEditor editor : editors) { if (editor instanceof TextEditor) { Editor textEditor = ((TextEditor)editor).getEditor(); TemplateState templateState = TemplateManagerImpl.getTemplateState(textEditor); if (templateState != null) { if (exitCode == Messages.YES) { TextRange range = templateState.getVariableRange(PRIMARY_VARIABLE_NAME); if (range != null) { PsiNavigationSupport.getInstance().createNavigatable(project, virtualFile, range.getStartOffset()) .navigate(true); return; } } else if (exitCode > 0){ stopIntroduce(textEditor, project, commandName); return; } } } } } } }