Skip to content

Completions based on your path #17

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 9 commits into from
Apr 7, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"search.exclude": {
"out": true
},
"tslint.autoFixOnSave": true,
"typescript.tsdk": "./node_modules/typescript/lib",
"typescript.tsc.autoDetect": "off"
}
2 changes: 1 addition & 1 deletion TODO.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
https://github.com/Microsoft/vscode/wiki/Extension-Authoring:-Adopting-Multi-Root-Workspace-APIs
- [ ] Code completion
- [x] Based on symbols in the file
- [x] Based on programs in your PATH
- [ ] Based on all symbols in the workspace
- [ ] Based on programs in your PATH
- [ ] Code Outline
- [x] Flat list of symbols
- [ ] Implement proper hierarchy by providing parent names for nodes
2 changes: 1 addition & 1 deletion server/bin/main.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env node

const server = require('../out/server')
const server = require('../out/index')
const package = require('../package')

const args = process.argv
Expand Down
133 changes: 133 additions & 0 deletions server/src/__tests__/__snapshots__/analyzer.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,139 @@ Array [
]
`;

exports[`findSymbolCompletions return a list of symbols 1`] = `
Array [
Object {
"data": Object {
"name": "ret",
"type": "function",
},
"kind": undefined,
"label": "ret",
},
Object {
"data": Object {
"name": "configures",
"type": "function",
},
"kind": undefined,
"label": "configures",
},
Object {
"data": Object {
"name": "npm_config_loglevel",
"type": "function",
},
"kind": undefined,
"label": "npm_config_loglevel",
},
Object {
"data": Object {
"name": "node",
"type": "function",
},
"kind": undefined,
"label": "node",
},
Object {
"data": Object {
"name": "TMP",
"type": "function",
},
"kind": undefined,
"label": "TMP",
},
Object {
"data": Object {
"name": "BACK",
"type": "function",
},
"kind": undefined,
"label": "BACK",
},
Object {
"data": Object {
"name": "tar",
"type": "function",
},
"kind": undefined,
"label": "tar",
},
Object {
"data": Object {
"name": "MAKE",
"type": "function",
},
"kind": undefined,
"label": "MAKE",
},
Object {
"data": Object {
"name": "make",
"type": "function",
},
"kind": undefined,
"label": "make",
},
Object {
"data": Object {
"name": "clean",
"type": "function",
},
"kind": undefined,
"label": "clean",
},
Object {
"data": Object {
"name": "node_version",
"type": "function",
},
"kind": undefined,
"label": "node_version",
},
Object {
"data": Object {
"name": "t",
"type": "function",
},
"kind": undefined,
"label": "t",
},
Object {
"data": Object {
"name": "url",
"type": "function",
},
"kind": undefined,
"label": "url",
},
Object {
"data": Object {
"name": "ver",
"type": "function",
},
"kind": undefined,
"label": "ver",
},
Object {
"data": Object {
"name": "isnpm10",
"type": "function",
},
"kind": undefined,
"label": "isnpm10",
},
Object {
"data": Object {
"name": "NODE",
"type": "function",
},
"kind": undefined,
"label": "NODE",
},
]
`;

exports[`findSymbols returns a list of SymbolInformation if uri is found 1`] = `
Array [
Object {
Expand Down
10 changes: 9 additions & 1 deletion server/src/__tests__/analyzer.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import FIXTURES from '../../../testing/fixtures'
import * as analyzer from '../analyser'
import Analyzer from '../analyser'

const analyzer = new Analyzer()

const CURRENT_URI = 'dummy-uri.sh'
beforeEach(() => {
Expand Down Expand Up @@ -65,3 +67,9 @@ describe('wordAtPoint', () => {
// expect(analyzer.wordAtPoint(CURRENT_URI, 24, 4)).toEqual('else')
})
})

describe('findSymbolCompletions', () => {
it('return a list of symbols', () => {
expect(analyzer.findSymbolCompletions(CURRENT_URI)).toMatchSnapshot()
})
})
47 changes: 47 additions & 0 deletions server/src/__tests__/executables.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import * as path from 'path'
import Executables from '../executables'

const executablesPromise = Executables.fromPath(
path.resolve(__dirname, '..', '..', '..', 'testing', 'executables'),
)

describe('list', () => {
it('finds executables on the PATH', async () => {
expect.assertions(1)
const executables = await executablesPromise
const result = executables.list().find(x => x === 'iam-executable')
return expect(result).toBeTruthy()
})

it.skip('only considers files that have the executable bit set', async () => {
expect.assertions(1)
const executables = await executablesPromise
const result = executables.list().find(x => x === 'iam-not-executable')
return expect(result).toBeFalsy()
})

it('only considers executable directly on the PATH', async () => {
expect.assertions(1)
const executables = await executablesPromise
const result = executables.list().find(x => x === 'iam-executable-in-sub-folder')
return expect(result).toBeFalsy()
})
})

describe('documentation', () => {
it('uses `man` so it disregards the PATH it has been initialized with', async () => {
expect.assertions(1)
const executables = await executablesPromise
const result = await executables.documentation('ls')
return expect(result).toBeTruthy()
})
})

describe('isExecutableOnPATH', () => {
it('looks at the PATH it has been initialized with', async () => {
expect.assertions(1)
const executables = await executablesPromise
const result = executables.isExecutableOnPATH('ls')
return expect(result).toEqual(false)
})
})
Loading