mirror of
https://github.com/adelphes/android-dev-ext.git
synced 2025-12-23 01:48:18 +00:00
add source types to list
hide this and super for non-methods
This commit is contained in:
@@ -345,12 +345,12 @@ connection.onDidChangeWatchedFiles((_change) => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @param {{name:string}} a
|
* @param {{name:string}} a
|
||||||
* @param {{name:string}} b
|
* @param {{name:string}} b
|
||||||
*/
|
*/
|
||||||
function sortByName(a,b) {
|
const sortBy = {
|
||||||
return a.name.localeCompare(b.name, undefined, {sensitivity: 'base'})
|
label: (a,b) => a.label.localeCompare(b.label, undefined, {sensitivity: 'base'}),
|
||||||
|
name: (a,b) => a.name.localeCompare(b.name, undefined, {sensitivity: 'base'}),
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -406,10 +406,10 @@ function getTypedNameCompletion(typemap, type_signature, opts, typelist) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
types.forEach((t,idx) => {
|
types.forEach((t,idx) => {
|
||||||
t.fields.sort(sortByName)
|
t.fields.sort(sortBy.name)
|
||||||
.filter(f => shouldInclude(f.modifiers, t))
|
.filter(f => shouldInclude(f.modifiers, t))
|
||||||
.forEach(f => fields.set(f.name, {f, t, sortText: `${idx+100}${f.name}`}));
|
.forEach(f => fields.set(f.name, {f, t, sortText: `${idx+100}${f.name}`}));
|
||||||
t.methods.sort(sortByName)
|
t.methods.sort(sortBy.name)
|
||||||
.filter(f => shouldInclude(f.modifiers, t))
|
.filter(f => shouldInclude(f.modifiers, t))
|
||||||
.forEach(m => methods.set(`${m.name}${m.methodSignature}`, {m, t, sortText: `${idx+100}${m.name}`}));
|
.forEach(m => methods.set(`${m.name}${m.methodSignature}`, {m, t, sortText: `${idx+100}${m.name}`}));
|
||||||
});
|
});
|
||||||
@@ -568,7 +568,7 @@ function initDefaultCompletionTypes(lib) {
|
|||||||
sortText: t,
|
sortText: t,
|
||||||
})),
|
})),
|
||||||
// literals
|
// literals
|
||||||
literals: 'false true null super'.split(' ').map((t) => ({
|
literals: 'false true null'.split(' ').map((t) => ({
|
||||||
label: t,
|
label: t,
|
||||||
kind: CompletionItemKind.Value,
|
kind: CompletionItemKind.Value,
|
||||||
sortText: t
|
sortText: t
|
||||||
@@ -605,7 +605,7 @@ connection.onCompletion(
|
|||||||
}
|
}
|
||||||
const lib = (parsed && parsed.typemap) || androidLibrary;
|
const lib = (parsed && parsed.typemap) || androidLibrary;
|
||||||
if (!lib) return [];
|
if (!lib) return [];
|
||||||
let locals = [], sortIdx = 10000;
|
let locals = [], sourceTypes = [], show_instances = false;
|
||||||
if (parsed.result && parsed.result.unit) {
|
if (parsed.result && parsed.result.unit) {
|
||||||
const index = parsed.indexAt(_textDocumentPosition.position);
|
const index = parsed.indexAt(_textDocumentPosition.position);
|
||||||
const options = parsed.result.unit.getCompletionOptionsAt(index);
|
const options = parsed.result.unit.getCompletionOptionsAt(index);
|
||||||
@@ -628,12 +628,19 @@ connection.onCompletion(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (options.method) {
|
if (options.method) {
|
||||||
locals = options.method.parameters.sort(sortByName).map(p => ({
|
show_instances = !options.method.modifiers.includes('static');
|
||||||
|
locals = options.method.parameters.sort(sortBy.name).map(p => ({
|
||||||
label: p.name,
|
label: p.name,
|
||||||
kind: CompletionItemKind.Variable,
|
kind: CompletionItemKind.Variable,
|
||||||
sortText: p.name,
|
sortText: p.name,
|
||||||
}))
|
}))
|
||||||
}
|
}
|
||||||
|
sourceTypes = parsed.result.unit.types.map(t => ({
|
||||||
|
label: t.dottedTypeName,
|
||||||
|
kind: typeKindMap[t.typeKind],
|
||||||
|
data: { type:t.shortSignature },
|
||||||
|
sortText: t.dottedTypeName,
|
||||||
|
}))
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!defaultCompletionTypes) {
|
if (!defaultCompletionTypes) {
|
||||||
@@ -641,11 +648,14 @@ connection.onCompletion(
|
|||||||
}
|
}
|
||||||
return [
|
return [
|
||||||
...locals,
|
...locals,
|
||||||
...defaultCompletionTypes.instances,
|
...(show_instances ? defaultCompletionTypes.instances : []),
|
||||||
...defaultCompletionTypes.primitiveTypes,
|
...defaultCompletionTypes.primitiveTypes,
|
||||||
...defaultCompletionTypes.literals,
|
...defaultCompletionTypes.literals,
|
||||||
...defaultCompletionTypes.modifiers,
|
...defaultCompletionTypes.modifiers,
|
||||||
...defaultCompletionTypes.types,
|
...[
|
||||||
|
...defaultCompletionTypes.types,
|
||||||
|
...sourceTypes,
|
||||||
|
].sort(sortBy.label),
|
||||||
...defaultCompletionTypes.packageNames,
|
...defaultCompletionTypes.packageNames,
|
||||||
].map((x,idx) => {
|
].map((x,idx) => {
|
||||||
x.sortText = `${10000+idx}-${x.label}`;
|
x.sortText = `${10000+idx}-${x.label}`;
|
||||||
|
|||||||
Reference in New Issue
Block a user