Examples of ICompilationUnit


Examples of org.apache.flex.compiler.units.ICompilationUnit

        IDefinition definition = projectScope.findDefinitionByName(qname);

        if (definition == null)
            return;

        ICompilationUnit thisCU = getCompilationUnit();
        ICompilationUnit otherCU = projectScope.getCompilationUnitForDefinition(definition);

        // otherCU will be null if qname is "*" because the "*" type does not come from any compilation unit
        if (otherCU != null)
        {
            FlexProject project = getProject();
View Full Code Here

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

    return new JavaModelStatus(IJavaModelStatusConstants.INVALID_CONTENTS);
  }
  if (!force) {
    //check for name collisions
    try {
      ICompilationUnit cu = getCompilationUnit();
      generateElementAST(null, getDocument(cu), cu);
    } catch (JavaModelException jme) {
      return jme.getJavaModelStatus();
    }
    return verifyNameCollision();
View Full Code Here

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

  Map options = this.project.getOptions(true);
  // transfer the imports of the IType to the evaluation context
  if (declaringType != null) {
    // retrieves the package statement
    this.context.setPackageName(declaringType.getPackageFragment().getElementName().toCharArray());
    ICompilationUnit compilationUnit = declaringType.getCompilationUnit();
    if (compilationUnit != null) {
      // retrieves the import statement
      IImportDeclaration[] imports = compilationUnit.getImports();
      int importsLength = imports.length;
      if (importsLength != 0) {
        char[][] importsNames = new char[importsLength][];
        for (int i = 0; i < importsLength; i++) {
          importsNames[i] = imports[i].getElementName().toCharArray();
View Full Code Here

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

* findLocalElement() cannot find local variable
*/
protected IJavaElement findLocalElement(int pos) {
  IJavaElement res = null;
  if(this.openable instanceof ICompilationUnit) {
    ICompilationUnit cu = (ICompilationUnit) this.openable;
    try {
      res = cu.getElementAt(pos);
    } catch (JavaModelException e) {
      // do nothing
    }
  } else if (this.openable instanceof ClassFile) {
    ClassFile cf = (ClassFile) this.openable;
View Full Code Here

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

        try {
          super.process(unit, i); // this.process(...) is optimized to not process already known units

          // requested AST
          char[] fileName = unit.compilationResult.getFileName();
          ICompilationUnit source = (ICompilationUnit) this.requestedSources.get(fileName);
          if (source != null) {
            // convert AST
            CompilationResult compilationResult = unit.compilationResult;
            org.aspectj.org.eclipse.jdt.internal.compiler.env.ICompilationUnit sourceUnit = compilationResult.compilationUnit;
            char[] contents = sourceUnit.getContents();
View Full Code Here

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

   */
  protected void executeOperation() throws JavaModelException {
    try {
      beginTask(Messages.operation_sortelements, getMainAmountOfWork());
      CompilationUnit copy = (CompilationUnit) this.elementsToProcess[0];
      ICompilationUnit unit = copy.getPrimary();
      IBuffer buffer = copy.getBuffer();
      if (buffer  == null) {
        return;
      }
      char[] bufferContents = buffer.getCharacters();
View Full Code Here

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

      throw new JavaModelException(new JavaModelStatus(IJavaModelStatusConstants.INVALID_ELEMENT_TYPES, this.elementsToProcess[0]));
   
    try {
      beginTask(Messages.operation_sortelements, getMainAmountOfWork());
     
      ICompilationUnit cu= (ICompilationUnit)this.elementsToProcess[0];
      String content= cu.getBuffer().getContents();
      ASTRewrite rewrite= sortCompilationUnit(unit, group);
      if (rewrite == null) {
        return null;
      }
     
View Full Code Here

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

    String packageName = type.getPackageFragment().getElementName();
    key.append(packageName.replace('.', '/'));
    if (packageName.length() > 0)
      key.append('/');
    String typeQualifiedName = type.getTypeQualifiedName('$');
    ICompilationUnit cu = (ICompilationUnit) type.getAncestor(IJavaElement.COMPILATION_UNIT);
    if (cu != null) {
      String cuName = cu.getElementName();
      String mainTypeName = cuName.substring(0, cuName.lastIndexOf('.'));
      int end = typeQualifiedName.indexOf('$');
      if (end == -1)
        end = typeQualifiedName.length();
      String topLevelTypeName = typeQualifiedName.substring(0, end);
View Full Code Here

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

*/
protected void executeOperation() throws JavaModelException {
  try {
    beginTask(Messages.operation_createUnitProgress, 2);
    JavaElementDelta delta = newJavaElementDelta();
    ICompilationUnit unit = getCompilationUnit();
    IPackageFragment pkg = (IPackageFragment) getParentElement();
    IContainer folder = (IContainer) pkg.getResource();
    worked(1);
    IFile compilationUnitFile = folder.getFile(new Path(fName));
    if (compilationUnitFile.exists()) {
      // update the contents of the existing unit if fForce is true
      if (force) {
        IBuffer buffer = unit.getBuffer();
        if (buffer == null) return;
        buffer.setContents(fSource);
        unit.save(new NullProgressMonitor(), false);
        resultElements = new IJavaElement[] {unit};
        if (!Util.isExcluded(unit)
            && unit.getParent().exists()) {
          for (int i = 0; i < resultElements.length; i++) {
            delta.changed(resultElements[i], IJavaElementDelta.F_CONTENT);
          }
          addDelta(delta);
        }
      } else {
        throw new JavaModelException(new JavaModelStatus(
          IJavaModelStatusConstants.NAME_COLLISION,
          Messages.bind(Messages.status_nameCollision, compilationUnitFile.getFullPath().toString())));
      }
    } else {
      try {
        String encoding = null;
        try {
          encoding = folder.getDefaultCharset(); // get folder encoding as file is not accessible
        }
        catch (CoreException ce) {
          // use no encoding
        }
        InputStream stream = new ByteArrayInputStream(encoding == null ? fSource.getBytes() : fSource.getBytes(encoding));
        createFile(folder, unit.getElementName(), stream, force);
        resultElements = new IJavaElement[] {unit};
        if (!Util.isExcluded(unit)
            && unit.getParent().exists()) {
          for (int i = 0; i < resultElements.length; i++) {
            delta.added(resultElements[i]);
          }
          addDelta(delta);
        }
View Full Code Here

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

  protected void groupElements() throws JavaModelException {
    childrenToRemove = new HashMap(1);
    int uniqueCUs = 0;
    for (int i = 0, length = elementsToProcess.length; i < length; i++) {
      IJavaElement e = elementsToProcess[i];
      ICompilationUnit cu = getCompilationUnitFor(e);
      if (cu == null) {
        throw new JavaModelException(new JavaModelStatus(IJavaModelStatusConstants.READ_ONLY, e));
      } else {
        IRegion region = (IRegion) childrenToRemove.get(cu);
        if (region == null) {
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.