Package org.eclipse.jdt.core

Examples of 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


  JavaElement parentHandle= (JavaElement) this.handleStack.peek();
  if (!(parentHandle.getElementType() == IJavaElement.COMPILATION_UNIT)) {
    Assert.isTrue(false); // Should not happen
  }

  ICompilationUnit parentCU= (ICompilationUnit)parentHandle;
  //create the import container and its info
  if (this.importContainer == null) {
    this.importContainer = createImportContainer(parentCU);
    this.importContainerInfo = new ImportContainerInfo();
    Object parentInfo = this.infoStack.peek();
View Full Code Here

      for (int i = 0, len = pkgs.length; i < len; i++) {
        int fragType = pkgs[i].getKind();
        switch(fragType) {
          case IPackageFragmentRoot.K_SOURCE:
            String unitName = "package-info.java"; //$NON-NLS-1$
            ICompilationUnit unit = pkgs[i].getCompilationUnit(unitName);
            if (unit != null && unit.exists()) {
              ASTParser p = ASTParser.newParser(AST.JLS3);
              p.setSource(unit);
              p.setResolveBindings(true);
              p.setUnitName(unitName);
              p.setFocalPosition(0);
View Full Code Here

  if (kind == IPackageFragmentRoot.K_SOURCE) {
    // add primary compilation units
    ICompilationUnit[] primaryCompilationUnits = getCompilationUnits(DefaultWorkingCopyOwner.PRIMARY);
    for (int i = 0, length = primaryCompilationUnits.length; i < length; i++) {
      ICompilationUnit primary = primaryCompilationUnits[i];
      vChildren.add(primary);
    }
  }

  IJavaElement[] children = new IJavaElement[vChildren.size()];
View Full Code Here

  if (workingCopies == null) return JavaModelManager.NO_WORKING_COPY;
  int length = workingCopies.length;
  ICompilationUnit[] result = new ICompilationUnit[length];
  int index = 0;
  for (int i = 0; i < length; i++) {
    ICompilationUnit wc = workingCopies[i];
    if (equals(wc.getParent()) && !Util.isExcluded(wc)) { // 59933 - excluded wc shouldn't be answered back
      result[index++] = wc;
    }
  }
  if (index != length) {
    System.arraycopy(result, 0, result = new ICompilationUnit[index], 0, index);
View Full Code Here

* 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

    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

      }
    });
    ParserFactory factory = ParserFactory.getDefaultParserFactory();
    if (factory == null)
      throw new Exception("No parser factory available!");
    ICompilationUnit unit = JavaCore.createCompilationUnitFrom(file.getFile());
    hostProject = unit.getJavaProject();
    ISourceParser sourceParser = factory.newParser();
    isParsing = true;
    VisualSwingPlugin.setCurrentEditor(this);
    this.designer.setCompilationUnit(unit);
    try {
View Full Code Here

          if (root != null) {
            WidgetAdapter rootAdapter = WidgetAdapter.getWidgetAdapter(root);
            JavaUtil.hideMenu();
            String lnfCN = getLnfClassname();
            rootAdapter.setPreferredLookAndFeel(lnfCN); //$NON-NLS-1$
            ICompilationUnit unit = sourceParser.generate(rootAdapter, monitor);
            rootAdapter.setPreferredLookAndFeel(null); //$NON-NLS-1$
            if (unit != null) {
              designer.initNamespaceWithUnit(unit);
              designer.setLnfChanged(false);
            }
View Full Code Here

     *            non null pattern for all matching .class file names
     * @return modified classNamePattern, if there are more then one type
     *         defined in the java file
     */
    private String addSecondaryTypesToPattern(IFile file, String fileName, String classNamePattern) {
        ICompilationUnit cu = JavaCore.createCompilationUnitFrom(file);
        if (cu == null) {
            FindbugsPlugin.getDefault().logError(
                    "NULL compilation unit for " + file + ", FB analysis might  be incomplete for included types");
            return classNamePattern;
        }
        try {
            IType[] types = cu.getTypes();
            if (types.length > 1) {
                for (IType type : types) {
                    if (fileName.equals(type.getElementName())) {
                        // "usual" type with the same name: we have it already
                        continue;
View Full Code Here

TOP

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

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.