Examples of ICompilationUnit


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

* <li> if no type - first thing in the CU
* <li>
*/
protected void initializeDefaultPosition() {
  try {
    ICompilationUnit cu = getCompilationUnit();
    IImportDeclaration[] imports = cu.getImports();
    if (imports.length > 0) {
      createBefore(imports[0]);
      return;
    }
    IType[] types = cu.getTypes();
    if (types.length > 0) {
      createBefore(types[0]);
      return;
    }
  } catch (JavaModelException e) {
View Full Code Here

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

   */
  protected void executeOperation() throws JavaModelException {
    try {
      beginTask(getMainTaskName(), getMainAmountOfWork());
      JavaElementDelta delta = newJavaElementDelta();
      ICompilationUnit unit = getCompilationUnit();
      generateNewCompilationUnitAST(unit);
      if (this.creationOccurred) {
        //a change has really occurred
        unit.save(null, false);
        boolean isWorkingCopy = unit.isWorkingCopy();
        if (!isWorkingCopy)
          setAttribute(HAS_MODIFIED_RESOURCE_ATTR, TRUE);
        worked(1);
        resultElements = generateResultHandles();
        if (!isWorkingCopy // if unit is working copy, then save will have already fired the delta
            && !Util.isExcluded(unit)
            && unit.getParent().exists()) {
          for (int i = 0; i < resultElements.length; i++) {
            delta.added(resultElements[i]);
          }
          addDelta(delta);
        } // else unit is created outside classpath
View Full Code Here

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

      } catch (CloneNotSupportedException e1) {
        // ignore (implementation of HashtableOfArrayToObject supports cloning)
      }
      this.typesInWorkingCopies = new HashMap();
      for (int i = 0, length = workingCopies.length; i < length; i++) {
        ICompilationUnit workingCopy = workingCopies[i];
        PackageFragment pkg = (PackageFragment) workingCopy.getParent();
        HashMap typeMap = (HashMap) this.typesInWorkingCopies.get(pkg);
        if (typeMap == null) {
          typeMap = new HashMap();
          this.typesInWorkingCopies.put(pkg, typeMap);
        }
        try {
          IType[] types = workingCopy.getTypes();
          int typeLength = types.length;
          if (typeLength == 0) {
            String typeName = Util.getNameWithoutJavaLikeExtension(workingCopy.getElementName());
            typeMap.put(typeName, NO_TYPES);
          } else {
            for (int j = 0; j < typeLength; j++) {
              IType type = types[j];
              String typeName = type.getElementName();
View Full Code Here

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

        return findCompilationUnit(pkgName, cuName, (PackageFragmentRoot) value);
      } else {
        IPackageFragmentRoot[] roots = (IPackageFragmentRoot[]) value;
        for (int i= 0; i < roots.length; i++) {
          PackageFragmentRoot root= (PackageFragmentRoot) roots[i];
          ICompilationUnit cu = findCompilationUnit(pkgName, cuName, root);
          if (cu != null)
            return cu;
        }
      }
    }
View Full Code Here

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

    if (!root.isArchive()) {
      IPackageFragment pkg = root.getPackageFragment(pkgName);
      try {
        ICompilationUnit[] cus = pkg.getCompilationUnits();
        for (int j = 0, length = cus.length; j < length; j++) {
          ICompilationUnit cu = cus[j];
          if (Util.equalsIgnoreJavaLikeExtension(cu.getElementName(), cuName))
            return cu;
        }
      } catch (JavaModelException e) {
        // pkg does not exist
        // -> try next package
View Full Code Here

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

    if (this.handleFactory != null) {
      Openable openable = this.handleFactory.createOpenable(path, this.scope);
      if (openable == null) return;
      switch (openable.getElementType()) {
        case IJavaElement.COMPILATION_UNIT:
          ICompilationUnit cu = (ICompilationUnit) openable;
          if (enclosingTypeNames != null && enclosingTypeNames.length > 0) {
            type = cu.getType(new String(enclosingTypeNames[0]));
            for (int j=1, l=enclosingTypeNames.length; j<l; j++) {
              type = type.getType(new String(enclosingTypeNames[j]));
            }
            type = type.getType(new String(simpleTypeName));
          } else {
            type = cu.getType(new String(simpleTypeName));
          }
          break;
        case IJavaElement.CLASS_FILE:
          type = ((IClassFile)openable).getType();
          break;
View Full Code Here

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

    pkgFragment= ((PackageFragmentRoot) this.lastPkgFragmentRoot).getPackageFragment(pkgName);
    this.packageHandles.put(pkgName, pkgFragment);
  }
  String simpleName= simpleNames[length];
  if (org.aspectj.org.eclipse.jdt.internal.core.util.Util.isJavaLikeFileName(simpleName)) {
    ICompilationUnit unit= pkgFragment.getCompilationUnit(simpleName);
    int etnLength = enclosingTypeNames == null ? 0 : enclosingTypeNames.length;
    IType type = (etnLength == 0) ? unit.getType(simpleTypeName) : unit.getType(new String(enclosingTypeNames[0]));
    if (etnLength > 0) {
      for (int i=1; i<etnLength; i++) {
        type = type.getType(new String(enclosingTypeNames[i]));
      }
      type = type.getType(simpleTypeName);
View Full Code Here

Examples of org.aspectj.org.eclipse.jdt.internal.compiler.env.ICompilationUnit

  }

  // Compile compilation unit
  CompilerRequestor compilerRequestor = new CompilerRequestor();
  Compiler compiler = getCompiler(compilerRequestor);
  compiler.compile(new ICompilationUnit[] {new ICompilationUnit() {
    public char[] getFileName() {
       // Name of class is name of CU
      return CharOperation.concat(Evaluator.this.getClassName(), Util.defaultJavaExtension().toCharArray());
    }
    public char[] getContents() {
View Full Code Here

Examples of org.aspectj.org.eclipse.jdt.internal.compiler.env.ICompilationUnit

}
private int retrieveClosingAngleBracketPosition(int start) {
  if (this.referenceContext == null) return start;
  CompilationResult compilationResult = this.referenceContext.compilationResult();
  if (compilationResult == null) return start;
  ICompilationUnit compilationUnit = compilationResult.getCompilationUnit();
  if (compilationUnit == null) return start;
  char[] contents = compilationUnit.getContents();
  if (contents.length == 0) return start;
  if (this.positionScanner == null) {
    this.positionScanner = new Scanner(false, false, false, this.options.sourceLevel, this.options.complianceLevel, null, null, false);
    this.positionScanner.returnOnlyGreater = true;
  }
View Full Code Here

Examples of org.aspectj.org.eclipse.jdt.internal.compiler.env.ICompilationUnit

}
private int retrieveEndingPositionAfterOpeningParenthesis(int sourceStart, int sourceEnd, int numberOfParen) {
  if (this.referenceContext == null) return sourceEnd;
  CompilationResult compilationResult = this.referenceContext.compilationResult();
  if (compilationResult == null) return sourceEnd;
  ICompilationUnit compilationUnit = compilationResult.getCompilationUnit();
  if (compilationUnit == null) return sourceEnd;
  char[] contents = compilationUnit.getContents();
  if (contents.length == 0) return sourceEnd;
  if (this.positionScanner == null) {
    this.positionScanner = new Scanner(false, false, false, this.options.sourceLevel, this.options.complianceLevel, null, null, false);
  }
  this.positionScanner.setSource(contents);
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.