Skip to content

Commit

Permalink
Merge branch 'main' into remote_main
Browse files Browse the repository at this point in the history
  • Loading branch information
mayyanar27 authored Oct 28, 2023
2 parents 4e8ac7f + 6a8a9da commit 5147d18
Show file tree
Hide file tree
Showing 71 changed files with 2,284 additions and 632 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci-build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
version: [2022.3.3, 2023.1.3, 2023.2.2]
version: [2022.3.3, 2023.1.3, 2023.2.3]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v3
Expand Down
2 changes: 1 addition & 1 deletion build-all.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/bin/bash

for v in "2022.3.3" "2023.1.3" "2023.2.2"; do
for v in "2022.3.3" "2023.1.3" "2023.2.3"; do
./build.sh $v
done
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ allprojects {
}

group = 'com.github.camel-tooling'
version = '1.1.1'
version = '1.1.5'
}

subprojects {
Expand Down
8 changes: 4 additions & 4 deletions camel-idea-plugin/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -66,17 +66,17 @@ dependencies {
// Needed to avoid conflicts with the version of the maven resolver used by IntelliJ
implementation "org.apache.maven.resolver:maven-resolver-api:${mavenResolverVersion}"
implementation "org.apache.maven.resolver:maven-resolver-impl:${mavenResolverVersion}"
implementation "io.github.classgraph:classgraph:4.8.162"
implementation "com.fasterxml.jackson.dataformat:jackson-dataformat-yaml:2.15.2"
implementation "io.fabric8:kubernetes-model-apiextensions:6.9.0"
implementation "io.github.classgraph:classgraph:4.8.163"
implementation "com.fasterxml.jackson.dataformat:jackson-dataformat-yaml:2.15.3"
implementation "io.fabric8:kubernetes-model-apiextensions:6.9.1"

testImplementation "org.apache.camel:camel-core:${camelVersion}"
testImplementation "org.apache.camel.springboot:camel-spring-boot:${camelVersion}"
testImplementation "org.apache.camel.springboot:camel-file-starter:${camelVersion}"
testImplementation 'org.jboss.shrinkwrap:shrinkwrap-depchain:1.2.6'
testImplementation 'org.jboss.shrinkwrap.resolver:shrinkwrap-resolver-depchain:3.2.1'
testImplementation 'org.hamcrest:hamcrest-all:1.3'
testImplementation 'org.springframework:spring-context:6.0.12'
testImplementation 'org.springframework:spring-context:6.0.13'
testImplementation "org.apache.camel:camel-jsonpath:${camelVersion}"
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@

import com.github.cameltooling.idea.completion.extension.CamelEndpointNameCompletionExtension;
import com.github.cameltooling.idea.completion.extension.CamelEndpointSmartCompletionExtension;
import com.github.cameltooling.idea.completion.extension.CamelKameletNameCompletion;
import com.github.cameltooling.idea.completion.extension.CamelKameletOptionNameCompletion;
import com.github.cameltooling.idea.completion.extension.CamelKameletOptionValueCompletion;
import com.github.cameltooling.idea.completion.header.CamelHeaderEndpointSource;
import com.github.cameltooling.idea.completion.header.CamelYamlHeaderNameCompletion;
import com.github.cameltooling.idea.completion.header.CamelYamlHeaderValueCompletion;
Expand All @@ -26,13 +29,21 @@
import com.github.cameltooling.idea.util.YamlPatternConditions;
import com.intellij.codeInsight.completion.CompletionInitializationContext;
import com.intellij.codeInsight.completion.CompletionType;
import com.intellij.patterns.PatternCondition;
import com.intellij.patterns.PlatformPatterns;
import com.intellij.patterns.PsiElementPattern;
import com.intellij.patterns.StandardPatterns;
import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiFile;
import com.intellij.psi.TokenType;
import com.intellij.util.ProcessingContext;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.yaml.YAMLElementTypes;
import org.jetbrains.yaml.YAMLTokenTypes;
import org.jetbrains.yaml.psi.YAMLKeyValue;
import org.jetbrains.yaml.psi.YAMLMapping;
import org.jetbrains.yaml.psi.YAMLSequence;
import org.jetbrains.yaml.psi.YAMLSequenceItem;

import static com.intellij.patterns.PlatformPatterns.psiElement;

Expand All @@ -41,6 +52,40 @@
*/
public class CamelYamlFileReferenceContributor extends CamelContributor {

private static final PatternCondition<PsiElement> WITH_FIRST_CHILD_IS_PROPERTIES = YamlPatternConditions.withFirstChild(
psiElement(YAMLTokenTypes.SCALAR_KEY)
.withText("properties")
);
private static final PsiElementPattern.Capture<YAMLMapping> IS_KIND_KAMELET = psiElement(YAMLMapping.class)
.withChild(
psiElement(YAMLKeyValue.class)
.with(
YamlPatternConditions.withFirstChild(
psiElement(YAMLTokenTypes.SCALAR_KEY)
.withText("ref")
)
)
.withChild(
psiElement(YAMLMapping.class)

.withChild(
psiElement(YAMLKeyValue.class)
.with(
YamlPatternConditions.withPair("kind", "Kamelet")
)
)
.withChild(
psiElement(YAMLKeyValue.class)
.with(
YamlPatternConditions.withFirstChild(
PlatformPatterns.psiElement(YAMLTokenTypes.SCALAR_KEY)
.withText("name")
)
)
)
)
);

public CamelYamlFileReferenceContributor() {
addCompletionExtension(new CamelEndpointNameCompletionExtension());
addCompletionExtension(new CamelEndpointSmartCompletionExtension(false));
Expand Down Expand Up @@ -212,5 +257,177 @@ public CamelYamlFileReferenceContributor() {
),
new CamelYamlPropertyValueCompletion()
);
// Detect the name of a Kamelet in a Kamelet binding
addCamelKameletNameCompletion("source", true);
addCamelKameletNameCompletion("steps", false);
addCamelKameletNameCompletion("sink", false);
addCamelKameletOptionNameCompletion();
addCamelKameletOptionValueCompletion();
}

private void addCamelKameletNameCompletion(String ancestorKeyName, boolean onlyConsumer) {
extend(CompletionType.BASIC,
psiElement(YAMLTokenTypes.TEXT)
.withSuperParent(
2,
psiElement(YAMLKeyValue.class)
.with(
YamlPatternConditions.withFirstChild(
PlatformPatterns.psiElement(YAMLTokenTypes.SCALAR_KEY)
.withText("name")
)
)
.withParent(
psiElement(YAMLMapping.class)
.withChild(
PlatformPatterns.psiElement(YAMLKeyValue.class)
.with(
YamlPatternConditions.withPair("kind", "Kamelet")
)
)
)
)
.withSuperParent(
4,
psiElement(YAMLKeyValue.class)
.with(
YamlPatternConditions.withFirstChild(
PlatformPatterns.psiElement(YAMLTokenTypes.SCALAR_KEY)
.withText("ref")
)
)
)
.withSuperParent(
6,
StandardPatterns.or(
psiElement(YAMLKeyValue.class)
.with(
YamlPatternConditions.withFirstChild(
PlatformPatterns.psiElement(YAMLTokenTypes.SCALAR_KEY)
.withText(ancestorKeyName)
)
),
psiElement(YAMLSequenceItem.class)
.withSuperParent(
2,
psiElement(YAMLKeyValue.class)
.with(
YamlPatternConditions.withFirstChild(
PlatformPatterns.psiElement(YAMLTokenTypes.SCALAR_KEY)
.withText(ancestorKeyName)
)
)
)
)

),
new CamelKameletNameCompletion(onlyConsumer)
);
}

private void addCamelKameletOptionNameCompletion() {
extend(CompletionType.BASIC,
psiElement()
.with(
YamlPatternConditions.or(
psiElement(YAMLTokenTypes.TEXT)
.withSuperParent(
2,
PlatformPatterns.psiElement(YAMLKeyValue.class)
.with(
WITH_FIRST_CHILD_IS_PROPERTIES
)
),
psiElement(YAMLTokenTypes.INDENT)
.afterSibling(
PlatformPatterns.psiElement(YAMLKeyValue.class)
.with(
WITH_FIRST_CHILD_IS_PROPERTIES
)
),
psiElement(YAMLTokenTypes.TEXT)
.withSuperParent(
3,
PlatformPatterns.psiElement(YAMLKeyValue.class)
.with(
WITH_FIRST_CHILD_IS_PROPERTIES
)
)
)
)
.withAncestor(
5,
StandardPatterns.or(
psiElement(YAMLKeyValue.class)
.with(
YamlPatternConditions.withFirstChild(
PlatformPatterns.psiElement(YAMLTokenTypes.SCALAR_KEY)
.with(YamlPatternConditions.withText("source", "sink"))
)
)
.withChild(IS_KIND_KAMELET),
psiElement(YAMLSequenceItem.class)
.withSuperParent(
2,
psiElement(YAMLKeyValue.class)
.with(
YamlPatternConditions.withFirstChild(
PlatformPatterns.psiElement(YAMLTokenTypes.SCALAR_KEY)
.withText("steps")
)
)
)
.withChild(IS_KIND_KAMELET)
)
),
new CamelKameletOptionNameCompletion()
);
}


private void addCamelKameletOptionValueCompletion() {
extend(CompletionType.BASIC,
psiElement()
.withParent(
psiElement().with(
YamlPatternConditions.withElementType(
YAMLElementTypes.SCALAR_PLAIN_VALUE, YAMLElementTypes.SCALAR_QUOTED_STRING
)
)
)
.withAncestor(
4,
PlatformPatterns.psiElement(YAMLKeyValue.class)
.with(
WITH_FIRST_CHILD_IS_PROPERTIES
)
)
.withAncestor(
6,
StandardPatterns.or(
psiElement(YAMLKeyValue.class)
.with(
YamlPatternConditions.withFirstChild(
PlatformPatterns.psiElement(YAMLTokenTypes.SCALAR_KEY)
.with(YamlPatternConditions.withText("source", "sink"))
)
)
.withChild(IS_KIND_KAMELET),
psiElement(YAMLSequenceItem.class)
.withSuperParent(
2,
psiElement(YAMLKeyValue.class)
.with(
YamlPatternConditions.withFirstChild(
PlatformPatterns.psiElement(YAMLTokenTypes.SCALAR_KEY)
.withText("steps")
)
)
)
.withChild(IS_KIND_KAMELET)
)
),
new CamelKameletOptionValueCompletion()
);
}
}
Loading

0 comments on commit 5147d18

Please sign in to comment.