/** * Force a reconcile of a compilation unit. * @param unit the compilation unit * @throws JavaModelException thrown when the compilation unit can not be accessed */ public static void reconcile(ICompilationUnit unit) throws JavaModelException { unit.reconcile( ICompilationUnit.NO_AST, false /* don't force problem detection */, null /* use primary owner */, null /* no progress monitor */); }
/** * Force a reconcile of a compilation unit. * @param unit */ public static void reconcile(ICompilationUnit unit) throws JavaModelException { unit.reconcile( ICompilationUnit.NO_AST, false /* don't force problem detection */, null /* use primary owner */, null /* no progress monitor */); }
/** * Force a reconcile of a compilation unit. * @param unit */ public static void reconcile(ICompilationUnit unit) throws JavaModelException { unit.reconcile( ICompilationUnit.NO_AST, false /* don't force problem detection */, null /* use primary owner */, null /* no progress monitor */); }
/** * Force a reconcile of a compilation unit. * @param unit the compilation unit * @throws JavaModelException thrown when the compilation unit can not be accessed */ public static void reconcile(ICompilationUnit unit) throws JavaModelException { unit.reconcile( ICompilationUnit.NO_AST, false /* don't force problem detection */, null /* use primary owner */, null /* no progress monitor */); }
public void run() { try { info.fCopy.reconcile(ICompilationUnit.NO_AST, false, null, subMonitor1); } catch (JavaModelException ex) { handleException(ex); } catch (OperationCanceledException ex) { // do not log this } } public void handleException(Throwable ex) {
private void publishDiagnostics(ICompilationUnit unit, IProgressMonitor monitor) throws JavaModelException { final DiagnosticsHandler handler = new DiagnosticsHandler(connection, unit); WorkingCopyOwner wcOwner = new WorkingCopyOwner() { /* (non-Javadoc) * @see org.eclipse.jdt.core.WorkingCopyOwner#createBuffer(org.eclipse.jdt.core.ICompilationUnit) */ @Override public IBuffer createBuffer(ICompilationUnit workingCopy) { ICompilationUnit original = workingCopy.getPrimary(); IResource resource = original.getResource(); if (resource instanceof IFile) { return new DocumentAdapter(workingCopy, (IFile) resource); } return DocumentAdapter.Null; } /* (non-Javadoc) * @see org.eclipse.jdt.core.WorkingCopyOwner#getProblemRequestor(org.eclipse.jdt.core.ICompilationUnit) */ @Override public IProblemRequestor getProblemRequestor(ICompilationUnit workingCopy) { return handler; } }; unit.reconcile(ICompilationUnit.NO_AST, true, wcOwner, monitor); }
@Override public synchronized void reconcile(ICompilationUnit icu, IProgressMonitor monitor) throws CoreException { if (!m_workingCopies.contains(icu)) { throw new CoreException(new ScoutStatus("compilation unit " + icu.getElementName() + " has not been registered")); } icu.reconcile(ICompilationUnit.NO_AST, true, icu.getOwner(), monitor); } }
private void organizeImports(ICompilationUnit cu) throws OperationCanceledException, CoreException { cu.becomeWorkingCopy(null); CompilationUnit unit = cu.reconcile(AST.JLS4, false, null, pm); NullProgressMonitor pm = new NullProgressMonitor(); OrganizeImportsOperation op = new OrganizeImportsOperation(cu, unit, true, true, true, null); TextEdit edit = op.createTextEdit(pm); if (edit == null) { return; } JavaModelUtil.applyEdit(cu, edit, true, pm); cu.commitWorkingCopy(true, pm); cu.save(pm, true); }
private IStatus performValidation(IProgressMonitor monitor) throws JavaModelException { long start = System.currentTimeMillis(); List<ICompilationUnit> cusToReconcile = new ArrayList<>(); synchronized (toReconcile) { cusToReconcile.addAll(toReconcile); toReconcile.clear(); } if (cusToReconcile.isEmpty()) { return Status.OK_STATUS; } // first reconcile all units with content changes SubMonitor progress = SubMonitor.convert(monitor, cusToReconcile.size() + 1); for (ICompilationUnit cu : cusToReconcile) { cu.reconcile(ICompilationUnit.NO_AST, true, null, progress.newChild(1)); } this.sharedASTProvider.disposeAST(); List<ICompilationUnit> toValidate = Arrays.asList(JavaCore.getWorkingCopies(null)); List<CompilationUnit> astRoots = new ArrayList<>(); for (ICompilationUnit rootToValidate : toValidate) { CompilationUnit astRoot = this.sharedASTProvider.getAST(rootToValidate, CoreASTProvider.WAIT_YES, monitor); astRoots.add(astRoot); } for (CompilationUnit astRoot : astRoots) { // report errors, even if there are no problems in the file: The client need to know that they got fixed. ICompilationUnit unit = (ICompilationUnit) astRoot.getTypeRoot(); publishDiagnostics(unit, progress.newChild(1)); } JavaLanguageServerPlugin.logInfo("Reconciled " + toReconcile.size() + ", validated: " + toValidate.size() + ". Took " + (System.currentTimeMillis() - start) + " ms"); return Status.OK_STATUS; }
static ICompilationUnit createNewWorkingCopy(ICompilationUnit cu, TextChangeManager manager, WorkingCopyOwner owner, SubProgressMonitor pm) throws CoreException { ICompilationUnit newWc= cu.getWorkingCopy(owner, null); String previewContent= manager.get(cu).getPreviewContent(new NullProgressMonitor()); newWc.getBuffer().setContents(previewContent); newWc.reconcile(ICompilationUnit.NO_AST, false, owner, pm); return newWc; }
static ICompilationUnit createNewWorkingCopy(ICompilationUnit cu, TextChangeManager manager, WorkingCopyOwner owner, SubProgressMonitor pm) throws CoreException { ICompilationUnit newWc= cu.getWorkingCopy(owner, null); String previewContent= manager.get(cu).getPreviewContent(new NullProgressMonitor()); newWc.getBuffer().setContents(previewContent); newWc.reconcile(ICompilationUnit.NO_AST, false, owner, pm); return newWc; }
static ICompilationUnit createNewWorkingCopy(ICompilationUnit cu, TextChangeManager manager, WorkingCopyOwner owner, SubProgressMonitor pm) throws CoreException { ICompilationUnit newWc= cu.getWorkingCopy(owner, null, null); String previewContent= manager.get(cu).getPreviewContent(new NullProgressMonitor()); newWc.getBuffer().setContents(previewContent); newWc.reconcile(ICompilationUnit.NO_AST, false, owner, pm); return newWc; }
static ICompilationUnit createNewWorkingCopy(ICompilationUnit cu, TextChangeManager manager, WorkingCopyOwner owner, SubProgressMonitor pm) throws CoreException { ICompilationUnit newWc= cu.getWorkingCopy(owner, null); String previewContent= manager.get(cu).getPreviewContent(new NullProgressMonitor()); newWc.getBuffer().setContents(previewContent); newWc.reconcile(ICompilationUnit.NO_AST, false, owner, pm); return newWc; }
| (ASTProvider.SHARED_BINDING_RECOVERY ? ICompilationUnit.ENABLE_BINDINGS_RECOVERY : 0); ast[0]= unit.reconcile(ASTProvider.SHARED_AST_LEVEL, reconcileFlags, null, fProgressMonitor); if (ast[0] != null) { unit.reconcile(ICompilationUnit.NO_AST, true, null, fProgressMonitor); } catch (OperationCanceledException ex) { Assert.isTrue(fProgressMonitor == null || fProgressMonitor.isCanceled());
reconcileFlags|= ICompilationUnit.ENABLE_BINDINGS_RECOVERY; CompilationUnit ast= unit.reconcile(ASTProvider.SHARED_AST_LEVEL, reconcileFlags, null, fProgressMonitor); if (ast != null) { unit.reconcile(ICompilationUnit.NO_AST, true, null, fProgressMonitor); } catch (OperationCanceledException ex) { Assert.isTrue(fProgressMonitor == null || fProgressMonitor.isCanceled());
/** * Reconciles the compilation unit for this JSPTranslation */ public void reconcileCompilationUnit() { ICompilationUnit cu = getCompilationUnit(); if (cu != null) { try { synchronized(cu) { cu.makeConsistent(getProgressMonitor()); cu.reconcile(ICompilationUnit.NO_AST, true, getWorkingCopyOwner(), getProgressMonitor()); } } catch (JavaModelException e) { Logger.logException(e); } } }
ICompilationUnit cunit = type.getCompilationUnit(); if (cunit.isWorkingCopy()) { cunit.reconcile(AST.JLS10, false, null, null);
ICompilationUnit unit = type.getCompilationUnit(); if (unit != null) { unit.reconcile(ICompilationUnit.NO_AST, false, null, null);
protected IMethod[] createInheritedConstructors(ICompilationUnit cu, IType type, IProgressMonitor monitor) throws CoreException { cu.reconcile(ICompilationUnit.NO_AST, false, null, null); Set handleIds = getHandleIds(type); ASTParser parser = ASTParser.newParser(AST.JLS3); parser.setResolveBindings(true); parser.setSource(cu); CompilationUnit unit = (CompilationUnit) parser.createAST(new SubProgressMonitor(monitor, 1)); ITypeBinding binding = getBinding(type, unit); if (binding != null) { IWorkspaceRunnable operation = AddUnimplementedConstructorsAction.createRunnable(unit, binding, null, -1, true, Modifier.PUBLIC, true); operation.run(monitor); cu.commitWorkingCopy(false, monitor); } return getTypeMethods(type, handleIds); }
@Override protected void releaseDocument(IDocument document, IProgressMonitor pm) throws CoreException { boolean isModified= isDocumentModified(); SubMonitor subMonitor= SubMonitor.convert(pm, 2); super.releaseDocument(document, subMonitor.split(1)); try { fCUnit.discardWorkingCopy(); } finally { if (isModified && !isDocumentAcquired()) { if (fCUnit.isWorkingCopy()) fCUnit.reconcile( ICompilationUnit.NO_AST, false /* don't force problem detection */, null /* use primary owner */, subMonitor.split(1, SubMonitor.SUPPRESS_BEGINTASK | SubMonitor.SUPPRESS_ISCANCELED)); else fCUnit.makeConsistent(subMonitor.split(1, SubMonitor.SUPPRESS_BEGINTASK | SubMonitor.SUPPRESS_ISCANCELED)); } } }