in plugin/src/software/aws/toolkits/eclipse/amazonq/inlineChat/InlineChatSession.java [96:143]
public boolean startSession(final ITextEditor editor) {
if (isSessionActive()) {
return false;
}
if (editor == null || !(editor instanceof ITextEditor)) {
return false;
}
try {
InlineChatEditorListener.getInstance().closePrompt();
this.document = editor.getDocumentProvider().getDocument(editor.getEditorInput());
if (this.document == null) {
return false;
}
setState(SessionState.ACTIVE);
// Get the context service and activate inline chat context used for button
contextActivation = contextService.activateContext(Constants.INLINE_CHAT_CONTEXT_ID);
workbenchPage = editor.getSite().getPage();
workbenchPage.addPartListener(this);
// Set up undoManager to batch document edits together
this.undoManager = DocumentUndoManagerRegistry.getDocumentUndoManager(this.document);
initUndoManager(this.document);
Display.getDefault().asyncExec(() -> {
projectionModel = attachFoldingListener(editor);
});
// Check if user has code references enabled
var currentLoginType = Activator.getLoginService().getAuthState().loginType();
this.referencesEnabled = Activator.getDefault().getPreferenceStore().getBoolean(AmazonQPreferencePage.CODE_REFERENCE_OPT_IN)
&& currentLoginType.equals(LoginType.BUILDER_ID);
createInlineChatTask(editor);
var isDarkTheme = themeDetector.isDarkTheme();
// Set up necessary managers with the context they need
this.uiManager.initNewTask(task, isDarkTheme);
this.diffManager.initNewTask(task, isDarkTheme);
CompletableFuture.runAsync(() -> start());
return true;
} catch (Exception e) {
uiManager.showErrorNotification();
endSession();
return false;
}
}