Skip to content

Commit

Permalink
adding code templates
Browse files Browse the repository at this point in the history
  • Loading branch information
deniswsrosa committed May 14, 2024
1 parent 0d1e7c1 commit edf3495
Show file tree
Hide file tree
Showing 14 changed files with 598 additions and 76 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.couchbase.intellij.searchworkbench.contributor;

import com.intellij.codeInsight.completion.CompletionResultSet;
import com.intellij.json.psi.JsonObject;
import com.intellij.json.psi.JsonProperty;

Expand All @@ -14,7 +15,7 @@ public boolean accept(String parentKey) {
}

@Override
public void contributeKey(String parentKey, JsonObject jsonObject, List<String> contributors) {
public void contributeKey(String parentKey, JsonObject jsonObject, List<String> contributors, CompletionResultSet result) {
List<String> existingKeys = jsonObject.getPropertyList().stream()
.map(JsonProperty::getName)
.toList();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ protected void addCompletions(@NotNull CompletionParameters parameters,
for (CBSContributor contributor : contributors) {
if (contributor.accept(type)) {
if (isKey) {
contributor.contributeKey(type, jsonObject, suggestions);
contributor.contributeKey(type, jsonObject, suggestions, result);
} else {
contributor.contributeValue(jsonObject, attributeName, suggestions);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.couchbase.intellij.searchworkbench.contributor;

import com.intellij.codeInsight.completion.CompletionResultSet;
import com.intellij.json.psi.JsonObject;

import java.util.List;
Expand All @@ -8,7 +9,7 @@ public interface CBSContributor {

boolean accept(String key);

void contributeKey(String parentKey, JsonObject jsonObject, List<String> contributors);
void contributeKey(String parentKey, JsonObject jsonObject, List<String> contributors, CompletionResultSet result);

void contributeValue(JsonObject jsonObject, String attributeKey, List<String> contributors);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package com.couchbase.intellij.searchworkbench.contributor;

import lombok.AllArgsConstructor;
import lombok.Data;

import java.util.List;

@Data
@AllArgsConstructor
public class CBSTemplateDef {

private String key;
private String desc;

private List<String> attrs;
}

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.couchbase.intellij.searchworkbench.contributor;

import com.intellij.codeInsight.completion.CompletionResultSet;
import com.intellij.json.psi.JsonObject;

import java.util.Arrays;
Expand All @@ -15,7 +16,7 @@ public boolean accept(String parentKey) {
}

@Override
public void contributeKey(String parentKey, JsonObject jsonObject, List<String> contributors) {
public void contributeKey(String parentKey, JsonObject jsonObject, List<String> contributors, CompletionResultSet result) {
ContributorUtil.suggestMissing(jsonObject, keys, contributors);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.couchbase.intellij.searchworkbench.contributor;

import com.intellij.codeInsight.completion.CompletionResultSet;
import com.intellij.json.psi.JsonObject;

import java.util.Arrays;
Expand All @@ -15,7 +16,7 @@ public boolean accept(String parentKey) {
}

@Override
public void contributeKey(String parentKey, JsonObject jsonObject, List<String> contributors) {
public void contributeKey(String parentKey, JsonObject jsonObject, List<String> contributors, CompletionResultSet result) {
ContributorUtil.suggestMissing(jsonObject, keys, contributors);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.couchbase.intellij.searchworkbench.contributor;

import com.intellij.codeInsight.completion.CompletionResultSet;
import com.intellij.json.psi.JsonObject;

import java.util.Arrays;
Expand All @@ -15,7 +16,7 @@ public boolean accept(String parentKey) {
}

@Override
public void contributeKey(String parentKey, JsonObject jsonObject, List<String> contributors) {
public void contributeKey(String parentKey, JsonObject jsonObject, List<String> contributors, CompletionResultSet result) {
ContributorUtil.suggestMissing(jsonObject, keys, contributors);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.couchbase.intellij.searchworkbench.contributor;

import com.intellij.codeInsight.completion.CompletionResultSet;
import com.intellij.json.psi.JsonObject;

import java.util.Arrays;
Expand All @@ -15,7 +16,7 @@ public boolean accept(String parentKey) {
}

@Override
public void contributeKey(String parentKey, JsonObject jsonObject, List<String> contributors) {
public void contributeKey(String parentKey, JsonObject jsonObject, List<String> contributors, CompletionResultSet result) {
ContributorUtil.suggestMissing(jsonObject, keys, contributors);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.couchbase.intellij.searchworkbench.contributor;

import com.intellij.codeInsight.completion.CompletionResultSet;
import com.intellij.json.psi.JsonObject;

import java.util.Arrays;
Expand All @@ -15,7 +16,7 @@ public boolean accept(String parentKey) {
}

@Override
public void contributeKey(String parentKey, JsonObject jsonObject, List<String> contributors) {
public void contributeKey(String parentKey, JsonObject jsonObject, List<String> contributors, CompletionResultSet result) {
ContributorUtil.suggestMissing(jsonObject, keys, contributors);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.couchbase.intellij.searchworkbench.contributor;

import com.intellij.codeInsight.completion.CompletionResultSet;
import com.intellij.json.psi.JsonObject;

import java.util.Arrays;
Expand All @@ -15,7 +16,7 @@ public boolean accept(String parentKey) {
}

@Override
public void contributeKey(String parentKey, JsonObject jsonObject, List<String> contributors) {
public void contributeKey(String parentKey, JsonObject jsonObject, List<String> contributors, CompletionResultSet result) {
ContributorUtil.suggestMissing(jsonObject, keys, contributors);
}

Expand Down
Loading

0 comments on commit edf3495

Please sign in to comment.