/** * Cleans the .api_settings file for the given project * * @param project */ void cleanupApiDescription(IProject project) { if (project != null && project.exists()) { ApiDescriptionManager.getManager().clean(JavaCore.create(project), true, false); } }
/** * Returns the singleton API description manager. * * @return API description manager */ public synchronized static ApiDescriptionManager getManager() { if (fgDefault == null) { fgDefault = new ApiDescriptionManager(); } return fgDefault; }
@Override protected IApiDescription createLocalApiDescription() throws CoreException { long time = System.currentTimeMillis(); if (Util.isApiProject(getJavaProject())) { setHasApiDescription(true); } IApiDescription apiDesc = ApiDescriptionManager.getManager().getApiDescription(this, getBundleDescription()); if (ApiPlugin.DEBUG_PROJECT_COMPONENT) { System.out.println("Time to create api description for: [" + fProject.getElementName() + "] " + (System.currentTimeMillis() - time) + "ms"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ } return apiDesc; }
IElementDescriptor elementDesc = null; if (element.getTagName().equals(IApiXmlConstants.ELEMENT_PACKAGE)) { int vis = getInt(element, IApiXmlConstants.ATTR_VISIBILITY); int res = getInt(element, IApiXmlConstants.ATTR_RESTRICTIONS); IJavaElement je = JavaCore.create(handle); if (je.getElementType() != IJavaElement.PACKAGE_FRAGMENT) { abort(ScannerMessages.ApiDescriptionManager_2 + handle, null); node = apiDesc.newPackageNode(fragments.toArray(new IPackageFragment[fragments.size()]), parentNode, elementDesc, vis, res); } else { abort(ScannerMessages.ApiDescriptionManager_2, null); } else if (element.getTagName().equals(IApiXmlConstants.ELEMENT_TYPE)) { String handle = element.getAttribute(IApiXmlConstants.ATTR_HANDLE); int vis = getInt(element, IApiXmlConstants.ATTR_VISIBILITY); int res = getInt(element, IApiXmlConstants.ATTR_RESTRICTIONS); IJavaElement je = JavaCore.create(handle); if (je.getElementType() != IJavaElement.TYPE) { abort(ScannerMessages.ApiDescriptionManager_3 + handle, null); TypeNode tn = apiDesc.newTypeNode(type, parentNode, elementDesc, vis, res); node = tn; tn.fTimeStamp = getLong(element, IApiXmlConstants.ATTR_MODIFICATION_STAMP); } else if (element.getTagName().equals(IApiXmlConstants.ELEMENT_FIELD)) { if (parentNode.element instanceof IReferenceTypeDescriptor) { IReferenceTypeDescriptor type = (IReferenceTypeDescriptor) parentNode.element; int vis = getInt(element, IApiXmlConstants.ATTR_VISIBILITY); int res = getInt(element, IApiXmlConstants.ATTR_RESTRICTIONS);
dmanager.clean(javaProject, false, true); dmanager.flushElementCache(javaProject);
private void cleanAndDisposeWorkspaceBaseline(IResource resource) { IJavaProject jp = (IJavaProject) JavaCore.create(resource); dmanager.clean(jp, true, true); bmanager.disposeWorkspaceBaseline(); } }
Element root = Util.parseDocument(xml); if (!root.getNodeName().equals(IApiXmlConstants.ELEMENT_COMPONENT)) { abort(ScannerMessages.ComponentXMLScanner_0, null); long timestamp = getLong(root, IApiXmlConstants.ATTR_MODIFICATION_STAMP); String version = root.getAttribute(IApiXmlConstants.ATTR_VERSION); description.setEmbeddedVersion(version); description.fPackageTimeStamp = timestamp; description.fManifestFile = project.getProject().getFile(JarFile.MANIFEST_NAME); restoreChildren(description, root, null, description.fPackageMap); return true; abort(MessageFormat.format(ScannerMessages.ApiDescriptionManager_1, project.getElementName()), e); } finally { if (stream != null) {
dmanager.projectClasspathChanged(proj); try { BuildState.setLastBuiltState(proj.getProject(), null); ApiPlugin.log("Failed to save build state for " + proj.getProject(), e); //$NON-NLS-1$ dmanager.flushElementCache(delta.getElement()); } else if ((flags & IJavaElementDelta.F_CHILDREN) != 0) { if (ApiPlugin.DEBUG_WORKSPACE_DELTA_PROCESSOR) { System.out.println("processed CLASSPATH CHANGED for package fragment root: [" + root.getElementName() + "]"); //$NON-NLS-1$ //$NON-NLS-2$ dmanager.projectClasspathChanged(project); System.out.println("processed CONTENT / FINE_GRAINED / PRIMARY_RESOURCE delta for: [" + delta.getElement().getElementName() + "]"); //$NON-NLS-1$//$NON-NLS-2$ dmanager.projectChanged(project); dmanager.flushElementCache(delta.getElement()); continue; dmanager.projectChanged(project); dmanager.flushElementCache(delta.getElement()); continue;
@Override public synchronized void saving(ISaveContext context) throws CoreException { if (context.getKind() == ISaveContext.PROJECT_SAVE && !Util.isJavaProject(context.getProject())) { return; } Iterator<Entry<IJavaProject, IApiDescription>> entries = fDescriptions.entrySet().iterator(); while (entries.hasNext()) { Entry<IJavaProject, IApiDescription> entry = entries.next(); IJavaProject project = entry.getKey(); ProjectApiDescription desc = (ProjectApiDescription) entry.getValue(); if (desc.isModified()) { File dir = API_DESCRIPTIONS_CONTAINER_PATH.append(project.getElementName()).toFile(); dir.mkdirs(); String xml = desc.getXML(); try { Util.saveFile(new File(dir, IApiCoreConstants.API_DESCRIPTION_XML_NAME), xml); desc.setModified(false); } catch (IOException e) { abort(MessageFormat.format(ScannerMessages.ApiDescriptionManager_0, project.getElementName()), e); } } } }
public Change perform(IProgressMonitor pm) throws CoreException { SubMonitor localmonitor = SubMonitor.convert(pm); localmonitor.beginTask(IApiToolsConstants.EMPTY_STRING, 1); localmonitor.setTaskName(WizardMessages.ProjectUpdateChange_adding_nature_and_builder); IProjectDescription description = this.fProject.getDescription(); String[] prevNatures = description.getNatureIds(); String[] newNatures = new String[prevNatures.length + 1]; System.arraycopy(prevNatures, 0, newNatures, 0, prevNatures.length); newNatures[prevNatures.length] = ApiPlugin.NATURE_ID; description.setNatureIds(newNatures); this.fProject.setDescription(description, localmonitor); IJavaProject javaProject = JavaCore.create(this.fProject); // make sure we get rid of the previous api description file ApiDescriptionManager.getManager().clean(javaProject, true, true); // we want a full build of the converted project next time a build is triggered if (ResourcesPlugin.getWorkspace().isAutoBuilding()) { Util.getBuildJob(new IProject[] { this.fProject }).schedule(); } else { /* * If autobuild is off, clear the last build state to force a full build of * this project on the next build. */ BuildState.setLastBuiltState(this.fProject, null); } Util.updateMonitor(localmonitor, 1); return null; } }
@Override public Change perform(IProgressMonitor pm) throws CoreException { SubMonitor localmonitor = SubMonitor.convert(pm); localmonitor.beginTask(IApiToolsConstants.EMPTY_STRING, 1); localmonitor.setTaskName(WizardMessages.ProjectUpdateChange_adding_nature_and_builder); IProjectDescription description = this.fProject.getDescription(); String[] prevNatures = description.getNatureIds(); String[] newNatures = new String[prevNatures.length + 1]; System.arraycopy(prevNatures, 0, newNatures, 0, prevNatures.length); newNatures[prevNatures.length] = ApiPlugin.NATURE_ID; description.setNatureIds(newNatures); this.fProject.setDescription(description, localmonitor); IJavaProject javaProject = JavaCore.create(this.fProject); // make sure we get rid of the previous api description file ApiDescriptionManager.getManager().clean(javaProject, true, true); // we want a full build of the converted project next time a build is // triggered if (ResourcesPlugin.getWorkspace().isAutoBuilding()) { Util.getBuildJob(new IProject[] { this.fProject }).schedule(); } else { /* * If autobuild is off, clear the last build state to force a full * build of this project on the next build. */ BuildState.setLastBuiltState(this.fProject, null); } localmonitor.split(1); return null; } }