This repository was archived by the owner on Feb 22, 2020. It is now read-only.
File tree Expand file tree Collapse file tree 3 files changed +40
-6
lines changed
Expand file tree Collapse file tree 3 files changed +40
-6
lines changed Original file line number Diff line number Diff line change 121121 "typescript" : " ^3.1.6"
122122 },
123123 "dependencies" : {
124- "@sourcegraph/basic-code-intel" : " 6.0.7 " ,
124+ "@sourcegraph/basic-code-intel" : " 6.0.9 " ,
125125 "@sourcegraph/vscode-ws-jsonrpc" : " 0.0.3-fork" ,
126126 "prettier" : " ^1.16.4" ,
127127 "rxjs" : " ^6.3.3" ,
Original file line number Diff line number Diff line change @@ -699,7 +699,35 @@ export function activate(ctx: sourcegraph.ExtensionContext = DUMMY_CTX): void {
699699 activateBasicCodeIntel ( {
700700 languageID : 'go' ,
701701 fileExts : [ 'go' ] ,
702- definitionPatterns : [ '\\b%s(,\\s\\w+)*\\s\\:=' , '(var|const)\\s%s\\s' ] ,
702+ filterDefinitions : ( { doc, pos, fileContent, results } ) => {
703+ const currentFileImportedPaths = fileContent
704+ . split ( '\n' )
705+ . map ( line => {
706+ // Matches the import at index 3
707+ const match = / ^ ( i m p o r t | \t ) ( \w + | \. ) ? " ( .* ) " $ / . exec ( line )
708+ return match ? match [ 3 ] : undefined
709+ } )
710+ . filter ( ( x ) : x is string => Boolean ( x ) )
711+
712+ function dir ( path : string ) : string {
713+ return path . slice ( 0 , path . lastIndexOf ( '/' ) )
714+ }
715+
716+ const currentFileURL = new URL ( doc . uri )
717+ const currentRepository = currentFileURL . hostname + currentFileURL . pathname
718+ const currentFilePath = currentFileURL . hash . slice ( 1 )
719+ const currentFileImportPath = currentRepository + '/' + dir ( currentFilePath )
720+
721+ const filteredResults = results . filter ( result => {
722+ const resultImportPath = result . repo + '/' + dir ( result . file )
723+ return (
724+ currentFileImportedPaths . some ( i => resultImportPath . includes ( i ) ) ||
725+ resultImportPath === currentFileImportPath
726+ )
727+ } )
728+
729+ return filteredResults . length === 0 ? results : filteredResults
730+ } ,
703731 commentStyle : {
704732 lineRegex : / \/ \/ \s ? / ,
705733 } ,
Original file line number Diff line number Diff line change 700700 resolved "https://registry.yarnpkg.com/@sindresorhus/is/-/is-0.7.0.tgz#9a06f4f137ee84d7df0460c1fdb1135ffa6c50fd"
701701 integrity sha512-ONhaKPIufzzrlNbqtWFFd+jlnemX6lJAgq9ZeiZtS7I1PIf/la7CW4m83rTXRnVnsMbW2k56pGYu7AUFJD9Pow==
702702
703- " @sourcegraph/basic-code-intel@6.0.7 " :
704- version "6.0.7 "
705- resolved "https://registry.yarnpkg.com/@sourcegraph/basic-code-intel/-/basic-code-intel-6.0.7 .tgz#6ba8623c1c5e71f780a059ccea2120ffdc1e3600 "
706- integrity sha512-+amGIq54N3aVOj7AxNtW6QtDfUVvtT253Ha+i9sofyo217L/7Ucwo/WoDGuded9Ng9FUxUM6UOS3MREW+lkUGQ ==
703+ " @sourcegraph/basic-code-intel@6.0.9 " :
704+ version "6.0.9 "
705+ resolved "https://registry.yarnpkg.com/@sourcegraph/basic-code-intel/-/basic-code-intel-6.0.9 .tgz#7c76513a5cda622e86e966a5dd4128be677278bc "
706+ integrity sha512-/pfZ1E8mhetl3wOVAD3nn8DfQoQHE+PzvezzPXF3P+sSZyn7p4oHErn+ezo4gR3d7UwjZ4UEn0UkbSdW5RWjnw ==
707707 dependencies :
708708 lodash "^4.17.11"
709709 rxjs "^6.3.3"
710710 sourcegraph "^23.0.0"
711+ sprintf-js "^1.1.2"
711712
712713" @sourcegraph/prettierrc@^2.2.0 " :
713714 version "2.2.0"
@@ -5155,6 +5156,11 @@ split-string@^3.0.1, split-string@^3.0.2:
51555156 dependencies :
51565157 extend-shallow "^3.0.0"
51575158
5159+ sprintf-js@^1.1.2 :
5160+ version "1.1.2"
5161+ resolved "https://registry.yarnpkg.com/sprintf-js/-/sprintf-js-1.1.2.tgz#da1765262bf8c0f571749f2ad6c26300207ae673"
5162+ integrity sha512-VE0SOVEHCk7Qc8ulkWw3ntAzXuqf7S2lvwQaDLRnUeIEaKNQJzV6BwmLKhOqT61aGhfUMrXeaBk+oDGCzvhcug==
5163+
51585164sprintf-js@~1.0.2 :
51595165 version "1.0.3"
51605166 resolved "https://registry.yarnpkg.com/sprintf-js/-/sprintf-js-1.0.3.tgz#04e6926f662895354f3dd015203633b857297e2c"
You can’t perform that action at this time.
0 commit comments