Examples of PackageDeclaration


Examples of org.apache.beehive.netui.compiler.typesystem.declaration.PackageDeclaration

            else
            {
                // Use the package name to infer the relative path (from web content root) to the page flow directory.
                String[] webContentRoots = CompilerUtils.getWebContentRoots( env );
                String jpfParentRelativePath = "";
                PackageDeclaration jpfPackage = outerClass.getPackage();
                if ( jpfPackage != null ) jpfParentRelativePath = jpfPackage.getQualifiedName().replace( '.', '/' );
               
                for ( int i = 0; i < webContentRoots.length; i++ )
                {
                    String webContentRoot = webContentRoots[i];
                    File desiredParentDir = new File( webContentRoot, jpfParentRelativePath );
View Full Code Here

Examples of org.aspectj.org.eclipse.jdt.core.dom.PackageDeclaration

    }
    return -1;
  }
 
  private int getPackageStatementEndPos(CompilationUnit root) {
    PackageDeclaration packDecl= root.getPackage();
    if (packDecl != null) {
      int lineAfterPackage= root.getLineNumber(packDecl.getStartPosition() + packDecl.getLength()) + 1;
      int afterPackageStatementPos= root.getPosition(lineAfterPackage, 0);
      if (afterPackageStatementPos >= 0) {
        int firstTypePos= getFirstTypeBeginPos(root);
        if (firstTypePos != -1 && firstTypePos <= afterPackageStatementPos) {
          if (firstTypePos <= afterPackageStatementPos) {
View Full Code Here

Examples of org.aspectj.org.eclipse.jdt.core.dom.PackageDeclaration

      this.creationOccurred = false;
      return null;
    }
  }
  AST ast = this.cuAST.getAST();
  PackageDeclaration pkgDeclaration = ast.newPackageDeclaration();
  Name astName = ast.newName(this.name);
  pkgDeclaration.setName(astName);
  return pkgDeclaration;
}
View Full Code Here

Examples of org.eclipse.jdt.core.dom.PackageDeclaration

       
        // create file in appropriate package
        m_compilationUnit = ast.newCompilationUnit();
        String pname = pack.getName();
        if (pname.length() > 0) {
            PackageDeclaration packageDeclaration = ast.newPackageDeclaration();
            packageDeclaration.setName(ast.newName(pname));
            m_compilationUnit.setPackage(packageDeclaration);
        }
    }
View Full Code Here

Examples of org.eclipse.jdt.core.dom.PackageDeclaration

          // Create new CompilationUnit
          try {
            AST ast = AST.newAST(AST.JLS3);
            CompilationUnit unit = ast.newCompilationUnit();
            PackageDeclaration packageDeclaration = ast
                .newPackageDeclaration();
            packageDeclaration.setName(ast.newSimpleName(pkg
                .getElementName()));
            unit.setPackage(packageDeclaration);
            TypeDeclaration type = ast.newTypeDeclaration();
            Javadoc comment = ast.newJavadoc();
            TagElement tag = ast.newTagElement();
View Full Code Here

Examples of org.eclipse.jdt.core.dom.PackageDeclaration

    }
    return -1;
  }

  private int getPackageStatementEndPos(CompilationUnit root) {
    PackageDeclaration packDecl= root.getPackage();
    if (packDecl != null) {
      int afterPackageStatementPos= -1;
      int lineNumber= root.getLineNumber(packDecl.getStartPosition() + packDecl.getLength());
      if (lineNumber >= 0) {
        int lineAfterPackage= lineNumber + 1;
        afterPackageStatementPos= root.getPosition(lineAfterPackage, 0);
      }
      if (afterPackageStatementPos < 0) {
        this.flags|= F_NEEDS_LEADING_DELIM;
        return packDecl.getStartPosition() + packDecl.getLength();
      }
      int firstTypePos= getFirstTypeBeginPos(root);
      if (firstTypePos != -1 && firstTypePos <= afterPackageStatementPos) {
        this.flags|= F_NEEDS_TRAILING_DELIM;
        if (firstTypePos == afterPackageStatementPos) {
View Full Code Here

Examples of org.eclipse.jdt.core.dom.PackageDeclaration

  private void updatePackageStatement(CompilationUnit astCU, String[] pkgName, ASTRewrite rewriter, ICompilationUnit cu) throws JavaModelException {
    boolean defaultPackage = pkgName.length == 0;
    AST ast = astCU.getAST();
    if (defaultPackage) {
      // remove existing package statement
      PackageDeclaration pkg = astCU.getPackage();
      if (pkg != null) {
        int pkgStart;
        Javadoc javadoc = pkg.getJavadoc();
        if (javadoc != null) {
          pkgStart = javadoc.getStartPosition() + javadoc.getLength() + 1;
        } else {
          pkgStart = pkg.getStartPosition();
        }
        int extendedStart = astCU.getExtendedStartPosition(pkg);
        if (pkgStart != extendedStart) {
          // keep the comments associated with package declaration
          // see https://bugs.eclipse.org/bugs/show_bug.cgi?id=247757
          String commentSource = cu.getSource().substring(extendedStart, pkgStart);
          ASTNode comment = rewriter.createStringPlaceholder(commentSource, ASTNode.PACKAGE_DECLARATION);
          rewriter.set(astCU, CompilationUnit.PACKAGE_PROPERTY, comment, null);
        } else {
          rewriter.set(astCU, CompilationUnit.PACKAGE_PROPERTY, null, null);
        }
      }
    } else {
      org.eclipse.jdt.core.dom.PackageDeclaration pkg = astCU.getPackage();
      if (pkg != null) {
        // rename package statement
        Name name = ast.newName(pkgName);
        rewriter.set(pkg, PackageDeclaration.NAME_PROPERTY, name, null);
      } else {
        // create new package statement
        pkg = ast.newPackageDeclaration();
        pkg.setName(ast.newName(pkgName));
        rewriter.set(astCU, CompilationUnit.PACKAGE_PROPERTY, pkg, null);
      }
    }
  }
View Full Code Here

Examples of org.eclipse.jdt.core.dom.PackageDeclaration

    public void afterTraverse(TypeAnalyzer analyzer, CompilationUnit root) {
        if ((_prefix != null) && (_prefix.length() > 0)) {
            // Add a prefix to each name node, if necessary.
            root.accept(new Renamer(analyzer.getState()));

            PackageDeclaration packageDeclaration = root.getPackage();
            AST ast = root.getAST();

            if (packageDeclaration == null) {
                packageDeclaration = ast.newPackageDeclaration();
                packageDeclaration.setName(AbstractTransformer.createName(ast,
                        _prefix));
                root.setPackage(packageDeclaration);
            }
        }
    }
View Full Code Here

Examples of org.eclipse.jdt.core.dom.PackageDeclaration

    return declaration;
  }

  @Override
  public PackageDeclaration newPackageDeclaration(AST ast) {
    PackageDeclaration declaration = ast.newPackageDeclaration();

    Name theName = ast.newName(name);
    declaration.setName(theName);

    return declaration;
  }
View Full Code Here

Examples of org.eclipse.jdt.core.dom.PackageDeclaration

  @Override
  public void writeTo(CompilationUnit compilationUnit) {
    AST ast = compilationUnit.getAST();

    PackageDeclaration declaration = ast.newPackageDeclaration();
    Name theName = ast.newName(name);
    declaration.setName(theName);

    compilationUnit.setPackage(declaration);
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.