/** * Constructs a source locator that searches for source * in the given Java project, and all of its required projects, * as specified by its build path or default source lookup * settings. * * @param project Java project * @exception CoreException if unable to read the project's * build path */ public JavaUISourceLocator(IJavaProject project) throws CoreException { fJavaProject = project; IJavaSourceLocation[] sls = JavaSourceLocator.getDefaultSourceLocations(project); fSourceLocator = new JavaSourceLocator(project); if (sls != null) { fSourceLocator.setSourceLocations(sls); } fAllowedToAsk = true; }
/** * @see JavaSourceLocator#getSourceLocations() */ public IJavaSourceLocation[] getSourceLocations() { return fSourceLocator.getSourceLocations(); }
/** * Constructs a new JavaSourceLocator that searches the * default set of source locations for the given Java project. * * @param project Java project * @exception CoreException if an exception occurs reading * the classpath of the given or any required project */ public JavaSourceLocator(IJavaProject project) throws CoreException { setSourceLocations(getDefaultSourceLocations(project)); }
/** * Returns a default collection of source locations for * the given Java project. Default source locations consist * of the given project and all of its required projects . * * @param project Java project * @return a collection of source locations for all required * projects * @exception CoreException if an exception occurs reading * computing the default locations */ public static IJavaSourceLocation[] getDefaultSourceLocations(IJavaProject project) throws CoreException { // create a temporary launch config ILaunchConfigurationType type = DebugPlugin.getDefault().getLaunchManager().getLaunchConfigurationType(IJavaLaunchConfigurationConstants.ID_JAVA_APPLICATION); ILaunchConfigurationWorkingCopy config = type.newInstance(null, project.getElementName()); config.setAttribute(IJavaLaunchConfigurationConstants.ATTR_PROJECT_NAME, project.getElementName()); JavaSourceLocator locator = new JavaSourceLocator(); locator.initializeDefaults(config); return locator.getSourceLocations(); }
String name = null; try { name = getFullyQualfiedName(frame); if (name == null) { return null; IJavaSourceLocation[] locations = getSourceLocations(); for (int i = 0; i < locations.length; i++) { try {
abort(LaunchingMessages.JavaSourceLocator_Unable_to_restore_Java_source_locator___invalid_format__6, null); String className = entry.getAttribute("class"); //$NON-NLS-1$ String data = entry.getAttribute("memento"); //$NON-NLS-1$ if (isEmpty(className)) { abort(LaunchingMessages.JavaSourceLocator_Unable_to_restore_Java_source_locator___invalid_format__10, null); clazz = bundle.loadClass(className); } catch (ClassNotFoundException e) { abort(NLS.bind(LaunchingMessages.JavaSourceLocator_Unable_to_restore_source_location___class_not_found___0__11, new String[] {className}), e); location = (IJavaSourceLocation)clazz.newInstance(); } catch (IllegalAccessException e) { abort(LaunchingMessages.JavaSourceLocator_Unable_to_restore_source_location__12, e); } catch (InstantiationException e) { abort(LaunchingMessages.JavaSourceLocator_Unable_to_restore_source_location__12, e); abort(LaunchingMessages.JavaSourceLocator_Unable_to_restore_Java_source_locator___invalid_format__14, null); setSourceLocations(sourceLocations.toArray(new IJavaSourceLocation[sourceLocations.size()])); return; } catch (ParserConfigurationException e) { ex = e; abort(LaunchingMessages.JavaSourceLocator_Exception_occurred_initializing_source_locator__15, ex);
@Override public void initializeDefaults(ILaunchConfiguration configuration) throws CoreException { IRuntimeClasspathEntry[] entries = JavaRuntime.computeUnresolvedSourceLookupPath(configuration); IRuntimeClasspathEntry[] resolved = JavaRuntime.resolveSourceLookupPath(entries, configuration); setSourceLocations(getSourceLocations(resolved)); }
for (int i= 0; i < projects.length; i++) { if (includeRequired) { collectRequiredProjects(projects[i], requiredProjects); } else { if (!requiredProjects.contains(projects[i])) { setSourceLocations(locations);
/** * Constructs a new JavaSourceLocator that searches the * specified set of source locations for source elements. * * @param locations the source locations to search for * source, in the order they should be searched */ public JavaSourceLocator(IJavaSourceLocation[] locations) { setSourceLocations(locations); }
/** * Constructs an empty source locator. */ public JavaUISourceLocator() { fSourceLocator = new JavaSourceLocator(); fAllowedToAsk = true; }
/** * @see IPersistableSourceLocator#initializeDefaults(ILaunchConfiguration) */ public void initializeDefaults(ILaunchConfiguration configuration) throws CoreException { fSourceLocator.initializeDefaults(configuration); fJavaProject = JavaRuntime.getJavaProject(configuration); fIsFindAllSourceElements = configuration.getAttribute(ATTR_FIND_ALL_SOURCE_ELEMENTS, false); }
/** * Returns whether the source attachments of the given package fragment * root and runtime classpath entry are equal. * * @param root package fragment root * @param entry runtime classpath entry * @return whether the source attachments of the given package fragment * root and runtime classpath entry are equal * @throws JavaModelException if there is a problem with the backing Java model */ private static boolean isSourceAttachmentEqual(IPackageFragmentRoot root, IRuntimeClasspathEntry entry) throws JavaModelException { return equalOrNull(root.getSourceAttachmentPath(), entry.getSourceAttachmentPath()); }
/** * Adds all projects required by <code>proj</code> to the list * <code>res</code> * * @param proj the project for which to compute required * projects * @param res the list to add all required projects too * @throws JavaModelException if there is a problem with the backing Java model */ protected static void collectRequiredProjects(IJavaProject proj, ArrayList<IJavaProject> res) throws JavaModelException { if (!res.contains(proj)) { res.add(proj); IJavaModel model= proj.getJavaModel(); IClasspathEntry[] entries= proj.getRawClasspath(); for (int i= 0; i < entries.length; i++) { IClasspathEntry curr= entries[i]; if (curr.getEntryKind() == IClasspathEntry.CPE_PROJECT) { IJavaProject ref= model.getJavaProject(curr.getPath().segment(0)); if (ref.exists()) { collectRequiredProjects(ref, res); } } } } }
case IRuntimeClasspathEntry.ARCHIVE: location = getArchiveSourceLocation(entry); if (location == null) { String path = entry.getSourceAttachmentLocation();
/** * Returns a default collection of source locations for * the given Java project. Default source locations consist * of the given project and all of its required projects . * * @param project Java project * @return a collection of source locations for all required * projects * @exception CoreException if an exception occurs reading * computing the default locations */ public static IJavaSourceLocation[] getDefaultSourceLocations(IJavaProject project) throws CoreException { // create a temporary launch config ILaunchConfigurationType type = DebugPlugin.getDefault().getLaunchManager().getLaunchConfigurationType(IJavaLaunchConfigurationConstants.ID_JAVA_APPLICATION); ILaunchConfigurationWorkingCopy config = type.newInstance(null, project.getElementName()); config.setAttribute(IJavaLaunchConfigurationConstants.ATTR_PROJECT_NAME, project.getElementName()); JavaSourceLocator locator = new JavaSourceLocator(); locator.initializeDefaults(config); return locator.getSourceLocations(); }
String name = null; try { name = getFullyQualfiedName(frame); if (name == null) { return null; IJavaSourceLocation[] locations = getSourceLocations(); for (int i = 0; i < locations.length; i++) { try {
abort(LaunchingMessages.JavaSourceLocator_Unable_to_restore_Java_source_locator___invalid_format__6, null); String className = entry.getAttribute("class"); //$NON-NLS-1$ String data = entry.getAttribute("memento"); //$NON-NLS-1$ if (isEmpty(className)) { abort(LaunchingMessages.JavaSourceLocator_Unable_to_restore_Java_source_locator___invalid_format__10, null); clazz = bundle.loadClass(className); } catch (ClassNotFoundException e) { abort(NLS.bind(LaunchingMessages.JavaSourceLocator_Unable_to_restore_source_location___class_not_found___0__11, new String[] {className}), e); location = (IJavaSourceLocation)clazz.newInstance(); } catch (IllegalAccessException e) { abort(LaunchingMessages.JavaSourceLocator_Unable_to_restore_source_location__12, e); } catch (InstantiationException e) { abort(LaunchingMessages.JavaSourceLocator_Unable_to_restore_source_location__12, e); abort(LaunchingMessages.JavaSourceLocator_Unable_to_restore_Java_source_locator___invalid_format__14, null); setSourceLocations(sourceLocations.toArray(new IJavaSourceLocation[sourceLocations.size()])); return; } catch (ParserConfigurationException e) { ex = e; abort(LaunchingMessages.JavaSourceLocator_Exception_occurred_initializing_source_locator__15, ex);
/** * Constructs a new JavaSourceLocator that searches the * default set of source locations for the given Java project. * * @param project Java project * @exception CoreException if an exception occurs reading * the classpath of the given or any required project */ public JavaSourceLocator(IJavaProject project) throws CoreException { setSourceLocations(getDefaultSourceLocations(project)); }
@Override public void initializeDefaults(ILaunchConfiguration configuration) throws CoreException { IRuntimeClasspathEntry[] entries = JavaRuntime.computeUnresolvedSourceLookupPath(configuration); IRuntimeClasspathEntry[] resolved = JavaRuntime.resolveSourceLookupPath(entries, configuration); setSourceLocations(getSourceLocations(resolved)); }
for (int i= 0; i < projects.length; i++) { if (includeRequired) { collectRequiredProjects(projects[i], requiredProjects); } else { if (!requiredProjects.contains(projects[i])) { setSourceLocations(locations);