Package org.eclipse.jdt.core.dom

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


  public void synchronizeObserves() throws Exception {
    // prepare editor
    AstEditor editor = m_javaInfoRoot.getEditor();
    // prepare node
    TypeDeclaration rootNode = JavaInfoUtils.getTypeDeclaration(m_javaInfoRoot);
    if (rootNode == null) {
      // use first type declaration from compilation unit
      CompilationUnit astUnit = editor.getAstUnit();
      rootNode = (TypeDeclaration) astUnit.types().get(0);
    }
View Full Code Here


      // prepare AstEditor
      IPackageFragment factoryPackageFragment = getPackage(root, clientFactoryPackageName);
      ICompilationUnit factoryUnit =
          factoryPackageFragment.getCompilationUnit(clientFactoryClassName + ".java");
      AstEditor editor = new AstEditor(factoryUnit);
      TypeDeclaration factoryPrimaryType = editor.getPrimaryType();
      BodyDeclarationTarget bodyDeclarationTarget =
          new BodyDeclarationTarget(factoryPrimaryType, false);
      // modifying ...
      MethodDeclaration methodDeclaration;
      if (factoryPrimaryType.isInterface()) {
        // interface
        String methodHeader = "public " + methodSignature + ";";
        methodDeclaration = editor.addMethodDeclaration(methodHeader, null, bodyDeclarationTarget);
      } else if (AstNodeUtils.isAbstract(factoryPrimaryType)) {
        // abstract class
View Full Code Here

   */
  private static MethodDeclaration getFactoryPlaceController(ICompilationUnit compilationUnit)
      throws Exception {
    if (compilationUnit != null && compilationUnit.exists()) {
      AstEditor editor = new AstEditor(compilationUnit);
      TypeDeclaration typeDeclaration = editor.getPrimaryType();
      MethodDeclaration[] methodDeclarations = typeDeclaration.getMethods();
      for (MethodDeclaration methodDeclaration : methodDeclarations) {
        Type returnType = methodDeclaration.getReturnType2();
        if (returnType != null
            && methodDeclaration.parameters().size() == 0
            && AstNodeUtils.isSuccessorOf(returnType, "com.google.gwt.place.shared.PlaceController")) {
View Full Code Here

      methodLines.add("postInitializeBindings();");
    }
    //
    JavaInfo javaInfoRoot = provider.getJavaInfoRoot();
    AstEditor editor = javaInfoRoot.getEditor();
    TypeDeclaration typeDeclaration = JavaInfoUtils.getTypeDeclaration(javaInfoRoot);
    BodyDeclarationTarget target = new BodyDeclarationTarget(typeDeclaration, null, false);
    MethodDeclaration lastInfoMethod = getLastInfoDeclaration(javaInfoRoot);
    //
    if (m_initDataBindings != null) {
      editor.removeBodyDeclaration(m_initDataBindings);
View Full Code Here

  //
  ////////////////////////////////////////////////////////////////////////////
  public DatabindingParser(JavaInfo javaInfoRoot, DatabindingsProvider provider) throws Exception {
    super(javaInfoRoot.getEditor(), provider);
    //
    TypeDeclaration rootNode = JavaInfoUtils.getTypeDeclaration(javaInfoRoot);
    //
    m_subParsers.add(provider.getRootInfo());
    for (ObserveTypeContainer container : provider.getContainers()) {
      container.createObservables(javaInfoRoot, this, m_editor, rootNode);
      m_subParsers.add(container);
View Full Code Here

      boolean oldFieldState = m_field;
      m_field = newFieldState;
      //
      final String oldVariable = getVariableIdentifier();
      setVariableIdentifier(newVariable);
      final TypeDeclaration rootNode = JavaInfoUtils.getTypeDeclaration(javaInfoRoot);
      //
      if (!oldFieldState && newFieldState) {
        ExecutionUtils.run(javaInfoRoot, new RunnableEx() {
          public void run() throws Exception {
            BodyDeclarationTarget fieldTarget = new BodyDeclarationTarget(rootNode, null, true);
            javaInfoRoot.getEditor().addFieldDeclaration(
                "private " + type + " " + newVariable + ";",
                fieldTarget);
          }
        });
      } else if (oldFieldState && !newFieldState) {
        ExecutionUtils.run(javaInfoRoot, new RunnableEx() {
          public void run() throws Exception {
            for (FieldDeclaration field : rootNode.getFields()) {
              VariableDeclarationFragment fragment = DomGenerics.fragments(field).get(0);
              if (fragment.getName().getIdentifier().equals(oldVariable)) {
                javaInfoRoot.getEditor().removeBodyDeclaration(field);
                return;
              }
            }
            Assert.fail("Undefine binding field: " + oldVariable);
          }
        });
      } else if (oldFieldState && newFieldState) {
        ExecutionUtils.run(javaInfoRoot, new RunnableEx() {
          public void run() throws Exception {
            for (FieldDeclaration field : rootNode.getFields()) {
              VariableDeclarationFragment fragment = DomGenerics.fragments(field).get(0);
              if (fragment.getName().getIdentifier().equals(oldVariable)) {
                javaInfoRoot.getEditor().setIdentifier(fragment.getName(), newVariable);
                return;
              }
View Full Code Here

        List<AbstractTypeDeclaration> topLevelType = unit.types();

        for (AbstractTypeDeclaration abstractTypeDeclaration : topLevelType) {
            // process TypeDeclaration (class, interface)
            if (abstractTypeDeclaration instanceof TypeDeclaration) {
                TypeDeclaration typeDeclaration = (TypeDeclaration)abstractTypeDeclaration;
                if (typeDeclaration.isInterface()) {
                    // is an interface top level type
                    InterfaceMetadata interfaceMetadata = new InterfaceMetadata();
                    interfaceMetadata.setName(JavaMetadataUtil.getName(typeDeclaration.getName()));
                    metadata.add(interfaceMetadata);
                } else {
                    // is a class top level type
                    ClassMetadata classMetadata = new ClassMetadata();
                    processModifiersOfTypDeclaration(typeDeclaration, classMetadata);
                    classMetadata.setName(JavaMetadataUtil.getName(typeDeclaration.getName()));
                    // fields of the class top level type
                    FieldDeclaration[] fieldDeclarations = typeDeclaration.getFields();
                    for (FieldDeclaration fieldDeclaration : fieldDeclarations) {
                        FieldMetadata fieldMetadata = getFieldMetadataFrom(fieldDeclaration);
                        classMetadata.getFields().add(fieldMetadata);
                    }
                    // methods of the class top level type
                    MethodDeclaration[] methodDeclarations = typeDeclaration.getMethods();
                    for (MethodDeclaration methodDeclaration : methodDeclarations) {
                        MethodMetadata methodMetadata = getMethodMetadataFrom(methodDeclaration);
                        classMetadata.getMethods().add(methodMetadata);
                    }
                    metadata.add(classMetadata);
View Full Code Here

    CodeReviewResource resource = getCurrentResource(history);
    List<?> list = resource.getTypedNodeList(resource.getResourceCompUnit(),
        ASTNode.TYPE_DECLARATION, true);
   
    for (Object obj : list) {
      TypeDeclaration typeDec = (TypeDeclaration) obj;
      ITypeBinding binding = typeDec.resolveBinding();
     
      String compName = mappingHelper.getComponentName(binding);
      if (compName != null) {
        Component comp = arch.getComponentByName(compName);
        if (comp != null && MODEL_COMPONENT_TYPE.equals(comp.getStyleType())) {
View Full Code Here

    CodeReviewResource resource = getCurrentResource(history);
    List<?> list = resource.getTypedNodeList(resource.getResourceCompUnit(),
        ASTNode.TYPE_DECLARATION, true);
   
    for (Object obj : list) {
      TypeDeclaration typeDec = (TypeDeclaration) obj;
      ITypeBinding binding = typeDec.resolveBinding();
     
      String compName = mappingHelper.getComponentName(binding);
      if (compName != null) {
        Component comp = arch.getComponentByName(compName);
        if (comp != null && VIEW_COMPONENT_TYPE.equals(comp.getStyleType())) {
View Full Code Here

  @Override
  public boolean satisfies(ASTNode node) {
    if (node.getNodeType() == ASTNode.TYPE_DECLARATION) {
     
      TypeDeclaration type = (TypeDeclaration) node;
      ITypeBinding binding = type.resolveBinding();

     
      for (IAnnotationBinding anno : binding.getAnnotations()) { 
        if (anno.getAnnotationType().getQualifiedName().equals(annotationClassName)) {         
          if (annotationValue != null) {
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.