本文整理了Java中org.antlr.runtime.tree.Tree.getCharPositionInLine()
方法的一些代码示例,展示了Tree.getCharPositionInLine()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Tree.getCharPositionInLine()
方法的具体详情如下:
包路径:org.antlr.runtime.tree.Tree
类名称:Tree
方法名:getCharPositionInLine
暂无
代码示例来源:origin: com.netflix.suro/suro-core
@Override
public String toString() {
return String.format(
"Unexpected token %s at %d:%d. Expected: %s",
unexpected.getText(),
unexpected.getLine(),
unexpected.getCharPositionInLine(),
joiner.join(expected));
}
代码示例来源:origin: net.peachjean.differentia/differentia-javaica
/**
* Returns text position of the given tree node.
*
* @param tree the source tree node.
* @return the text position.
*/
public static Position getTextPosition(final Tree tree) {
return new Position(tree.getLine(), tree.getCharPositionInLine());
}
代码示例来源:origin: antlr/antlr3
@Override
public int getCharPositionInLine(){
int col=0;
if ( token!=null ) {
col = token.getCharPositionInLine();
}
if ( col==0 ) {
Tree child = getChild(0);
if ( child!=null ) {
col = child.getCharPositionInLine();
}
}
return col;
}
代码示例来源:origin: antlr/antlr3
@Override
public int getCharPositionInLine(){
int col=0;
if ( token!=null ) {
col = token.getCharPositionInLine();
}
if ( col==0 ) {
Tree child = getChild(0);
if ( child!=null ) {
col = child.getCharPositionInLine();
}
}
return col;
}
代码示例来源:origin: jruesga/rview
private String getDefaultFieldText(Tree tree) throws QueryParseException {
String val = tree.getChild(0).toString();
if (val.startsWith("\"") && val.endsWith("\"") && val.length() >= 2) {
val = val.substring(1, val.length() - 1);
}
if (!isValidExpression(val)) {
throw new QueryParseException("Invalid query at " +
tree.getCharPositionInLine() + ": " + tree.getText());
}
return Query.sanitizeValue(val);
}
代码示例来源:origin: org.eclipse.epsilon/epsilon-core
public Component getTreeCellRendererComponent(JTree arg0, Object arg1, boolean selected, boolean expanded, boolean leaf, int row, boolean arg6) {
JLabel label = new JLabel();
Tree ast = (Tree) arg1;
if (selected){
label.setOpaque(true);
label.setBackground(SystemColor.activeCaption);
label.setForeground(SystemColor.activeCaptionText);
}
label.setIcon(new ImageIcon(V3TreeCellRenderer.class.getResource("node.gif")));
label.setText("<html>" +
getText(ast)
+ " (" + v3Resolver.getField(ast.getType()) + "-" + ast.getType() + ")"
+ "<font color='#C0C0C0'>"
+ " (Line:" + ast.getLine() + ",Col:"
+ ast.getCharPositionInLine() //+ ", Props: "
//+ toString(((EolAst) ast).getProperties())
//+ (ast instanceof FileAst ? ((FileAst) ast).getFile().getAbsolutePath() : "")
+ ")"
//+ StringUtil.toString(ast.getNextSibling())
+ "</font>"
+ "</html>");
return label;
}
代码示例来源:origin: fabriciocolombo/sonar-delphi
child.setAttribute("column", String.valueOf(childNode.getCharPositionInLine()));
child.setAttribute("class", "");
child.setAttribute("method", "");
代码示例来源:origin: org.batoo.jpa/batoo-jpa
private void putAlias(BaseQuery<?> q, Tree aliasedDef, final Aliased aliased, final AbstractFrom<?, ?> from) {
Map<String, AbstractFrom<?, ?>> aliasMap = this.aliasMap.get(q);
if (aliasMap == null) {
aliasMap = Maps.newHashMap();
this.aliasMap.put(q, aliasMap);
}
String alias = aliased.getAlias();
if (alias == null) {
alias = aliased.getQualified().getSegments().getLast();
from.alias(alias);
}
if (aliasMap.containsKey(alias)) {
throw new PersistenceException("Alias already exists: " + alias + ", line " + aliasedDef.getLine() + ":" + aliasedDef.getCharPositionInLine());
}
aliasMap.put(aliased.getAlias(), from);
}
}
代码示例来源:origin: BatooOrg/BatooJPA
private void putAlias(BaseQuery<?> q, Tree aliasedDef, final Aliased aliased, final AbstractFrom<?, ?> from) {
Map<String, AbstractFrom<?, ?>> aliasMap = this.aliasMap.get(q);
if (aliasMap == null) {
aliasMap = Maps.newHashMap();
this.aliasMap.put(q, aliasMap);
}
String alias = aliased.getAlias();
if (alias == null) {
alias = aliased.getQualified().getSegments().getLast();
from.alias(alias);
}
if (aliasMap.containsKey(alias)) {
throw new PersistenceException("Alias already exists: " + alias + ", line " + aliasedDef.getLine() + ":" + aliasedDef.getCharPositionInLine());
}
aliasMap.put(aliased.getAlias(), from);
}
}
代码示例来源:origin: fabriciocolombo/sonar-delphi
/**
* @return a Delphi statement
*/
public StatementInterface createStatement() {
StatementInterface statement = new DelphiStatement(lastStatementText, checkedNode.getLine(),
checkedNode.getCharPositionInLine(), delphiProjectHelper);
statement.setComplexity(isComplex);
return statement;
}
代码示例来源:origin: fabriciocolombo/sonar-delphi
private String getFunctionName(CommonTree functionNode) {
Tree nameNode = functionNode.getFirstChildWithType(LexerMetrics.FUNCTION_NAME.toMetrics());
if (nameNode == null) {
return "";
}
functionLine = nameNode.getLine();
functionCharPosition = nameNode.getCharPositionInLine();
StringBuilder str = new StringBuilder();
for (int i = 0; i < nameNode.getChildCount(); ++i) {
Tree child = nameNode.getChild(i);
str.append(child.getText());
}
return str.toString();
}
代码示例来源:origin: com.ning.billing/killbill-osgi-bundles-analytics
public int getCharPositionInLine() {
if ( token==null || token.getCharPositionInLine()==-1 ) {
if ( getChildCount()>0 ) {
return getChild(0).getCharPositionInLine();
}
return 0;
}
return token.getCharPositionInLine();
}
代码示例来源:origin: antlr/antlr3
@Override
public int getCharPositionInLine() {
if ( token==null || token.getCharPositionInLine()==-1 ) {
if ( getChildCount()>0 ) {
return getChild(0).getCharPositionInLine();
}
return 0;
}
return token.getCharPositionInLine();
}
代码示例来源:origin: com.impetus.fabric/fabric-jdbc-driver-shaded
@Override
public int getCharPositionInLine() {
if ( token==null || token.getCharPositionInLine()==-1 ) {
if ( getChildCount()>0 ) {
return getChild(0).getCharPositionInLine();
}
return 0;
}
return token.getCharPositionInLine();
}
代码示例来源:origin: antlr/antlr3
@Override
public int getCharPositionInLine() {
if ( token==null || token.getCharPositionInLine()==-1 ) {
if ( getChildCount()>0 ) {
return getChild(0).getCharPositionInLine();
}
return 0;
}
return token.getCharPositionInLine();
}
代码示例来源:origin: io.virtdata/virtdata-lib-realer
@Override
public int getCharPositionInLine() {
if ( token==null || token.getCharPositionInLine()==-1 ) {
if ( getChildCount()>0 ) {
return getChild(0).getCharPositionInLine();
}
return 0;
}
return token.getCharPositionInLine();
}
代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.antlr-runtime
@Override
public int getCharPositionInLine() {
if ( token==null || token.getCharPositionInLine()==-1 ) {
if ( getChildCount()>0 ) {
return getChild(0).getCharPositionInLine();
}
return 0;
}
return token.getCharPositionInLine();
}
代码示例来源:origin: org.batoo.jpa/batoo-jpa
throw new PersistenceException("Cannot load class: " + className + ", line " + selectDef.getLine() + ":" + selectDef.getCharPositionInLine());
代码示例来源:origin: BatooOrg/BatooJPA
throw new PersistenceException("Cannot load class: " + className + ", line " + selectDef.getLine() + ":" + selectDef.getCharPositionInLine());
代码示例来源:origin: com.ning.billing/killbill-osgi-bundles-analytics
this.charPositionInLine = ((Tree)this.node).getCharPositionInLine();
if ( this.node instanceof CommonTree) {
this.token = ((CommonTree)this.node).token;
内容来源于网络,如有侵权,请联系作者删除!