Package org.eclipse.jdt.core

Examples of org.eclipse.jdt.core.IType


  public void goToAction(String action) {
    action = (action.startsWith("controllers.") ? "": "controllers.") + action;
    String fullClassName = action.replaceFirst(".[^.]+$", "");
    System.out.println("goToAction for class: " + fullClassName);
    String method = action.substring(action.lastIndexOf('.') + 1);
    IType type = findType(fullClassName);
    if (type == null) {
      PlayPlugin.showError("The controller " + fullClassName + " can't be found.");
      return;
    }
   
    IFile file;
    try {
      file = (IFile)type.getCompilationUnit().getCorrespondingResource();
    } catch (JavaModelException e1) {
      // Should not happen
      e1.printStackTrace();
      return;
    }
View Full Code Here


   * open a java code editor for the class source
   * @param className
   * @author bran
   */
  public void openClass(String className) {
    IType type = findType(className);
    if (type == null) {
      PlayPlugin.showError("The controller " + className + " can't be found.");
      return;
    }
   
    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?
        }
      }
    } catch (JavaModelException e1) {
      // Should not happen
View Full Code Here

public class FindIntegrationTest extends BaseRescripterIntegrationTest {
  @Test public void
  finds_types_by_name() throws IOException, CoreException {
    RunScript runScript = new RunScript(getWindow());
    runScript.withContents("var person = Find.typeByName('Person');\n", null, "inline script");
    IType type = runScript.getProperty(IType.class, "person");
    assertThat(type, is(notNullValue()));
    assertThat(type, is(getJavaProject().findType("com.example.Person")));
  }
View Full Code Here

  @SuppressWarnings("unchecked")
  @Test public void
  finds_covered_node() throws IOException, CoreException {
    RunScript runScript = new RunScript(getWindow());
    String methodCallText = "person.setName(\"Bob\")";
    IType personType = getJavaProject().findType("com.example.Person");
    String personSource = personType.getCompilationUnit().getSource();
    int offsetOfCall = personSource.indexOf(methodCallText);
    runScript.withContents(
        "var person = Find.typeByName('Person');\n" +
        "var ast = AST.parseCompilationUnit(person.getCompilationUnit());\n" +
        "var node = AST.findCoveredNode(ast, " + offsetOfCall + ", " + methodCallText.length() + ");\n"
View Full Code Here

  private static IRegion getRegionOfWicketComponent(final ITextViewer textViewer, final int offset, final IRegion wordRegion, final IJavaElement javaElement) throws JavaModelException
  {
    if (javaElement != null && javaElement instanceof NamedMember)
    {
      final NamedMember method = (NamedMember) javaElement;
      final IType type = method.getDeclaringType();
      if (type != null)
      {
        final ITypeHierarchy hierarchy = type.newSupertypeHierarchy(null);
        if (hierarchy != null)
        {
          final IType[] supertypes = hierarchy.getAllSupertypes(type);
          for (final IType iType : supertypes)
          {
View Full Code Here

      StringWriter sw = new StringWriter();
      PrintWriter pw = new PrintWriter(sw);
      pw.println();
      pw.println("public static class Builder {");

      IType clazz = cu.getTypes()[0];

      int pos = clazz.getSourceRange().getOffset() + clazz.getSourceRange().getLength() - 1;

      createFieldDeclarations(pw, fields);

      createBuilderMethods(pw, fields);
      if (createBuilderConstructor) {
View Full Code Here

  }

  public List<IField> findAllFIelds(ICompilationUnit compilationUnit) {
    List<IField> fields = new ArrayList<IField>();
    try {
      IType clazz = compilationUnit.getTypes()[0];
     
      for(IField field: clazz.getFields()) {
        int flags = field.getFlags();
        boolean notFinal = !Flags.isFinal(flags);
        boolean notStatic = !Flags.isStatic(flags);
        if (notFinal && notStatic) {
          fields.add(field);
View Full Code Here

     
      String eventTypeSig = Signature.createTypeSignature(pname, false);
     
      IFileEditorInput file = (IFileEditorInput) editor.getEditorInput();
      ICompilationUnit unit = JavaCore.createCompilationUnitFrom(file.getFile());
      IType meType = unit.getType(className);
      IMember member = meType.getMethod(methodDesc.getName(),new String[] {eventTypeSig });
      JavaUI.revealInEditor(editor, (IJavaElement) member);
    }   
  }
View Full Code Here

      ICompilationUnit unit = JavaCore.createCompilationUnitFrom(file.getFile());
      String name = file.getName();
      dot = name.lastIndexOf('.');
      if (dot != -1)
        name = name.substring(0, dot);
      IType type = unit.getType(name);
     
      IMember member = type.getMethod(methodName,
          new String[] { eventTypeSig });
      JavaUI.revealInEditor(editor, (IJavaElement) member);
    }
  }
View Full Code Here

      int dot = pname.lastIndexOf('.');
      if (dot != -1)
        pname = pname.substring(dot + 1);
     
      String eventTypeSig = Signature.createTypeSignature(pname, false);
      IType meType = listenerUnit.getType(className);
      IMember member = meType.getMethod(methodDesc.getName(),new String[] {eventTypeSig });
      try {
        JavaUI.openInEditor((IJavaElement) member);
      } catch (Exception e) {
         ParserPlugin.getLogger().error(e);
      }
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.