View Javadoc
1 /* FOREGEJ - FOrmatting REfactoring GEnerating Java 2 * 3 * Copyright (C) 2003 Andreas Arrgard 4 * 5 * This library is free software; you can redistribute it and/or 6 * modify it under the terms of the GNU Lesser General Public 7 * License as published by the Free Software Foundation; either 8 * version 2.1 of the License, or (at your option) any later version. 9 * 10 * This library is distributed in the hope that it will be useful, 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 * Lesser General Public License for more details. 14 * 15 * You should have received a copy of the GNU Lesser General Public 16 * License along with this library; if not, write to the Free Software 17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 */ 19 package com.octagroup.foregej.html; 20 import antlr.collections.AST; 21 import com.octagroup.foregej.antlr.BaseAST; 22 import com.octagroup.foregej.antlr.NodeWriter; 23 import com.octagroup.foregej.html.ast.Tag; 24 import com.octagroup.foregej.java.doc.ast.JTag; 25 /*** 26 */ 27 public class HtmlNodeWriter extends NodeWriter 28 { 29 private BaseAST lastAST_=null; 30 /*** 31 * Before a html ast is written we must determine if there were one or 32 * more whitespaces before. 33 * 34 * @param ast 35 */ 36 public void write(AST ast) 37 { 38 if(lastAST_!=null) { 39 writeHiddenBetween(lastAST_, (BaseAST)ast); 40 } 41 lastAST_=(BaseAST)ast; 42 super.write(ast); 43 } 44 /*** 45 * @param lastAST 46 * @param ast 47 */ 48 private void writeHiddenBetween(BaseAST lastAST,BaseAST ast) 49 { 50 if(ast instanceof JTag) { 51 return; 52 } 53 if(lastAST instanceof Tag||ast instanceof Tag) { 54 if(ast.getParentAst()!=lastAST) { 55 return; 56 } 57 } 58 if(lastAST.getHiddenAfter()==null) { 59 return; 60 } 61 write(" "); 62 } 63 }

This page was automatically generated by Maven