Skip to content
This repository has been archived by the owner on May 7, 2021. It is now read-only.

Commit

Permalink
Correctly handle scenarios when the symbol isn't used
Browse files Browse the repository at this point in the history
  • Loading branch information
Josh Ghiloni committed Jul 20, 2018
1 parent 03e6450 commit bc55113
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 11 deletions.
12 changes: 7 additions & 5 deletions lib/guru-utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import path from 'path'
import {getEditor, getCursorPosition, isValidEditor, utf8OffsetForBufferPosition} from './utils'

const scopedModes = ['callees', 'callers', 'callstack', 'pointsto', 'whicherrs', 'peers']
const scopedModes = ['callees', 'callers', 'callstack', 'pointsto', 'whicherrs', 'peers', 'referrers']

function buildGuruArchive (editor: any = null) {
let archive = ''
Expand All @@ -27,13 +27,15 @@ function computeArgs (mode: string, options: ?{gopath: string}, editor: any = ge
const filePath = editor.getPath()
const args = ['-json']
if (scopedModes.includes(mode)) {
const src = 'src/'
let relPath = atom.project.relativizePath(filePath)
if (relPath && relPath.length > 0 && relPath[0] !== null) {
// Make it relative to GOPATH because guru tool requires it.
if (options && options.gopath && options.gopath.length) {
const scope = path.relative(options.gopath + '/src', relPath[0] + '/...')
args.push('-scope', scope)
let scope = relPath[0]
const srcIndex = scope.indexOf(src)
if (srcIndex != -1) {
scope = scope.substring(srcIndex + src.length, scope.length)
}
args.push('-scope', scope + '/...')
}
}

Expand Down
8 changes: 2 additions & 6 deletions lib/usage/usage.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,11 +76,7 @@ class Usage implements PanelModel {
}

parse (obj: Array<Object>): ?Object {
if (!obj) {
return undefined
}

if (obj.length < 2) {
if (!obj || !obj.length) {
return undefined
}

Expand All @@ -107,7 +103,7 @@ class Usage implements PanelModel {
if (state === 'running' || state === 'error' || state === 'initial') {
props.content = content
} else {
if (!content || !content.packages) {
if (!content || !content.packages || !content.packages.size) {
props.content = 'No usage found...'
} else {
props.content = {
Expand Down

0 comments on commit bc55113

Please sign in to comment.