当前位置: 首页>>代码示例>>Java>>正文


Java Statement.getLength方法代码示例

本文整理汇总了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();
}
 
开发者ID:eclipse,项目名称:eclipse.jdt.ls,代码行数:13,代码来源:QuickAssistProcessor.java

示例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;
}
 
开发者ID:eclipse,项目名称:eclipse.jdt.ls,代码行数:36,代码来源:FlowAnalyzer.java

示例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;
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:35,代码来源:FlowAnalyzer.java

示例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();
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:13,代码来源:QuickAssistProcessor.java


注:本文中的org.eclipse.jdt.core.dom.Statement.getLength方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。