Search in sources :

Example 26 with ITextFileBuffer

use of org.eclipse.core.filebuffers.ITextFileBuffer in project eclipse.platform.text by eclipse.

the class FileBuffersForNonExistingWorkspaceFiles method testBug118199_fixed.

@Test
public void testBug118199_fixed() throws Exception {
    IPath location = getPath();
    IFile file = getProject().getWorkspace().getRoot().getFileForLocation(location);
    if (file == null) {
        // $NON-NLS-1$ //$NON-NLS-2$
        throw new IOException("File '" + location + "' can not be found.");
    }
    IPath path = file.getFullPath();
    assertFalse(file.exists());
    fManager.connect(path, LocationKind.IFILE, null);
    try {
        ITextFileBuffer buffer = fManager.getTextFileBuffer(path, LocationKind.IFILE);
        buffer.getDocument().set("test");
        buffer.commit(null, false);
    } finally {
        fManager.disconnect(path, LocationKind.IFILE, null);
    }
    assertTrue(file.exists());
}
Also used : IFile(org.eclipse.core.resources.IFile) IPath(org.eclipse.core.runtime.IPath) ITextFileBuffer(org.eclipse.core.filebuffers.ITextFileBuffer) IOException(java.io.IOException) Test(org.junit.Test)

Example 27 with ITextFileBuffer

use of org.eclipse.core.filebuffers.ITextFileBuffer in project eclipse.platform.text by eclipse.

the class FileBuffersForNonExistingWorkspaceFiles method testBug118199.

@Test
public void testBug118199() throws Exception {
    IFile file = getProject().getWorkspace().getRoot().getFile(getPath());
    assertFalse(file.exists());
    fManager.connect(getPath(), LocationKind.NORMALIZE, null);
    try {
        ITextFileBuffer buffer = fManager.getTextFileBuffer(getPath(), LocationKind.NORMALIZE);
        buffer.getDocument().set("test");
        buffer.commit(null, false);
    } finally {
        fManager.disconnect(getPath(), LocationKind.NORMALIZE, null);
    }
    assertFalse(file.exists());
}
Also used : IFile(org.eclipse.core.resources.IFile) ITextFileBuffer(org.eclipse.core.filebuffers.ITextFileBuffer) Test(org.junit.Test)

Example 28 with ITextFileBuffer

use of org.eclipse.core.filebuffers.ITextFileBuffer in project eclipse.platform.text by eclipse.

the class FileStoreFileBufferFunctions method test1.

/*
	 * Tests getLocation.
	 */
@Test
public void test1() throws Exception {
    fManager.connectFileStore(fFileStore, null);
    try {
        ITextFileBuffer buffer = fManager.getFileStoreTextFileBuffer(fFileStore);
        assertEquals(fFileStore, buffer.getFileStore());
    } finally {
        fManager.disconnectFileStore(fFileStore, null);
    }
}
Also used : ITextFileBuffer(org.eclipse.core.filebuffers.ITextFileBuffer) Test(org.junit.Test)

Example 29 with ITextFileBuffer

use of org.eclipse.core.filebuffers.ITextFileBuffer in project eclipse.platform.text by eclipse.

the class FileStoreFileBufferFunctions method test9_1.

/*
	 * Test resetStateValidation.
	 */
@Test
public void test9_1() throws Exception {
    fManager.connectFileStore(fFileStore, null);
    try {
        ITextFileBuffer fileBuffer = fManager.getFileStoreTextFileBuffer(fFileStore);
        fileBuffer.validateState(null, null);
        fileBuffer.resetStateValidation();
        if (isStateValidationSupported())
            assertFalse(fileBuffer.isStateValidated());
    } finally {
        fManager.disconnectFileStore(fFileStore, null);
    }
}
Also used : ITextFileBuffer(org.eclipse.core.filebuffers.ITextFileBuffer) Test(org.junit.Test)

Example 30 with ITextFileBuffer

use of org.eclipse.core.filebuffers.ITextFileBuffer in project eclipse.platform.text by eclipse.

the class FileStoreFileBufferFunctions method testGetFileStoreFileBuffers.

@Test
public void testGetFileStoreFileBuffers() throws Exception {
    fManager.connectFileStore(fFileStore, null);
    try {
        ITextFileBuffer buffer = fManager.getFileStoreTextFileBuffer(fFileStore);
        assertNotNull(buffer);
        IFileBuffer[] fileBuffers = fManager.getFileStoreFileBuffers();
        assertNotNull(fileBuffers);
        assertEquals(1, fileBuffers.length);
        assertSame(buffer, fileBuffers[0]);
        fileBuffers = fManager.getFileBuffers();
        assertNotNull(fileBuffers);
        assertEquals(0, fileBuffers.length);
    } finally {
        fManager.disconnectFileStore(fFileStore, null);
    }
}
Also used : IFileBuffer(org.eclipse.core.filebuffers.IFileBuffer) ITextFileBuffer(org.eclipse.core.filebuffers.ITextFileBuffer) Test(org.junit.Test)

Aggregations

ITextFileBuffer (org.eclipse.core.filebuffers.ITextFileBuffer)133 Test (org.junit.Test)85 IDocument (org.eclipse.jface.text.IDocument)54 IFileBuffer (org.eclipse.core.filebuffers.IFileBuffer)37 ITextFileBufferManager (org.eclipse.core.filebuffers.ITextFileBufferManager)35 IPath (org.eclipse.core.runtime.IPath)31 IFile (org.eclipse.core.resources.IFile)18 BadLocationException (org.eclipse.jface.text.BadLocationException)15 IFileStore (org.eclipse.core.filesystem.IFileStore)9 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)9 CoreException (org.eclipse.core.runtime.CoreException)8 Position (org.eclipse.jface.text.Position)8 IFileInfo (org.eclipse.core.filesystem.IFileInfo)7 IAnnotationModel (org.eclipse.jface.text.source.IAnnotationModel)7 Match (org.eclipse.search.ui.text.Match)7 IFolder (org.eclipse.core.resources.IFolder)5 IStatus (org.eclipse.core.runtime.IStatus)5 Path (org.eclipse.core.runtime.Path)5 SubProgressMonitor (org.eclipse.core.runtime.SubProgressMonitor)5 Status (org.eclipse.core.runtime.Status)4