Search in sources :

Example 6 with FileURI

use of org.eclipse.n4js.workspace.locations.FileURI in project n4js by eclipse.

the class AbstractIdeTest method createFile.

/**
 * Same as {@link #createFile(FileURI, CharSequence)}, using the {@link #DEFAULT_SOURCE_FOLDER}.
 */
protected void createFile(String projectName, String modulePathAndName, CharSequence content) {
    FileURI projectRoot = toFileURI(getProjectRoot(projectName));
    NameAndExtension nameAndExt = testWorkspaceManager.getN4JSNameAndExtension(modulePathAndName);
    String filePathAndName = nameAndExt.extension == null ? modulePathAndName + "." + TestWorkspaceManager.DEFAULT_EXTENSION : modulePathAndName;
    FileURI fileURI = projectRoot.resolve(DEFAULT_SOURCE_FOLDER).resolve(filePathAndName);
    createFile(fileURI, content);
}
Also used : FileURI(org.eclipse.n4js.workspace.locations.FileURI) NameAndExtension(org.eclipse.n4js.ide.tests.helper.server.TestWorkspaceManager.NameAndExtension)

Example 7 with FileURI

use of org.eclipse.n4js.workspace.locations.FileURI in project n4js by eclipse.

the class AbstractIdeTest method renameFile.

/**
 * Same as {@link #renameFileOnDiskWithoutNotification(FileURI, String)}, but also notifies the server.
 */
protected void renameFile(FileURI fileURI, String newFileNameIncludingExtension) {
    FileURI fileURIRenamed = fileURI.getParent().appendSegment(newFileNameIncludingExtension);
    internalMoveFile(fileURI, fileURIRenamed, true);
}
Also used : FileURI(org.eclipse.n4js.workspace.locations.FileURI)

Example 8 with FileURI

use of org.eclipse.n4js.workspace.locations.FileURI in project n4js by eclipse.

the class AbstractIdeTest method changeNonOpenedFile.

/**
 * Change a non-opened file <em>on disk</em> and notify the LSP server.
 * <p>
 * Use method {@link #changeOpenedFile(String, Pair...)} instead if the file was previously opened with one of the
 * {@link #openFile(FileURI) #openFile()} methods.
 *
 * @param modification
 *            a function returning the desired new content when given the file's current content on disk.
 */
protected void changeNonOpenedFile(String moduleName, Function<String, ? extends CharSequence> modification) {
    FileURI fileURI = getFileURIFromModuleName(moduleName);
    changeNonOpenedFile(fileURI, modification);
}
Also used : FileURI(org.eclipse.n4js.workspace.locations.FileURI)

Example 9 with FileURI

use of org.eclipse.n4js.workspace.locations.FileURI in project n4js by eclipse.

the class AbstractIdeTest method openFile.

/**
 * Same as {@link #openFile(FileURI)}, accepting a module name instead of a file URI.
 */
protected void openFile(String moduleName) {
    FileURI fileURI = getFileURIFromModuleName(moduleName);
    openFile(fileURI);
}
Also used : FileURI(org.eclipse.n4js.workspace.locations.FileURI)

Example 10 with FileURI

use of org.eclipse.n4js.workspace.locations.FileURI in project n4js by eclipse.

the class AbstractIdeTest method assertOutputFileContains.

/**
 * Asserts the output file of the given module located in the given project contains the given sub-string.
 */
protected void assertOutputFileContains(String projectName, String moduleName, CharSequence expectedSubString) {
    FileURI outputFileURI = toFileURI(getOutputFile(projectName, moduleName));
    String outputCode = getContentOfFileOnDisk(outputFileURI);
    Assert.assertTrue("output code did not contain the expected sub-string:\n" + "EXPECTED SUB-STRING: " + expectedSubString + "\n" + "ACTUAL OUTPUT CODE:\n" + outputCode, outputCode.contains(expectedSubString));
}
Also used : FileURI(org.eclipse.n4js.workspace.locations.FileURI)

Aggregations

FileURI (org.eclipse.n4js.workspace.locations.FileURI)49 List (java.util.List)13 Path (java.nio.file.Path)11 ArrayList (java.util.ArrayList)11 File (java.io.File)10 Position (org.eclipse.lsp4j.Position)9 Either (org.eclipse.lsp4j.jsonrpc.messages.Either)9 IOException (java.io.IOException)7 CompletionList (org.eclipse.lsp4j.CompletionList)7 Collections (java.util.Collections)6 Range (org.eclipse.lsp4j.Range)6 Lists (com.google.common.collect.Lists)5 Sets (com.google.common.collect.Sets)5 Files (java.nio.file.Files)5 LinkedHashSet (java.util.LinkedHashSet)5 Set (java.util.Set)5 CompletableFuture (java.util.concurrent.CompletableFuture)5 URI (org.eclipse.emf.common.util.URI)5 CompletionItem (org.eclipse.lsp4j.CompletionItem)5 Diagnostic (org.eclipse.lsp4j.Diagnostic)5