Skip to content

Commit

Permalink
refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
Cammisuli committed Aug 23, 2022
1 parent 29098a1 commit 28b14cd
Showing 1 changed file with 21 additions and 15 deletions.
36 changes: 21 additions & 15 deletions apps/nxls/src/completions/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,30 @@ export async function getCompletionItems(
node: ASTNode,
document: TextDocument
): Promise<CompletionItem[]> {
const items: Array<CompletionItem> = [];

if (!workingPath) {
return items;
return [];
}

const items = completionItems(workingPath, node, document);

if (hasCompletionType(schema)) {
const completion = schema[X_COMPLETION_TYPE];
if (hasCompletionGlob(schema)) {
return items(completion, schema[X_COMPLETION_GLOB]);
}

return items(completion);
} else {
return [];
}
}

const completionItems = async (
function completionItems(
workingPath: string,
node: ASTNode,
document: TextDocument
) {
return async (
completion: CompletionType,
glob?: string
): Promise<CompletionItem[]> => {
Expand All @@ -51,15 +68,4 @@ export async function getCompletionItems(
}
}
};

if (hasCompletionType(schema)) {
const completion = schema[X_COMPLETION_TYPE];
if (hasCompletionGlob(schema)) {
return completionItems(completion, schema[X_COMPLETION_GLOB]);
}

return completionItems(completion);
} else {
return [];
}
}

0 comments on commit 28b14cd

Please sign in to comment.