test_class.declarator: documentManager
test_class.modifier: private
test_class.original_string: private WorkspaceDocumentManagerImpl documentManager;
test_class.type: WorkspaceDocumentManagerImpl
test_class.var_name: documentManager
test_class.declarator: filePath
test_class.modifier: private
test_class.original_string: private Path filePath;
test_class.type: Path
test_class.var_name: filePath
test_class.declarator: docUpdatePath1
test_class.modifier: private
test_class.original_string: private Path docUpdatePath1;
test_class.type: Path
test_class.var_name: docUpdatePath1
test_class.declarator: docUpdatePath2
test_class.modifier: private
test_class.original_string: private Path docUpdatePath2;
test_class.type: Path
test_class.var_name: docUpdatePath2
test_class.declarator: docUpdatePath3
test_class.modifier: private
test_class.original_string: private Path docUpdatePath3;
test_class.type: Path
test_class.var_name: docUpdatePath3
test_class.declarator: RES_DIR = Paths.get("src/test/resources/").toAbsolutePath()
test_class.modifier: public static final
test_class.original_string: public static final Path RES_DIR = Paths.get("src/test/resources/").toAbsolutePath();
test_class.type: Path
test_class.var_name: RES_DIR
test_class.file: language-server/modules/langserver-compiler/src/test/java/org/ballerinalang/langserver/compiler/workspace/WorkspaceDocumentManagerImplTest.java
test_class.identifier: WorkspaceDocumentManagerImplTest
test_case.body: @Test(dependsOnMethods = "testGetFileContent")
      public void testUpdateFile() throws IOException, WorkspaceDocumentException {
          String updateContent = readAll(filePath.toFile()) + "\nfunction foo(){\n}\n";
          // Update the file
          Optional<Lock> lock = documentManager.lockFile(filePath);
          try {
              TextDocumentContentChangeEvent changeEvent = new TextDocumentContentChangeEvent(updateContent);
              documentManager.updateFile(filePath, Collections.singletonList(changeEvent));
          } finally {
              lock.ifPresent(Lock::unlock);
          }
          // Call get file content
          String actualContent = documentManager.getFileContent(filePath);
          // Test actual against expected content
          Assert.assertEquals(actualContent, updateContent);
      }
test_case.class_method_signature: WorkspaceDocumentManagerImplTest.testUpdateFile()
test_case.full_signature: @Test(dependsOnMethods = "testGetFileContent") public void testUpdateFile()
test_case.identifier: testUpdateFile
test_case.invocations: readAll toFile lockFile updateFile singletonList ifPresent getFileContent assertEquals
test_case.modifiers: @Test(dependsOnMethods = "testGetFileContent") public
test_case.parameters: ()
test_case.return: void
test_case.signature: void testUpdateFile()
focal_class.declarator: documentList = new ConcurrentHashMap<>()
focal_class.modifier: private volatile
focal_class.original_string: private volatile Map<Path, DocumentPair> documentList = new ConcurrentHashMap<>();
focal_class.type: Map<Path, DocumentPair>
focal_class.var_name: documentList
focal_class.declarator: INSTANCE = new WorkspaceDocumentManagerImpl()
focal_class.modifier: private static final
focal_class.original_string: private static final WorkspaceDocumentManagerImpl INSTANCE = new WorkspaceDocumentManagerImpl();
focal_class.type: WorkspaceDocumentManagerImpl
focal_class.var_name: INSTANCE
focal_class.file: language-server/modules/langserver-compiler/src/main/java/org/ballerinalang/langserver/compiler/workspace/WorkspaceDocumentManagerImpl.java
focal_class.identifier: WorkspaceDocumentManagerImpl
focal_class.interfaces: implements WorkspaceDocumentManager
focal_class.class_method_signature: WorkspaceDocumentManagerImpl.WorkspaceDocumentManagerImpl()
focal_class.full_signature: protected  WorkspaceDocumentManagerImpl()
focal_class.identifier: WorkspaceDocumentManagerImpl
focal_class.modifiers: protected
focal_class.parameters: ()
focal_class.signature:  WorkspaceDocumentManagerImpl()
focal_class.class_method_signature: WorkspaceDocumentManagerImpl.getInstance()
focal_class.full_signature: public static WorkspaceDocumentManagerImpl getInstance()
focal_class.identifier: getInstance
focal_class.modifiers: public static
focal_class.parameters: ()
focal_class.return: WorkspaceDocumentManagerImpl
focal_class.signature: WorkspaceDocumentManagerImpl getInstance()
focal_class.class_method_signature: WorkspaceDocumentManagerImpl.isFileOpen(Path filePath)
focal_class.full_signature: @Override public boolean isFileOpen(Path filePath)
focal_class.identifier: isFileOpen
focal_class.modifiers: @Override public
focal_class.parameters: (Path filePath)
focal_class.return: boolean
focal_class.signature: boolean isFileOpen(Path filePath)
focal_class.class_method_signature: WorkspaceDocumentManagerImpl.openFile(Path filePath, String content)
focal_class.full_signature: @Override public void openFile(Path filePath, String content)
focal_class.identifier: openFile
focal_class.modifiers: @Override public
focal_class.parameters: (Path filePath, String content)
focal_class.return: void
focal_class.signature: void openFile(Path filePath, String content)
focal_class.class_method_signature: WorkspaceDocumentManagerImpl.updateFile(Path filePath, List<TextDocumentContentChangeEvent> changeEvent)
focal_class.full_signature: @Override public void updateFile(Path filePath, List<TextDocumentContentChangeEvent> changeEvent)
focal_class.identifier: updateFile
focal_class.modifiers: @Override public
focal_class.parameters: (Path filePath, List<TextDocumentContentChangeEvent> changeEvent)
focal_class.return: void
focal_class.signature: void updateFile(Path filePath, List<TextDocumentContentChangeEvent> changeEvent)
focal_class.class_method_signature: WorkspaceDocumentManagerImpl.getTextRange(TextDocument textDocument, TextDocumentContentChangeEvent change)
focal_class.full_signature: private TextRange getTextRange(TextDocument textDocument, TextDocumentContentChangeEvent change)
focal_class.identifier: getTextRange
focal_class.modifiers: private
focal_class.parameters: (TextDocument textDocument, TextDocumentContentChangeEvent change)
focal_class.return: TextRange
focal_class.signature: TextRange getTextRange(TextDocument textDocument, TextDocumentContentChangeEvent change)
focal_class.class_method_signature: WorkspaceDocumentManagerImpl.setCodeLenses(Path filePath, List<CodeLens> codeLens)
focal_class.full_signature: @Override public void setCodeLenses(Path filePath, List<CodeLens> codeLens)
focal_class.identifier: setCodeLenses
focal_class.modifiers: @Override public
focal_class.parameters: (Path filePath, List<CodeLens> codeLens)
focal_class.return: void
focal_class.signature: void setCodeLenses(Path filePath, List<CodeLens> codeLens)
focal_class.class_method_signature: WorkspaceDocumentManagerImpl.closeFile(Path filePath)
focal_class.full_signature: @Override public void closeFile(Path filePath)
focal_class.identifier: closeFile
focal_class.modifiers: @Override public
focal_class.parameters: (Path filePath)
focal_class.return: void
focal_class.signature: void closeFile(Path filePath)
focal_class.class_method_signature: WorkspaceDocumentManagerImpl.getCodeLenses(Path filePath)
focal_class.full_signature: @Override public List<CodeLens> getCodeLenses(Path filePath)
focal_class.identifier: getCodeLenses
focal_class.modifiers: @Override public
focal_class.parameters: (Path filePath)
focal_class.return: List<CodeLens>
focal_class.signature: List<CodeLens> getCodeLenses(Path filePath)
focal_class.class_method_signature: WorkspaceDocumentManagerImpl.getLSDocument(Path filePath)
focal_class.full_signature: @Override public LSDocumentIdentifier getLSDocument(Path filePath)
focal_class.identifier: getLSDocument
focal_class.modifiers: @Override public
focal_class.parameters: (Path filePath)
focal_class.return: LSDocumentIdentifier
focal_class.signature: LSDocumentIdentifier getLSDocument(Path filePath)
focal_class.class_method_signature: WorkspaceDocumentManagerImpl.getFileContent(Path filePath)
focal_class.full_signature: @Override public String getFileContent(Path filePath)
focal_class.identifier: getFileContent
focal_class.modifiers: @Override public
focal_class.parameters: (Path filePath)
focal_class.return: String
focal_class.signature: String getFileContent(Path filePath)
focal_class.class_method_signature: WorkspaceDocumentManagerImpl.lockFile(Path filePath)
focal_class.full_signature: @Override public Optional<Lock> lockFile(Path filePath)
focal_class.identifier: lockFile
focal_class.modifiers: @Override public
focal_class.parameters: (Path filePath)
focal_class.return: Optional<Lock>
focal_class.signature: Optional<Lock> lockFile(Path filePath)
focal_class.class_method_signature: WorkspaceDocumentManagerImpl.getAllFilePaths()
focal_class.full_signature: @Override public Set<Path> getAllFilePaths()
focal_class.identifier: getAllFilePaths
focal_class.modifiers: @Override public
focal_class.parameters: ()
focal_class.return: Set<Path>
focal_class.signature: Set<Path> getAllFilePaths()
focal_class.class_method_signature: WorkspaceDocumentManagerImpl.clearAllFilePaths()
focal_class.full_signature: @Override public void clearAllFilePaths()
focal_class.identifier: clearAllFilePaths
focal_class.modifiers: @Override public
focal_class.parameters: ()
focal_class.return: void
focal_class.signature: void clearAllFilePaths()
focal_class.class_method_signature: WorkspaceDocumentManagerImpl.getTree(Path filePath)
focal_class.full_signature: @Override public SyntaxTree getTree(Path filePath)
focal_class.identifier: getTree
focal_class.modifiers: @Override public
focal_class.parameters: (Path filePath)
focal_class.return: SyntaxTree
focal_class.signature: SyntaxTree getTree(Path filePath)
focal_class.class_method_signature: WorkspaceDocumentManagerImpl.setTree(Path filePath, SyntaxTree newTree)
focal_class.full_signature: @Override public void setTree(Path filePath, SyntaxTree newTree)
focal_class.identifier: setTree
focal_class.modifiers: @Override public
focal_class.parameters: (Path filePath, SyntaxTree newTree)
focal_class.return: void
focal_class.signature: void setTree(Path filePath, SyntaxTree newTree)
focal_class.class_method_signature: WorkspaceDocumentManagerImpl.readFromFileSystem(Path filePath)
focal_class.full_signature: private SyntaxTree readFromFileSystem(Path filePath)
focal_class.identifier: readFromFileSystem
focal_class.modifiers: private
focal_class.parameters: (Path filePath)
focal_class.return: SyntaxTree
focal_class.signature: SyntaxTree readFromFileSystem(Path filePath)
focal_class.class_method_signature: WorkspaceDocumentManagerImpl.rescanProjectRoot(Path filePath)
focal_class.full_signature: private void rescanProjectRoot(Path filePath)
focal_class.identifier: rescanProjectRoot
focal_class.modifiers: private
focal_class.parameters: (Path filePath)
focal_class.return: void
focal_class.signature: void rescanProjectRoot(Path filePath)
focal_method.body: @Override
      public void updateFile(Path filePath, List<TextDocumentContentChangeEvent> changeEvent)
              throws WorkspaceDocumentException {
          if (!isFileOpen(filePath)) {
              throw new WorkspaceDocumentException("File " + filePath.toString() + " is not opened in document manager.");
          }
          if (changeEvent.size() == 1 && changeEvent.get(0).getRange() == null) {
              // Full Sync
              documentList.get(filePath).getDocument().ifPresent(
                      document -> document.setContent(changeEvent.get(0).getText())
              );
          } else {
              // Incremental Sync
              documentList.get(filePath).getDocument().ifPresent(document -> {
                  TextEdit[] edits = new TextEdit[changeEvent.size()];
                  TextDocument textDocument = document.getTree().textDocument();
                  for (int i = 0; i < changeEvent.size(); i++) {
                      TextDocumentContentChangeEvent change = changeEvent.get(i);
                      edits[i] = TextEdit.from(getTextRange(textDocument, change), change.getText());
                  }
                  document.setTree(SyntaxTree.from(document.getTree(), TextDocumentChange.from(edits)));
              });
          }
      }
focal_method.class_method_signature: WorkspaceDocumentManagerImpl.updateFile(Path filePath, List<TextDocumentContentChangeEvent> changeEvent)
focal_method.full_signature: @Override public void updateFile(Path filePath, List<TextDocumentContentChangeEvent> changeEvent)
focal_method.identifier: updateFile
focal_method.invocations: isFileOpen toString size getRange get ifPresent getDocument get setContent getText get ifPresent getDocument get size textDocument getTree size get from getTextRange getText setTree from getTree from
focal_method.modifiers: @Override public
focal_method.parameters: (Path filePath, List<TextDocumentContentChangeEvent> changeEvent)
focal_method.return: void
focal_method.signature: void updateFile(Path filePath, List<TextDocumentContentChangeEvent> changeEvent)