private void notifyParticipants(final CompilationUnit workingCopy) { IJavaProject javaProject = getWorkingCopy().getJavaProject(); CompilationParticipant[] participants = JavaModelManager.getJavaModelManager().compilationParticipants.getCompilationParticipants(javaProject); if (participants == null) return; final ReconcileContext context = new ReconcileContext(this, workingCopy); for (int i = 0, length = participants.length; i < length; i++) { final CompilationParticipant participant = participants[i]; SafeRunner.run(new ISafeRunnable() { public void handleException(Throwable exception) { if (exception instanceof Error) { throw (Error) exception; // errors are not supposed to be caught } else if (exception instanceof OperationCanceledException) throw (OperationCanceledException) exception; else if (exception instanceof UnsupportedOperationException) { // might want to disable participant as it tried to modify the buffer of the working copy being reconciled Util.log(exception, "Reconcile participant attempted to modify the buffer of the working copy being reconciled"); //$NON-NLS-1$ } else Util.log(exception, "Exception occurred in reconcile participant"); //$NON-NLS-1$ } public void run() throws Exception { participant.reconcile(context); } }); } }
private void notifyParticipants(final CompilationUnit workingCopy) { IJavaProject javaProject = getWorkingCopy().getJavaProject(); CompilationParticipant[] participants = JavaModelManager.getJavaModelManager().compilationParticipants.getCompilationParticipants(javaProject); if (participants == null) return; final ReconcileContext context = new ReconcileContext(this, workingCopy); for (int i = 0, length = participants.length; i < length; i++) { final CompilationParticipant participant = participants[i]; SafeRunner.run(new ISafeRunnable() { public void handleException(Throwable exception) { if (exception instanceof Error) { throw (Error) exception; // errors are not supposed to be caught } else if (exception instanceof OperationCanceledException) throw (OperationCanceledException) exception; else if (exception instanceof UnsupportedOperationException) { // might want to disable participant as it tried to modify the buffer of the working copy being reconciled Util.log(exception, "Reconcile participant attempted to modify the buffer of the working copy being reconciled"); //$NON-NLS-1$ } else Util.log(exception, "Exception occurred in reconcile participant"); //$NON-NLS-1$ } public void run() throws Exception { participant.reconcile(context); } }); } }
private void notifyParticipants(final CompilationUnit workingCopy) { IJavaProject javaProject = getWorkingCopy().getJavaProject(); CompilationParticipant[] participants = JavaModelManager.getJavaModelManager().compilationParticipants.getCompilationParticipants(javaProject); if (participants == null) return; final ReconcileContext context = new ReconcileContext(this, workingCopy); for (int i = 0, length = participants.length; i < length; i++) { final CompilationParticipant participant = participants[i]; SafeRunner.run(new ISafeRunnable() { public void handleException(Throwable exception) { if (exception instanceof Error) { throw (Error) exception; // errors are not supposed to be caught } else if (exception instanceof OperationCanceledException) throw (OperationCanceledException) exception; else if (exception instanceof UnsupportedOperationException) { // might want to disable participant as it tried to modify the buffer of the working copy being reconciled Util.log(exception, "Reconcile participant attempted to modify the buffer of the working copy being reconciled"); //$NON-NLS-1$ } else Util.log(exception, "Exception occurred in reconcile participant"); //$NON-NLS-1$ } public void run() throws Exception { participant.reconcile(context); } }); } }
private void notifyParticipants(final CompilationUnit workingCopy) { IJavaProject javaProject = getWorkingCopy().getJavaProject(); CompilationParticipant[] participants = JavaModelManager.getJavaModelManager().compilationParticipants.getCompilationParticipants(javaProject); if (participants == null) return; final ReconcileContext context = new ReconcileContext(this, workingCopy); for (int i = 0, length = participants.length; i < length; i++) { final CompilationParticipant participant = participants[i]; SafeRunner.run(new ISafeRunnable() { public void handleException(Throwable exception) { if (exception instanceof Error) { throw (Error) exception; // errors are not supposed to be caught } else if (exception instanceof OperationCanceledException) throw (OperationCanceledException) exception; else if (exception instanceof UnsupportedOperationException) { // might want to disable participant as it tried to modify the buffer of the working copy being reconciled Util.log(exception, "Reconcile participant attempted to modify the buffer of the working copy being reconciled"); //$NON-NLS-1$ } else Util.log(exception, "Exception occurred in reconcile participant"); //$NON-NLS-1$ } public void run() throws Exception { participant.reconcile(context); } }); } }
private void notifyParticipants(final CompilationUnit workingCopy) { IJavaProject javaProject = getWorkingCopy().getJavaProject(); CompilationParticipant[] participants = JavaModelManager.getJavaModelManager().compilationParticipants.getCompilationParticipants(javaProject); if (participants == null) return; final ReconcileContext context = new ReconcileContext(this, workingCopy); for (int i = 0, length = participants.length; i < length; i++) { final CompilationParticipant participant = participants[i]; SafeRunner.run(new ISafeRunnable() { @Override public void handleException(Throwable exception) { if (exception instanceof Error) { throw (Error) exception; // errors are not supposed to be caught } else if (exception instanceof OperationCanceledException) throw (OperationCanceledException) exception; else if (exception instanceof UnsupportedOperationException) { // might want to disable participant as it tried to modify the buffer of the working copy being reconciled Util.log(exception, "Reconcile participant attempted to modify the buffer of the working copy being reconciled"); //$NON-NLS-1$ } else Util.log(exception, "Exception occurred in reconcile participant"); //$NON-NLS-1$ } @Override public void run() throws Exception { participant.reconcile(context); } }); } }
private void notifyParticipants(final CompilationUnit workingCopy) { IJavaProject javaProject = getWorkingCopy().getJavaProject(); CompilationParticipant[] participants = JavaModelManager.getJavaModelManager().compilationParticipants.getCompilationParticipants(javaProject); if (participants == null) return; final ReconcileContext context = new ReconcileContext(this, workingCopy); for (int i = 0, length = participants.length; i < length; i++) { final CompilationParticipant participant = participants[i]; SafeRunner.run(new ISafeRunnable() { public void handleException(Throwable exception) { if (exception instanceof Error) { throw (Error) exception; // errors are not supposed to be caught } else if (exception instanceof OperationCanceledException) throw (OperationCanceledException) exception; else if (exception instanceof UnsupportedOperationException) { // might want to disable participant as it tried to modify the buffer of the working copy being reconciled Util.log(exception, "Reconcile participant attempted to modify the buffer of the working copy being reconciled"); //$NON-NLS-1$ } else Util.log(exception, "Exception occurred in reconcile participant"); //$NON-NLS-1$ } public void run() throws Exception { participant.reconcile(context); } }); } }
/** * @see ICompilationUnit#createType(String, IJavaElement, boolean, IProgressMonitor) */ public IType createType(String content, IJavaElement sibling, boolean force, IProgressMonitor monitor) throws JavaModelException { if (!exists()) { //autogenerate this compilation unit IPackageFragment pkg = (IPackageFragment) getParent(); String source = ""; //$NON-NLS-1$ if (!pkg.isDefaultPackage()) { //not the default package...add the package declaration String lineSeparator = Util.getLineSeparator(null/*no existing source*/, getJavaProject()); source = "package " + pkg.getElementName() + ";" + lineSeparator + lineSeparator; //$NON-NLS-1$ //$NON-NLS-2$ } CreateCompilationUnitOperation op = new CreateCompilationUnitOperation(pkg, this.name, source, force); op.runOperation(monitor); } CreateTypeOperation op = new CreateTypeOperation(this, content, force); if (sibling != null) { op.createBefore(sibling); } op.runOperation(monitor); return (IType) op.getResultElements()[0]; } /**
/** * @see ICompilationUnit#createType(String, IJavaElement, boolean, IProgressMonitor) */ public IType createType(String content, IJavaElement sibling, boolean force, IProgressMonitor monitor) throws JavaModelException { if (!exists()) { //autogenerate this compilation unit IPackageFragment pkg = (IPackageFragment) getParent(); String source = ""; //$NON-NLS-1$ if (!pkg.isDefaultPackage()) { //not the default package...add the package declaration String lineSeparator = Util.getLineSeparator(null/*no existing source*/, getJavaProject()); source = "package " + pkg.getElementName() + ";" + lineSeparator + lineSeparator; //$NON-NLS-1$ //$NON-NLS-2$ } CreateCompilationUnitOperation op = new CreateCompilationUnitOperation(pkg, this.name, source, force); op.runOperation(monitor); } CreateTypeOperation op = new CreateTypeOperation(this, content, force); if (sibling != null) { op.createBefore(sibling); } op.runOperation(monitor); return (IType) op.getResultElements()[0]; } /**
/** * @see ICompilationUnit#createType(String, IJavaElement, boolean, IProgressMonitor) */ public IType createType(String content, IJavaElement sibling, boolean force, IProgressMonitor monitor) throws JavaModelException { if (!exists()) { //autogenerate this compilation unit IPackageFragment pkg = (IPackageFragment) getParent(); String source = ""; //$NON-NLS-1$ if (!pkg.isDefaultPackage()) { //not the default package...add the package declaration String lineSeparator = Util.getLineSeparator(null/*no existing source*/, getJavaProject()); source = "package " + pkg.getElementName() + ";" + lineSeparator + lineSeparator; //$NON-NLS-1$ //$NON-NLS-2$ } CreateCompilationUnitOperation op = new CreateCompilationUnitOperation(pkg, this.name, source, force); op.runOperation(monitor); } CreateTypeOperation op = new CreateTypeOperation(this, content, force); if (sibling != null) { op.createBefore(sibling); } op.runOperation(monitor); return (IType) op.getResultElements()[0]; } /**
/** * @see ICompilationUnit#createType(String, IJavaElement, boolean, IProgressMonitor) */ public IType createType(String content, IJavaElement sibling, boolean force, IProgressMonitor monitor) throws JavaModelException { if (!exists()) { //autogenerate this compilation unit IPackageFragment pkg = (IPackageFragment) getParent(); String source = ""; //$NON-NLS-1$ if (!pkg.isDefaultPackage()) { //not the default package...add the package declaration String lineSeparator = Util.getLineSeparator(null/*no existing source*/, getJavaProject()); source = "package " + pkg.getElementName() + ";" + lineSeparator + lineSeparator; //$NON-NLS-1$ //$NON-NLS-2$ } CreateCompilationUnitOperation op = new CreateCompilationUnitOperation(pkg, this.name, source, force); op.runOperation(monitor); } CreateTypeOperation op = new CreateTypeOperation(this, content, force); if (sibling != null) { op.createBefore(sibling); } op.runOperation(monitor); return (IType) op.getResultElements()[0]; } /**
/** * @see ICompilationUnit#createType(String, IJavaElement, boolean, IProgressMonitor) */ public IType createType(String content, IJavaElement sibling, boolean force, IProgressMonitor monitor) throws JavaModelException { if (!exists()) { //autogenerate this compilation unit IPackageFragment pkg = (IPackageFragment) getParent(); String source = ""; //$NON-NLS-1$ if (!pkg.isDefaultPackage()) { //not the default package...add the package declaration String lineSeparator = Util.getLineSeparator(null/*no existing source*/, getJavaProject()); source = "package " + pkg.getElementName() + ";" + lineSeparator + lineSeparator; //$NON-NLS-1$ //$NON-NLS-2$ } CreateCompilationUnitOperation op = new CreateCompilationUnitOperation(pkg, this.name, source, force); op.runOperation(monitor); } CreateTypeOperation op = new CreateTypeOperation(this, content, force); if (sibling != null) { op.createBefore(sibling); } op.runOperation(monitor); return (IType) op.getResultElements()[0]; } /**
/** * @see ICompilationUnit#createType(String, IJavaElement, boolean, IProgressMonitor) */ @Override public IType createType(String content, IJavaElement sibling, boolean force, IProgressMonitor monitor) throws JavaModelException { if (!exists()) { //autogenerate this compilation unit IPackageFragment pkg = (IPackageFragment) getParent(); String source = ""; //$NON-NLS-1$ if (!pkg.isDefaultPackage()) { //not the default package...add the package declaration String lineSeparator = Util.getLineSeparator(null/*no existing source*/, getJavaProject()); source = "package " + pkg.getElementName() + ";" + lineSeparator + lineSeparator; //$NON-NLS-1$ //$NON-NLS-2$ } CreateCompilationUnitOperation op = new CreateCompilationUnitOperation(pkg, this.name, source, force); op.runOperation(monitor); } CreateTypeOperation op = new CreateTypeOperation(this, content, force); if (sibling != null) { op.createBefore(sibling); } op.runOperation(monitor); return (IType) op.getResultElements()[0]; } /**
protected IStatus validateCompilationUnit(IResource resource) { IPackageFragmentRoot root = getPackageFragmentRoot(); // root never null as validation is not done for working copies try { if (root.getKind() != IPackageFragmentRoot.K_SOURCE) return new JavaModelStatus(IJavaModelStatusConstants.INVALID_ELEMENT_TYPES, root); } catch (JavaModelException e) { return e.getJavaModelStatus(); } if (resource != null) { char[][] inclusionPatterns = ((PackageFragmentRoot)root).fullInclusionPatternChars(); char[][] exclusionPatterns = ((PackageFragmentRoot)root).fullExclusionPatternChars(); if (Util.isExcluded(resource, inclusionPatterns, exclusionPatterns)) return new JavaModelStatus(IJavaModelStatusConstants.ELEMENT_NOT_ON_CLASSPATH, this); if (!resource.isAccessible()) return new JavaModelStatus(IJavaModelStatusConstants.ELEMENT_DOES_NOT_EXIST, this); } IJavaProject project = getJavaProject(); return JavaConventions.validateCompilationUnitName(getElementName(),project.getOption(JavaCore.COMPILER_SOURCE, true), project.getOption(JavaCore.COMPILER_COMPLIANCE, true)); } /*
protected IStatus validateCompilationUnit(IResource resource) { IPackageFragmentRoot root = getPackageFragmentRoot(); // root never null as validation is not done for working copies try { if (root.getKind() != IPackageFragmentRoot.K_SOURCE) return new JavaModelStatus(IJavaModelStatusConstants.INVALID_ELEMENT_TYPES, root); } catch (JavaModelException e) { return e.getJavaModelStatus(); } if (resource != null) { char[][] inclusionPatterns = ((PackageFragmentRoot)root).fullInclusionPatternChars(); char[][] exclusionPatterns = ((PackageFragmentRoot)root).fullExclusionPatternChars(); if (Util.isExcluded(resource, inclusionPatterns, exclusionPatterns)) return new JavaModelStatus(IJavaModelStatusConstants.ELEMENT_NOT_ON_CLASSPATH, this); if (!resource.isAccessible()) return new JavaModelStatus(IJavaModelStatusConstants.ELEMENT_DOES_NOT_EXIST, this); } IJavaProject project = getJavaProject(); return JavaConventions.validateCompilationUnitName(getElementName(),project.getOption(JavaCore.COMPILER_SOURCE, true), project.getOption(JavaCore.COMPILER_COMPLIANCE, true)); }
protected IStatus validateCompilationUnit(IResource resource) { IPackageFragmentRoot root = getPackageFragmentRoot(); // root never null as validation is not done for working copies try { if (root.getKind() != IPackageFragmentRoot.K_SOURCE) return new JavaModelStatus(IJavaModelStatusConstants.INVALID_ELEMENT_TYPES, root); } catch (JavaModelException e) { return e.getJavaModelStatus(); } if (resource != null) { char[][] inclusionPatterns = ((PackageFragmentRoot)root).fullInclusionPatternChars(); char[][] exclusionPatterns = ((PackageFragmentRoot)root).fullExclusionPatternChars(); if (Util.isExcluded(resource, inclusionPatterns, exclusionPatterns)) return new JavaModelStatus(IJavaModelStatusConstants.ELEMENT_NOT_ON_CLASSPATH, this); if (!resource.isAccessible()) return new JavaModelStatus(IJavaModelStatusConstants.ELEMENT_DOES_NOT_EXIST, this); } IJavaProject project = getJavaProject(); return JavaConventions.validateCompilationUnitName(getElementName(),project.getOption(JavaCore.COMPILER_SOURCE, true), project.getOption(JavaCore.COMPILER_COMPLIANCE, true)); } /*
protected IStatus validateCompilationUnit(IResource resource) { IPackageFragmentRoot root = getPackageFragmentRoot(); // root never null as validation is not done for working copies try { if (root.getKind() != IPackageFragmentRoot.K_SOURCE) return new JavaModelStatus(IJavaModelStatusConstants.INVALID_ELEMENT_TYPES, root); } catch (JavaModelException e) { return e.getJavaModelStatus(); } if (resource != null) { char[][] inclusionPatterns = ((PackageFragmentRoot)root).fullInclusionPatternChars(); char[][] exclusionPatterns = ((PackageFragmentRoot)root).fullExclusionPatternChars(); if (Util.isExcluded(resource, inclusionPatterns, exclusionPatterns)) return new JavaModelStatus(IJavaModelStatusConstants.ELEMENT_NOT_ON_CLASSPATH, this); if (!resource.isAccessible()) return new JavaModelStatus(IJavaModelStatusConstants.ELEMENT_DOES_NOT_EXIST, this); } IJavaProject project = getJavaProject(); return JavaConventions.validateCompilationUnitName(getElementName(),project.getOption(JavaCore.COMPILER_SOURCE, true), project.getOption(JavaCore.COMPILER_COMPLIANCE, true)); } /*
protected IStatus validateCompilationUnit(IResource resource) { IPackageFragmentRoot root = getPackageFragmentRoot(); // root never null as validation is not done for working copies try { if (root.getKind() != IPackageFragmentRoot.K_SOURCE) return new JavaModelStatus(IJavaModelStatusConstants.INVALID_ELEMENT_TYPES, root); } catch (JavaModelException e) { return e.getJavaModelStatus(); } if (resource != null) { char[][] inclusionPatterns = ((PackageFragmentRoot)root).fullInclusionPatternChars(); char[][] exclusionPatterns = ((PackageFragmentRoot)root).fullExclusionPatternChars(); if (Util.isExcluded(resource, inclusionPatterns, exclusionPatterns)) return new JavaModelStatus(IJavaModelStatusConstants.ELEMENT_NOT_ON_CLASSPATH, this); if (!resource.isAccessible()) return new JavaModelStatus(IJavaModelStatusConstants.ELEMENT_DOES_NOT_EXIST, this); } IJavaProject project = getJavaProject(); return JavaConventions.validateCompilationUnitName(getElementName(),project.getOption(JavaCore.COMPILER_SOURCE, true), project.getOption(JavaCore.COMPILER_COMPLIANCE, true)); } /*
protected IStatus validateCompilationUnit(IResource resource) { IPackageFragmentRoot root = getPackageFragmentRoot(); // root never null as validation is not done for working copies try { if (root.getKind() != IPackageFragmentRoot.K_SOURCE) return new JavaModelStatus(IJavaModelStatusConstants.INVALID_ELEMENT_TYPES, root); } catch (JavaModelException e) { return e.getJavaModelStatus(); } if (resource != null) { char[][] inclusionPatterns = ((PackageFragmentRoot)root).fullInclusionPatternChars(); char[][] exclusionPatterns = ((PackageFragmentRoot)root).fullExclusionPatternChars(); if (Util.isExcluded(resource, inclusionPatterns, exclusionPatterns)) return new JavaModelStatus(IJavaModelStatusConstants.ELEMENT_NOT_ON_CLASSPATH, this); if (!resource.isAccessible()) return new JavaModelStatus(IJavaModelStatusConstants.ELEMENT_DOES_NOT_EXIST, this); } IJavaProject project = getJavaProject(); return JavaConventions.validateCompilationUnitName(getElementName(),project.getOption(JavaCore.COMPILER_SOURCE, true), project.getOption(JavaCore.COMPILER_COMPLIANCE, true)); } /*
int useCount = manager.discardPerWorkingCopyInfo(workingCopy); if (useCount == 0) { IJavaProject javaProject = workingCopy.getJavaProject(); if (ExternalJavaProject.EXTERNAL_PROJECT_NAME.equals(javaProject.getElementName())) { manager.removePerProjectInfo((JavaProject) javaProject, true /* remove external jar files indexes and timestamps*/);
int useCount = manager.discardPerWorkingCopyInfo(workingCopy); if (useCount == 0) { IJavaProject javaProject = workingCopy.getJavaProject(); if (ExternalJavaProject.EXTERNAL_PROJECT_NAME.equals(javaProject.getElementName())) { manager.removePerProjectInfo((JavaProject) javaProject, true /* remove external jar files indexes and timestamps*/);