From 6821976fb8066e1964d01807e7d0f3dfd155f55c Mon Sep 17 00:00:00 2001 From: Olivier Notteghem Date: Wed, 8 Apr 2020 21:42:18 -0700 Subject: [PATCH 01/14] - Disable search menu entry when no text is selected. - Fix handling of local branch - Move menu entries into sub-menu - Implement copy link functionality - Use Project storage API to load config from --- README.md | 8 ++++ resources/META-INF/plugin.xml | 17 +++++--- resources/icons/icon.png | Bin 0 -> 369 bytes resources/icons/icon@2x.png | Bin 0 -> 880 bytes sourcegraph.jar | Bin 8461 -> 13330 bytes src/Config.java | 34 +++++++++++++++ src/Copy.java | 20 +++++++++ src/FileAction.java | 80 ++++++++++++++++++++++++++++++++++ src/Open.java | 72 +++--------------------------- src/Search.java | 32 +++++++++++++- src/Util.java | 32 +++++++++----- 11 files changed, 212 insertions(+), 83 deletions(-) create mode 100644 resources/icons/icon.png create mode 100644 resources/icons/icon@2x.png create mode 100644 src/Config.java create mode 100644 src/Copy.java create mode 100644 src/FileAction.java diff --git a/README.md b/README.md index 84a3af2..709a2c9 100644 --- a/README.md +++ b/README.md @@ -74,6 +74,14 @@ Please file an issue: https://github.com/sourcegraph/sourcegraph-jetbrains/issue ## Version History +#### v1.2 + +- Disable search menu entry when no text is selected. +- Fix handling of local branch +- Move menu entries into sub-menu +- Implement copy link functionality +- Use Project storage API to load config from + #### v1.1.2 - Fixed an error that occurred when trying to search with no selection. diff --git a/resources/META-INF/plugin.xml b/resources/META-INF/plugin.xml index 85b8128..32524e4 100644 --- a/resources/META-INF/plugin.xml +++ b/resources/META-INF/plugin.xml @@ -45,18 +45,25 @@ com.intellij.modules.lang - + - - + - - + + + + + + + + + + diff --git a/resources/icons/icon.png b/resources/icons/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..7248dc42a04e6f0fd898b212b84f641759270460 GIT binary patch literal 369 zcmV-%0gnEOP)k~Mb1Znrh)o_@466c|0mK+Wk^vjdzk^-I#K8R3_aqw+h)uKsFwHRM`=8_l z>je{hJHNeQWME+b=+4Cp;v;*3n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)M@WL2#YUe(vVf2duw$Gm?Tr z+Q$tG1%-m>?+^bYR1%c`veQ%?UfKVU(ga=#)DV=^cf1gzzcBS5oP+YmEchpG9-*LU zDCo;TRWud3|Lym;>|a0x`lkp5g$^|p!bfNPmlgf%K>TGz|BYgdf639m&HvW@t1|xo zI=#oKVf;_!{|-X_Gh6)scK(x9k)xpK!L7Y)9sdKSwAC;${|> { + + String url; + + public String getUrl() { + return url; + } + + @Nullable + @Override + public Config getState() { + return this; + } + + @Override + public void loadState(@NotNull Config config) { + this.url = config.url; + } + + @Nullable static Config getInstance(Project project) { + return ServiceManager.getService(project, Config.class); + } +} diff --git a/src/Copy.java b/src/Copy.java new file mode 100644 index 0000000..5882602 --- /dev/null +++ b/src/Copy.java @@ -0,0 +1,20 @@ +import com.intellij.notification.Notification; +import com.intellij.notification.NotificationType; +import com.intellij.notification.Notifications; +import com.intellij.openapi.ide.CopyPasteManager; + +import java.awt.datatransfer.StringSelection; + +public class Copy extends FileAction { + + @Override + void handleFileUri(String uri) { + // Copy file uri to clipboard + CopyPasteManager.getInstance().setContents(new StringSelection(uri)); + + // Display bubble + Notification notification = new Notification("SourceGraph", "SourceGraph", + "File url has been copied to clipboard.", NotificationType.INFORMATION); + Notifications.Bus.notify(notification); + } +} \ No newline at end of file diff --git a/src/FileAction.java b/src/FileAction.java new file mode 100644 index 0000000..4ad8d88 --- /dev/null +++ b/src/FileAction.java @@ -0,0 +1,80 @@ +import com.intellij.openapi.actionSystem.AnAction; +import com.intellij.openapi.actionSystem.AnActionEvent; +import com.intellij.openapi.application.ApplicationInfo; +import com.intellij.openapi.diagnostic.Logger; +import com.intellij.openapi.editor.Document; +import com.intellij.openapi.editor.Editor; +import com.intellij.openapi.editor.LogicalPosition; +import com.intellij.openapi.editor.SelectionModel; +import com.intellij.openapi.fileEditor.FileDocumentManager; +import com.intellij.openapi.fileEditor.FileEditorManager; +import com.intellij.openapi.project.Project; +import com.intellij.openapi.vfs.VirtualFile; + +import java.awt.*; +import java.io.IOException; +import java.io.UnsupportedEncodingException; +import java.net.URI; +import java.net.URLEncoder; + +public abstract class FileAction extends AnAction { + + abstract void handleFileUri(String uri); + + @Override + public void actionPerformed(AnActionEvent e) { + Logger logger = Logger.getInstance(this.getClass()); + + // Get project, editor, document, file, and position information. + final Project project = e.getProject(); + if (project == null) { + return; + } + Editor editor = FileEditorManager.getInstance(project).getSelectedTextEditor(); + if (editor == null) { + return; + } + Document currentDoc = editor.getDocument(); + if (currentDoc == null) { + return; + } + VirtualFile currentFile = FileDocumentManager.getInstance().getFile(currentDoc); + if (currentFile == null) { + return; + } + SelectionModel sel = editor.getSelectionModel(); + + // Get repo information. + RepoInfo repoInfo = Util.repoInfo(currentFile.getPath()); + if (repoInfo.remoteURL == "") { + return; + } + + // Build the URL that we will open. + String productName = ApplicationInfo.getInstance().getVersionName(); + String productVersion = ApplicationInfo.getInstance().getFullVersion(); + String uri; + try { + LogicalPosition start = editor.visualToLogicalPosition(sel.getSelectionStartPosition()); + LogicalPosition end = editor.visualToLogicalPosition(sel.getSelectionEndPosition()); + uri = Util.sourcegraphURL(project)+"-/editor" + + "?remote_url=" + URLEncoder.encode(repoInfo.remoteURL, "UTF-8") + + "&branch=" + URLEncoder.encode(repoInfo.branch, "UTF-8") + + "&file=" + URLEncoder.encode(repoInfo.fileRel, "UTF-8") + + "&editor=" + URLEncoder.encode("JetBrains", "UTF-8") + + "&version=" + URLEncoder.encode(Util.VERSION, "UTF-8") + + "&utm_product_name=" + URLEncoder.encode(productName, "UTF-8") + + "&utm_product_version=" + URLEncoder.encode(productVersion, "UTF-8") + + "&start_row=" + URLEncoder.encode(Integer.toString(start.line), "UTF-8") + + "&start_col=" + URLEncoder.encode(Integer.toString(start.column), "UTF-8") + + "&end_row=" + URLEncoder.encode(Integer.toString(end.line), "UTF-8") + + "&end_col=" + URLEncoder.encode(Integer.toString(end.column), "UTF-8"); + } catch (UnsupportedEncodingException err) { + logger.debug("failed to build URL"); + err.printStackTrace(); + return; + } + + handleFileUri(uri); + } +} \ No newline at end of file diff --git a/src/Open.java b/src/Open.java index 4842c73..2c22aac 100644 --- a/src/Open.java +++ b/src/Open.java @@ -1,76 +1,14 @@ -import com.intellij.openapi.actionSystem.AnAction; -import com.intellij.openapi.actionSystem.AnActionEvent; -import com.intellij.openapi.editor.Document; -import com.intellij.openapi.editor.Editor; -import com.intellij.openapi.editor.SelectionModel; -import com.intellij.openapi.fileEditor.FileDocumentManager; -import com.intellij.openapi.fileEditor.FileEditorManager; -import com.intellij.openapi.editor.LogicalPosition; -import com.intellij.openapi.project.Project; -import com.intellij.openapi.vfs.VirtualFile; import com.intellij.openapi.diagnostic.Logger; -import com.intellij.openapi.application.ApplicationInfo; -import java.io.*; -import java.awt.Desktop; +import java.awt.*; +import java.io.IOException; import java.net.URI; -import java.net.URLEncoder; -public class Open extends AnAction { +public class Open extends FileAction { + @Override - public void actionPerformed(AnActionEvent e) { + void handleFileUri(String uri) { Logger logger = Logger.getInstance(this.getClass()); - - // Get project, editor, document, file, and position information. - final Project project = e.getProject(); - if (project == null) { - return; - } - Editor editor = FileEditorManager.getInstance(project).getSelectedTextEditor(); - if (editor == null) { - return; - } - Document currentDoc = editor.getDocument(); - if (currentDoc == null) { - return; - } - VirtualFile currentFile = FileDocumentManager.getInstance().getFile(currentDoc); - if (currentFile == null) { - return; - } - SelectionModel sel = editor.getSelectionModel(); - - // Get repo information. - RepoInfo repoInfo = Util.repoInfo(currentFile.getPath()); - if (repoInfo.remoteURL == "") { - return; - } - - // Build the URL that we will open. - String productName = ApplicationInfo.getInstance().getVersionName(); - String productVersion = ApplicationInfo.getInstance().getFullVersion(); - String uri; - try { - LogicalPosition start = editor.visualToLogicalPosition(sel.getSelectionStartPosition()); - LogicalPosition end = editor.visualToLogicalPosition(sel.getSelectionEndPosition()); - uri = Util.sourcegraphURL()+"-/editor" - + "?remote_url=" + URLEncoder.encode(repoInfo.remoteURL, "UTF-8") - + "&branch=" + URLEncoder.encode(repoInfo.branch, "UTF-8") - + "&file=" + URLEncoder.encode(repoInfo.fileRel, "UTF-8") - + "&editor=" + URLEncoder.encode("JetBrains", "UTF-8") - + "&version=" + URLEncoder.encode(Util.VERSION, "UTF-8") - + "&utm_product_name=" + URLEncoder.encode(productName, "UTF-8") - + "&utm_product_version=" + URLEncoder.encode(productVersion, "UTF-8") - + "&start_row=" + URLEncoder.encode(Integer.toString(start.line), "UTF-8") - + "&start_col=" + URLEncoder.encode(Integer.toString(start.column), "UTF-8") - + "&end_row=" + URLEncoder.encode(Integer.toString(end.line), "UTF-8") - + "&end_col=" + URLEncoder.encode(Integer.toString(end.column), "UTF-8"); - } catch (UnsupportedEncodingException err) { - logger.debug("failed to build URL"); - err.printStackTrace(); - return; - } - // Open the URL in the browser. try { Desktop.getDesktop().browse(URI.create(uri)); diff --git a/src/Search.java b/src/Search.java index 1f69f51..f7251fe 100644 --- a/src/Search.java +++ b/src/Search.java @@ -10,6 +10,7 @@ import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.application.ApplicationInfo; +import javax.annotation.Nullable; import java.io.*; import java.awt.Desktop; import java.net.URI; @@ -52,7 +53,7 @@ public void actionPerformed(AnActionEvent e) { String productName = ApplicationInfo.getInstance().getVersionName(); String productVersion = ApplicationInfo.getInstance().getFullVersion(); try { - uri = Util.sourcegraphURL()+"-/editor" + uri = Util.sourcegraphURL(project)+"-/editor" + "?remote_url=" + URLEncoder.encode(repoInfo.remoteURL, "UTF-8") + "&branch=" + URLEncoder.encode(repoInfo.branch, "UTF-8") + "&file=" + URLEncoder.encode(repoInfo.fileRel, "UTF-8") @@ -76,4 +77,33 @@ public void actionPerformed(AnActionEvent e) { } return; } + + @Override + public void update(AnActionEvent e) { + final Project project = e.getProject(); + if (project == null) { + return; + } + String selectedText = getSelectedText(project); + e.getPresentation().setEnabled(selectedText != null && selectedText.length() > 0); + } + + @Nullable + private String getSelectedText(Project project) { + Editor editor = FileEditorManager.getInstance(project).getSelectedTextEditor(); + if (editor == null) { + return null; + } + Document currentDoc = editor.getDocument(); + if (currentDoc == null) { + return null; + } + VirtualFile currentFile = FileDocumentManager.getInstance().getFile(currentDoc); + if (currentFile == null) { + return null; + } + SelectionModel sel = editor.getSelectionModel(); + + return sel.getSelectedText(); + } } \ No newline at end of file diff --git a/src/Util.java b/src/Util.java index 802ea58..1a93db2 100644 --- a/src/Util.java +++ b/src/Util.java @@ -1,10 +1,11 @@ import com.intellij.openapi.diagnostic.Logger; +import com.intellij.openapi.project.Project; import java.io.*; import java.util.Properties; public class Util { - public static String VERSION = "v1.1.2"; + public static String VERSION = "v1.2"; // gitRemoteURL returns the remote URL for the given remote name. // e.g. "origin" -> "git@github.com:foo/bar" @@ -43,7 +44,22 @@ public static String gitBranch(String repoDir) throws IOException { return exec("git rev-parse --abbrev-ref HEAD", repoDir).trim(); } + // verify that provided branch exists on remote + public static boolean isRemoteBranch(String branch, String repoDir) throws IOException { + return exec("git show-branch remotes/origin/" + branch, repoDir).length() > 0; + } + + public static String sourcegraphURL(Project project) { + String url = Config.getInstance(project).getUrl(); + if (url == null || url.length() == 0) { + Properties props = readProps(); + url = props.getProperty("url", "https://sourcegraph.com/"); + } + return url.endsWith("/") ? url : url + "/"; + } + // readProps tries to read the $HOME/sourcegraph-jetbrains.properties file. + @Deprecated private static Properties readProps() { Properties props = new Properties(); InputStream input = null; @@ -66,15 +82,6 @@ private static Properties readProps() { return props; } - public static String sourcegraphURL() { - Properties props = readProps(); - String url = props.getProperty("url", "https://sourcegraph.com"); - if (!url.endsWith("/")) { - return url + "/"; - } - return url; - } - // repoInfo returns the Sourcegraph repository URI, and the file path // relative to the repository root. If the repository URI cannot be // determined, a RepoInfo with empty strings is returned. @@ -91,6 +98,11 @@ public static RepoInfo repoInfo(String fileName) { fileRel = fileName.substring(repoRoot.length()+1); remoteURL = configuredGitRemoteURL(repoRoot); branch = gitBranch(repoRoot); + + // If user is on a local, use "master" instead + if (!isRemoteBranch(branch, repoRoot)) { + branch = "master"; + } } catch (Exception err) { Logger.getInstance(Util.class).info(err); err.printStackTrace(); From 419479e7c5dda52cc6f18135c2307ac4ab09e201 Mon Sep 17 00:00:00 2001 From: Stephen Gutekanst Date: Thu, 16 Apr 2020 14:28:27 -0700 Subject: [PATCH 02/14] remove comitted jar file --- sourcegraph.jar | Bin 13330 -> 0 bytes 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 sourcegraph.jar diff --git a/sourcegraph.jar b/sourcegraph.jar deleted file mode 100644 index d17b650a3be30e9c6ee4073ef8924bf1b390bcd5..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 13330 zcmaKT1yr2NmNo7Y+(~eEcXyZI?(Wif&;)`z!5xA_SRcXxOF$(uKGbMHTI&RW%9 zuhrkF>atV2cI{G>0f#^bfq{VmX)XPx2=a%agFt}DiKzd$O*|yiHoVI(#wgz z4uODN$&C!l%FxkIBFfNFkByAiC^OEmtnWC{OUuzp$xXWc1S+48&`6CA4qhvtyEwXT z?`-aXfhfvA!&oPEoU^}|!up;R|6|!7-hUOhv@sPjcCoa#qc^rObaqZqfAGVTz<86V zwN^W-O{ZiMf|W`Kem13ujAdsPved%ww@Vm`tg@-k2b$4E?8vD#8`V0YMb<65X9Xud z!A&IQevwg3Lm$F{%a4Dejdywhdjrix2h`9EN78ad3cQYtd0m}8w53d{yzxCjd|A0K zlopZiWktY{a8L~nZGnTY!-t~-AmU?)H8@d9If?h`au#fI>fv=AoqIysD>`zV#&owj z0gT~SgE(X+>jxIJxmF8uM7X&k>xUP3&|6eGn^jxz&XmseEO&we?gr1EFqR9~eIY-> z#9TvT@Mf(GL4JhW=)V6J7PV;%$4?)sKzW}RpdjU(xqBZT5XbyH{&U`cytn}>a}V%s z%P?f!HN>=Gj)k?isSgLt$4!k9Sco8lkZ>8-h4YI-ZZk;5O`N0OwLjV=7{{S7f;cb{ zmr-^y)e&)Nv44WQOj}b$ay8kQ(WOUO;u?p~?of?B!;PSO=p?Rf(N)1%gHxq04ofp+ zrAoDLtRHb0qrehBbP3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YQiTEX5n}REQ*eluNnu%1B+}F(dV^d$wI_h?gi~zB@LA6V~1+ zGoYOI2~8zA-zFouHj;1qF<+&RO@|_1bE?fhHHfggENF*4W7Wdr&ZRkiXcYKQAWyzWVTY`yYASKQ2Nj%KSZ-Kjn_Uxxl~7`~B-buQdGA z`%k&vZ_e>Avw1&b|GPl)w=W#X`%L-|g1*0e58vnG|NQ@d7Wt=g=eNM`FGG3H`+wa2 zlKcHLgFjUOzjsA{neuxT{*?Rt)ALV$_IE`1%Op_$)C~MzHT})B{$+dk|IPaSv#dW^ z!@svIJi&ka{5QAzPv1Y;i{HHBU)D Date: Thu, 16 Apr 2020 15:05:24 -0700 Subject: [PATCH 03/14] README: reword changelog, update plugin.xml changelog --- .idea/misc.xml | 2 +- README.md | 14 ++++++++------ resources/META-INF/plugin.xml | 15 +++++++++++---- 3 files changed, 20 insertions(+), 11 deletions(-) diff --git a/.idea/misc.xml b/.idea/misc.xml index 55b0f50..91a4741 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -38,7 +38,7 @@ - + \ No newline at end of file diff --git a/README.md b/README.md index 709a2c9..dae42cd 100644 --- a/README.md +++ b/README.md @@ -74,13 +74,15 @@ Please file an issue: https://github.com/sourcegraph/sourcegraph-jetbrains/issue ## Version History -#### v1.2 +#### v1.2.0 -- Disable search menu entry when no text is selected. -- Fix handling of local branch -- Move menu entries into sub-menu -- Implement copy link functionality -- Use Project storage API to load config from +- The search menu entry is now no longer present when no text has been selected. +- When on a branch that does not exist remotely, `master` will now be used instead. +- Menu entries (Open file, etc.) are now under a Sourcegraph sub-menu. +- Added a "Copy link to file" action. +- The Project storage API is now used for loading configuration. + +(special thanks to @oliviernotteghem for this release) #### v1.1.2 diff --git a/resources/META-INF/plugin.xml b/resources/META-INF/plugin.xml index 32524e4..b464cc6 100644 --- a/resources/META-INF/plugin.xml +++ b/resources/META-INF/plugin.xml @@ -1,7 +1,7 @@ com.sourcegraph.jetbrains Sourcegraph - 1.1.2 + 1.2.0 Sourcegraph -
  • v1.1.2 - Minor bug fixes around searching. -
      -
    • Fixed an error that occurred when trying to search with no selection.
    • +
    • v1.2.0 - Copy link to file, improved configuration, and bug fixes +
        +
      • The search menu entry is now no longer present when no text has been selected.
      • +
      • When on a branch that does not exist remotely, `master` will now be used instead.
      • +
      • Menu entries (Open file, etc.) are now under a Sourcegraph sub-menu.
      • +
      • Added a "Copy link to file" action.
      • +
      • The Project storage API is now used for loading configuration.
      +
    • +
    • v1.1.2 - Minor bug fixes around searching.
        +
      • Fixed an error that occurred when trying to search with no selection.
      • The git remote used for repository detection is now `sourcegraph` and then `origin`, instead of the previously poor choice of just the first git remote.
    • From dc306afe1311456cb8221f154656d44eb5d0fbbd Mon Sep 17 00:00:00 2001 From: Stephen Gutekanst Date: Thu, 16 Apr 2020 15:13:56 -0700 Subject: [PATCH 04/14] update version constant --- src/Util.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Util.java b/src/Util.java index 1a93db2..3c67966 100644 --- a/src/Util.java +++ b/src/Util.java @@ -5,7 +5,7 @@ import java.util.Properties; public class Util { - public static String VERSION = "v1.2"; + public static String VERSION = "v1.2.0"; // gitRemoteURL returns the remote URL for the given remote name. // e.g. "origin" -> "git@github.com:foo/bar" From b20352ffb25cc0e50b0305cf61d1f7c6f22cbac7 Mon Sep 17 00:00:00 2001 From: Stephen Gutekanst Date: Thu, 16 Apr 2020 15:15:25 -0700 Subject: [PATCH 05/14] SourceGraph -> Sourcegraph (case) --- resources/META-INF/plugin.xml | 2 +- src/Copy.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/resources/META-INF/plugin.xml b/resources/META-INF/plugin.xml index b464cc6..9efe654 100644 --- a/resources/META-INF/plugin.xml +++ b/resources/META-INF/plugin.xml @@ -65,7 +65,7 @@ - + diff --git a/src/Copy.java b/src/Copy.java index 5882602..07d7895 100644 --- a/src/Copy.java +++ b/src/Copy.java @@ -13,7 +13,7 @@ void handleFileUri(String uri) { CopyPasteManager.getInstance().setContents(new StringSelection(uri)); // Display bubble - Notification notification = new Notification("SourceGraph", "SourceGraph", + Notification notification = new Notification("Sourcegraph", "Sourcegraph", "File url has been copied to clipboard.", NotificationType.INFORMATION); Notifications.Bus.notify(notification); } From 1ea5a568ef5db7fa2dffbf496615ea204131d747 Mon Sep 17 00:00:00 2001 From: Stephen Gutekanst Date: Thu, 16 Apr 2020 15:16:55 -0700 Subject: [PATCH 06/14] README: indicate to use GitHub releases --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index dae42cd..7090da3 100644 --- a/README.md +++ b/README.md @@ -69,7 +69,8 @@ Please file an issue: https://github.com/sourcegraph/sourcegraph-jetbrains/issue 3. Update `README.md` (copy changelog from plugin.xml). 5. choose `Build` -> `Prepare Plugin Module 'sourcegraph' For Deployment` 6. `git commit -m "all: release v"` and `git push` and `git tag v` and `git push --tags` - 7. Publish according to http://www.jetbrains.org/intellij/sdk/docs/basics/getting_started/publishing_plugin.html (note: it takes ~2 business days for JetBrains support team to review the plugin). + 7. Upload the jar to the releases tab of this repository. + 8. Publish according to http://www.jetbrains.org/intellij/sdk/docs/basics/getting_started/publishing_plugin.html (note: it takes ~2 business days for JetBrains support team to review the plugin). ## Version History From ec91f7056fd8d24eb0564e46270eb57d92896473 Mon Sep 17 00:00:00 2001 From: Stephen Gutekanst Date: Thu, 16 Apr 2020 15:30:12 -0700 Subject: [PATCH 07/14] gitignore: jar --- .gitignore | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.gitignore b/.gitignore index a5d4cc8..896c55f 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,8 @@ # Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and Webstorm # Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839 +*.jar + # User-specific stuff: .idea/**/workspace.xml .idea/**/tasks.xml From 75337d1c8449c0272480cdad79ad3abb9ac07690 Mon Sep 17 00:00:00 2001 From: Stephen Gutekanst Date: Thu, 16 Apr 2020 15:31:44 -0700 Subject: [PATCH 08/14] reword copy notification --- src/Copy.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Copy.java b/src/Copy.java index 07d7895..4134a17 100644 --- a/src/Copy.java +++ b/src/Copy.java @@ -14,7 +14,7 @@ void handleFileUri(String uri) { // Display bubble Notification notification = new Notification("Sourcegraph", "Sourcegraph", - "File url has been copied to clipboard.", NotificationType.INFORMATION); + "File URL copied to clipboard.", NotificationType.INFORMATION); Notifications.Bus.notify(notification); } } \ No newline at end of file From 43b6c8e58ce9d8f64a7eb6f4730369a4eaf1adef Mon Sep 17 00:00:00 2001 From: Stephen Gutekanst Date: Thu, 16 Apr 2020 15:37:02 -0700 Subject: [PATCH 09/14] clarify comment --- src/Util.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Util.java b/src/Util.java index 3c67966..304dabe 100644 --- a/src/Util.java +++ b/src/Util.java @@ -99,7 +99,7 @@ public static RepoInfo repoInfo(String fileName) { remoteURL = configuredGitRemoteURL(repoRoot); branch = gitBranch(repoRoot); - // If user is on a local, use "master" instead + // If on a branch that does not exist on the remote, use "master" instead. if (!isRemoteBranch(branch, repoRoot)) { branch = "master"; } From 3e36ea2e0cfea6c6b3aa102232bb410cc6cc8ef5 Mon Sep 17 00:00:00 2001 From: Stephen Gutekanst Date: Tue, 12 May 2020 19:34:53 -0700 Subject: [PATCH 10/14] not deprecated, just the fallback --- src/Util.java | 1 - 1 file changed, 1 deletion(-) diff --git a/src/Util.java b/src/Util.java index 304dabe..debe4f9 100644 --- a/src/Util.java +++ b/src/Util.java @@ -59,7 +59,6 @@ public static String sourcegraphURL(Project project) { } // readProps tries to read the $HOME/sourcegraph-jetbrains.properties file. - @Deprecated private static Properties readProps() { Properties props = new Properties(); InputStream input = null; From b53aebc994fb3143923f177e85e8775a515ca342 Mon Sep 17 00:00:00 2001 From: Stephen Gutekanst Date: Thu, 14 May 2020 02:23:38 -0700 Subject: [PATCH 11/14] add "Search in repository" support --- README.md | 3 +- resources/META-INF/plugin.xml | 7 ++- src/Search.java | 89 +-------------------------- src/SearchActionBase.java | 111 ++++++++++++++++++++++++++++++++++ src/SearchRepository.java | 24 ++++++++ 5 files changed, 145 insertions(+), 89 deletions(-) create mode 100644 src/SearchActionBase.java create mode 100644 src/SearchRepository.java diff --git a/README.md b/README.md index 7090da3..20184ea 100644 --- a/README.md +++ b/README.md @@ -80,7 +80,8 @@ Please file an issue: https://github.com/sourcegraph/sourcegraph-jetbrains/issue - The search menu entry is now no longer present when no text has been selected. - When on a branch that does not exist remotely, `master` will now be used instead. - Menu entries (Open file, etc.) are now under a Sourcegraph sub-menu. -- Added a "Copy link to file" action. +- Added a "Copy link to file" action (alt+c / opt+c). +- Added a "Search in repository" action (alt+r / opt+r). - The Project storage API is now used for loading configuration. (special thanks to @oliviernotteghem for this release) diff --git a/resources/META-INF/plugin.xml b/resources/META-INF/plugin.xml index 9efe654..440fd4d 100644 --- a/resources/META-INF/plugin.xml +++ b/resources/META-INF/plugin.xml @@ -15,7 +15,8 @@
    • The search menu entry is now no longer present when no text has been selected.
    • When on a branch that does not exist remotely, `master` will now be used instead.
    • Menu entries (Open file, etc.) are now under a Sourcegraph sub-menu.
    • -
    • Added a "Copy link to file" action.
    • +
    • Added a "Copy link to file" action (alt+c / opt+c).
    • +
    • Added a "Search in repository" action (alt+r / opt+r).
    • The Project storage API is now used for loading configuration.
  • @@ -62,11 +63,15 @@ + + + + diff --git a/src/Search.java b/src/Search.java index f7251fe..e589d0d 100644 --- a/src/Search.java +++ b/src/Search.java @@ -16,94 +16,9 @@ import java.net.URI; import java.net.URLEncoder; -public class Search extends AnAction { +public class Search extends SearchActionBase { @Override public void actionPerformed(AnActionEvent e) { - Logger logger = Logger.getInstance(this.getClass()); - - // Get project, editor, document, file, and position information. - final Project project = e.getProject(); - if (project == null) { - return; - } - Editor editor = FileEditorManager.getInstance(project).getSelectedTextEditor(); - if (editor == null) { - return; - } - Document currentDoc = editor.getDocument(); - if (currentDoc == null) { - return; - } - VirtualFile currentFile = FileDocumentManager.getInstance().getFile(currentDoc); - if (currentFile == null) { - return; - } - SelectionModel sel = editor.getSelectionModel(); - - // Get repo information. - RepoInfo repoInfo = Util.repoInfo(currentFile.getPath()); - - String q = sel.getSelectedText(); - if (q == null || q.equals("")) { - return; // nothing to query - } - - // Build the URL that we will open. - String uri; - String productName = ApplicationInfo.getInstance().getVersionName(); - String productVersion = ApplicationInfo.getInstance().getFullVersion(); - try { - uri = Util.sourcegraphURL(project)+"-/editor" - + "?remote_url=" + URLEncoder.encode(repoInfo.remoteURL, "UTF-8") - + "&branch=" + URLEncoder.encode(repoInfo.branch, "UTF-8") - + "&file=" + URLEncoder.encode(repoInfo.fileRel, "UTF-8") - + "&editor=" + URLEncoder.encode("JetBrains", "UTF-8") - + "&version=" + URLEncoder.encode(Util.VERSION, "UTF-8") - + "&utm_product_name=" + URLEncoder.encode(productName, "UTF-8") - + "&utm_product_version=" + URLEncoder.encode(productVersion, "UTF-8") - + "&search=" + URLEncoder.encode(q, "UTF-8"); - } catch (UnsupportedEncodingException err) { - logger.debug("failed to build URL"); - err.printStackTrace(); - return; - } - - // Open the URL in the browser. - try { - Desktop.getDesktop().browse(URI.create(uri)); - } catch (IOException err) { - logger.debug("failed to open browser"); - err.printStackTrace(); - } - return; - } - - @Override - public void update(AnActionEvent e) { - final Project project = e.getProject(); - if (project == null) { - return; - } - String selectedText = getSelectedText(project); - e.getPresentation().setEnabled(selectedText != null && selectedText.length() > 0); - } - - @Nullable - private String getSelectedText(Project project) { - Editor editor = FileEditorManager.getInstance(project).getSelectedTextEditor(); - if (editor == null) { - return null; - } - Document currentDoc = editor.getDocument(); - if (currentDoc == null) { - return null; - } - VirtualFile currentFile = FileDocumentManager.getInstance().getFile(currentDoc); - if (currentFile == null) { - return null; - } - SelectionModel sel = editor.getSelectionModel(); - - return sel.getSelectedText(); + super.actionPerformedMode(e, "search"); } } \ No newline at end of file diff --git a/src/SearchActionBase.java b/src/SearchActionBase.java new file mode 100644 index 0000000..90d8119 --- /dev/null +++ b/src/SearchActionBase.java @@ -0,0 +1,111 @@ +import com.intellij.openapi.actionSystem.AnAction; +import com.intellij.openapi.actionSystem.AnActionEvent; +import com.intellij.openapi.editor.Document; +import com.intellij.openapi.editor.Editor; +import com.intellij.openapi.editor.SelectionModel; +import com.intellij.openapi.fileEditor.FileDocumentManager; +import com.intellij.openapi.fileEditor.FileEditorManager; +import com.intellij.openapi.project.Project; +import com.intellij.openapi.vfs.VirtualFile; +import com.intellij.openapi.diagnostic.Logger; +import com.intellij.openapi.application.ApplicationInfo; + +import javax.annotation.Nullable; +import java.io.*; +import java.awt.Desktop; +import java.net.URI; +import java.net.URLEncoder; + +public abstract class SearchActionBase extends AnAction { + public void actionPerformedMode(AnActionEvent e, String mode) { + Logger logger = Logger.getInstance(this.getClass()); + + // Get project, editor, document, file, and position information. + final Project project = e.getProject(); + if (project == null) { + return; + } + Editor editor = FileEditorManager.getInstance(project).getSelectedTextEditor(); + if (editor == null) { + return; + } + Document currentDoc = editor.getDocument(); + if (currentDoc == null) { + return; + } + VirtualFile currentFile = FileDocumentManager.getInstance().getFile(currentDoc); + if (currentFile == null) { + return; + } + SelectionModel sel = editor.getSelectionModel(); + + // Get repo information. + RepoInfo repoInfo = Util.repoInfo(currentFile.getPath()); + + String q = sel.getSelectedText(); + if (q == null || q.equals("")) { + return; // nothing to query + } + + // Build the URL that we will open. + String uri; + String productName = ApplicationInfo.getInstance().getVersionName(); + String productVersion = ApplicationInfo.getInstance().getFullVersion(); + try { + uri = Util.sourcegraphURL(project)+"-/editor" + + "?editor=" + URLEncoder.encode("JetBrains", "UTF-8") + + "&version=" + URLEncoder.encode(Util.VERSION, "UTF-8") + + "&utm_product_name=" + URLEncoder.encode(productName, "UTF-8") + + "&utm_product_version=" + URLEncoder.encode(productVersion, "UTF-8") + + "&search=" + URLEncoder.encode(q, "UTF-8"); + + if (mode == "search.repository") { + uri += "&search_remote_url=" + URLEncoder.encode(repoInfo.remoteURL, "UTF-8") + + "&search_branch=" + URLEncoder.encode(repoInfo.branch, "UTF-8"); + } + + } catch (UnsupportedEncodingException err) { + logger.debug("failed to build URL"); + err.printStackTrace(); + return; + } + + // Open the URL in the browser. + try { + Desktop.getDesktop().browse(URI.create(uri)); + } catch (IOException err) { + logger.debug("failed to open browser"); + err.printStackTrace(); + } + return; + } + + @Override + public void update(AnActionEvent e) { + final Project project = e.getProject(); + if (project == null) { + return; + } + String selectedText = getSelectedText(project); + e.getPresentation().setEnabled(selectedText != null && selectedText.length() > 0); + } + + @Nullable + private String getSelectedText(Project project) { + Editor editor = FileEditorManager.getInstance(project).getSelectedTextEditor(); + if (editor == null) { + return null; + } + Document currentDoc = editor.getDocument(); + if (currentDoc == null) { + return null; + } + VirtualFile currentFile = FileDocumentManager.getInstance().getFile(currentDoc); + if (currentFile == null) { + return null; + } + SelectionModel sel = editor.getSelectionModel(); + + return sel.getSelectedText(); + } +} \ No newline at end of file diff --git a/src/SearchRepository.java b/src/SearchRepository.java new file mode 100644 index 0000000..7b7a13c --- /dev/null +++ b/src/SearchRepository.java @@ -0,0 +1,24 @@ +import com.intellij.openapi.actionSystem.AnAction; +import com.intellij.openapi.actionSystem.AnActionEvent; +import com.intellij.openapi.editor.Document; +import com.intellij.openapi.editor.Editor; +import com.intellij.openapi.editor.SelectionModel; +import com.intellij.openapi.fileEditor.FileDocumentManager; +import com.intellij.openapi.fileEditor.FileEditorManager; +import com.intellij.openapi.project.Project; +import com.intellij.openapi.vfs.VirtualFile; +import com.intellij.openapi.diagnostic.Logger; +import com.intellij.openapi.application.ApplicationInfo; + +import javax.annotation.Nullable; +import java.io.*; +import java.awt.Desktop; +import java.net.URI; +import java.net.URLEncoder; + +public class SearchRepository extends SearchActionBase { + @Override + public void actionPerformed(AnActionEvent e) { + super.actionPerformedMode(e, "search.repository"); + } +} \ No newline at end of file From 639802dcde9447d71f3c1fc8796a9ad30d4eec8a Mon Sep 17 00:00:00 2001 From: Stephen Gutekanst Date: Wed, 10 Jun 2020 15:06:37 -0700 Subject: [PATCH 12/14] fix config loading --- src/Config.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Config.java b/src/Config.java index ea80c51..3263a78 100644 --- a/src/Config.java +++ b/src/Config.java @@ -11,7 +11,7 @@ storages = {@Storage("sourcegraph.xml")}) class Config implements PersistentStateComponent { - String url; + public String url; public String getUrl() { return url; From 1dd58f30c76087a461e14283e366c2a91e3a9080 Mon Sep 17 00:00:00 2001 From: Stephen Gutekanst Date: Wed, 10 Jun 2020 15:15:05 -0700 Subject: [PATCH 13/14] better README / CHANGELOG wording --- README.md | 40 +++++++++++++++++++---------------- resources/META-INF/plugin.xml | 5 +++-- 2 files changed, 25 insertions(+), 20 deletions(-) diff --git a/README.md b/README.md index 20184ea..8dcdede 100644 --- a/README.md +++ b/README.md @@ -16,7 +16,6 @@ The Sourcegraph plugin for JetBrains IDEs enables you to quickly open and search - Rider - Android Studio - ## Installation - Select `IntelliJ IDEA` then `Preferences` (or use ⌘,) @@ -24,7 +23,6 @@ The Sourcegraph plugin for JetBrains IDEs enables you to quickly open and search - Choose `Browse repositories...` - Search for `Sourcegraph` -> `Install` - ## Usage Right click any code or selection and choose `Sourcegraph: Open` or `Sourcegraph: Search`. @@ -32,33 +30,41 @@ Right click any code or selection and choose `Sourcegraph: Open` or `Sourcegraph Keyboard Shortcuts: | Description | Mac | Linux / Windows | -|---------------------------------|---------------------|------------------| +| ------------------------------- | ------------------- | ---------------- | | Open file in Sourcegraph | Option+A | Alt+A | | Search selection in Sourcegraph | Option+S | Alt+S | - ## Settings -The plugin is configurable by creating a `sourcegraph-jetbrains.properties` in your home directory. For example, modify the following URL to match your on-premises Sourcegraph instance URL: +The plugin is configurable _globally_ by creating a `sourcegraph-jetbrains.properties` in your home directory. For example, modify the following URL to match your on-premises Sourcegraph instance URL: ``` -url = https://sourcegraph.com +url = https://sourcegraph.example.com +``` + +You may also choose to configure it _per repository_ using a `.idea/sourcegraph.xml` file in your repository like so: + +```xml + + + + + ``` -By default, the plugin will use the `origin` git remote to determine which repository on Sourcegraph corresponds to the local repository. You may configure this by adding a `sourcegraph` remote which will take priority. +By default, the plugin will use the `origin` git remote to determine which repository on Sourcegraph corresponds to your local repository. If your `origin` remote doesn't match Sourcegraph, you may instead configure a `sourcegraph` Git remote which will take priority. ## Questions & Feedback Please file an issue: https://github.com/sourcegraph/sourcegraph-jetbrains/issues/new - ## Uninstallation - Select `IntelliJ IDEA` then `Preferences` (or use ⌘,) - Click `Plugins` in the left-hand pane. - Search for `Sourcegraph` -> Right click -> `Uninstall` (or uncheck to disable) - ## Development - Start IntelliJ and choose `Check out from Version Control` -> `Git` -> `https://github.com/sourcegraph/sourcegraph-jetbrains` @@ -67,11 +73,10 @@ Please file an issue: https://github.com/sourcegraph/sourcegraph-jetbrains/issue 1. Update `plugin.xml` (change version AND describe changes in change notes). 2. Update `Util.java` (change `VERSION` constant). 3. Update `README.md` (copy changelog from plugin.xml). - 5. choose `Build` -> `Prepare Plugin Module 'sourcegraph' For Deployment` - 6. `git commit -m "all: release v"` and `git push` and `git tag v` and `git push --tags` - 7. Upload the jar to the releases tab of this repository. - 8. Publish according to http://www.jetbrains.org/intellij/sdk/docs/basics/getting_started/publishing_plugin.html (note: it takes ~2 business days for JetBrains support team to review the plugin). - + 4. choose `Build` -> `Prepare Plugin Module 'sourcegraph' For Deployment` + 5. `git commit -m "all: release v"` and `git push` and `git tag v` and `git push --tags` + 6. Upload the jar to the releases tab of this repository. + 7. Publish according to http://www.jetbrains.org/intellij/sdk/docs/basics/getting_started/publishing_plugin.html (note: it takes ~2 business days for JetBrains support team to review the plugin). ## Version History @@ -81,10 +86,9 @@ Please file an issue: https://github.com/sourcegraph/sourcegraph-jetbrains/issue - When on a branch that does not exist remotely, `master` will now be used instead. - Menu entries (Open file, etc.) are now under a Sourcegraph sub-menu. - Added a "Copy link to file" action (alt+c / opt+c). -- Added a "Search in repository" action (alt+r / opt+r). -- The Project storage API is now used for loading configuration. - -(special thanks to @oliviernotteghem for this release) +- Added a "Search in repository" action (alt+r / opt+r). +- It is now possible to configure the plugin per-repository using a `.idea/sourcegraph.xml` file. See the README for details. +- Special thanks: @oliviernotteghem for contributing the new features in this release! #### v1.1.2 diff --git a/resources/META-INF/plugin.xml b/resources/META-INF/plugin.xml index 440fd4d..cb8328b 100644 --- a/resources/META-INF/plugin.xml +++ b/resources/META-INF/plugin.xml @@ -10,14 +10,15 @@ -
  • v1.2.0 - Copy link to file, improved configuration, and bug fixes +
  • v1.2.0 - Copy link to file, search in repository, per-repository configuration, bug fixes & more
    • The search menu entry is now no longer present when no text has been selected.
    • When on a branch that does not exist remotely, `master` will now be used instead.
    • Menu entries (Open file, etc.) are now under a Sourcegraph sub-menu.
    • Added a "Copy link to file" action (alt+c / opt+c).
    • Added a "Search in repository" action (alt+r / opt+r).
    • -
    • The Project storage API is now used for loading configuration.
    • +
    • It is now possible to configure the plugin per-repository using a `.idea/sourcegraph.xml` file. See the README for details.
    • +
    • Special thanks: @oliviernotteghem for contributing the new features in this release!
  • v1.1.2 - Minor bug fixes around searching. From a5789917dba4ab0d0ad3cda055383ebae9ec93ea Mon Sep 17 00:00:00 2001 From: Stephen Gutekanst Date: Wed, 10 Jun 2020 16:03:34 -0700 Subject: [PATCH 14/14] README: clarify what the plugin does --- README.md | 20 +++++++------------- resources/META-INF/plugin.xml | 5 +++++ 2 files changed, 12 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index 8dcdede..b76ceef 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,10 @@ # Sourcegraph for JetBrains IDEs [![JetBrains Plugin](https://img.shields.io/badge/JetBrains-Sourcegraph-green.svg)](https://plugins.jetbrains.com/plugin/9682-sourcegraph) -The Sourcegraph plugin for JetBrains IDEs enables you to quickly open and search code on Sourcegraph easily and efficiently in JetBrains IDEs such as IntelliJ. This plugin works with most JetBrains IDEs: +- Search snippets of code on Sourcegraph. +- Copy and share a link to code on Sourcegraph. +- Quickly go from files in your editor to Sourcegraph. + +The plugin works with all JetBrains IDEs including: - IntelliJ IDEA - IntelliJ IDEA Community Edition @@ -22,19 +26,9 @@ The Sourcegraph plugin for JetBrains IDEs enables you to quickly open and search - Click `Plugins` in the left-hand pane. - Choose `Browse repositories...` - Search for `Sourcegraph` -> `Install` +- Restart your IDE if needed, then select some code and choose `Sourcegraph` in the right-click context menu to see actions and keyboard shortcuts. -## Usage - -Right click any code or selection and choose `Sourcegraph: Open` or `Sourcegraph: Search`. - -Keyboard Shortcuts: - -| Description | Mac | Linux / Windows | -| ------------------------------- | ------------------- | ---------------- | -| Open file in Sourcegraph | Option+A | Alt+A | -| Search selection in Sourcegraph | Option+S | Alt+S | - -## Settings +## Configuring for use with a private Sourcegraph instance The plugin is configurable _globally_ by creating a `sourcegraph-jetbrains.properties` in your home directory. For example, modify the following URL to match your on-premises Sourcegraph instance URL: diff --git a/resources/META-INF/plugin.xml b/resources/META-INF/plugin.xml index cb8328b..4b95bc1 100644 --- a/resources/META-INF/plugin.xml +++ b/resources/META-INF/plugin.xml @@ -6,6 +6,11 @@ +
      +
    • Search snippets of code on Sourcegraph.
    • +
    • Copy and share a link to code on Sourcegraph.
    • +
    • Quickly go from files in your editor to Sourcegraph.
    • +
    ]]>