summaryrefslogtreecommitdiffstats
path: root/integration
diff options
context:
space:
mode:
authorJon Bratseth <bratseth@gmail.com>2022-02-14 14:11:33 +0100
committerJon Bratseth <bratseth@gmail.com>2022-02-14 14:11:33 +0100
commita0c5e6317fb8720eeafa50a4c68f9b6f460029eb (patch)
treecbc636d5d198f3fda2a9a0d82b902f6a0b31b3d4 /integration
parentba03fb8bd9150adc08fca30c2c72e6edd6ff8151 (diff)
Retrieve project from definition
Diffstat (limited to 'integration')
-rw-r--r--integration/intellij/src/main/java/ai/vespa/intellij/schema/findUsages/SdFindUsagesHandler.java2
-rw-r--r--integration/intellij/src/main/java/ai/vespa/intellij/schema/hierarchy/SdCallTreeStructure.java2
-rw-r--r--integration/intellij/src/main/java/ai/vespa/intellij/schema/model/Schema.java13
3 files changed, 7 insertions, 10 deletions
diff --git a/integration/intellij/src/main/java/ai/vespa/intellij/schema/findUsages/SdFindUsagesHandler.java b/integration/intellij/src/main/java/ai/vespa/intellij/schema/findUsages/SdFindUsagesHandler.java
index 00b9590c5e9..5029d51405f 100644
--- a/integration/intellij/src/main/java/ai/vespa/intellij/schema/findUsages/SdFindUsagesHandler.java
+++ b/integration/intellij/src/main/java/ai/vespa/intellij/schema/findUsages/SdFindUsagesHandler.java
@@ -34,7 +34,7 @@ public class SdFindUsagesHandler extends FindUsagesHandler {
public SdFindUsagesHandler(PsiElement psiElement) {
super(psiElement);
PsiFile file = psiElement.getContainingFile();
- functionsMap = file instanceof SdFile ? new Schema((SdFile)file, null, psiElement.getProject()).definedFunctions()
+ functionsMap = file instanceof SdFile ? new Schema((SdFile)file, null).definedFunctions()
: Map.of();
}
diff --git a/integration/intellij/src/main/java/ai/vespa/intellij/schema/hierarchy/SdCallTreeStructure.java b/integration/intellij/src/main/java/ai/vespa/intellij/schema/hierarchy/SdCallTreeStructure.java
index 2abcb182698..50c65b21a81 100644
--- a/integration/intellij/src/main/java/ai/vespa/intellij/schema/hierarchy/SdCallTreeStructure.java
+++ b/integration/intellij/src/main/java/ai/vespa/intellij/schema/hierarchy/SdCallTreeStructure.java
@@ -37,7 +37,7 @@ public abstract class SdCallTreeStructure extends HierarchyTreeStructure {
super(project, new SdCallHierarchyNodeDescriptor(null, element, true));
myScopeType = currentScopeType;
myFile = (SdFile) element.getContainingFile();
- functionsMap = new Schema(myFile, null, project).definedFunctions();
+ functionsMap = new Schema(myFile, null).definedFunctions();
ranksHeritageMap = new HashMap<>();
}
diff --git a/integration/intellij/src/main/java/ai/vespa/intellij/schema/model/Schema.java b/integration/intellij/src/main/java/ai/vespa/intellij/schema/model/Schema.java
index 73d59b75e8e..94c4a85c182 100644
--- a/integration/intellij/src/main/java/ai/vespa/intellij/schema/model/Schema.java
+++ b/integration/intellij/src/main/java/ai/vespa/intellij/schema/model/Schema.java
@@ -30,16 +30,12 @@ public class Schema {
/** The path to this schema */
private final Path path;
- /** The project this is part of */
- private final Project project;
-
/** The schema this inherits, or empty if none. Resolved lazily. */
private Optional<Schema> inherited = null;
- public Schema(SdFile definition, Path path, Project project) {
+ public Schema(SdFile definition, Path path) {
this.definition = definition;
this.path = path;
- this.project = project;
}
public String name() { return definition.getName().substring(0, definition.getName().length() - 3); }
@@ -53,14 +49,15 @@ public class Schema {
return inherited = AST.inherits(schemaDefinition.get())
.stream()
.findFirst() // Only one schema can be inherited; ignore any following
- .map(inheritedNode -> fromProjectFile(project, path.getParentPath().append(inheritedNode.getText() + ".sd")));
+ .map(inheritedNode -> fromProjectFile(definition.getProject(), path.getParentPath().append(inheritedNode.getText() + ".sd")));
}
/** Returns a rank profile belonging to this, defined either inside it or in a separate .profile file */
public Optional<RankProfile> rankProfile(String name) {
var definition = findProfileElement(name, this.definition); // Look up in this
if (definition.isEmpty()) { // Look up in a separate file schema-name/profile-name.profile
- Optional<PsiFile> file = Files.open(path.getParentPath().append(name()).append(name + ".profile"), project);
+ Optional<PsiFile> file = Files.open(path.getParentPath().append(name()).append(name + ".profile"),
+ this.definition.getProject());
if (file.isPresent())
definition = findProfileElement(name, file.get());
}
@@ -98,7 +95,7 @@ public class Schema {
throw new IllegalArgumentException("Could not find file '" + file + "'");
if ( ! (psiFile.get() instanceof SdFile))
throw new IllegalArgumentException(file + " is not a schema file");
- return new Schema((SdFile)psiFile.get(), file, project);
+ return new Schema((SdFile)psiFile.get(), file);
}
}