Package org.eclipse.jdt.core.dom

Examples of org.eclipse.jdt.core.dom.TypeDeclaration


    private AbstractTypeDeclaration createClass(String cname, boolean isenum) {
        AbstractTypeDeclaration abstype;
        if (isenum) {
            abstype = m_ast.newEnumDeclaration();
        } else {
            TypeDeclaration type = m_ast.newTypeDeclaration();
            type.setInterface(false);
            abstype = type;
        }
        abstype.modifiers().add(m_ast.newModifier(Modifier.ModifierKeyword.PUBLIC_KEYWORD));
        abstype.setName(m_ast.newSimpleName(cname));
        return abstype;
View Full Code Here


            // parse the resulting text
            m_parser.setSource(buff.toString().toCharArray());
            CompilationUnit unit = (CompilationUnit)m_parser.createAST(null);
           
            // add all methods from output tree to class under construction
            TypeDeclaration typedecl = (TypeDeclaration)unit.types().get(0);
            for (Iterator iter = typedecl.bodyDeclarations().iterator(); iter.hasNext();) {
                ASTNode node = (ASTNode)iter.next();
                if (node instanceof MethodDeclaration) {
                    holder.addMethod((MethodDeclaration)node);
                }
            }
View Full Code Here

           
            // parse class text to get field declaration
            String text = "class gorph { private static final long serialVersionUID = " + m_serialVersion + "; }";
            m_parser.setSource(text.toCharArray());
            CompilationUnit unit = (CompilationUnit)m_parser.createAST(null);
            TypeDeclaration type = (TypeDeclaration)unit.types().get(0);
            FieldDeclaration field = (FieldDeclaration)type.bodyDeclarations().get(0);
            holder.addField(field);
           
        }
    }
View Full Code Here

  public JClass getDeclaredClass() {
    List types = _unit.types();
    ListIterator typeIter = types.listIterator(0);
    if (typeIter.hasNext()) {
      TypeDeclaration object = (TypeDeclaration) typeIter.next();
      _class = new JClass();
      setClassInformation(_class, object);
      return _class;
    }
    return null;
View Full Code Here

    {
      declaringType = ASTUtil.getFirstTypeParameter( (AnonymousClassDeclaration) node);
    }
    else if( node instanceof TypeDeclaration )
    {
      TypeDeclaration typeDec = (TypeDeclaration) node;
      ITypeBinding curType = typeDec.resolveBinding();

      if( hasMockClass(curType) )
      {
        declaringType = findRealClassType(curType);
      }
      else if( isMockUpType(curType.getSuperclass()) )
      {
        declaringType = ASTUtil.getFirstTypeParam(typeDec.getSuperclassType());
      }
    }

    return declaringType;
  }
View Full Code Here

    while (node != null && !(node instanceof TypeDeclaration)) {
      node = node.getParent();
    }
    if (node == null)
      return NamespaceUtil.getFieldNameFromGetMethodName(getMethodName);
    TypeDeclaration type = (TypeDeclaration) node;
    MethodDeclaration[] methods = type.getMethods();
    for (MethodDeclaration method : methods) {
      String methodName = method.getName().getFullyQualifiedName();
      if (!method.isConstructor()&&methodName.equals(getMethodName)) {
        String fName = NamespaceUtil.findReturnFieldName(method);
        return fName;
View Full Code Here

  @Override
  protected IStatus run(IProgressMonitor monitor) {
    if (componentType != null) {
      EvaluationContext context = createContext();
      TypeDeclaration typeDec = getCompTypeDeclaration();
      if (typeDec != null) {
        MethodDeclaration constructor = getConstructor(typeDec);
        if (constructor != null) {
          IEvaluator evaluator = (IEvaluator) Platform
              .getAdapterManager().getAdapter(constructor,
View Full Code Here

    }
    return constructor;
  }

  private TypeDeclaration getCompTypeDeclaration() {
    TypeDeclaration typeDec = null;
    List types = cunit.types();
    IType type = null;
    try {
      type = unit.getTypes()[0];
    } catch (JavaModelException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }
    if(type == null)
      return null;
    String eName = type.getElementName();
    int dot = eName.lastIndexOf('.');
    if(dot!=-1)
      eName = eName.substring(dot+1);
    System.out.println(eName);
    for(int i=0;i<types.size();i++){
      TypeDeclaration tDec = (TypeDeclaration) types.get(i);
      SimpleName sName = tDec.getName();
      String tName = sName.getIdentifier();
      System.out.println(tName);
      if(tName.equals(eName)){
        typeDec = tDec;
        break;
View Full Code Here

  private MethodDeclaration getMethodDeclaration() {
    String name = invocation.getName().getIdentifier();
    ASTNode root = invocation.getRoot();
    CompilationUnit unit = (CompilationUnit) root;
    TypeDeclaration typeDec = (TypeDeclaration) unit.types().get(0);
    MethodDeclaration[] methods = typeDec.getMethods();
    MethodDeclaration mi = null;
con:    for (MethodDeclaration method : methods) {
      String methodName = method.getName().getIdentifier();
      if (name.equals(methodName)) {
        List<Type> mParamTypes = getMethodParamTypes(method);
View Full Code Here

      }
    }
  }

  private void parsePropertyValue(String lnfClassname, CompilationUnit cunit, WidgetAdapter adapter) {
    TypeDeclaration type = (TypeDeclaration) cunit.types().get(0);
    IWidgetASTParser widgetParser = (IWidgetASTParser) adapter.getAdapter(IWidgetASTParser.class);
    widgetParser.parse(lnfClassname, type);
    if (adapter instanceof CompositeAdapter) {
      CompositeAdapter compositeAdapter = (CompositeAdapter) adapter;
      int count = compositeAdapter.getChildCount();
View Full Code Here

TOP

Related Classes of org.eclipse.jdt.core.dom.TypeDeclaration

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.