Package org.eclipse.jdt.core

Examples of org.eclipse.jdt.core.ICompilationUnit


       }
       graphs.add(graph);
    }

    private String getPath(MethodCallNode methodCallNode) {
        ICompilationUnit compilationUnit = methodCallNode.getSourceMethod().getMember().getCompilationUnit();
        if (compilationUnit == null) return null;
        String path = Resources.asPath(compilationUnit);
        return path;
    }
View Full Code Here


    public static ICompilationUnit getCompilationUnit(SearchMatch match) {
        IJavaElement enclosingElement = getEnclosingJavaElement(match);
        if (enclosingElement != null) {
            if (enclosingElement instanceof ICompilationUnit)
                return (ICompilationUnit) enclosingElement;
            ICompilationUnit cu = (ICompilationUnit) enclosingElement.getAncestor(IJavaElement.COMPILATION_UNIT);
            if (cu != null)
                return cu;
        }

        IJavaElement jElement = JavaCore.create(match.getResource());
View Full Code Here

    private String makeText(ArrayList<ICompilationUnit> compilationUnits) {
        if (compilationUnits.isEmpty()) {
            return EMPTY;
        }
        if (compilationUnits.size() == 1) {
            ICompilationUnit unit = compilationUnits.get(0);
            return unit.getElementName();
        }
        return compilationUnits.size() + " Classes";
    }
View Full Code Here

                    {
                        IFile f = (IFile) resource;
                        IContentType ct = contentTypeManager.findContentTypeFor(f.getName());
                        if (ct != null && ct.isKindOf(javaContentType))
                        {
                            ICompilationUnit cu = (ICompilationUnit) JavaCore.create(f);
                            IPackageFragment pf = (IPackageFragment) cu.getAncestor(IJavaElement.PACKAGE_FRAGMENT);
                            packages.add(pf.getElementName());
                        }
                    }

                    return true;
View Full Code Here

                        findIndirectReferences(indirect,
                            findPackage(cf.getType().getSuperclassName()), p, p);
                    }
                    break;
                case IJavaElement.COMPILATION_UNIT:
                    ICompilationUnit cu = (ICompilationUnit) e;
                    break;
            }

            if (!skip && e instanceof IParent)
            {
View Full Code Here

    String packageName = "";
    IEditorInput editorInput = editor.textEditor.getEditorInput();
   
    ITextSelection selection = (ITextSelection) editor.textEditor.getSelectionProvider().getSelection();
    IJavaElement elem = JavaUI.getEditorInputJavaElement(editorInput);
    ICompilationUnit unit = null;
    if (elem instanceof ICompilationUnit) {
      unit = (ICompilationUnit) elem;
      try {
        IPackageDeclaration[] packs = unit.getPackageDeclarations();
        if (packs.length < 1) {
          info("This action can only apply to controllers.");
          return null;
        } else {
          packageName = packs[0].getElementName();
          if (!packageName.startsWith("controllers")) {
            info("This action can only apply to controllers.");
            return null;
          }
        }
       
        // get the class declaration line
        IType type = unit.getType(controllerName);
        ITypeHierarchy superTypes = type.newSupertypeHierarchy(null);
//        String name = JapidController.class.getName(); // this will require play.jar
        String name = "cn.bran.play.JapidController";
        IType japidController = jProject.findType(name);
        if (superTypes.contains(japidController)) {
          useJapid = true;
        }
        else {
          useJapid = false;
        }
       
//        String superclassName = type.getSuperclassName();
//        if (superclassName.toLowerCase().contains("japid")) {
//          useJapid = true;
//        }
       
        // current selected elem
            IJavaElement[] elements= unit.codeSelect(selection.getOffset(), selection.getLength());
            if (elements.length > 0) {
              // TODO extract the current selection to tell if the cursor in on renderJapidXXX line
              System.out.println(elements);
            }
View Full Code Here

      IStructuredSelection selection = (IStructuredSelection) activeMenuSelection;
      p = Navigation.getProject(selection);
      Object firstElement = selection.getFirstElement();
      if (firstElement instanceof IMethod) {
        IMethod m = (IMethod) firstElement;
        ICompilationUnit unit = m.getCompilationUnit();
        try {
          IPackageDeclaration[] packs = unit.getPackageDeclarations();
          if (packs.length < 1) {
            info("This action can only apply to controllers.");
            return null;
          } else {
            packageName = packs[0].getElementName();
            if (!packageName.startsWith("controllers")) {
              info("This action can only apply to controllers.");
              return null;
            }
          }

          IType type = unit.getTypes()[0];
          controllerName = type.getElementName();
          String superclassName = type.getSuperclassName();
          if (superclassName.toLowerCase().contains("japid")) {
            useJapid = true;
          }
View Full Code Here

    case IJavaElement.PACKAGE_FRAGMENT:
        if (isAddedOrRemoved)
          return true;
        return processChildrenDelta(delta.getAffectedChildren());
    case IJavaElement.COMPILATION_UNIT:
      ICompilationUnit cu = (ICompilationUnit) elem;
      if (cu.getPrimary().equals(cu)) {
        System.out.println("code change:" + cu.getElementName());
        if (isAddedOrRemoved || isPossibleStructruralChange(delta.getFlags())) {
          return true;
        }
      }
      return processChildrenDelta(delta.getAffectedChildren());
View Full Code Here

    String packageName = "";
    IEditorInput editorInput = editor.textEditor.getEditorInput();
   
    ITextSelection selection = (ITextSelection) editor.textEditor.getSelectionProvider().getSelection();
    IJavaElement elem = JavaUI.getEditorInputJavaElement(editorInput);
    ICompilationUnit unit = null;
    if (elem instanceof ICompilationUnit) {
      unit = (ICompilationUnit) elem;
      try {
        IPackageDeclaration[] packs = unit.getPackageDeclarations();
        if (packs.length < 1) {
          info("This action can only apply to controllers.");
          return null;
        } else {
          packageName = packs[0].getElementName();
          if (!packageName.startsWith("controllers")) {
            info("This action can only apply to controllers.");
            return null;
          }
        }
       
//        // get the class declaration line
//        IType type = unit.getType(controllerName);
//        ITypeHierarchy superTypes = type.newSupertypeHierarchy(null);
////        String name = JapidController.class.getName(); // this will require play.jar
//        String name = "cn.bran.play.JapidController";
//        IType japidController = jProject.findType(name);
//       
        // current selected elem
            IJavaElement[] elements= unit.codeSelect(selection.getOffset(), selection.getLength());
            if (elements.length > 0) {
              // TODO extract the current selection to tell if the cursor in on renderJapidXXX line
//              System.out.println(elements);
            }
View Full Code Here

    }
   
    IFile file = null;
    try {
      if (!type.isBinary()) {
        ICompilationUnit cu = type.getCompilationUnit();
        file = (IFile)cu.getCorrespondingResource();
      } else {
        // the type is in binary form, meaning a type in the classpath
        if(type.getParent() instanceof IClassFile) {
          return; // TODO what to do with class in classpath?
        }
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.