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; }
@Override public void initializeDefaults(ILaunchConfiguration configuration) throws CoreException { dispose(); setLaunchConfiguration(configuration); String projectName = configuration.getAttribute( IJavaLaunchConfigurationConstants.ATTR_PROJECT_NAME, ""); // $NON-NLS-1$ if (projectName != null && projectName.length() > 0) { IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(projectName); if (project != null && project.isOpen()) { ProjectState state = Sdk.getProjectState(project); if (state == null) { initDefaults(); return; } IAndroidTarget target = state.getTarget(); if (target == null) { initDefaults(); return; } // String path = target.getPath(IAndroidTarget.ANDROID_JAR); String path = AdtPlugin.getAuidtJar(); if (path == null) { initDefaults(); return; } IJavaProject javaProject = JavaCore.create(project); if (javaProject != null && javaProject.isOpen()) { IClasspathEntry[] entries = javaProject.getResolvedClasspath(true); IClasspathEntry androidEntry = null; for (int i = 0; i < entries.length; i++) { IClasspathEntry entry = entries[i]; if (entry.getEntryKind() == IClasspathEntry.CPE_LIBRARY && path.equals(entry.getPath().toString())) { androidEntry = entry; break; } } if (androidEntry != null) { IPath sourceAttachmentPath = androidEntry.getSourceAttachmentPath(); if (sourceAttachmentPath != null) { String androidSrc = sourceAttachmentPath.toString(); if (androidSrc != null && androidSrc.trim().length() > 0) { File srcFile = new File(androidSrc); ISourceContainer adtContainer = null; if (srcFile.isFile()) { adtContainer = new ExternalArchiveSourceContainer(androidSrc, true); } if (srcFile.isDirectory()) { adtContainer = new DirectorySourceContainer(srcFile, false); } if (adtContainer != null) { ISourceContainer defaultContainer = new DefaultSourceContainer(); setSourceContainers(new ISourceContainer[] {adtContainer, defaultContainer}); initializeParticipants(); return; } } } } } } } initDefaults(); }