Package org.eclipse.jdt.core.dom

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


  @Override
  public boolean satisfies(ASTNode node) {
    if (node.getNodeType() == ASTNode.TYPE_DECLARATION) {
     
      TypeDeclaration type = (TypeDeclaration) node;
      ITypeBinding binding = type.resolveBinding();
      String compName = mapping.getComponentName(binding);
      if (compName == null) {
        return false;
      }
      if (requestedName == null) {
View Full Code Here


    CodeReviewResource resource = getCurrentResource(history);
    List<?> classes = resource.getTypedNodeList(resource
        .getResourceCompUnit(), ASTNode.TYPE_DECLARATION, false);
   
    for (Object typeObj : classes) {
      TypeDeclaration type = (TypeDeclaration) typeObj;
      ITypeBinding binding = type.resolveBinding();
      String compName = mappingHelper.getComponentName(binding);
      if (compName == null) {
        generateResultsForASTNode(history,
            type, resource, "The type "+ binding.getName() + " does not belong to a component or connector");
      } else if (arch.getComponentOrConnectorByName(compName) == null) {
View Full Code Here

    CodeReviewResource resource = getCurrentResource(history);
    List list = resource.getTypedNodeList(resource
        .getResourceCompUnit(), ASTNode.TYPE_DECLARATION);
   
    for (Object obj : list) {
      TypeDeclaration type = (TypeDeclaration) obj;
      ITypeBinding binding = type.resolveBinding();
      if (binding == null) {
        continue;
      }
     
      ImplementationArtifactDefinition artifactDef = qualifiedNames.
          get(binding.getQualifiedName());
      if (artifactDef == null) {
        // The information could also be contained in
        // annotations or classNamePatterns
        artifactDef = mappingHelper.getClassInformation(binding);
      }
     
     
      if (artifactDef != null) {
        // We have found the artifact
        artifactsNotPresent.remove(artifactDef);

        if (artifactDef instanceof InterfaceDefinition &&
            !binding.isInterface()) {
          generateResultsForASTNode(history, type, resource,
              "The type "+ binding.getQualifiedName() + " is a class"+
              ", but should be an interface according to the definition in "+
              artifactDef.getParent().getName());
          continue;
        }
        if (artifactDef instanceof ClassDefinition &&
            binding.isInterface()) {
          generateResultsForASTNode(history, type, resource,
              "The type "+ binding.getQualifiedName() + " is "+
              "an interface, but should be a class according to the definition in "+
              artifactDef.getParent().getName());
          continue;
        }
       

        if (binding.getSuperclass() != null &&
            binding.getSuperclass() != type.getAST().resolveWellKnownType("java.lang.Object")) {
          // Check Restriction.noSuperClass
          ImplementationArtifactType artifactType = mappingHelper.getTypeOf(artifactDef);
          if (artifactType != null && artifactType instanceof ClassType) {
            ClassType classType = (ClassType) artifactType;
            if (classType.getRestrictions().contains(ClassTypeRestriction.noSuperclass)) {
View Full Code Here

      ASTHelper.satisfy(list,
          new ComponentRuleFilter(mappingHelper, null, true));

      for (Iterator<?> it = list.iterator(); it.hasNext();) {
        TypeDeclaration type = (TypeDeclaration) it.next();
        ITypeBinding binding = type.resolveBinding();
        String compName = mappingHelper.getComponentName(binding);
       
        components.remove(compName);
      }
    } catch (final RuntimeException e) {
View Full Code Here

    ImportDeclaration id = ast.newImportDeclaration();
    id.setName(ast.newName(new String[] {
        "java", "util", "Set" }));
    cu.imports().add(id);

    TypeDeclaration td = ast.newTypeDeclaration();
    td.setName(ast.newSimpleName("Foo"));
    TypeParameter tp = ast.newTypeParameter();
    tp.setName(ast.newSimpleName("X"));
    td.typeParameters().add(tp);
    cu.types().add(td);

    MethodDeclaration md = ast.newMethodDeclaration();
    md.modifiers().add(ast.newModifier(ModifierKeyword.PUBLIC_KEYWORD));
    md.setName(ast.newSimpleName("bar"));

    SingleVariableDeclaration var = ast.newSingleVariableDeclaration();
    var.setType(ast.newSimpleType(ast.newSimpleName("String")));
    var.setName(ast.newSimpleName("a"));
    md.parameters().add(var);
    td.bodyDeclarations().add(md);

    Block block = ast.newBlock();
    md.setBody(block);

    MethodInvocation mi = ast.newMethodInvocation();
View Full Code Here

    if (node.getNodeType() != ASTNode.TYPE_DECLARATION) {
      createdNodeSource = generateSyntaxIncorrectAST();
      if (this.createdNode == null)
        throw new JavaModelException(new JavaModelStatus(IJavaModelStatusConstants.INVALID_CONTENTS));
    } else {
      TypeDeclaration typeDeclaration = (TypeDeclaration) node;
      if ((typeDeclaration.getFlags() & ASTNode.MALFORMED) != 0) {
        createdNodeSource = generateSyntaxIncorrectAST();
        if (this.createdNode == null)
          throw new JavaModelException(new JavaModelStatus(IJavaModelStatusConstants.INVALID_CONTENTS));
      } else {
        List bodyDeclarations = typeDeclaration.bodyDeclarations();
        if (bodyDeclarations.size() == 0) {
          throw new JavaModelException(new JavaModelStatus(IJavaModelStatusConstants.INVALID_CONTENTS));
        }
        this.createdNode = (ASTNode) bodyDeclarations.iterator().next();
        createdNodeSource = this.source;
View Full Code Here

  buff.append(this.source);
  buff.append(lineSeparator).append('}');
  ASTParser parser = ASTParser.newParser(AST.JLS8);
  parser.setSource(buff.toString().toCharArray());
  CompilationUnit compilationUnit = (CompilationUnit) parser.createAST(null);
  TypeDeclaration typeDeclaration = (TypeDeclaration) compilationUnit.types().iterator().next();
  List bodyDeclarations = typeDeclaration.bodyDeclarations();
  if (bodyDeclarations.size() != 0)
    this.createdNode = (ASTNode) bodyDeclarations.iterator().next();
  return buff.toString();
}
View Full Code Here

   }

   @Override
   public List<TypeVariableSource<O>> getTypeVariables()
   {
      TypeDeclaration type = (TypeDeclaration) body;
      List<TypeParameter> typeParameters = type.typeParameters();
      List<TypeVariableSource<O>> result = new ArrayList<TypeVariableSource<O>>();
      for (TypeParameter typeParameter : typeParameters)
      {
         result.add(new TypeVariableImpl<O>((O) this, typeParameter));
      }
View Full Code Here

   }

   @Override
   public TypeVariableSource<O> getTypeVariable(String name)
   {
      TypeDeclaration type = (TypeDeclaration) body;
      List<TypeParameter> typeParameters = type.typeParameters();
      for (TypeParameter typeParameter : typeParameters)
      {
         if (Strings.areEqual(name, typeParameter.getName().getIdentifier()))
         {
            return new TypeVariableImpl<O>((O) this, typeParameter);
View Full Code Here

   }

   @Override
   public TypeVariableSource<O> addTypeVariable()
   {
      TypeDeclaration type = (TypeDeclaration) body;
      TypeParameter tp2 = unit.getAST().newTypeParameter();
      type.typeParameters().add(tp2);
      return new TypeVariableImpl<O>((O) this, tp2);
   }
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.