コード例 #1
0
ファイル: XMLSchema.java プロジェクト: wilden/deegree2-base
 private void resolveReferences(TypeDeclaration typeDeclaration)
     throws UnresolvableReferenceException {
   LOG.logDebug(
       "Resolving references in type declaration '"
           + typeDeclaration.getName().getLocalName()
           + "'.");
   if (typeDeclaration instanceof SimpleTypeDeclaration) {
     LOG.logDebug("SimpleType.");
     SimpleTypeDeclaration simpleType = (SimpleTypeDeclaration) typeDeclaration;
     TypeReference typeReference = simpleType.getRestrictionBaseType();
     if (typeReference != null) {
       LOG.logDebug("restriction base='" + typeReference.getName() + "'");
       try {
         resolveType(typeReference);
       } catch (XMLSchemaException e) {
         throw new UndefinedXSDTypeException(
             "Declaration of type '"
                 + typeDeclaration.getName()
                 + "' derives type '"
                 + typeReference.getName()
                 + "' which is not a defined simple type.");
       }
     }
   } else {
     LOG.logDebug("ComplexType.");
     ComplexTypeDeclaration complexType = (ComplexTypeDeclaration) typeDeclaration;
     TypeReference typeReference = complexType.getExtensionBaseType();
     if (typeReference != null) {
       LOG.logDebug("extension base='" + typeReference.getName() + "'");
       try {
         resolveType(typeReference);
       } catch (XMLSchemaException e) {
         throw new UndefinedXSDTypeException(
             "Declaration of type '"
                 + typeDeclaration.getName()
                 + "' derives type '"
                 + typeReference.getName()
                 + "' which is not a defined complex type.");
       }
     }
     ElementDeclaration[] elements = complexType.getExplicitElements();
     for (int i = 0; i < elements.length; i++) {
       resolveReferences(elements[i]);
     }
   }
 }
コード例 #2
0
ファイル: Import.java プロジェクト: davidfestal/ceylon-spec
 @Override
 public String toString() {
   return "Import["
       + alias
       + "="
       + (typeDeclaration == null ? "" : typeDeclaration.getName())
       + declaration.getName()
       + "]";
 }
コード例 #3
0
ファイル: CompilationUnit.java プロジェクト: RPI-WCL/salsa2
 public List<String> generateJavaCode() throws IOException {
   List<String> generatedFiles = new ArrayList<String>();
   String header = this.getHeaderCode("");
   for (Iterator<TypeDeclaration> it = typeDeclarations.iterator(); it.hasNext(); ) {
     TypeDeclaration td = it.next();
     if (td instanceof BehaviorDeclaration) {
       BehaviorDeclaration bd = (BehaviorDeclaration) td;
       String refFileName = sourceDirName + File.separator + bd.getName() + ".java";
       writeFile(refFileName, header + bd.toJavaRefCode(""));
       String stateFileName = sourceDirName + File.separator + td.getName() + "State.java";
       writeFile(stateFileName, header + bd.toJavaCode(""));
       generatedFiles.add(refFileName);
       generatedFiles.add(stateFileName);
     } else if (td instanceof ClassDeclaration) {
       String classFileName = sourceDirName + File.separator + td.getName() + ".java";
       writeFile(classFileName, header + td.toJavaCode(""));
       generatedFiles.add(classFileName);
     }
   }
   return generatedFiles;
 }
コード例 #4
0
  public boolean visit(TypeDeclaration type) throws Exception {
    if (type instanceof NamespaceDeclaration) {
      NamespaceDeclaration namespaceDecl = (NamespaceDeclaration) type;
      fCurrentNamespace = namespaceDecl;
      fLastUseParts.clear();
      if (namespaceDecl.isGlobal()) {
        return visitGeneral(type);
      }
      declarations.push(type);

      int modifiers = type.getModifiers() | Modifiers.AccNameSpace;
      fCurrentQualifier = type.getName();
      Integer count = fCurrentQualifierCounts.get(fCurrentQualifier);
      count = count != null ? count + 1 : 1;
      fCurrentQualifierCounts.put(fCurrentQualifier, count);

      modifiers = markAsDeprecated(modifiers, type);
      StringBuilder metadata = new StringBuilder();
      if (fCurrentQualifier != null) {
        metadata.append(fCurrentQualifierCounts.get(fCurrentQualifier));
        metadata.append(";"); // $NON-NLS-1$
      }
      modifyDeclaration(
          type,
          new DeclarationInfo(
              IModelElement.PACKAGE_DECLARATION,
              modifiers,
              type.sourceStart(),
              type.sourceEnd() - type.sourceStart(),
              type.getNameStart(),
              type.getNameEnd() - type.getNameStart(),
              type.getName(),
              metadata.length() == 0 ? null : metadata.toString(),
              encodeDocInfo(type),
              null,
              null));
    } else {
      Declaration parentDeclaration = null;
      if (!declarations.empty()) {
        parentDeclaration = declarations.peek();
      }
      declarations.push(type);

      if (!(parentDeclaration instanceof NamespaceDeclaration)) {
        type.setModifier(Modifiers.AccGlobal);
      }

      // In case we are entering a nested element
      if (parentDeclaration instanceof MethodDeclaration) {
        if (fCurrentNamespace == null) {
          deferredDeclarations.add(type);
        } else {
          deferredNamespacedDeclarations.add(type);
        }
        return visitGeneral(type);
      }

      int modifiers = type.getModifiers();
      fCurrentParent = type.getName();

      String[] superClasses = processSuperClasses(type);
      StringBuilder metadata = new StringBuilder();
      if (fCurrentQualifier != null) {
        metadata.append(fCurrentQualifierCounts.get(fCurrentQualifier));
        metadata.append(";"); // $NON-NLS-1$
      }
      for (int i = 0; i < superClasses.length; ++i) {
        metadata.append(superClasses[i]);
        if (i < superClasses.length - 1) {
          metadata.append(","); // $NON-NLS-1$
        }
      }
      modifiers = markAsDeprecated(modifiers, type);
      modifyDeclaration(
          type,
          new DeclarationInfo(
              IModelElement.TYPE,
              modifiers,
              type.sourceStart(),
              type.sourceEnd() - type.sourceStart(),
              type.getNameStart(),
              type.getNameEnd() - type.getNameStart(),
              type.getName(),
              metadata.length() == 0 ? null : metadata.toString(),
              encodeDocInfo(type),
              fCurrentQualifier,
              null));
    }

    for (PhpIndexingVisitorExtension visitor : extensions) {
      visitor.visit(type);
    }

    return visitGeneral(type);
  }
コード例 #5
0
 /*
  * @see ASTVisitor#visit(TypeDeclaration)
  */
 @Override
 public boolean visit(TypeDeclaration node) {
   if (node.getJavadoc() != null) {
     node.getJavadoc().accept(this);
   }
   if (node.getAST().apiLevel() >= JLS3) {
     printModifiers(node.modifiers());
   }
   this.fBuffer.append(node.isInterface() ? "interface " : "class "); // $NON-NLS-2$//$NON-NLS-1$
   node.getName().accept(this);
   if (node.getAST().apiLevel() >= JLS3) {
     if (!node.typeParameters().isEmpty()) {
       this.fBuffer.append("<"); // $NON-NLS-1$
       for (Iterator<TypeParameter> it = node.typeParameters().iterator(); it.hasNext(); ) {
         TypeParameter t = it.next();
         t.accept(this);
         if (it.hasNext()) {
           this.fBuffer.append(","); // $NON-NLS-1$
         }
       }
       this.fBuffer.append(">"); // $NON-NLS-1$
     }
   }
   this.fBuffer.append(" "); // $NON-NLS-1$
   if (node.getAST().apiLevel() >= JLS3) {
     if (node.getSuperclassType() != null) {
       this.fBuffer.append("extends "); // $NON-NLS-1$
       node.getSuperclassType().accept(this);
       this.fBuffer.append(" "); // $NON-NLS-1$
     }
     if (!node.superInterfaceTypes().isEmpty()) {
       this.fBuffer.append(
           node.isInterface() ? "extends " : "implements "); // $NON-NLS-2$//$NON-NLS-1$
       for (Iterator<Type> it = node.superInterfaceTypes().iterator(); it.hasNext(); ) {
         Type t = it.next();
         t.accept(this);
         if (it.hasNext()) {
           this.fBuffer.append(", "); // $NON-NLS-1$
         }
       }
       this.fBuffer.append(" "); // $NON-NLS-1$
     }
   }
   this.fBuffer.append("{"); // $NON-NLS-1$
   BodyDeclaration prev = null;
   for (Iterator<BodyDeclaration> it = node.bodyDeclarations().iterator(); it.hasNext(); ) {
     BodyDeclaration d = it.next();
     if (prev instanceof EnumConstantDeclaration) {
       // enum constant declarations do not include punctuation
       if (d instanceof EnumConstantDeclaration) {
         // enum constant declarations are separated by commas
         this.fBuffer.append(", "); // $NON-NLS-1$
       } else {
         // semicolon separates last enum constant declaration from
         // first class body declarations
         this.fBuffer.append("; "); // $NON-NLS-1$
       }
     }
     d.accept(this);
     prev = d;
   }
   this.fBuffer.append("}"); // $NON-NLS-1$
   return false;
 }