X-Git-Url: http://nitlanguage.org diff --git a/src/test_highlight.nit b/src/test_highlight.nit new file mode 100644 index 0000000..96d0835 --- /dev/null +++ b/src/test_highlight.nit @@ -0,0 +1,74 @@ +# This file is part of NIT ( http://www.nitlanguage.org ). +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Program used to test the Nit highlighter +module test_highlight + +import highlight +import test_phase + +redef fun do_work(mainmodule, mmodules, mb) +do + var v = new HighlightVisitor + print """ + + + {{{v.head_content}}} + + """ + + for mm in mmodules do for cd in mm.mclassdefs do for pd in cd.mpropdefs do + var n = mb.mpropdef2node(pd) + if not n isa APropdef then continue + var hl = new HighlightVisitor + hl.enter_visit(n) + print "

{pd.full_name}

" + printn "
"
+		hl.html.write_to(stdout)
+		print "
" + end + + # Some random nodes + var thlv = new THLVisitor + for mm in mmodules do + var n = mb.mmodule2node(mm) + thlv.enter_visit(n) + end + + print v.foot_content + print "" +end + +class THLVisitor + super Visitor + var seen = new HashSet[String] + redef fun visit(n) + do + var cn = n.class_name + if not seen.has(cn) then + seen.add cn + + var hl = new HighlightVisitor + hl.enter_visit(n) + print "

AST node: {cn} at {n.location}

" + printn "
"
+			hl.html.write_to(stdout)
+			print "
" + end + + n.visit_all(self) + end +end