private static String ppPos(Position pos) { String file = pos.getURL().getFile(); file = file.substring(file.lastIndexOf('/')+1); int line = pos.getFirstLine(), start_offset = pos.getFirstOffset(), end_offset = pos.getLastOffset(); return file + '@' + line + ':' + start_offset + '-' + end_offset; }
private static String ppPos(Position pos) { String file = pos.getURL().getFile(); file = file.substring(file.lastIndexOf('/')+1); int line = pos.getFirstLine(), start_offset = pos.getFirstOffset(), end_offset = pos.getLastOffset(); return file + '@' + line + ':' + start_offset + '-' + end_offset; }
} while (p.getLastOffset()>=0? p.getFirstOffset() > offset: p.getFirstLine() > line); if (p.getLastOffset() >= 0) { if (p.getFirstOffset() == offset) { lines.add("\n"); } else { int startOffset = p.getFirstOffset() - (offset-currentLine.length()-1); if (offset > p.getLastOffset()) { int endOffset = p.getLastOffset() - (offset-currentLine.length()-1); lines.add(currentLine.substring(startOffset, endOffset)); } else { while (p.getLastOffset()>=0? p.getLastOffset() >= offset: p.getLastLine() >= line) { currentLine = reader.readLine(); offset = p.getLastOffset(); break; } else { if (p.getLastOffset() >= 0) { if (offset > p.getLastOffset()) { lines.add(currentLine.substring(0, currentLine.length() - (offset - p.getLastOffset()) + 1)); } else { lines.add(currentLine);
} while (p.getLastOffset()>=0? p.getFirstOffset() > offset: p.getFirstLine() > line); if (p.getLastOffset() >= 0) { if (p.getFirstOffset() == offset) { lines.add("\n"); } else { int startOffset = p.getFirstOffset() - (offset-currentLine.length()-1); if (offset > p.getLastOffset()) { int endOffset = p.getLastOffset() - (offset-currentLine.length()-1); lines.add(currentLine.substring(startOffset, endOffset)); } else { while (p.getLastOffset()>=0? p.getLastOffset() >= offset: p.getLastLine() >= line) { currentLine = reader.readLine(); offset = p.getLastOffset(); break; } else { if (p.getLastOffset() >= 0) { if (offset > p.getLastOffset()) { lines.add(currentLine.substring(0, currentLine.length() - (offset - p.getLastOffset()) + 1)); } else { lines.add(currentLine);
.pos().getPosition(stmtNodes[stmtNodes.length - 1]).getLastOffset()); caseNodes.add(makeNode(childContext, fFactory, positionOfAll, CAstNode.BLOCK_STMT, stmtNodes)); currentBlock.clear(); .getPosition(stmtNodes[stmtNodes.length - 1]).getLastOffset()); caseNodes.add(makeNode(childContext, fFactory, positionOfAll, CAstNode.BLOCK_STMT, stmtNodes));
private static void findNodesAtPos(int kind, Position pos, CAstSourcePositionMap spmap, ChildPos nodep, Set<ChildPos> res) { CAstNode node = nodep.getChild(); if(node == null) return; Position ndpos = spmap.getPosition(node); if(ndpos != null) { // if we are in the wrong file or past the position pos, abort search if(!ndpos.getURL().equals(pos.getURL())) return; if(pos.getLastLine() >= 0 && ndpos.getFirstLine() > pos.getLastLine()) return; //if(node.getKind() == kind && ndpos.getFirstLine() == pos.getFirstLine() && ndpos.getLastLine() == pos.getLastLine()) if(node.getKind() == kind && ndpos.getFirstOffset() == pos.getFirstOffset() && ndpos.getLastOffset() == pos.getLastOffset()) res.add(nodep); } for(int i=0;i<node.getChildCount();++i) findNodesAtPos(kind, pos, spmap, nodep.getChildPos(i), res); }
private static void findNodesAtPos(int kind, Position pos, CAstSourcePositionMap spmap, ChildPos nodep, Set<ChildPos> res) { CAstNode node = nodep.getChild(); if(node == null) return; Position ndpos = spmap.getPosition(node); if(ndpos != null) { // if we are in the wrong file or past the position pos, abort search if(!ndpos.getURL().equals(pos.getURL())) return; if(pos.getLastLine() >= 0 && ndpos.getFirstLine() > pos.getLastLine()) return; //if(node.getKind() == kind && ndpos.getFirstLine() == pos.getFirstLine() && ndpos.getLastLine() == pos.getLastLine()) if(node.getKind() == kind && ndpos.getFirstOffset() == pos.getFirstOffset() && ndpos.getLastOffset() == pos.getLastOffset()) res.add(nodep); } for(int i=0;i<node.getChildCount();++i) findNodesAtPos(kind, pos, spmap, nodep.getChildPos(i), res); }
@Override public boolean equals(Object o){ if (o instanceof Position) { Position p = (Position)o; return getFirstLine() == p.getFirstLine() && getLastLine() == p.getLastLine() && getFirstCol() == p.getFirstCol() && getLastCol() == p.getLastCol() && getFirstOffset() == p.getFirstOffset() && getLastOffset() == p.getLastOffset() && ( (getURL() != null)? getURL().equals(p.getURL()): p.getURL() == null); } else { return false; } }
@Override public boolean equals(Object o){ if (o instanceof Position) { Position p = (Position)o; return getFirstLine() == p.getFirstLine() && getLastLine() == p.getLastLine() && getFirstCol() == p.getFirstCol() && getLastCol() == p.getLastCol() && getFirstOffset() == p.getFirstOffset() && getLastOffset() == p.getLastOffset() && ( (getURL() != null)? getURL().equals(p.getURL()): p.getURL() == null); } else { return false; } }
@Override public int getLastOffset() { return pos.getLastOffset()==-1? -1: (pos.getLastOffset()-range.getStart()); }
public boolean includes(Position offset) { return offset.getFirstOffset() != -1? rangeStart <= offset.getFirstOffset() && offset.getLastOffset() <= rangeEnd: rangeStartingLine <= offset.getFirstLine() && (offset.getLastLine() == -1? offset.getFirstLine(): offset.getLastLine()) <= rangeEndingLine; }
@Override public int getLastOffset() { return pos.getLastOffset()==-1? -1: (pos.getLastOffset()-range.getStart()); }
public boolean includes(Position offset) { return offset.getFirstOffset() != -1? rangeStart <= offset.getFirstOffset() && offset.getLastOffset() <= rangeEnd: rangeStartingLine <= offset.getFirstLine() && (offset.getLastLine() == -1? offset.getFirstLine(): offset.getLastLine()) <= rangeEndingLine; }
@Override public int compareTo(Object o) { Position other = (Position) o; if (startOffset != other.getFirstOffset()) { return startOffset - other.getFirstOffset(); } else { return endOffset - other.getLastOffset(); } }
@Override public int compareTo(Object o) { Position other = (Position) o; if (startOffset != other.getFirstOffset()) { return startOffset - other.getFirstOffset(); } else { return endOffset - other.getLastOffset(); } }