GlueGen v2.6.0-rc-20250712
GlueGen, Native Binding Generator for Java™ (public API).
ASTLocusTag.java
Go to the documentation of this file.
1/**
2 * Copyright 2015 JogAmp Community. All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without modification, are
5 * permitted provided that the following conditions are met:
6 *
7 * 1. Redistributions of source code must retain the above copyright notice, this list of
8 * conditions and the following disclaimer.
9 *
10 * 2. Redistributions in binary form must reproduce the above copyright notice, this list
11 * of conditions and the following disclaimer in the documentation and/or other materials
12 * provided with the distribution.
13 *
14 * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED
15 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
16 * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR
17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
18 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
19 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
20 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
21 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
22 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
23 *
24 * The views and conclusions contained in the software and documentation are those of the
25 * authors and should not be interpreted as representing official policies, either expressed
26 * or implied, of JogAmp Community.
27 */
28package com.jogamp.gluegen;
29
30/**
31 * An AST location tag.
32 */
33public class ASTLocusTag {
34 /** Source object, might be {@link String}. */
35 public final Object source;
36 /** Line number, {@code -1} if undefined */
37 public final int line;
38 /** Column number, {@code -1} if undefined */
39 public final int column;
40 /** Source text reflecting current location, {@code null} if undefined */
41 public final String text;
42
43 public ASTLocusTag(final Object source, final int line, final int column, final String text) {
44 this.source = source;
45 this.line = line;
46 this.column = column;
47 this.text = text;
48 }
49
50 public String toString() {
51 return toString(new StringBuilder(), null, true).toString();
52 }
53 public StringBuilder toString(final StringBuilder sb, final String level, final boolean inclText) {
54 boolean preCol = false;
55 if (source != null) {
56 sb.append(source);
57 preCol = true;
58 }
59 if (line != -1) {
60 if( preCol ) {
61 sb.append(":");
62 } else {
63 sb.append("line ");
64 }
65 sb.append(line);
66 if (column != -1) {
67 sb.append(":" + column);
68 }
69 preCol = true;
70 }
71 if( null != level && level.length()>0 ) {
72 if( preCol ) {
73 sb.append(": ");
74 }
75 sb.append(level);
76 preCol = true;
77 }
78 if( inclText && null != text && text.length()>0 ) {
79 if( preCol ) {
80 sb.append(": ");
81 } else {
82 sb.append("text ");
83 }
84 sb.append("'").append(text).append("'");
85 }
86 return sb;
87 }
88
89 /**
90 * Interface tag for {@link ASTLocusTag} provider.
91 */
92 public static interface ASTLocusTagProvider {
93 /**
94 * Returns this instance's {@link ASTLocusTag}, if available,
95 * otherwise returns {@code null}.
96 */
98 }
99}
ASTLocusTag(final Object source, final int line, final int column, final String text)
final int column
Column number, -1 if undefined.
final Object source
Source object, might be String.
final int line
Line number, -1 if undefined.
final String text
Source text reflecting current location, null if undefined.
StringBuilder toString(final StringBuilder sb, final String level, final boolean inclText)
Interface tag for ASTLocusTag provider.
ASTLocusTag getASTLocusTag()
Returns this instance's ASTLocusTag, if available, otherwise returns null.