Exemplo n.º 1
0
 /**
  * Returns the location of the Javadoc.
  *
  * @param element whose Javadoc location has to be found
  * @param isBinary <code>true</code> if the Java element is from a binary container
  * @return the location URL of the Javadoc or <code>null</code> if the location cannot be found
  * @throws JavaModelException thrown when the Java element cannot be accessed
  * @since 3.9
  */
 public static String getBaseURL(IJavaElement element, boolean isBinary)
     throws JavaModelException {
   if (isBinary) {
     // Source attachment usually does not include Javadoc resources
     // => Always use the Javadoc location as base:
     URL baseURL = JavaUI.getJavadocLocation(element, false);
     if (baseURL != null) {
       if (baseURL.getProtocol().equals(JAR_PROTOCOL)) {
         // It's a JarURLConnection, which is not known to the browser widget.
         // Let's start the help web server:
         URL baseURL2 =
             PlatformUI.getWorkbench().getHelpSystem().resolve(baseURL.toExternalForm(), true);
         if (baseURL2 != null) { // can be null if org.eclipse.help.ui is not available
           baseURL = baseURL2;
         }
       }
       return baseURL.toExternalForm();
     }
   } else {
     IResource resource = element.getResource();
     if (resource != null) {
       /*
        * Too bad: Browser widget knows nothing about EFS and custom URL handlers,
        * so IResource#getLocationURI() does not work in all cases.
        * We only support the local file system for now.
        * A solution could be https://bugs.eclipse.org/bugs/show_bug.cgi?id=149022 .
        */
       IPath location = resource.getLocation();
       if (location != null) return location.toFile().toURI().toString();
     }
   }
   return null;
 }
 private IResource getResource(IJavaElement element) {
   if (element == null) return null;
   if (element.getElementType() == IJavaElement.PACKAGE_FRAGMENT) {
     String pkgName = element.getElementName();
     int firstDot = pkgName.indexOf('.');
     if (firstDot != -1) {
       element =
           ((IPackageFragmentRoot) element.getParent())
               .getPackageFragment(pkgName.substring(0, firstDot));
     }
   }
   return element.getResource();
 }
Exemplo n.º 3
0
  protected List<String> getStoriesFullPaths() throws CoreException {
    List<String> stories = null;
    if (btnRadioSingleStory.getSelection() && storyFile != null) {
      String singleStory = (storyFile == null ? "" : storyFile.getRawLocation().toOSString());
      stories = new ArrayList<String>(1);
      stories.add(singleStory);

    } else if (container != null) {
      stories = BehaviourSearch.findStoryPaths(container.getResource());
    }

    return stories;
  }
 /**
  * Tests that removing a source file from an API aware project causes the workspace description to
  * be updated
  */
 public void testWPUpdateSourceRemoved() throws Exception {
   IJavaProject project = getTestingProject();
   assertNotNull("The testing project must exist", project);
   IPackageFragmentRoot root =
       project.findPackageFragmentRoot(
           new Path(project.getElementName()).append(ProjectUtils.SRC_FOLDER).makeAbsolute());
   assertNotNull("the 'src' package fragment root must exist", root);
   assertTestSource(root, TESTING_PACKAGE, "TestClass1");
   IJavaElement element = project.findElement(new Path("a/b/c/TestClass1.java"));
   assertNotNull("the class a.b.c.TestClass1 must exist in the project", element);
   element.getResource().delete(true, new NullProgressMonitor());
   IApiDescription desc = getTestProjectApiDescription();
   assertNotNull("the testing project api description must exist", desc);
   IApiAnnotations annot = desc.resolveAnnotations(Factory.typeDescriptor("a.b.c.TestClass1"));
   assertNull("the annotations for a.b.c.TestClass1 should no longer be present", annot);
 }