use of org.ballerinalang.langserver.workspace.WorkspaceDocumentManagerImpl in project ballerina by ballerina-lang.
the class CompletionTestUtil method prepareDocumentManager.
/**
* Prepare the Document manager instance with the given file and issue the did open operation.
*
* @param uri File Uri
* @param balContent File Content
* @return {@link WorkspaceDocumentManagerImpl}
*/
public static WorkspaceDocumentManagerImpl prepareDocumentManager(String uri, String balContent) {
Path openedPath;
WorkspaceDocumentManagerImpl documentManager = WorkspaceDocumentManagerImpl.getInstance();
openedPath = Paths.get(uri);
documentManager.openFile(openedPath, balContent);
return documentManager;
}
use of org.ballerinalang.langserver.workspace.WorkspaceDocumentManagerImpl in project ballerina by ballerina-lang.
the class CompletionTest method test.
// @Test(dataProvider = "completion-data-provider")
public void test(String config, String configPath) {
String configJsonPath = SAMPLES_COPY_DIR + File.separator + configPath + File.separator + config;
JsonObject jsonObject = FileUtils.fileContentAsObject(configJsonPath);
JsonArray expectedItems = jsonObject.get("items").getAsJsonArray();
JsonObject positionObj = jsonObject.get("position").getAsJsonObject();
String balPath = SAMPLES_COPY_DIR + File.separator + jsonObject.get("source").getAsString();
Position position = new Position();
String content = FileUtils.fileContent(balPath);
position.setLine(positionObj.get("line").getAsInt());
position.setCharacter(positionObj.get("character").getAsInt());
TextDocumentPositionParams positionParams = CompletionTestUtil.getPositionParams(position, balPath);
WorkspaceDocumentManagerImpl documentManager = CompletionTestUtil.prepareDocumentManager(balPath, content);
List<CompletionItem> responseItemList = CompletionTestUtil.getCompletions(documentManager, positionParams);
List<CompletionItem> expectedList = CompletionTestUtil.getExpectedItemList(expectedItems);
Assert.assertEquals(true, CompletionTestUtil.isSubList(expectedList, responseItemList));
}
Aggregations