private void writeForStatement(IASTForStatement forStatement) { scribe.noNewLines(); scribe.print(FOR); writeStatement(forStatement.getInitializerStatement(), false); if (forStatement instanceof ICPPASTForStatement) { ICPPASTForStatement cppForStatment = (ICPPASTForStatement) forStatement; IASTDeclaration cppConditionDeclaration = cppForStatment.getConditionDeclaration(); if (cppConditionDeclaration == null) { visitNodeIfNotNull(cppForStatment.getConditionExpression()); scribe.printSemicolon(); } else { cppConditionDeclaration.accept(visitor); } } else { if (forStatement.getConditionExpression() != null) { forStatement.getConditionExpression().accept(visitor); scribe.printSemicolon(); } } visitNodeIfNotNull(forStatement.getIterationExpression()); scribe.print(')'); scribe.newLines(); nextCompoundNoNewLine(); writeBodyStatement(forStatement.getBody(), false); }
private void visitFor(IASTForStatement statement) throws BadLocationException { /* TODO: specific params: show also initializer && increment expressions */ IASTExpression cond = statement.getConditionExpression(); String hint = ""; // $NON-NLS-1$ if (cond != null) hint = cond.getRawSignature(); hint = "for( " + hint + " )"; // $NON-NLS-1$ //$NON-NLS-2$ int startLoc = statement.getFileLocation().getNodeOffset(); _scopeStack.push(new ScopeInfo(hint, startLoc, statement)); IASTStatement body = statement.getBody(); if (body instanceof IASTCompoundStatement) { IASTFileLocation location = body.getFileLocation(); int endLoc = location.getNodeOffset() + location.getNodeLength() - 1; _container.add(new Hint("for", startLoc, endLoc, hint)); // $NON-NLS-1$ } }