private void writeArrayDeclarator(IASTArrayDeclarator arrDecl) {
    IASTPointerOperator[] pointOps = arrDecl.getPointerOperators();
    writePointerOperators(arrDecl, pointOps);
    IASTName name = arrDecl.getName();
    name.accept(visitor);

    writeNestedDeclarator(arrDecl);

    IASTArrayModifier[] arrMods = arrDecl.getArrayModifiers();
    writeArrayModifiers(arrDecl, arrMods);
    IASTInitializer initializer = getInitializer(arrDecl);
    if (initializer != null) {
      initializer.accept(visitor);
    }
  }
Beispiel #2
0
 private IASTDeclarator createDeclarator(
     INodeFactory nodeFactory, IASTDeclarator sourceDeclarator, String name) {
   IASTName astName =
       name != null ? nodeFactory.newName(name.toCharArray()) : nodeFactory.newName();
   IASTDeclarator declarator;
   if (sourceDeclarator instanceof IASTArrayDeclarator) {
     IASTArrayDeclarator arrDeclarator = (IASTArrayDeclarator) sourceDeclarator;
     IASTArrayDeclarator arrayDeclarator = nodeFactory.newArrayDeclarator(astName);
     IASTArrayModifier[] arrayModifiers = arrDeclarator.getArrayModifiers();
     for (IASTArrayModifier arrayModifier : arrayModifiers) {
       arrayDeclarator.addArrayModifier(arrayModifier.copy(CopyStyle.withLocations));
     }
     declarator = arrayDeclarator;
   } else {
     declarator = nodeFactory.newDeclarator(astName);
   }
   for (IASTPointerOperator pointerOp : sourceDeclarator.getPointerOperators()) {
     declarator.addPointerOperator(pointerOp.copy(CopyStyle.withLocations));
   }
   return declarator;
 }