Package org.eclipse.jdt.core

Examples of org.eclipse.jdt.core.IType


      IPackageFragment pack = (IPackageFragment) elem.getAncestor(IJavaElement.PACKAGE_FRAGMENT);
      if (pack != null) {
        fPackageDialogField.setText(pack.getElementName());
      }

      IType aspect = null;
      IType typeInCU = (IType) elem.getAncestor(IJavaElement.TYPE);
      if (typeInCU != null) {
        if (typeInCU.getCompilationUnit() != null) {
          aspect = typeInCU;
        }
      } else {
        ICompilationUnit cu = (ICompilationUnit) elem.getAncestor(IJavaElement.COMPILATION_UNIT);
        if (cu != null) {
View Full Code Here


      // Step 2: Create aspect if not already existent.
      boolean needsCommit = false;
      String lineDelimiter = null;
      String aspectName = getAspectName();
      IType aspect = getAspect();
      if (aspect == null) {
        lineDelimiter = System.getProperty("line.separator", "\n"); //$NON-NLS-1$ //$NON-NLS-2$

        ICompilationUnit parentCU = pack.createCompilationUnit(
            aspectName + ".java", "", false, new SubProgressMonitor(monitor, 2)); //$NON-NLS-1$ //$NON-NLS-2$
        // create a working copy with a new owner
        createdWorkingCopy = parentCU.getWorkingCopy(null);

        // use the compiler template a first time to read the imports
        String content = CodeGeneration.getCompilationUnitContent(createdWorkingCopy, null, "", lineDelimiter); //$NON-NLS-1$
        if (content != null) {
          createdWorkingCopy.getBuffer().setContents(content);
        }

        ImportsManager imports = new ImportsManager(createdWorkingCopy);
        // add an import that will be removed again. Having this import solves 14661
        imports.addImport(JavaModelUtil.concatenateName(pack.getElementName(), aspectName));

        String typeContent = writeBasicAspect(imports, lineDelimiter);
        String cuContent = constructCUContent(parentCU, typeContent, lineDelimiter);
        createdWorkingCopy.getBuffer().setContents(cuContent);
        if (monitor.isCanceled()) {
          throw new InterruptedException();
        }

        imports.create(false, new SubProgressMonitor(monitor, 1));
        JavaModelUtil.reconcile(createdWorkingCopy);
        aspect = createdWorkingCopy.getType(aspectName);
        needsCommit = true;
      }
      if (monitor.isCanceled()) {
        throw new InterruptedException();
      }

      ICompilationUnit cu = aspect.getCompilationUnit();
      boolean needsSave = cu.isWorkingCopy();
      ImportsManager imports = new ImportsManager(cu);
      lineDelimiter = StubUtility.getLineDelimiterUsed(aspect);

      // Write crosscut and format it
View Full Code Here

    public NewMemberCutWizardPage(String name) {
        super(name);

        fTargetClassDialogField = new StringButtonDialogField(new IStringButtonAdapter() {
            public void changeControlPressed(DialogField field) {
                IType type = chooseTargetClass();
                if (type != null) {
                  fTargetClassDialogField.setText(JavaModelUtil.getFullyQualifiedName(type));
                }
            }
        });
View Full Code Here

                return;
            } catch (InvocationTargetException e) {
                MessageDialog.openError(getShell(), "Launch failed", e.getMessage());
                return;
            }
            IType type = null;
            if (types.length == 0) {
                String message = null;
                if (editor) {
                    message = "The active editor does not contain a main type.";
                } else {
View Full Code Here

            status.setError("Target class name is not valid.");
            return status;
        }
        if (root != null) {
            try {
                IType type = resolveClassName(root.getJavaProject(), targetClassName);
                if (type == null) {
                    status.setWarning("Target class does not exist in current project.");
                    return status;
                }
                fTargetClass = type;
View Full Code Here

    /* (non-Javadoc)
     * @see ch.ethz.prose.eclipse.internal.wizards.NewCrosscutWizardPage#writeAdviceSignature(ch.ethz.prose.eclipse.internal.wizards.ImportsManager, java.lang.StringBuffer)
     */
    public void writeAdviceSignature(ImportsManager imports, StringBuffer source) {
        IType targetClass = getTargetClass();
        String targetClassName = getTargetClassName();
        if (targetClass != null) {
            imports.addImport(targetClass.getFullyQualifiedName());
            source.append(targetClass.getElementName());
        } else if (targetClassName.length() != 0) {
            source.append(targetClassName);
        } else {
            return;
        }
View Full Code Here

        dialog.setMessage("Choose Main Type");
        if (dialog.open() == Window.CANCEL) { return; }

        Object[] results = dialog.getResult();
        if ((results == null) || (results.length < 1)) { return; }
        IType type = (IType) results[0];
        if (type != null) {
            fMainText.setText(type.getFullyQualifiedName());
            javaProject = type.getJavaProject();
            fProjText.setText(javaProject.getElementName());
        }
    }
View Full Code Here

     */
    protected IType resolveClassName(IJavaProject jproject, String sclassName) throws JavaModelException {
        if (!jproject.exists()) {
            return null;
        }
        IType type = null;
        IPackageFragment currPack = getMainPage().getPackageFragment();
        if (type == null && currPack != null) {
            String packName = currPack.getElementName();
            // search in own package
            if (!currPack.isDefaultPackage()) {
View Full Code Here

    /* (non-Javadoc)
     * @see ch.ethz.prose.eclipse.internal.wizards.NewCrosscutWizardPage#writeAdviceSignature(ch.ethz.prose.eclipse.internal.wizards.ImportsManager, java.lang.StringBuffer)
     */
    public void writeAdviceSignature(ImportsManager imports, StringBuffer source) {
        IType targetClass = getTargetClass();
        String targetClassName = getTargetClassName();
        if (targetClass != null) {
            imports.addImport(targetClass.getFullyQualifiedName());
            source.append(targetClass.getElementName());
        } else if (targetClassName.length() != 0) {
            source.append(targetClassName);
        } else {
            return;
        }
View Full Code Here

    /* (non-Javadoc)
     * @see ch.ethz.prose.eclipse.internal.wizards.NewCrosscutWizardPage#writeAdviceSignature(ch.ethz.prose.eclipse.internal.wizards.ImportsManager, java.lang.StringBuffer)
     */
    public void writeAdviceSignature(ImportsManager imports, StringBuffer source) {
        IType targetClass = getTargetClass();
        String targetClassName = getTargetClassName();
        if (targetClass != null) {
            imports.addImport(targetClass.getFullyQualifiedName());
            source.append(targetClass.getElementName());
        } else if (targetClassName.length() != 0) {
            source.append(targetClassName);
        } else {
            return;
        }
View Full Code Here

TOP

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

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.