/**
  * Sets the deltas to register the changes resulting from this operation for this source element
  * and its destination. If the operation is a cross project operation
  *
  * <ul>
  *   <li>On a copy, the delta should be rooted in the dest project
  *   <li>On a move, two deltas are generated
  *       <ul>
  *         <li>one rooted in the source project
  *         <li>one rooted in the destination project
  *       </ul>
  * </ul>
  *
  * If the operation is rooted in a single project, the delta is rooted in that project
  */
 protected void prepareDeltas(
     IJavaElement sourceElement, IJavaElement destinationElement, boolean isMove) {
   if (Util.isExcluded(sourceElement) || Util.isExcluded(destinationElement)) return;
   IJavaProject destProject = destinationElement.getJavaProject();
   if (isMove) {
     IJavaProject sourceProject = sourceElement.getJavaProject();
     getDeltaFor(sourceProject).movedFrom(sourceElement, destinationElement);
     getDeltaFor(destProject).movedTo(destinationElement, sourceElement);
   } else {
     getDeltaFor(destProject).added(destinationElement);
   }
 }
 @Override
 public void addPages() {
   super.addPages();
   if (page == null) {
     IJavaElement selectedElement = getSelectedJavaElement(selection);
     String repoPath = null;
     IProject project = null;
     if (selectedElement != null) {
       project = selectedElement.getJavaProject().getProject();
       /*List<String> paths = getCeylonRepositories(project.getProject());
       if (paths!=null) {
           for (int i=paths.size()-1; i>=0; i--) {
               String path = paths.get(i);
               if (!path.startsWith("http://")) {
                   repoPath = path;
                   break;
               }
           }
       }*/
     }
     if (repoPath == null) repoPath = getDefaultRepositoryPath();
     page = new ExportModuleWizardPage(repoPath, project, selectedElement);
     // page.init(selection);
   }
   addPage(page);
 }
 /**
  * Initializes the source folder field with a valid package fragment root. The package fragment
  * root is computed from the given Java element.
  *
  * @param elem the Java element used to compute the initial package fragment root used as the
  *     source folder
  */
 protected void initContainerPage(IJavaElement elem) {
   IPackageFragmentRoot initRoot = null;
   if (elem != null) {
     initRoot = JavaModelUtil.getPackageFragmentRoot(elem);
     try {
       if (initRoot == null || initRoot.getKind() != IPackageFragmentRoot.K_SOURCE) {
         IJavaProject jproject = elem.getJavaProject();
         if (jproject != null) {
           initRoot = null;
           if (jproject.exists()) {
             IPackageFragmentRoot[] roots = jproject.getPackageFragmentRoots();
             for (int i = 0; i < roots.length; i++) {
               if (roots[i].getKind() == IPackageFragmentRoot.K_SOURCE) {
                 initRoot = roots[i];
                 break;
               }
             }
           }
           if (initRoot == null) {
             initRoot = jproject.getPackageFragmentRoot(jproject.getResource());
           }
         }
       }
     } catch (JavaModelException e) {
       JavaPlugin.log(e);
     }
   }
   setPackageFragmentRoot(initRoot, true);
 }
  QuerySpecification createQuery(IJavaElement element) throws JavaModelException {
    JavaSearchScopeFactory factory = JavaSearchScopeFactory.getInstance();
    JavaEditor editor = getEditor();

    IJavaSearchScope scope;
    String description;
    boolean isInsideJRE = true;
    if (editor != null) {
      scope = factory.createJavaProjectSearchScope(editor.getEditorInput(), isInsideJRE);
      description = factory.getProjectScopeDescription(editor.getEditorInput(), isInsideJRE);
    } else {
      scope = factory.createJavaProjectSearchScope(element.getJavaProject(), isInsideJRE);
      description = factory.getProjectScopeDescription(element.getJavaProject(), isInsideJRE);
    }
    return new ElementQuerySpecification(element, getLimitTo(), scope, description);
  }
 @Override
 protected List<? extends IRenameElementContext> createRenameElementContexts(Object element) {
   if (element instanceof IJavaElement) {
     IJavaElement javaElement = (IJavaElement) element;
     EClass expectedJvmType = getExpectedJvmType(javaElement);
     if (expectedJvmType != null) {
       IJavaProject javaProject = javaElement.getJavaProject();
       IProject project = javaProject.getProject();
       ResourceSet resourceSet = resourceSetProvider.get(project);
       EObject directJvmElement =
           jvmElementFinder.getCorrespondingJvmElement(javaElement, resourceSet);
       if (directJvmElement != null && expectedJvmType.isSuperTypeOf(directJvmElement.eClass())) {
         EObject indexedJvmElement =
             jvmElementFinder.findJvmElementDeclarationInIndex(directJvmElement, project);
         if (indexedJvmElement != null)
           // jvmElement is indexed, thus contained in an XtextResurce and likely inferred from
           // some Xtext-based elements
           return getContextFactory(indexedJvmElement)
               .createJdtParticipantXtextSourceContexts(indexedJvmElement);
         else if (directJvmElement instanceof JvmMember)
           // jvmElement is only cross referenced by Xtext-based elements
           return createJdtRenameParticipantContext((JvmMember) directJvmElement, javaElement);
       }
     }
   }
   return null;
 }
 /**
  * Collects the existing tags on the {@link IJavaElement} we have been activated on
  *
  * @param element
  * @param jcontext
  * @throws JavaModelException
  * @throws BadLocationException
  */
 private void collectExistingTags(
     IJavaElement element, JavaContentAssistInvocationContext jcontext) throws JavaModelException {
   if (element instanceof IMember) {
     IMember member = (IMember) element;
     ICompilationUnit cunit = jcontext.getCompilationUnit();
     if (cunit != null) {
       if (cunit.isWorkingCopy()) {
         cunit.reconcile(ICompilationUnit.NO_AST, false, false, null, null);
       }
       fParser.setSource(member.getSource().toCharArray());
       fParser.setKind(ASTParser.K_CLASS_BODY_DECLARATIONS);
       Map<String, String> options = element.getJavaProject().getOptions(true);
       options.put(JavaCore.COMPILER_DOC_COMMENT_SUPPORT, JavaCore.ENABLED);
       fParser.setCompilerOptions(options);
       fParser.setStatementsRecovery(false);
       fParser.setResolveBindings(false);
       fParser.setBindingsRecovery(false);
       ASTNode ast = fParser.createAST(null);
       TagCollector collector = new TagCollector();
       if (ast.getNodeType() == ASTNode.TYPE_DECLARATION) {
         TypeDeclaration typeDeclaration = (TypeDeclaration) ast;
         List<BodyDeclaration> bodyDeclarations = typeDeclaration.bodyDeclarations();
         if (bodyDeclarations.size() == 1) {
           // only one element should be there as we are parsing a
           // specific member
           BodyDeclaration bodyDeclaration = bodyDeclarations.iterator().next();
           Javadoc javadoc = bodyDeclaration.getJavadoc();
           if (javadoc != null) {
             javadoc.accept(collector);
           }
         }
       }
     }
   }
 }
 protected IPackageFragmentRoot getFragmentRoot(IJavaElement elem) {
   IPackageFragmentRoot initRoot = null;
   if (elem != null) {
     initRoot = (IPackageFragmentRoot) elem.getAncestor(IJavaElement.PACKAGE_FRAGMENT_ROOT);
     try {
       if (initRoot == null || initRoot.getKind() != IPackageFragmentRoot.K_SOURCE) {
         IJavaProject jproject = elem.getJavaProject();
         if (jproject != null) {
           initRoot = null;
           if (jproject.exists()) {
             IPackageFragmentRoot[] roots = jproject.getPackageFragmentRoots();
             for (int i = 0; i < roots.length; i++) {
               if (roots[i].getKind() == IPackageFragmentRoot.K_SOURCE) {
                 initRoot = roots[i];
                 break;
               }
             }
           }
           if (initRoot == null) {
             initRoot = jproject.getPackageFragmentRoot(jproject.getResource());
           }
         }
       }
     } catch (JavaModelException e) {
       // TODO
       e.printStackTrace();
     }
   }
   return initRoot;
 }
  public void elementChanged(ElementChangedEvent event) {
    IJavaElementDelta[] children = event.getDelta().getChangedChildren(); // children = IProjects
    for (IJavaElementDelta child : children) {
      IProject project = child.getElement().getJavaProject().getProject();
      int size = child.getAffectedChildren().length; // .getChangedElement() = JavaProject
      if (size == 1) {
        IJavaElementDelta elementDelta =
            child.getAffectedChildren()[0]; // if it is only 1, name is ".tmp"
        // and elementDelta.kind = 4
        // (CHANGED)
        IJavaElement changedElement = elementDelta.getElement();
        if (changedElement
            .getElementName()
            .equals(ImportUtils.getImportPref(ResourceBuilder.LOCALE_INTERFACES_FOLDER_NAME))) {
          _changedBuildClasspath.put(project.getName(), Boolean.FALSE);
          break;
        }
      }
      if (isClasspathChange(
          child)) { // adding classpath entries might induce reordering the classpath entries
        _changedBuildClasspath.put(project.getName(), Boolean.TRUE);
        // notify the listeners
        EJDEEventNotifier.getInstance()
            .notifyClassPathChanged(child.getElement().getJavaProject(), hasCPRemoved(child));
        // validate the project
        ValidationManager.getInstance()
            .validateProjects(
                ProjectUtils.getAllReferencingProjects(
                    new IProject[] {child.getElement().getJavaProject().getProject()}),
                null);
      }
      if ((child.getFlags() & IJavaElementDelta.F_CLASSPATH_CHANGED) != 0
          || (child.getFlags() & IJavaElementDelta.F_RESOLVED_CLASSPATH_CHANGED) != 0) {
        IJavaElement javaElement = child.getElement();
        final IJavaProject javaProject = javaElement.getJavaProject();
        classPathChanged(javaProject, child);
      }
      checkSourceAttachement(child.getAffectedChildren());
    }

    for (final IJavaElementDelta addedElemDelta : event.getDelta().getAddedChildren()) {
      final IJavaProject javaProject = addedElemDelta.getElement().getJavaProject();
      try {
        if (javaProject.getProject().hasNature(BlackBerryProjectCoreNature.NATURE_ID)) {
          if (addedElemDelta.getAffectedChildren().length == 0) {
            final IJavaElement addedElement = addedElemDelta.getElement();
            if (addedElement instanceof IJavaProject) {
              final IJavaProject addedJavaProj = (IJavaProject) addedElement;
              if (addedJavaProj.equals(javaProject)) {
                projectCreated(javaProject);
              }
            }
          }
        }
      } catch (final CoreException ce) {
        _log.error("", ce);
      }
    }
  }
Exemple #9
0
 /**
  * Determines if an item or list of items are found on the build path. Once any one single items
  * matches though, the method returns true, this method is intended to be used in OR like
  * situations, where we do not care if all of the items are on the build path, only that one of
  * them is.
  *
  * @param element the element whose build path should be checked
  * @param args the value(s) to search for on the build path
  * @return true if any one of the args is found on the build path
  */
 private boolean hasItemOnBuildPath(IJavaElement element, Object[] args) {
   if (element != null && args != null) {
     IJavaProject project = element.getJavaProject();
     Set searched = new HashSet();
     searched.add(project);
     return hasItemsOnBuildPath(project, searched, args);
   }
   return false;
 }
Exemple #10
0
 public URI getFullURI(IJavaElement javaElement) {
   @SuppressWarnings("all")
   ASTParser parser = ASTParser.newParser(AST.JLS3);
   parser.setProject(javaElement.getJavaProject());
   IBinding[] bindings = parser.createBindings(new IJavaElement[] {javaElement}, null);
   if (bindings[0] != null) {
     return getFullURI(bindings[0]);
   }
   return null;
 }
Exemple #11
0
 /**
  * determines if the project selected has the specified nature
  *
  * @param resource the resource to get the project for
  * @param ntype the specified nature type
  * @return true if the specified nature matches the project, false otherwise
  */
 private boolean hasProjectNature(IJavaElement element, String ntype) {
   try {
     if (element != null) {
       IJavaProject jproj = element.getJavaProject();
       if (jproj != null) {
         IProject proj = jproj.getProject();
         return proj.isAccessible() && proj.hasNature(ntype);
       }
     }
     return false;
   } catch (CoreException e) {
     return false;
   }
 }
 public void launch(IEditorPart editor, String mode) {
   IEditorInput input = editor.getEditorInput();
   IJavaElement element = (IJavaElement) input.getAdapter(IJavaElement.class);
   if (element != null) {
     IJavaProject jproject = element.getJavaProject();
     if (jproject != null) {
       launch(jproject.getProject().getFullPath(), mode);
     }
   } else {
     IFile file = ResourceUtil.getFile(input);
     if (file != null) {
       if (file.getName().endsWith(LaunchConstants.EXT_BNDRUN)) {
         launch(file.getFullPath(), mode);
       } else if (file.getName().equals(Project.BNDFILE)) {
         launch(file.getProject().getFullPath(), mode);
       }
     }
   }
 }
  private IJavaProject getProject() {
    ITextEditor editor = getEditor();
    if (editor == null) return null;

    IJavaElement element = null;
    IEditorInput input = editor.getEditorInput();
    IDocumentProvider provider = editor.getDocumentProvider();
    if (provider instanceof ICompilationUnitDocumentProvider) {
      ICompilationUnitDocumentProvider cudp = (ICompilationUnitDocumentProvider) provider;
      element = cudp.getWorkingCopy(input);
    } else if (input instanceof IClassFileEditorInput) {
      IClassFileEditorInput cfei = (IClassFileEditorInput) input;
      element = cfei.getClassFile();
    }

    if (element == null) return null;

    return element.getJavaProject();
  }
  public String convertToString(Object parameterValue) throws ParameterValueConversionException {

    if (!(parameterValue instanceof IJavaElement)) {
      throw new ParameterValueConversionException(
          "parameterValue must be an IJavaElement"); //$NON-NLS-1$
    }

    IJavaElement javaElement = (IJavaElement) parameterValue;

    IJavaProject javaProject = javaElement.getJavaProject();
    if (javaProject == null) {
      throw new ParameterValueConversionException(
          "Could not get IJavaProject for element"); //$NON-NLS-1$
    }

    StringBuffer buffer;

    if (javaElement instanceof IType) {
      IType type = (IType) javaElement;
      buffer = composeTypeReference(type);
    } else if (javaElement instanceof IMethod) {
      IMethod method = (IMethod) javaElement;
      buffer = composeTypeReference(method.getDeclaringType());
      buffer.append(TYPE_END_CHAR);
      buffer.append(method.getElementName());
      String[] parameterTypes = method.getParameterTypes();
      buffer.append(PARAM_START_CHAR);
      for (int i = 0; i < parameterTypes.length; i++) {
        buffer.append(parameterTypes[i]);
      }
      buffer.append(PARAM_END_CHAR);
    } else if (javaElement instanceof IField) {
      IField field = (IField) javaElement;
      buffer = composeTypeReference(field.getDeclaringType());
      buffer.append(TYPE_END_CHAR);
      buffer.append(field.getElementName());
    } else {
      throw new ParameterValueConversionException("Unsupported IJavaElement type"); // $NON-NLS-1$
    }

    return buffer.toString();
  }
  @Override
  public IStatus satisfiesPreconditions() {
    ForStatement statement = getForStatement();
    CompilationUnit ast = (CompilationUnit) statement.getRoot();

    IJavaElement javaElement = ast.getJavaElement();
    if (javaElement == null) return ERROR_STATUS;

    if (!JavaModelUtil.is50OrHigher(javaElement.getJavaProject())) return ERROR_STATUS;

    if (!validateInitializers(statement)) return ERROR_STATUS;

    if (!validateExpression(statement)) return ERROR_STATUS;

    if (!validateUpdaters(statement)) return ERROR_STATUS;

    if (!validateBody(statement)) return ERROR_STATUS;

    return Status.OK_STATUS;
  }
 private void checkElementExistence(IWorkingSet workingSet) {
   List<IAdaptable> elements = new ArrayList<>(Arrays.asList(workingSet.getElements()));
   boolean changed = false;
   for (Iterator<IAdaptable> iter = elements.iterator(); iter.hasNext(); ) {
     IAdaptable element = iter.next();
     boolean remove = false;
     if (element instanceof IJavaElement) {
       IJavaElement jElement = (IJavaElement) element;
       // If we have directly a project then remove it when it
       // doesn't exist anymore. However if we have a sub element
       // under a project only remove the element if the parent
       // project is open. Otherwise we would remove all elements
       // in closed projects.
       if (jElement instanceof IJavaProject) {
         remove = !jElement.exists();
       } else {
         final IJavaProject javaProject = jElement.getJavaProject();
         final boolean isProjectOpen =
             javaProject != null ? javaProject.getProject().isOpen() : true;
         remove = isProjectOpen && !jElement.exists();
       }
     } else if (element instanceof IResource) {
       IResource resource = (IResource) element;
       // See comments above
       if (resource instanceof IProject) {
         remove = !resource.exists();
       } else {
         IProject project = resource.getProject();
         remove = (project != null ? project.isOpen() : true) && !resource.exists();
       }
     }
     if (remove) {
       iter.remove();
       changed = true;
     }
   }
   if (changed) {
     workingSet.setElements(elements.toArray(new IAdaptable[elements.size()]));
   }
 }
 /**
  * Resolves the {@link IJavaProject} within the context of the given {@link IJavaStackFrame}
  *
  * @param frame
  * @return the {@link IJavaProject} or <code>null</code>
  * @since 3.8.0
  */
 public static IJavaProject resolveJavaProject(IJavaStackFrame frame) {
   ILaunch launch = frame.getLaunch();
   if (launch != null) {
     try {
       Object sourceElement = resolveSourceElement(frame, JAVA_STRATUM, launch);
       IJavaElement element = getJavaElement(sourceElement);
       if (element != null) {
         return element.getJavaProject();
       }
       // If Source element is not a Java element
       if (sourceElement instanceof IResource) {
         IJavaProject project = JavaCore.create(((IResource) sourceElement).getProject());
         if (project.exists()) {
           return project;
         }
       }
     } catch (CoreException ce) {
       // do nothing, return null
     }
   }
   return null;
 }
  /**
   * Creates a new search scope with all compilation units possibly referencing <code>javaElement
   * </code>.
   *
   * @param javaElement the java element
   * @param considerVisibility consider visibility of javaElement iff <code>true</code>
   * @param sourceReferencesOnly consider references in source only (no references in binary)
   * @return the search scope
   * @throws JavaModelException if an error occurs
   */
  public static IJavaSearchScope create(
      IJavaElement javaElement, boolean considerVisibility, boolean sourceReferencesOnly)
      throws JavaModelException {
    if (considerVisibility & javaElement instanceof IMember) {
      IMember member = (IMember) javaElement;
      if (JdtFlags.isPrivate(member)) {
        if (member.getCompilationUnit() != null)
          return SearchEngine.createJavaSearchScope(
              new IJavaElement[] {member.getCompilationUnit()});
        else return SearchEngine.createJavaSearchScope(new IJavaElement[] {member});
      }
      // Removed code that does some optimizations regarding package visible members. The problem is
      // that
      // there can be a package fragment with the same name in a different source folder or project.
      // So we
      // have to treat package visible members like public or protected members.
    }

    IJavaProject javaProject = javaElement.getJavaProject();
    return SearchEngine.createJavaSearchScope(
        getAllScopeElements(javaProject, sourceReferencesOnly), false);
  }
 protected void launchJavaElement(IJavaElement element, String mode) throws CoreException {
   launch(element.getJavaProject().getProject().getFullPath(), mode);
 }
  public static URL getJavadocLocation(IJavaElement element, boolean includeMemberReference)
      throws JavaModelException {
    URL baseLocation = getJavadocBaseLocation(element);
    if (baseLocation == null) {
      return null;
    }

    String urlString = baseLocation.toExternalForm();

    StringBuffer urlBuffer = new StringBuffer(urlString);
    if (!urlString.endsWith("/")) { // $NON-NLS-1$
      urlBuffer.append('/');
    }

    StringBuffer pathBuffer = new StringBuffer();
    StringBuffer fragmentBuffer = new StringBuffer();

    switch (element.getElementType()) {
      case IJavaElement.PACKAGE_FRAGMENT:
        appendPackageSummaryPath((IPackageFragment) element, pathBuffer);
        break;
      case IJavaElement.JAVA_PROJECT:
      case IJavaElement.PACKAGE_FRAGMENT_ROOT:
        appendIndexPath(pathBuffer);
        break;
      case IJavaElement.IMPORT_CONTAINER:
        element = element.getParent();
        // $FALL-THROUGH$
      case IJavaElement.COMPILATION_UNIT:
        IType mainType = ((ICompilationUnit) element).findPrimaryType();
        if (mainType == null) {
          return null;
        }
        appendTypePath(mainType, pathBuffer);
        break;
      case IJavaElement.CLASS_FILE:
        appendTypePath(((IClassFile) element).getType(), pathBuffer);
        break;
      case IJavaElement.TYPE:
        appendTypePath((IType) element, pathBuffer);
        break;
      case IJavaElement.FIELD:
        IField field = (IField) element;
        appendTypePath(field.getDeclaringType(), pathBuffer);
        if (includeMemberReference) {
          appendFieldReference(field, fragmentBuffer);
        }
        break;
      case IJavaElement.METHOD:
        IMethod method = (IMethod) element;
        appendTypePath(method.getDeclaringType(), pathBuffer);
        if (includeMemberReference) {
          appendMethodReference(method, fragmentBuffer);
        }
        break;
      case IJavaElement.INITIALIZER:
        appendTypePath(((IMember) element).getDeclaringType(), pathBuffer);
        break;
      case IJavaElement.IMPORT_DECLARATION:
        IImportDeclaration decl = (IImportDeclaration) element;

        if (decl.isOnDemand()) {
          IJavaElement cont =
              JavaModelUtil.findTypeContainer(
                  element.getJavaProject(), Signature.getQualifier(decl.getElementName()));
          if (cont instanceof IType) {
            appendTypePath((IType) cont, pathBuffer);
          } else if (cont instanceof IPackageFragment) {
            appendPackageSummaryPath((IPackageFragment) cont, pathBuffer);
          }
        } else {
          IType imp = element.getJavaProject().findType(decl.getElementName());
          appendTypePath(imp, pathBuffer);
        }
        break;
      case IJavaElement.PACKAGE_DECLARATION:
        IJavaElement pack = element.getAncestor(IJavaElement.PACKAGE_FRAGMENT);
        if (pack != null) {
          appendPackageSummaryPath((IPackageFragment) pack, pathBuffer);
        } else {
          return null;
        }
        break;
      default:
        return null;
    }

    try {
      String fragment = fragmentBuffer.length() == 0 ? null : fragmentBuffer.toString();
      try {
        URI relativeURI = new URI(null, null, pathBuffer.toString(), fragment);
        urlBuffer.append(relativeURI.toString());
        return new URL(urlBuffer.toString());
      } catch (URISyntaxException e) {
        JavaPlugin.log(e);
        return new URL(urlBuffer.append(pathBuffer).toString());
      }
    } catch (MalformedURLException e) {
      JavaPlugin.log(e);
    }
    return null;
  }
  public JavadocHelpContext(IContext context, Object[] elements) throws JavaModelException {
    Assert.isNotNull(elements);
    if (context instanceof IContext2) fTitle = ((IContext2) context).getTitle();

    List helpResources = new ArrayList();

    String javadocSummary = null;
    for (int i = 0; i < elements.length; i++) {
      if (elements[i] instanceof IJavaElement) {
        IJavaElement element = (IJavaElement) elements[i];
        // if element isn't on the build path skip it
        if (!ActionUtil.isOnBuildPath(element)) continue;

        // Create Javadoc summary
        if (BUG_85721_FIXED) {
          if (javadocSummary == null) {
            javadocSummary = retrieveText(element);
            if (javadocSummary != null) {
              String elementLabel =
                  JavaElementLabels.getTextLabel(element, JavaElementLabels.ALL_DEFAULT);

              // FIXME: needs to be NLSed once the code becomes active
              javadocSummary =
                  "<b>Javadoc for "
                      + elementLabel
                      + ":</b><br>"
                      + javadocSummary; //$NON-NLS-1$//$NON-NLS-2$
            }
          } else {
            javadocSummary = ""; // no Javadoc summary for multiple selection //$NON-NLS-1$
          }
        }

        URL url = JavaUI.getJavadocLocation(element, true);
        if (url == null || doesNotExist(url)) {
          IPackageFragmentRoot root = JavaModelUtil.getPackageFragmentRoot(element);
          if (root != null) {
            url = JavaUI.getJavadocBaseLocation(element);
            if (root.getKind() == IPackageFragmentRoot.K_SOURCE) {
              element = element.getJavaProject();
            } else {
              element = root;
            }
            url = JavaUI.getJavadocLocation(element, false);
          }
        }
        if (url != null) {
          IHelpResource javaResource = new JavaUIHelpResource(element, getURLString(url));
          helpResources.add(javaResource);
        }
      }
    }

    // Add static help topics
    if (context != null) {
      IHelpResource[] resources = context.getRelatedTopics();
      if (resources != null) {
        for (int j = 0; j < resources.length; j++) {
          helpResources.add(resources[j]);
        }
      }
    }

    fHelpResources =
        (IHelpResource[]) helpResources.toArray(new IHelpResource[helpResources.size()]);

    if (context != null) fText = context.getText();

    if (BUG_85721_FIXED) {
      if (javadocSummary != null && javadocSummary.length() > 0) {
        if (fText != null) fText = context.getText() + "<br><br>" + javadocSummary; // $NON-NLS-1$
        else fText = javadocSummary;
      }
    }

    if (fText == null) fText = ""; // $NON-NLS-1$
  }