Package org.aspectj.org.eclipse.jdt.core

Examples of org.aspectj.org.eclipse.jdt.core.IJavaElement


      Object target = JavaModel.getTarget(ResourcesPlugin.getWorkspace().getRoot(), new Path(this.containerPaths[index]+'/'+this.relativePaths[index]), false);
      if (target instanceof IProject) {
        return project.getPackageFragmentRoot((IProject) target);
      }
      if (target instanceof IResource) {
        IJavaElement element = JavaCore.create((IResource)target);
        return (IPackageFragmentRoot) element.getAncestor(IJavaElement.PACKAGE_FRAGMENT_ROOT);
      }
      if (isJarFile) {
        return project.getPackageFragmentRoot(this.containerPaths[index]);
      }
    }
View Full Code Here


*/
private void initializeIndexLocations() {
  IPath[] projectsAndJars = this.searchScope.enclosingProjectsAndJars();
  IndexManager manager = JavaModelManager.getJavaModelManager().getIndexManager();
  SimpleSet locations = new SimpleSet();
  IJavaElement focus = MatchLocator.projectOrJarFocus(this.pattern);
  if (focus == null) {
    for (int i = 0; i < projectsAndJars.length; i++)
      locations.add(manager.computeIndexLocation(projectsAndJars[i]));
  } else {
    try {
      // find the projects from projectsAndJars that see the focus then walk those projects looking for the jars from projectsAndJars
      int length = projectsAndJars.length;
      JavaProject[] projectsCanSeeFocus = new JavaProject[length];
      SimpleSet visitedProjects = new SimpleSet(length);
      int projectIndex = 0;
      SimpleSet jarsToCheck = new SimpleSet(length);
      IClasspathEntry[] focusEntries = null;
      if (this.pattern instanceof MethodPattern) { // should consider polymorphic search for method patterns
        JavaProject focusProject = focus instanceof JarPackageFragmentRoot ? (JavaProject) focus.getParent() : (JavaProject) focus;
        focusEntries = focusProject.getExpandedClasspath();
      }
      IJavaModel model = JavaModelManager.getJavaModelManager().getJavaModel();
      for (int i = 0; i < length; i++) {
        IPath path = projectsAndJars[i];
View Full Code Here

            }
          }
        }
      }
    } else {
      IJavaElement fromFactory = JavaCore.create(possibleFragment);
      if (fromFactory == null) {
        return null;
      }
      switch (fromFactory.getElementType()) {
        case IJavaElement.PACKAGE_FRAGMENT:
          return (IPackageFragment) fromFactory;
        case IJavaElement.JAVA_PROJECT:
          // default package in a default root
          JavaProject project = (JavaProject) fromFactory;
View Full Code Here

        }
        int matchLength = name.length();
        for (int i = 0; i < length; i++) {
          if (requestor.isCanceled())
            return;
          IJavaElement classFile= classFiles[i];
          // MatchName will never have the extension ".class" and the elementName always will.
          String elementName = classFile.getElementName();
          if (elementName.regionMatches(true /*ignore case*/, 0, name, 0, matchLength)) {
            IType type = ((ClassFile) classFile).getType();
            String typeName = type.getElementName();
            if (typeName.length() > 0 && !Character.isDigit(typeName.charAt(0))) { //not an anonymous type
              if (nameMatches(unqualifiedName, type, true/*partial match*/) && acceptType(type, acceptFlags, false/*not a source type*/))
 
View Full Code Here

        try {
          IJavaElement[] compilationUnits = pkg.getChildren();
          for (int i = 0, length = compilationUnits.length; i < length; i++) {
            if (requestor.isCanceled())
              return;
            IJavaElement cu = compilationUnits[i];
            String cuName = cu.getElementName();
            int lastDot = cuName.lastIndexOf('.');
            if (lastDot != topLevelTypeName.length() || !topLevelTypeName.regionMatches(0, cuName, 0, lastDot))
              continue;
            IType type = ((ICompilationUnit) cu).getType(topLevelTypeName);
            type = getMemberType(type, name, firstDot);
            if (acceptType(type, acceptFlags, true/*a source type*/)) { // accept type checks for existence
              requestor.acceptType(type);
              break// since an exact match was requested, no other matching type can exist
            }
          }
        } catch (JavaModelException e) {
          // package doesn't exist -> ignore
        }
      } else {
        try {
          String cuPrefix = firstDot == -1 ? name : name.substring(0, firstDot);
          IJavaElement[] compilationUnits = pkg.getChildren();
          for (int i = 0, length = compilationUnits.length; i < length; i++) {
            if (requestor.isCanceled())
              return;
            IJavaElement cu = compilationUnits[i];
            if (!cu.getElementName().toLowerCase().startsWith(cuPrefix))
              continue;
            try {
              IType[] types = ((ICompilationUnit) cu).getTypes();
              for (int j = 0, typeLength = types.length; j < typeLength; j++)
                seekTypesInTopLevelType(name, firstDot, types[j], requestor, acceptFlags);
View Full Code Here

  }
  this.needsInitialize = false;
}
public void processDelta(IJavaElementDelta delta) {
  if (this.needsInitialize) return;
  IJavaElement element = delta.getElement();
  switch (element.getElementType()) {
    case IJavaElement.JAVA_MODEL:
      IJavaElementDelta[] children = delta.getAffectedChildren();
      for (int i = 0, length = children.length; i < length; i++) {
        IJavaElementDelta child = children[i];
        this.processDelta(child);
View Full Code Here

  /*
   * Finds the TypeDeclaration in the given ast corresponding to the given type handle.
   * Returns null if not found.
   */
  public TypeDeclaration findType(IType typeHandle) {
    IJavaElement parent = typeHandle.getParent();
    final char[] typeName = typeHandle.getElementName().toCharArray();
    final int occurenceCount = ((SourceType)typeHandle).occurrenceCount;
    final boolean findAnonymous = typeName.length == 0;
    class Visitor extends ASTVisitor {
      TypeDeclaration result;
      int count = 0;
      public boolean visit(TypeDeclaration typeDeclaration, BlockScope scope) {
        if (result != null) return false;
        if ((typeDeclaration.bits & ASTNode.IsAnonymousType) != 0) {
          if (findAnonymous && ++count == occurenceCount) {
            result = typeDeclaration;
          }
        } else {
          if (!findAnonymous && CharOperation.equals(typeName, typeDeclaration.name)) {
            result = typeDeclaration;
          }
        }
        return false; // visit only one level
      }
    }
    switch (parent.getElementType()) {
      case IJavaElement.COMPILATION_UNIT:
        TypeDeclaration[] types = this.unit.types;
        if (types != null) {
          for (int i = 0, length = types.length; i < length; i++) {
            TypeDeclaration type = types[i];
View Full Code Here

/**
* Returns the nested operation to use for processing this element
*/
protected JavaModelOperation getNestedOperation(IJavaElement element) {
  try {
    IJavaElement dest = getDestinationParent(element);
    switch (element.getElementType()) {
      case IJavaElement.PACKAGE_DECLARATION :
        return new CreatePackageDeclarationOperation(element.getElementName(), (ICompilationUnit) dest);
      case IJavaElement.IMPORT_DECLARATION :
        IImportDeclaration importDeclaration = (IImportDeclaration) element;
        return new CreateImportOperation(element.getElementName(), (ICompilationUnit) dest, importDeclaration.getFlags());
      case IJavaElement.TYPE :
        if (isRenamingMainType(element, dest)) {
          IPath path = element.getPath();
          String extension = path.getFileExtension();
          return new RenameResourceElementsOperation(new IJavaElement[] {dest}, new IJavaElement[] {dest.getParent()}, new String[]{getNewNameFor(element) + '.' + extension}, this.force);
        } else {
          String source = getSourceFor(element);
          String lineSeparator = org.aspectj.org.eclipse.jdt.internal.core.util.Util.getLineSeparator(source, element.getJavaProject());
          return new CreateTypeOperation(dest, source + lineSeparator, this.force);
        }
View Full Code Here

  boolean createElementInCUOperation =op instanceof CreateElementInCUOperation;
  if (op == null) {
    return;
  }
  if (createElementInCUOperation) {
    IJavaElement sibling = (IJavaElement) this.insertBeforeElements.get(element);
    if (sibling != null) {
      ((CreateElementInCUOperation) op).setRelativePosition(sibling, CreateElementInCUOperation.INSERT_BEFORE);
    } else
      if (isRename()) {
        IJavaElement anchor = resolveRenameAnchor(element);
        if (anchor != null) {
          ((CreateElementInCUOperation) op).setRelativePosition(anchor, CreateElementInCUOperation.INSERT_AFTER); // insert after so that the anchor is found before when deleted below
        }
      }
    String newName = getNewNameFor(element);
View Full Code Here

*/
private IJavaElement resolveRenameAnchor(IJavaElement element) throws JavaModelException {
  IParent parent = (IParent) element.getParent();
  IJavaElement[] children = parent.getChildren();
  for (int i = 0; i < children.length; i++) {
    IJavaElement child = children[i];
    if (child.equals(element)) {
      return child;
    }
  }
  return null;
}
View Full Code Here

TOP

Related Classes of org.aspectj.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.