private void handleAttribute(Entry<String, Pair<String,Position>> a, String funcName, ITag tag) { URL url = entrypointUrl; try { url = new URL(entrypointUrl, "#" + tag.getElementPosition().getFirstOffset()); } catch (MalformedURLException e) { // TODO Auto-generated catch block if (DEBUG) { e.printStackTrace(); } } Position pos = a.getValue().snd; String attName = a.getKey(); String attValue = a.getValue().fst; if (attName.toLowerCase().startsWith("on") || (attValue != null && attValue.toLowerCase().startsWith("javascript:"))) { String fName = tag.getName().toLowerCase() + '_' + attName + '_' + funcName; String signatureLine = "function " + fName + "(event) {"; // Defines the function domRegion.println(signatureLine + '\n' + extructJS(attValue) + "\n}", pos, url, true); // Run it writeEntrypoint('\t' + fName + "(null);", pos, url, true); } }
private void handleAttribute(Entry<String, Pair<String,Position>> a, String funcName, ITag tag) { URL url = entrypointUrl; try { url = new URL(entrypointUrl, "#" + tag.getElementPosition().getFirstOffset()); } catch (MalformedURLException e) { // TODO Auto-generated catch block if (DEBUG) { e.printStackTrace(); } } Position pos = a.getValue().snd; String attName = a.getKey(); String attValue = a.getValue().fst; if (attName.toLowerCase().startsWith("on") || (attValue != null && attValue.toLowerCase().startsWith("javascript:"))) { String fName = tag.getName().toLowerCase() + '_' + attName + '_' + funcName; String signatureLine = "function " + fName + "(event) {"; // Defines the function domRegion.println(signatureLine + '\n' + extructJS(attValue) + "\n}", pos, url, true); // Run it writeEntrypoint('\t' + fName + "(null);", pos, url, true); } }
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; }
T positionOfAll = makePosition(childContext.pos().getPosition(stmtNodes[0]).getFirstOffset(), childContext .pos().getPosition(stmtNodes[stmtNodes.length - 1]).getLastOffset()); caseNodes.add(makeNode(childContext, fFactory, positionOfAll, CAstNode.BLOCK_STMT, stmtNodes)); T positionOfAll = makePosition(childContext.pos().getPosition(stmtNodes[0]).getFirstOffset(), childContext.pos() .getPosition(stmtNodes[stmtNodes.length - 1]).getLastOffset()); caseNodes.add(makeNode(childContext, fFactory, positionOfAll, CAstNode.BLOCK_STMT, stmtNodes));
} while (p.getLastOffset()>=0? p.getFirstOffset() > offset: p.getFirstLine() > line); 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);
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 hack.getFirstOffset(); } @Override
@Override public int getFirstOffset() { return hack.getFirstOffset(); } @Override
@Override public int getLastOffset() { return hack.getFirstOffset(); } @Override
@Override public int getFirstOffset() { return hack.getFirstOffset(); } @Override
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; }
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; }
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 getFirstOffset() { return pos.getFirstOffset()==-1? -1: (pos.getFirstOffset()-range.getStart()); }
@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 getFirstOffset() { return pos.getFirstOffset()==-1? -1: (pos.getFirstOffset()-range.getStart()); }
@Override public int compareTo(Object o) { Position other = (Position) o; if (startOffset != other.getFirstOffset()) { return startOffset - other.getFirstOffset(); } else { return endOffset - other.getLastOffset(); } }