Java Code Examples for org.eclipse.jdt.core.JavaCore#getWorkingCopies()
The following examples show how to use
org.eclipse.jdt.core.JavaCore#getWorkingCopies() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: WorkspaceEventsHandler.java From eclipse.jdt.ls with Eclipse Public License 2.0 | 6 votes |
private void discardWorkingCopies(String parentUri) { IPath parentPath = ResourceUtils.filePathFromURI(parentUri); if (parentPath != null && !parentPath.lastSegment().endsWith(".java")) { ICompilationUnit[] workingCopies = JavaCore.getWorkingCopies(null); for (ICompilationUnit workingCopy : workingCopies) { IResource resource = workingCopy.getResource(); if (resource == null) { continue; } IPath cuPath = resource.getRawLocation() != null ? resource.getRawLocation() : resource.getLocation(); if (cuPath != null && parentPath.isPrefixOf(cuPath)) { try { workingCopy.discardWorkingCopy(); } catch (JavaModelException e) { // do nothing. } } } } }
Example 2
Source File: JdtValidationJobScheduler.java From xtext-eclipse with Eclipse Public License 2.0 | 5 votes |
@Override protected boolean isDirty(URI uri) { if (uri == null) return false; if (URIHelperConstants.PROTOCOL.equals(uri.scheme())) { String path = uri.path(); if (URIHelperConstants.PRIMITIVES.equals(path)) return false; String topLevelTypeName = path.substring(URIHelperConstants.OBJECTS.length()); ICompilationUnit[] workingCopies = JavaCore.getWorkingCopies(null); for(ICompilationUnit cu: workingCopies) { try { if (cu.hasUnsavedChanges()) { IType primaryType = cu.findPrimaryType(); if (primaryType != null) { if (topLevelTypeName.equals(primaryType.getFullyQualifiedName())) { return true; } } } } catch (JavaModelException e) { // ignore } } } return super.isDirty(uri); }
Example 3
Source File: SyntaxServerTest.java From eclipse.jdt.ls with Eclipse Public License 2.0 | 5 votes |
@After public void tearDown() throws Exception { if (oldServerMode == null) { System.clearProperty(JDTEnvironmentUtils.SYNTAX_SERVER_ID); } else { System.setProperty(JDTEnvironmentUtils.SYNTAX_SERVER_ID, oldServerMode); } ProjectsManager.setAutoBuilding(oldBuildStatus); server.getClientConnection().disconnect(); for (ICompilationUnit cu : JavaCore.getWorkingCopies(null)) { cu.discardWorkingCopy(); } }
Example 4
Source File: DiagnosticsCommandTest.java From eclipse.jdt.ls with Eclipse Public License 2.0 | 5 votes |
@After public void tearDown() throws Exception { JavaLanguageServerPlugin.getNonProjectDiagnosticsState().setGlobalErrorLevel(originalGlobalErrorLevel); javaClient.disconnect(); for (ICompilationUnit cu : JavaCore.getWorkingCopies(null)) { cu.discardWorkingCopy(); } }
Example 5
Source File: MavenClasspathTest.java From eclipse.jdt.ls with Eclipse Public License 2.0 | 5 votes |
@After public void tearDown() throws Exception { sharedASTProvider.disposeAST(); javaClient.disconnect(); for (ICompilationUnit cu : JavaCore.getWorkingCopies(null)) { cu.discardWorkingCopy(); } }
Example 6
Source File: SemanticHighlightingTest.java From eclipse.jdt.ls with Eclipse Public License 2.0 | 5 votes |
@After public void tearDown() throws Exception { javaClient.disconnect(); for (ICompilationUnit unit : JavaCore.getWorkingCopies(null)) { unit.discardWorkingCopy(); } }
Example 7
Source File: DocumentLifeCycleHandlerTest.java From eclipse.jdt.ls with Eclipse Public License 2.0 | 5 votes |
@After public void tearDown() throws Exception { JavaLanguageServerPlugin.getNonProjectDiagnosticsState().setGlobalErrorLevel(true); javaClient.disconnect(); for (ICompilationUnit cu : JavaCore.getWorkingCopies(null)) { cu.discardWorkingCopy(); } FileUtils.deleteQuietly(temp); }
Example 8
Source File: WorkspaceEventHandlerTest.java From eclipse.jdt.ls with Eclipse Public License 2.0 | 5 votes |
@After public void tearDown() throws Exception { javaClient.disconnect(); handler.removeResourceChangeListener(); for (ICompilationUnit cu : JavaCore.getWorkingCopies(null)) { cu.discardWorkingCopy(); } }
Example 9
Source File: NonProjectFixTest.java From eclipse.jdt.ls with Eclipse Public License 2.0 | 5 votes |
@After public void tearDown() throws Exception { JavaLanguageServerPlugin.getNonProjectDiagnosticsState().setGlobalErrorLevel(true); javaClient.disconnect(); for (ICompilationUnit cu : JavaCore.getWorkingCopies(null)) { cu.discardWorkingCopy(); } }
Example 10
Source File: SuperTypeRefactoringProcessor.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
/** * Resets the working copies. */ protected void resetWorkingCopies() { final ICompilationUnit[] units= JavaCore.getWorkingCopies(fOwner); for (int index= 0; index < units.length; index++) { final ICompilationUnit unit= units[index]; try { unit.discardWorkingCopy(); } catch (Exception exception) { // Do nothing } } }