assert startPos.getFirstLine() != -1; assert endPos.getFirstLine() != -1; if(!entity.getPosition().getURL().equals(startPos.getURL())) return true; startNodes = findNodesAtPos(CAstNode.OBJECT_REF, startPos, entity);
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)); currentBlock.clear(); 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));
public void substitute(Position range, String newText) { int startLine = range.getFirstLine() - p.getFirstLine(); int endLine = range.getLastLine() - p.getFirstLine(); lines[startLine].substring(0, range.getFirstCol()) + lines[endLine].substring(range.getLastCol()); while(i < newLines.length) { newLines[i] = lines[i+ (endLine-startLine)]; lines[startLine].substring(0, range.getFirstCol()) + newTextLines[0] + lines[startLine].substring(range.getLastCol()+1); } else { String[] newLines = lines[startLine].substring(0, range.getFirstCol()) + newTextLines[0]; lines[endLine].substring(range.getLastCol()+1);
assert startPos.getFirstLine() != -1; assert endPos.getFirstLine() != -1; if(!entity.getPosition().getURL().equals(startPos.getURL())) return true; startNodes = findNodesAtPos(CAstNode.OBJECT_REF, startPos, entity);
public void substitute(Position range, String newText) { int startLine = range.getFirstLine() - p.getFirstLine(); int endLine = range.getLastLine() - p.getFirstLine(); lines[startLine].substring(0, range.getFirstCol()) + lines[endLine].substring(range.getLastCol()); while(i < newLines.length) { newLines[i] = lines[i+ (endLine-startLine)]; lines[startLine].substring(0, range.getFirstCol()) + newTextLines[0] + lines[startLine].substring(range.getLastCol()+1); } else { String[] newLines = lines[startLine].substring(0, range.getFirstCol()) + newTextLines[0]; lines[endLine].substring(range.getLastCol()+1);
BufferedReader reader = new BufferedReader(p.getReader()); } 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 { lines.add(currentLine.substring(p.getFirstCol())); 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);
BufferedReader reader = new BufferedReader(p.getReader()); } 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 { lines.add(currentLine.substring(p.getFirstCol())); 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);
if (!nodeIter.hasNext()) { if (m instanceof AstMethod) { String fn = ((AstClass)m.getDeclaringClass()).getSourcePosition().getURL().getFile(); if (sourcePaths.contains(fn.substring(fn.lastIndexOf(File.separator)+1))) { System.err.println(("Method " + m.getReference() + " not reachable?"));
Position pos = M.getSourcePosition(i); if (pos != null) { String fileName = pos.getURL().toString(); if (fileName.lastIndexOf('/') >= 0) { fileName = fileName.substring(fileName.lastIndexOf('/')+1); if (pos.getFirstLine() >= (Integer) assertionData[j][2] && (pos.getLastLine() != -1? pos.getLastLine(): pos.getFirstLine()) <= (Integer) assertionData[j][3]) { System.err.println("found " + inst + " of " + M + " at expected position " + pos); continue insts;
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); } }
@Override public void handleEndTag(ITag tag) { super.handleEndTag(tag); endElement(stack.pop()); if (tag.getName().equalsIgnoreCase("FORM")) { forms.pop(); } for(Entry<String,Pair<String, Position>> e : tag.getAllAttributes().entrySet()) { String a = e.getKey(); String v = e.getValue().fst; if (v != null && v.startsWith("javascript:")) { try { writeEntrypoint(" " + v.substring(11), e.getValue().snd, new URL(tag.getElementPosition().getURL().toString() + '#' + a), true); } catch (MalformedURLException ex) { writeEntrypoint(v.substring(11), e.getValue().snd, entrypointUrl, false); } } } }
@Override public void handleEndTag(ITag tag) { super.handleEndTag(tag); endElement(stack.pop()); if (tag.getName().equalsIgnoreCase("FORM")) { forms.pop(); } for(Entry<String,Pair<String, Position>> e : tag.getAllAttributes().entrySet()) { String a = e.getKey(); String v = e.getValue().fst; if (v != null && v.startsWith("javascript:")) { try { writeEntrypoint(" " + v.substring(11), e.getValue().snd, new URL(tag.getElementPosition().getURL().toString() + '#' + a), true); } catch (MalformedURLException ex) { writeEntrypoint(v.substring(11), e.getValue().snd, entrypointUrl, false); } } } }
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 int compareTo(Object o) { if (o instanceof Position) { Position p = (Position)o; if (getFirstLine() != p.getFirstLine()) { return getFirstLine() - p.getFirstLine(); } else if (getFirstCol() != p.getFirstCol()) { return getFirstCol() - p.getFirstCol(); } else if (getLastLine() != p.getLastLine()) { return getLastLine() - p.getLastLine(); } else { return getLastCol() - p.getLastCol(); } } else { return 0; } }
@Override public int compareTo(Object o) { if (o instanceof Position) { Position p = (Position)o; if (getFirstLine() != p.getFirstLine()) { return getFirstLine() - p.getFirstLine(); } else if (getFirstCol() != p.getFirstCol()) { return getFirstCol() - p.getFirstCol(); } else if (getLastLine() != p.getLastLine()) { return getLastLine() - p.getLastLine(); } else { return getLastCol() - p.getLastCol(); } } else { return 0; } }
@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 getFirstCol() { return hack.getFirstCol(); } @Override