本文整理汇总了Java中org.eclipse.jdt.core.dom.Statement.getLength方法的典型用法代码示例。如果您正苦于以下问题:Java Statement.getLength方法的具体用法?Java Statement.getLength怎么用?Java Statement.getLength使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.jdt.core.dom.Statement
的用法示例。
在下文中一共展示了Statement.getLength方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getIndex
import org.eclipse.jdt.core.dom.Statement; //导入方法依赖的package包/类
private static int getIndex(int offset, List<Statement> statements) {
for (int i = 0; i < statements.size(); i++) {
Statement s = statements.get(i);
if (offset <= s.getStartPosition()) {
return i;
}
if (offset < s.getStartPosition() + s.getLength()) {
return -1;
}
}
return statements.size();
}
示例2: createSwitchData
import org.eclipse.jdt.core.dom.Statement; //导入方法依赖的package包/类
protected SwitchData createSwitchData(SwitchStatement node) {
SwitchData result = new SwitchData();
List<Statement> statements = node.statements();
if (statements.isEmpty()) {
return result;
}
int start = -1, end = -1;
GenericSequentialFlowInfo info = null;
for (Iterator<Statement> iter = statements.iterator(); iter.hasNext();) {
Statement statement = iter.next();
if (statement instanceof SwitchCase) {
SwitchCase switchCase = (SwitchCase) statement;
if (switchCase.isDefault()) {
result.setHasDefaultCase();
}
if (info == null) {
info = createSequential();
start = statement.getStartPosition();
} else {
if (info.isReturn() || info.isPartialReturn() || info.branches()) {
result.add(new Region(start, end - start + 1), info);
info = createSequential();
start = statement.getStartPosition();
}
}
} else {
info.merge(getFlowInfo(statement), fFlowContext);
}
end = statement.getStartPosition() + statement.getLength() - 1;
}
result.add(new Region(start, end - start + 1), info);
return result;
}
示例3: createSwitchData
import org.eclipse.jdt.core.dom.Statement; //导入方法依赖的package包/类
protected SwitchData createSwitchData(SwitchStatement node) {
SwitchData result= new SwitchData();
List<Statement> statements= node.statements();
if (statements.isEmpty())
return result;
int start= -1, end= -1;
GenericSequentialFlowInfo info= null;
for (Iterator<Statement> iter= statements.iterator(); iter.hasNext(); ) {
Statement statement= iter.next();
if (statement instanceof SwitchCase) {
SwitchCase switchCase= (SwitchCase)statement;
if (switchCase.isDefault()) {
result.setHasDefaultCase();
}
if (info == null) {
info= createSequential();
start= statement.getStartPosition();
} else {
if (info.isReturn() || info.isPartialReturn() || info.branches()) {
result.add(new Region(start, end - start + 1), info);
info= createSequential();
start= statement.getStartPosition();
}
}
} else {
info.merge(getFlowInfo(statement), fFlowContext);
}
end= statement.getStartPosition() + statement.getLength() - 1;
}
result.add(new Region(start, end - start + 1), info);
return result;
}
示例4: getIndex
import org.eclipse.jdt.core.dom.Statement; //导入方法依赖的package包/类
private static int getIndex(int offset, List<Statement> statements) {
for (int i= 0; i < statements.size(); i++) {
Statement s= statements.get(i);
if (offset <= s.getStartPosition()) {
return i;
}
if (offset < s.getStartPosition() + s.getLength()) {
return -1;
}
}
return statements.size();
}