org.antlr.runtime.tree.Tree.getLine()方法的使用及代码示例

x33g5p2x  于2022-01-29 转载在 其他  
字(6.7k)|赞(0)|评价(0)|浏览(142)

本文整理了Java中org.antlr.runtime.tree.Tree.getLine()方法的一些代码示例,展示了Tree.getLine()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Tree.getLine()方法的具体详情如下:
包路径:org.antlr.runtime.tree.Tree
类名称:Tree
方法名:getLine

Tree.getLine介绍

[英]In case we don't have a token payload, what is the line for errors?
[中]如果我们没有令牌有效载荷,那么错误的界限是什么?

代码示例

代码示例来源:origin: FeatureIDE/FeatureIDE

private void reportWarning(Tree curNode, String message) {
  if (modelMarkerHandler != null) {
    modelMarkerHandler.createModelMarker(message, org.eclipse.core.resources.IMarker.SEVERITY_WARNING, curNode.getLine());
  }
  Logger.logWarning(message + " (at line " + curNode.getLine() + ((featureModelFile != null) ? IN_FILE + featureModelFile.getName() : "") + ": \""
    + curNode.getText() + "\")");
}

代码示例来源:origin: FeatureIDE/FeatureIDE

private void reportWarning(Tree curNode, String message) {
  if (modelMarkerHandler != null) {
    modelMarkerHandler.createModelMarker(message, org.eclipse.core.resources.IMarker.SEVERITY_WARNING, curNode.getLine());
  }
  Logger.logWarning(message + " (at line " + curNode.getLine() + ((featureModelFile != null) ? IN_FILE + featureModelFile.getName() : "") + ": \""
    + curNode.getText() + "\")");
}

代码示例来源: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: FeatureIDE/FeatureIDE

private void reportWarning(Tree curNode, String message) {
  Logger.logWarning(message + " (at line " + curNode.getLine() + ((featureModelFile != null) ? IN_FILE + featureModelFile.getFileName() : "") + ": \""
    + curNode.getText() + "\")");
}

代码示例来源: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 getLine() {
  int line=0;
  if ( token!=null ) {
    line = token.getLine();
  }
  if ( line==0 ) {
    Tree child = getChild(0);
    if ( child!=null ) {
      line = child.getLine();
    }
  }
  return line;
}

代码示例来源:origin: antlr/antlr3

@Override
public int getLine() {
  int line=0;
  if ( token!=null ) {
    line = token.getLine();
  }
  if ( line==0 ) {
    Tree child = getChild(0);
    if ( child!=null ) {
      line = child.getLine();
    }
  }
  return line;
}

代码示例来源: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: 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

protected int getLastLine(Tree node) {
  int line = -1;
  for (int i = 0; i < node.getChildCount(); ++i) {
   Tree child = node.getChild(i);
   if (child.getLine() > line) {
    line = child.getLine();
   }
   if (child.getType() == DelphiLexer.BEGIN) {
    line = getLastLine(child);
   } else if (child.getType() == DelphiLexer.END) {
    return line;
   }
  }

  return line;
 }
}

代码示例来源: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

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: org.apache.servicemix.bundles/org.apache.servicemix.bundles.antlr-runtime

@Override
public int getLine() {
  if ( token==null || token.getLine()==0 ) {
    if ( getChildCount()>0 ) {
      return getChild(0).getLine();
    }
    return 0;
  }
  return token.getLine();
}

代码示例来源:origin: com.impetus.fabric/fabric-jdbc-driver-shaded

@Override
public int getLine() {
  if ( token==null || token.getLine()==0 ) {
    if ( getChildCount()>0 ) {
      return getChild(0).getLine();
    }
    return 0;
  }
  return token.getLine();
}

代码示例来源:origin: com.ning.billing/killbill-osgi-bundles-analytics

public int getLine() {
  if ( token==null || token.getLine()==0 ) {
    if ( getChildCount()>0 ) {
      return getChild(0).getLine();
    }
    return 0;
  }
  return token.getLine();
}

代码示例来源:origin: antlr/antlr3

@Override
public int getLine() {
  if ( token==null || token.getLine()==0 ) {
    if ( getChildCount()>0 ) {
      return getChild(0).getLine();
    }
    return 0;
  }
  return token.getLine();
}

代码示例来源:origin: io.virtdata/virtdata-lib-realer

@Override
public int getLine() {
  if ( token==null || token.getLine()==0 ) {
    if ( getChildCount()>0 ) {
      return getChild(0).getLine();
    }
    return 0;
  }
  return token.getLine();
}

代码示例来源:origin: antlr/antlr3

@Override
public int getLine() {
  if ( token==null || token.getLine()==0 ) {
    if ( getChildCount()>0 ) {
      return getChild(0).getLine();
    }
    return 0;
  }
  return token.getLine();
}

代码示例来源:origin: fabriciocolombo/sonar-delphi

private UnitInterface createUnit(Tree currentNode, String fileName) {
 UnitInterface activeUnit = new DelphiUnit();
 activeUnit.setPath(fileName);
 activeUnit.setName(getUnitName(currentNode));
 activeUnit.setLine(currentNode.getLine());
 return activeUnit;
}

代码示例来源:origin: fabriciocolombo/sonar-delphi

private int extractLine(Tree currentCodeNode) {
 Tree parent = currentCodeNode.getParent();
 for (int i = currentCodeNode.getChildIndex() - 1; i >= 0; i--) {
  Tree child = parent.getChild(i);
  if (child.getType() == DelphiLexer.FUNCTION
   || child.getType() == DelphiLexer.PROCEDURE
   || child.getType() == DelphiLexer.CONSTRUCTOR
   || child.getType() == DelphiLexer.DESTRUCTOR
   || child.getType() == DelphiLexer.OPERATOR) {
   return child.getLine();
  }
 }
 return -1;
}

相关文章