Skip to content

Commit

Permalink
keskiju#8 added ScopeDescriptor, which is supported by autocomplete-p…
Browse files Browse the repository at this point in the history
…lus, playing with class resolution using scopes, next to come, grammar tokens
  • Loading branch information
Jaroslaw Palka committed Aug 18, 2016
1 parent 9e982bc commit d7ec389
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions lib/AtomAutocompleteProvider.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,20 +22,24 @@ export class AtomAutocompleteProvider {
}

// autocomplete-plus
getSuggestions({editor, bufferPosition, prefix: origPrefix}) {
getSuggestions({editor, bufferPosition, scopeDescriptor, prefix: origPrefix}) {
// text: 'package.Class.me', prefix: 'package.Class', suffix: 'me'
// text: 'package.Cla', prefix: 'package', suffix: 'Cla'
// text: 'Cla', prefix: '', suffix: 'Cla'
// line: 'new Cla', text: 'Cla', prevWord: 'new'

const line = atomJavaUtil.getLine(editor, bufferPosition);
const prevWord = atomJavaUtil.getPrevWord(editor, bufferPosition);
const text = atomJavaUtil.getWord(editor, bufferPosition, true)
.replace('@', '');
const prefix = text.substring(0, text.lastIndexOf('.'));
const suffix = origPrefix.replace('.', '');
const couldBeClass = /^[A-Z]/.test(suffix) || prefix;
let isInstance = false;

const scopes = scopeDescriptor.getScopesArray();
// check if last scope is storage.type.java
const couldBeClass = (_.last(scopes)=="storage.type.java")

let results = null;
if (couldBeClass) {
const classes = this.classLoader.findClass(text);
Expand Down

0 comments on commit d7ec389

Please sign in to comment.