-
Notifications
You must be signed in to change notification settings - Fork 609
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: reparsing schema when moving rank profile to separate file
- Loading branch information
Showing
8 changed files
with
118 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
54 changes: 54 additions & 0 deletions
54
...language-server/src/main/java/ai/vespa/schemals/lsp/command/commandtypes/CommandList.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
package ai.vespa.schemals.lsp.command.commandtypes; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
import java.util.Optional; | ||
|
||
import org.eclipse.lsp4j.ExecuteCommandParams; | ||
|
||
import com.google.gson.JsonArray; | ||
import com.google.gson.JsonObject; | ||
|
||
import ai.vespa.schemals.lsp.command.CommandRegistry; | ||
import ai.vespa.schemals.context.EventExecuteCommandContext; | ||
|
||
/** | ||
* CommandList | ||
* Represents a chain of commands to be executed one after another. | ||
*/ | ||
public class CommandList implements SchemaCommand { | ||
|
||
List<SchemaCommand> commandsToExecute = new ArrayList<>(); | ||
|
||
@Override | ||
public int getArity() { | ||
return -1; | ||
} | ||
|
||
@Override | ||
public boolean setArguments(List<Object> arguments) { | ||
commandsToExecute.clear(); | ||
|
||
for (Object object : arguments) { | ||
if (!(object instanceof JsonObject))return false; | ||
|
||
JsonObject jsonObject = (JsonObject)object; | ||
|
||
if (!jsonObject.has("command") || !jsonObject.get("command").isJsonPrimitive())return false; | ||
if (!jsonObject.has("arguments") || !jsonObject.get("arguments").isJsonArray())return false; | ||
|
||
var params = new ExecuteCommandParams(jsonObject.get("command").getAsString(), new ArrayList<Object>(((JsonArray)jsonObject.get("arguments")).asList())); | ||
Optional<SchemaCommand> command = CommandRegistry.getCommand(params); | ||
if (command.isEmpty()) return false; | ||
commandsToExecute.add(command.get()); | ||
} | ||
return true; | ||
} | ||
|
||
@Override | ||
public void execute(EventExecuteCommandContext context) { | ||
for (SchemaCommand cmd : commandsToExecute) { | ||
cmd.execute(context); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
...nguage-server/src/main/java/ai/vespa/schemals/lsp/command/commandtypes/DocumentParse.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package ai.vespa.schemals.lsp.command.commandtypes; | ||
|
||
import java.util.List; | ||
|
||
import com.google.gson.JsonPrimitive; | ||
|
||
import ai.vespa.schemals.context.EventExecuteCommandContext; | ||
import ai.vespa.schemals.schemadocument.DocumentManager; | ||
|
||
/** | ||
* DocumentParse | ||
*/ | ||
public class DocumentParse implements SchemaCommand { | ||
private String fileURI; | ||
|
||
@Override | ||
public int getArity() { | ||
return 1; | ||
} | ||
|
||
@Override | ||
public boolean setArguments(List<Object> arguments) { | ||
assert arguments.size() == getArity(); | ||
|
||
if (!(arguments.get(0) instanceof JsonPrimitive)) | ||
return false; | ||
|
||
JsonPrimitive arg = (JsonPrimitive) arguments.get(0); | ||
this.fileURI = arg.getAsString(); | ||
return true; | ||
} | ||
|
||
@Override | ||
public void execute(EventExecuteCommandContext context) { | ||
DocumentManager document = context.scheduler.getDocument(fileURI); | ||
if (document == null) return; | ||
document.reparseContent(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters