1 | // Copyright (C) 2008 Google Inc. |
2 | // |
3 | // Licensed under the Apache License, Version 2.0 (the "License"); |
4 | // you may not use this file except in compliance with the License. |
5 | // You may obtain a copy of the License at |
6 | // |
7 | // http://www.apache.org/licenses/LICENSE-2.0 |
8 | // |
9 | // Unless required by applicable law or agreed to in writing, software |
10 | // distributed under the License is distributed on an "AS IS" BASIS, |
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
12 | // See the License for the specific language governing permissions and |
13 | // limitations under the License. |
14 | |
15 | package com.google.caja.ancillary.jsdoc; |
16 | |
17 | import com.google.caja.lexer.FilePosition; |
18 | import com.google.caja.lexer.TokenConsumer; |
19 | import com.google.caja.reporting.RenderContext; |
20 | import java.util.Collections; |
21 | |
22 | /** |
23 | * An annotation that marks up a range of text, such as |
24 | * <pre>{@code code here}</pre> |
25 | * |
26 | * @author mikesamuel@gmail.com |
27 | */ |
28 | public final class InlineAnnotation extends AbstractAnnotation { |
29 | InlineAnnotation(String name, TextAnnotation value, FilePosition pos) { |
30 | super(name, Collections.singletonList(value), pos); |
31 | if (name == null) { throw new NullPointerException(); } |
32 | } |
33 | |
34 | public void render(RenderContext r) { |
35 | TokenConsumer tc = r.getOut(); |
36 | tc.mark(getFilePosition()); |
37 | tc.consume("{"); |
38 | tc.consume("@" + getValue()); |
39 | tc.consume(" "); |
40 | for (Annotation child : children()) { child.render(r); } |
41 | tc.consume("}"); |
42 | } |
43 | } |