Package org.eclipse.jdt.core

Examples of org.eclipse.jdt.core.IJavaElement


        HashMap<String, List<String>> forPackage = new HashMap<String, List<String>>();       
        for(Point each: mapPerProject.getConfiguration().points()) {
            String fileName = each.getDocument();
            IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
            IResource resource = root.findMember(new Path(fileName));
            IJavaElement create = JavaCore.create(resource);
           
            if (!(create instanceof ICompilationUnit)) continue;
            ICompilationUnit unit = (ICompilationUnit) create;
            try {
                IPackageDeclaration[] packageDeclarations = unit.getPackageDeclarations();
View Full Code Here


            JavaCompletionProposal jcp = (JavaCompletionProposal) o;
            //TODO: FIXME: this is very fragile as it uses reflection to access the private completion field.
            //Yet this is needed to do mvel filtering based on the method signtures, IF we use the richer JDT completion
            //                    Object field = ReflectionUtils.getField( o,
            //                                                             "fProposal" );
            IJavaElement javaElement = jcp.getJavaElement();
            if ( javaElement.getElementType() == IJavaElement.FIELD ) {
                set.add( o );

            }
        } else {
            set.add( o );
View Full Code Here

    int index = name.length();
    /* Stop at the last fragment */
    JavaProject project = (JavaProject) this.compilationUnit.getJavaProject();
    do {
      String testedName = new String(searchedName, 0, index);
      IJavaElement fragment = null;
      try {
        fragment = project.findPackageFragment(testedName);
      } catch (JavaModelException e) {
        return name;
      }
View Full Code Here

    try {
      if (!this.hasComputedEnclosingJavaElements) {
        computeEnclosingJavaElements();
      }
      if (this.compilationUnit == null) return null;
      IJavaElement enclosingElement = this.compilationUnit.getElementAt(this.completionContext.offset);
      return enclosingElement == null ? this.compilationUnit : enclosingElement;
    } catch (JavaModelException e) {
      Util.log(e, "Cannot compute enclosing element"); //$NON-NLS-1$
      return null;
    }
View Full Code Here

    final int length = elements.length;
    final HashMap sourceElementPositions = new HashMap(); // a map from ICompilationUnit to int[] (positions in elements)
    int cuNumber = 0;
    final HashtableOfObjectToInt binaryElementPositions = new HashtableOfObjectToInt(); // a map from String (binding key) to int (position in elements)
    for (int i = 0; i < length; i++) {
      IJavaElement element = elements[i];
      if (!(element instanceof SourceRefElement))
        throw new IllegalStateException(element + " is not part of a compilation unit or class file"); //$NON-NLS-1$
      Object cu = element.getAncestor(IJavaElement.COMPILATION_UNIT);
      if (cu != null) {
        // source member
        IntArrayList intList = (IntArrayList) sourceElementPositions.get(cu);
        if (intList == null) {
          sourceElementPositions.put(cu, intList = new IntArrayList());
View Full Code Here

}
private boolean filterEnum(SearchMatch match) {
 
  // filter org.apache.commons.lang.enum package for projects above 1.5
  // https://bugs.eclipse.org/bugs/show_bug.cgi?id=317264 
  IJavaElement element = (IJavaElement)match.getElement();
  PackageFragment pkg = (PackageFragment)element.getAncestor(IJavaElement.PACKAGE_FRAGMENT);
  if (pkg != null) {
    // enum was found in org.apache.commons.lang.enum at index 5
    if (pkg.names.length == 5 && pkg.names[4].equals("enum")) {  //$NON-NLS-1$
      if (this.options == null) {
        IJavaProject proj = (IJavaProject)pkg.getAncestor(IJavaElement.JAVA_PROJECT);
View Full Code Here

    SearchPattern[] patterns = ((OrPattern) searchPattern).patterns;
    for (int i = 0, length = patterns.length; i < length; i++) {
      locatePackageDeclarations(patterns[i], participant, projects);
    }
  } else if (searchPattern instanceof PackageDeclarationPattern) {
    IJavaElement focus = searchPattern.focus;
    if (focus != null) {
      if (encloses(focus)) {
        SearchMatch match = new PackageDeclarationMatch(focus.getAncestor(IJavaElement.PACKAGE_FRAGMENT), SearchMatch.A_ACCURATE, -1, -1, participant, focus.getResource());
        report(match);
      }
      return;
    }
    PackageDeclarationPattern pkgPattern = (PackageDeclarationPattern) searchPattern;
View Full Code Here

* Visit the given method declaration and report the nodes that match exactly the
* search pattern (i.e. the ones in the matching nodes set)
* Note that the method declaration has already been checked.
*/
protected void reportMatching(AbstractMethodDeclaration method, TypeDeclaration type, IJavaElement parent, int accuracy, boolean typeInHierarchy, MatchingNodeSet nodeSet) throws CoreException {
  IJavaElement enclosingElement = null;

  // report method declaration itself
  if (accuracy > -1) {
    enclosingElement = createHandle(method, parent);
    if (enclosingElement != null) { // skip if unable to find method
View Full Code Here

* @param otherElements TODO
*/
protected void reportMatching(Annotation[] annotations, IJavaElement enclosingElement, IJavaElement[] otherElements, Binding elementBinding, MatchingNodeSet nodeSet, boolean matchedContainer, boolean enclosesElement) throws CoreException {
  for (int i=0, al=annotations.length; i<al; i++) {
    Annotation annotationType = annotations[i];
    IJavaElement localAnnotation = null;
    IJavaElement[] otherAnnotations = null;
    int length = otherElements == null ? 0 : otherElements.length;
    boolean handlesCreated = false;

    // Look for annotation type ref
View Full Code Here

    if (nodes != null) {
      if (!matchedUnitContainer) {
        for (int i = 0, l = nodes.length; i < l; i++)
          nodeSet.matchingNodes.removeKey(nodes[i]);
      } else {
        IJavaElement element = createPackageDeclarationHandle(unit);
        for (int i = 0, l = nodes.length; i < l; i++) {
          ASTNode node = nodes[i];
          Integer level = (Integer) nodeSet.matchingNodes.removeKey(node);
          if (encloses(element)) {
            this.patternLocator.matchReportReference(node, element, null, null, null/*no binding*/, level.intValue(), this);
          }
        }
      }
    }
  }

  if (matchedUnitContainer) {
    ImportReference pkg = unit.currentPackage;
    if (pkg != null && pkg.annotations != null) {
      IJavaElement element = createPackageDeclarationHandle(unit);
      if (element != null) {
        reportMatching(pkg.annotations, element, null, null, nodeSet, true, encloses(element));
      }
    }

View Full Code Here

TOP

Related Classes of org.eclipse.jdt.core.IJavaElement

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.