@Test(dependsOnMethods = "testLockFile") public void testCloseFile() throws WorkspaceDocumentException { documentManager.closeFile(filePath); boolean fileOpen = documentManager.isFileOpen(filePath); Assert.assertFalse(fileOpen); }
@Override public void closeFile(Path filePath) throws WorkspaceDocumentException { if (isFileOpen(filePath)) { Lock lock = documentList.get(filePath).getLock(); try { lock.lock(); documentList.get(filePath).setDocument(null); documentList.remove(filePath); } finally { lock.unlock(); } LSDocumentIdentifier document = new LSDocumentIdentifierImpl(filePath.toUri().toString()); if (document.isWithinProject()) { rescanProjectRoot(filePath); } } else { throw new WorkspaceDocumentException("File " + filePath.toString() + " is not opened in document manager."); } }
WorkspaceDocumentManagerImpl implements WorkspaceDocumentManager { @Override public void closeFile(Path filePath) throws WorkspaceDocumentException { if (isFileOpen(filePath)) { Lock lock = documentList.get(filePath).getLock(); try { lock.lock(); documentList.get(filePath).setDocument(null); documentList.remove(filePath); } finally { lock.unlock(); } LSDocumentIdentifier document = new LSDocumentIdentifierImpl(filePath.toUri().toString()); if (document.isWithinProject()) { rescanProjectRoot(filePath); } } else { throw new WorkspaceDocumentException("File " + filePath.toString() + " is not opened in document manager."); } } }
WorkspaceDocumentManagerImpl implements WorkspaceDocumentManager { @Override public void closeFile(Path filePath) throws WorkspaceDocumentException { if (isFileOpen(filePath)) { Lock lock = documentList.get(filePath).getLock(); try { lock.lock(); documentList.get(filePath).setDocument(null); documentList.remove(filePath); } finally { lock.unlock(); } LSDocumentIdentifier document = new LSDocumentIdentifierImpl(filePath.toUri().toString()); if (document.isWithinProject()) { rescanProjectRoot(filePath); } } else { throw new WorkspaceDocumentException("File " + filePath.toString() + " is not opened in document manager."); } } protected  WorkspaceDocumentManagerImpl(); }
WorkspaceDocumentManagerImpl implements WorkspaceDocumentManager { @Override public void closeFile(Path filePath) throws WorkspaceDocumentException { if (isFileOpen(filePath)) { Lock lock = documentList.get(filePath).getLock(); try { lock.lock(); documentList.get(filePath).setDocument(null); documentList.remove(filePath); } finally { lock.unlock(); } LSDocumentIdentifier document = new LSDocumentIdentifierImpl(filePath.toUri().toString()); if (document.isWithinProject()) { rescanProjectRoot(filePath); } } else { throw new WorkspaceDocumentException("File " + filePath.toString() + " is not opened in document manager."); } } protected  WorkspaceDocumentManagerImpl(); static WorkspaceDocumentManagerImpl getInstance(); @Override boolean isFileOpen(Path filePath); @Override void openFile(Path filePath, String content); @Override void updateFile(Path filePath, List<TextDocumentContentChangeEvent> changeEvent); @Override void setCodeLenses(Path filePath, List<CodeLens> codeLens); @Override void closeFile(Path filePath); @Override List<CodeLens> getCodeLenses(Path filePath); @Override LSDocumentIdentifier getLSDocument(Path filePath); @Override String getFileContent(Path filePath); @Override Optional<Lock> lockFile(Path filePath); @Override Set<Path> getAllFilePaths(); @Override void clearAllFilePaths(); @Override SyntaxTree getTree(Path filePath); @Override void setTree(Path filePath, SyntaxTree newTree); }
WorkspaceDocumentManagerImpl implements WorkspaceDocumentManager { @Override public void closeFile(Path filePath) throws WorkspaceDocumentException { if (isFileOpen(filePath)) { Lock lock = documentList.get(filePath).getLock(); try { lock.lock(); documentList.get(filePath).setDocument(null); documentList.remove(filePath); } finally { lock.unlock(); } LSDocumentIdentifier document = new LSDocumentIdentifierImpl(filePath.toUri().toString()); if (document.isWithinProject()) { rescanProjectRoot(filePath); } } else { throw new WorkspaceDocumentException("File " + filePath.toString() + " is not opened in document manager."); } } protected  WorkspaceDocumentManagerImpl(); static WorkspaceDocumentManagerImpl getInstance(); @Override boolean isFileOpen(Path filePath); @Override void openFile(Path filePath, String content); @Override void updateFile(Path filePath, List<TextDocumentContentChangeEvent> changeEvent); @Override void setCodeLenses(Path filePath, List<CodeLens> codeLens); @Override void closeFile(Path filePath); @Override List<CodeLens> getCodeLenses(Path filePath); @Override LSDocumentIdentifier getLSDocument(Path filePath); @Override String getFileContent(Path filePath); @Override Optional<Lock> lockFile(Path filePath); @Override Set<Path> getAllFilePaths(); @Override void clearAllFilePaths(); @Override SyntaxTree getTree(Path filePath); @Override void setTree(Path filePath, SyntaxTree newTree);  }