Package org.eclipse.jdt.core

Examples of org.eclipse.jdt.core.IImportDeclaration


    List existingImport= null;
    if (restoreExistingImports) {
      existingImport= new ArrayList();
      IImportDeclaration[] imports= cu.getImports();
      for (int i= 0; i < imports.length; i++) {
        IImportDeclaration curr= imports[i];
        char prefix= Flags.isStatic(curr.getFlags()) ? STATIC_PREFIX : NORMAL_PREFIX;
        existingImport.add(prefix + curr.getElementName());
      }
    }
    return new ImportRewrite(cu, null, existingImport);
  }
View Full Code Here


        if(typeName!=null) {
          // If we don't have the type fully qualified name,
          if(typeName.startsWith("Q")) {
            // We get the simple name
            typeName = typeName.substring(1, typeName.length()-1);
            IImportDeclaration imp = null;
            // And try to resolve the full name from the imports
            if(imports!=null) {
              for(int i=0 ; i<imports.length ; i++) {
                imp = imports[i];
                if(imp.getElementName().endsWith(typeName)) {
                  typeName = imp.getElementName();
                  imported = true;
                  break;
                }
              }
              /*
 
View Full Code Here

        if(typeName!=null) {
          // If we don't have the type fully qualified name,
          if(typeName.startsWith("Q")) {
            // We get the simple name
            typeName = typeName.substring(1, typeName.length()-1);
            IImportDeclaration imp = null;
            // And try to resolve the full name from the imports
            if(imports!=null) {
              for(int i=0 ; i<imports.length ; i++) {
                imp = imports[i];
                if(imp.getElementName().endsWith(typeName)) {
                  typeName = imp.getElementName();
                  imported = true;
                  break;
                }
              }
              /*
 
View Full Code Here

                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);
View Full Code Here

    List existingImport= null;
    if (restoreExistingImports) {
      existingImport= new ArrayList();
      IImportDeclaration[] imports= cu.getImports();
      for (int i= 0; i < imports.length; i++) {
        IImportDeclaration curr= imports[i];
        char prefix= Flags.isStatic(curr.getFlags()) ? STATIC_PREFIX : NORMAL_PREFIX;
        existingImport.add(prefix + curr.getElementName());
      }
    }
    return new ImportRewrite(cu, null, existingImport);
  }
View Full Code Here

    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);
View Full Code Here

          return true;
        }
      }
    }
    ICompilationUnit compilationUnit = type.getCompilationUnit();
    IImportDeclaration importDeclaration = compilationUnit.getImport(TEST_ANNOTATION_FULL_NAME);
    return importDeclaration.exists();
  }
View Full Code Here

    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);
View Full Code Here

    List existingImport= null;
    if (restoreExistingImports) {
      existingImport= new ArrayList();
      IImportDeclaration[] imports= cu.getImports();
      for (int i= 0; i < imports.length; i++) {
        IImportDeclaration curr= imports[i];
        char prefix= Flags.isStatic(curr.getFlags()) ? STATIC_PREFIX : NORMAL_PREFIX;
        existingImport.add(prefix + curr.getElementName());
      }
    }
    return new ImportRewrite(cu, null, existingImport);
  }
View Full Code Here

   */
  public boolean hasAssists(IInvocationContext context) throws CoreException {
    IImportDeclaration[] imports = context.getCompilationUnit().getImports();
    // See if we have any JUnit import
    for (int i = 0; i < imports.length; i++) {
      IImportDeclaration id = imports[i];
      String name = id.getElementName();
      if (name.indexOf("junit") != -1) {
        return true;
      }
    }

View Full Code Here

TOP

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

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.