From 30513462b4f6b284f44ccd1d616712658914f3c8 Mon Sep 17 00:00:00 2001 From: Shruti Sinha Date: Thu, 26 Sep 2024 14:10:43 -0700 Subject: [PATCH] fix plugin checkstyle issues --- .../amazonq/lsp/manager/DefaultLspManager.java | 2 +- .../amazonq/views/AmazonQChatWebview.java | 18 +++++++++--------- .../eclipse/amazonq/views/AmazonQView.java | 9 ++++----- .../amazonq/views/ToolkitLoginWebview.java | 12 ++++++------ 4 files changed, 20 insertions(+), 21 deletions(-) diff --git a/plugin/src/software/aws/toolkits/eclipse/amazonq/lsp/manager/DefaultLspManager.java b/plugin/src/software/aws/toolkits/eclipse/amazonq/lsp/manager/DefaultLspManager.java index e9da557b..fc381ac5 100644 --- a/plugin/src/software/aws/toolkits/eclipse/amazonq/lsp/manager/DefaultLspManager.java +++ b/plugin/src/software/aws/toolkits/eclipse/amazonq/lsp/manager/DefaultLspManager.java @@ -60,7 +60,7 @@ public LspInstallation getLspInstallation() { } } - private static void makeExecutable(final Path filePath, PluginPlatform platform) throws IOException { + private static void makeExecutable(final Path filePath, final PluginPlatform platform) throws IOException { // don't set file permissions for windows as it has issues using the executable // otherwise if (platform == PluginPlatform.WINDOWS) { diff --git a/plugin/src/software/aws/toolkits/eclipse/amazonq/views/AmazonQChatWebview.java b/plugin/src/software/aws/toolkits/eclipse/amazonq/views/AmazonQChatWebview.java index 69561b33..775311c2 100644 --- a/plugin/src/software/aws/toolkits/eclipse/amazonq/views/AmazonQChatWebview.java +++ b/plugin/src/software/aws/toolkits/eclipse/amazonq/views/AmazonQChatWebview.java @@ -57,16 +57,16 @@ public Object function(final Object[] arguments) { } private String getContent() { - String jsFile = PluginUtils.getAwsDirectory(LspConstants.LSP_SUBDIRECTORY).resolve("amazonq-ui.js").toString(); + String jsFile = PluginUtils.getAwsDirectory(LspConstants.LSP_SUBDIRECTORY).resolve("amazonq-ui.js").toString(); var jsParent = Path.of(jsFile).getParent(); var jsDirectoryPath = Path.of(jsParent.toUri()).normalize().toString(); - + server = setupVirtualServer(jsDirectoryPath); if (server == null) { - return "Failed to load JS"; + return "Failed to load JS"; } - - var chatJsPath = server.getURI().toString()+"amazonq-ui.js"; + + var chatJsPath = server.getURI().toString() + "amazonq-ui.js"; return String.format("\n" + "\n" + "\n" @@ -74,7 +74,8 @@ private String getContent() { + " \n" + " " + " Chat UI\n" + " %s\n" @@ -129,11 +130,10 @@ protected final void handleAuthStatusChange(final boolean isLoggedIn) { } }); } - + @Override - public void dispose() { + public final void dispose() { stopVirtualServer(server); super.dispose(); } - } diff --git a/plugin/src/software/aws/toolkits/eclipse/amazonq/views/AmazonQView.java b/plugin/src/software/aws/toolkits/eclipse/amazonq/views/AmazonQView.java index c5048cec..9b82ead0 100644 --- a/plugin/src/software/aws/toolkits/eclipse/amazonq/views/AmazonQView.java +++ b/plugin/src/software/aws/toolkits/eclipse/amazonq/views/AmazonQView.java @@ -111,18 +111,17 @@ private void setupAuthStatusListeners() { } /** - * Sets up virtual host mapping for the given path using jetty server - * + * Sets up virtual host mapping for the given path using Jetty server. * @param jsPath * @return server launched */ - protected Server setupVirtualServer(String jsPath) { + protected Server setupVirtualServer(final String jsPath) { Server server = null; try { server = new Server(0); var servletContext = new ContextHandler(); servletContext.setContextPath("/"); - servletContext.addVirtualHosts(new String[] { "localhost" }); + servletContext.addVirtualHosts(new String[] {"localhost"}); var handler = new ResourceHandler(); @@ -143,7 +142,7 @@ protected Server setupVirtualServer(String jsPath) { } } - protected void stopVirtualServer(Server server) { + protected final void stopVirtualServer(final Server server) { if (server != null) { try { server.stop(); diff --git a/plugin/src/software/aws/toolkits/eclipse/amazonq/views/ToolkitLoginWebview.java b/plugin/src/software/aws/toolkits/eclipse/amazonq/views/ToolkitLoginWebview.java index c8f3ed34..087fbf50 100644 --- a/plugin/src/software/aws/toolkits/eclipse/amazonq/views/ToolkitLoginWebview.java +++ b/plugin/src/software/aws/toolkits/eclipse/amazonq/views/ToolkitLoginWebview.java @@ -57,7 +57,7 @@ protected void handleAuthStatusChange(final boolean isLoggedIn) { Display.getDefault().asyncExec(() -> { amazonQCommonActions.updateActionVisibility(isLoggedIn, getViewSite()); if (!isLoggedIn) { - browser.setText(getContent()); + browser.setText(getContent()); } else { browser.setText("Signed in"); AmazonQView.showView(AmazonQChatWebview.ID); @@ -70,13 +70,13 @@ private String getContent() { URL jsFile = PluginUtils.getResource("webview/build/assets/js/getStart.js"); var jsParent = Path.of(jsFile.toURI()).getParent(); var jsDirectoryPath = Path.of(jsParent.toUri()).normalize().toString(); - + server = setupVirtualServer(jsDirectoryPath); if (server == null) { - return "Failed to load JS"; + return "Failed to load JS"; } - var loginJsPath = server.getURI().toString()+"getStart.js"; - + var loginJsPath = server.getURI().toString() + "getStart.js"; + return String.format("\n" + "\n" + " \n" @@ -101,7 +101,7 @@ private String getContent() { return "Failed to load JS"; } } - + @Override public void dispose() { stopVirtualServer(server);