private void visitSwitch(IASTSwitchStatement statement) throws BadLocationException {
   String hint = statement.getControllerExpression().getRawSignature();
   IASTFileLocation location = statement.getBody().getFileLocation();
   int endLoc = location.getNodeOffset() + location.getNodeLength() - 1;
   int startLoc = statement.getFileLocation().getNodeOffset();
   hint = "switch( " + hint + " )"; // $NON-NLS-1$ //$NON-NLS-2$
   _container.add(new Hint("switch", startLoc, endLoc, hint)); // $NON-NLS-1$
   _scopeStack.push(new ScopeInfo(hint, startLoc, statement));
 }
Example #2
0
  private void writeSwitchStatement(IASTSwitchStatement switchStatement) {
    switchIsNew = true;

    scribe.print(SWITCH_BRACKET);
    scribe.noNewLines();
    if (switchStatement instanceof ICPPASTSwitchStatement) {
      ICPPASTSwitchStatement cppSwitchStatement = (ICPPASTSwitchStatement) switchStatement;
      if (cppSwitchStatement.getControllerDeclaration() == null) {
        cppSwitchStatement.getControllerExpression().accept(visitor);
      } else {
        declWriter.writeDeclaration(cppSwitchStatement.getControllerDeclaration(), false);
      }
    } else {
      switchStatement.getControllerExpression().accept(visitor);
    }
    scribe.print(')');
    scribe.newLines();
    nextCompoundNoNewLine();
    writeBodyStatement(switchStatement.getBody(), false);

    switchIsNew = false;
  }