private DmdlParserWrapper createWrapper(IProject project) { IJavaProject jproject = JavaCore.create(project); if (jproject == null) { return null; } DmdlParserWrapper wrapper = null; try { IFile file = project.getFile(".classpath"); long time = file.getLocalTimeStamp(); Long cache = (Long) project.getSessionProperty(TIME_KEY); wrapper = (DmdlParserWrapper) project.getSessionProperty(PASER_KEY); if (wrapper == null || (cache != null && cache < time)) { wrapper = new DmdlParserWrapper(jproject); project.setSessionProperty(PASER_KEY, wrapper); project.setSessionProperty(TIME_KEY, time); } } catch (CoreException e) { if (wrapper == null) { wrapper = new DmdlParserWrapper(jproject); } } return wrapper.isValid() ? wrapper : null; }
public static ProjectLintConfiguration get( LintClient client, IProject project, boolean fatalOnly) { // Don't cache fatal-only configurations: they're only used occasionally and typically // not repeatedly if (fatalOnly) { return create(client, project, GlobalLintConfiguration.get(), true); } ProjectLintConfiguration configuration = null; try { Object value = project.getSessionProperty(CONFIGURATION_NAME); configuration = (ProjectLintConfiguration) value; } catch (CoreException e) { // Not a problem; we will just create a new one } if (configuration == null) { configuration = create(client, project, GlobalLintConfiguration.get(), false); try { project.setSessionProperty(CONFIGURATION_NAME, configuration); } catch (CoreException e) { AdtPlugin.log(e, "Can't store lint configuration"); } } return configuration; }
/* (non-Javadoc) * @see org.eclipse.core.internal.jobs.InternalJob#run(org.eclipse.core.runtime.IProgressMonitor) */ protected IStatus run(IProgressMonitor monitor) { TreeNode root = new TreeNode(""); File it = new File(proj.getLocation().addTrailingSeparator() + "goblin.xml"); if (!it.canRead()) return new Status(IStatus.ERROR, "ee.ut.goblin", 97, "Can't read analysis file.", null); DefaultHandler handler = new XMLHandler(root); SAXParserFactory factory = SAXParserFactory.newInstance(); try { // Parse the input SAXParser saxParser = factory.newSAXParser(); saxParser.parse(it, handler); } catch (Throwable t) { return new Status(IStatus.ERROR, "ee.ut.goblin", 96, t.getMessage(), t); } TreeAnalysisMap tam = new TreeAnalysisMap((TreeAnalysis) root.getChildren()[0]); try { proj.setSessionProperty(GoblinPlugin.RESULT_NAME, tam); } catch (CoreException e) { return new Status(IStatus.ERROR, "ee.ut.goblin", 95, e.getMessage(), e); } monitor.done(); return Status.OK_STATUS; }
public static ISharpenProject create(IProject project, IProgressMonitor monitor) throws CoreException { if (!project.hasNature(SharpenNature.NATURE_ID)) { return null; } ISharpenProject cached = (ISharpenProject) project.getSessionProperty(PROJECT_SESSION_KEY); if (null == cached) { cached = new SharpenProject(project); project.setSessionProperty(PROJECT_SESSION_KEY, cached); } return cached; }
/** * Returns the {@link CustomViewFinder} for the given project * * @param project the project the finder is associated with * @return a {@CustomViewFinder} for the given project, never null */ public static CustomViewFinder get(IProject project) { CustomViewFinder finder = null; try { finder = (CustomViewFinder) project.getSessionProperty(CUSTOM_VIEW_FINDER); } catch (CoreException e) { // Not a problem; we will just create a new one } if (finder == null) { finder = new CustomViewFinder(project); try { project.setSessionProperty(CUSTOM_VIEW_FINDER, finder); } catch (CoreException e) { AdtPlugin.log(e, "Can't store CustomViewFinder"); } } return finder; }
/** * Returns the {@link ManifestInfo} for the given project * * @param project the project the finder is associated with * @return a {@ManifestInfo} for the given project, never null */ @NonNull public static ManifestInfo get(IProject project) { ManifestInfo finder = null; try { finder = (ManifestInfo) project.getSessionProperty(MANIFEST_FINDER); } catch (CoreException e) { // Not a problem; we will just create a new one } if (finder == null) { finder = new ManifestInfo(project); try { project.setSessionProperty(MANIFEST_FINDER, finder); } catch (CoreException e) { AdtPlugin.log(e, "Can't store ManifestInfo"); } } return finder; }
/** * Returns the {@link RenderPreviewList} for the given project * * @param project the project the list is associated with * @return a {@link RenderPreviewList} for the given project, never null */ @NonNull public static RenderPreviewList get(@NonNull IProject project) { RenderPreviewList list = null; try { list = (RenderPreviewList) project.getSessionProperty(PREVIEW_LIST); } catch (CoreException e) { // Not a problem; we will just create a new one } if (list == null) { list = new RenderPreviewList(project); try { project.setSessionProperty(PREVIEW_LIST, list); } catch (CoreException e) { AndmoreAndroidPlugin.log(e, null); } } return list; }
public DiscoveredScannerInfo getDiscoveredScannerInfo(IProject project, boolean cacheInfo) throws CoreException { DiscoveredScannerInfo scannerInfo = null; // See if there's already one associated with the resource for this // session scannerInfo = (DiscoveredScannerInfo) project.getSessionProperty(scannerInfoProperty); if (scannerInfo == null) { scannerInfo = new DiscoveredScannerInfo(project); // this will convert user info org.eclipse.cdt.make.core.MakeScannerInfo makeScannerInfo = org.eclipse.cdt.make.core.MakeScannerProvider.getDefault() .getMakeScannerInfo(project, cacheInfo); scannerInfo.setUserScannerInfo(makeScannerInfo); // migrate to new C Path Entries IContainerEntry container = CoreModel.newContainerEntry(DiscoveredPathContainer.CONTAINER_ID); ICProject cProject = CoreModel.getDefault().create(project); if (cProject != null) { IPathEntry[] entries = cProject.getRawPathEntries(); List<IPathEntry> newEntries = new ArrayList<IPathEntry>(Arrays.asList(entries)); if (!newEntries.contains(container)) { newEntries.add(container); cProject.setRawPathEntries(newEntries.toArray(new IPathEntry[newEntries.size()]), null); } } ICDescriptor descriptor = CCorePlugin.getDefault().getCProjectDescription(project); descriptor.remove( CCorePlugin.BUILD_SCANNER_INFO_UNIQ_ID); // remove scanner provider which will fallback to // default // cpath provider. // place holder to that we don't convert again. project.setSessionProperty(scannerInfoProperty, scannerInfo); } return scannerInfo; }