Skip to content

Commit

Permalink
Minor fix
Browse files Browse the repository at this point in the history
  • Loading branch information
prajwal-pai77 committed Jul 18, 2024
1 parent 9a39b63 commit 900ed48
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import { ctlCbsContributor } from "./ctlCbsContributor";
import { shapeCbsContributor } from "./shapeCbsContributor";
import { SearchWorkbench } from "../searchWorkbench";
import { logger } from "../../../../logger/logger";
import { CacheService } from "../../../../util/cacheService/cacheService";

export class AutocompleteVisitor {
public topLevelKeywords: string[] = [
Expand Down Expand Up @@ -51,6 +52,7 @@ export class AutocompleteVisitor {
document: vscode.TextDocument,
position: vscode.Position,
searchWorkBench?: SearchWorkbench,
cache?:CacheService
): Promise<vscode.CompletionItem[]> {
const text = document.getText();
// const rootNode = jsonc.parseTree(text);
Expand Down Expand Up @@ -125,11 +127,13 @@ export class AutocompleteVisitor {
if (
attributeName == "field" &&
queryContext?.bucketName &&
queryContext?.indexName
queryContext?.indexName &&
cache
) {
fields = await fieldsContributor.getFieldNames(
queryContext?.bucketName,
queryContext?.indexName,
cache
);
}
contributor.contributeValue(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,15 @@ export class fieldsContributor {
static async getFieldNames(
bucketName: string,
indexName: string,
cache: CacheService
): Promise<string[]> {
const cache = new CacheService();
const suggestions: string[] = [];
const connection = getActiveConnection();
if (!connection) {
return [];
}
const api = new CouchbaseRestAPI(connection);

cache.loadCache(connection);
const bucketCache = cache.getCache(bucketName);
const result = await api.fetchSearchIndexDefinition(indexName);
if (!bucketCache) {
Expand Down
2 changes: 1 addition & 1 deletion src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ const provider = vscode.languages.registerCompletionItemProvider(
{
async provideCompletionItems(document, position, token, context) {
const autoComplete = new AutocompleteVisitor();
const suggestions = await autoComplete.getAutoCompleteContributor(document, position, currentSearchWorkbench);
const suggestions = await autoComplete.getAutoCompleteContributor(document, position, currentSearchWorkbench, cacheService);
if (suggestions.length === 0) {
return [new vscode.CompletionItem('', vscode.CompletionItemKind.Text)].map(item => {
item.sortText = '\u0000';
Expand Down

0 comments on commit 900ed48

Please sign in to comment.