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


Java Block.getStartPosition方法代码示例

本文整理汇总了Java中org.eclipse.jdt.core.dom.Block.getStartPosition方法的典型用法代码示例。如果您正苦于以下问题:Java Block.getStartPosition方法的具体用法?Java Block.getStartPosition怎么用?Java Block.getStartPosition使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.eclipse.jdt.core.dom.Block的用法示例。


在下文中一共展示了Block.getStartPosition方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: createMethod

import org.eclipse.jdt.core.dom.Block; //导入方法依赖的package包/类
public RastNode createMethod(String methodSignature, HasChildrenNodes parent, String sourceFilePath, boolean constructor, MethodDeclaration ast) {
	String methodName = ast.isConstructor() ? "" : ast.getName().getIdentifier();
	RastNode rastNode = new RastNode(++nodeCounter);
	rastNode.setType(ast.getClass().getSimpleName());
	
	Block body = ast.getBody();
	int bodyStart;
	int bodyLength;
       if (body == null) {
           rastNode.addStereotypes(Stereotype.ABSTRACT);
           bodyStart = ast.getStartPosition() + ast.getLength();
           bodyLength = 0;
       } else {
       	bodyStart = body.getStartPosition();
           bodyLength = body.getLength();
       }
       rastNode.setLocation(new Location(sourceFilePath, ast.getStartPosition(), ast.getStartPosition() + ast.getLength(), bodyStart, bodyStart + bodyLength));
	rastNode.setLocalName(methodSignature);
	rastNode.setSimpleName(methodName);
	parent.addNode(rastNode);
	keyMap.put(JavaParser.getKey(rastNode), rastNode);
	return rastNode;
}
 
开发者ID:aserg-ufmg,项目名称:RefDiff,代码行数:24,代码来源:SDModel.java

示例2: visit

import org.eclipse.jdt.core.dom.Block; //导入方法依赖的package包/类
@Override
public boolean visit(MethodDeclaration node) {
	Block body = node.getBody();
	if (body == null) {
		return false;
	}
	Selection selection = getSelection();
	int nodeStart = body.getStartPosition();
	int nodeExclusiveEnd = nodeStart + body.getLength();
	// if selection node inside of the method body ignore method
	if (!(nodeStart < selection.getOffset() && selection.getExclusiveEnd() < nodeExclusiveEnd)) {
		return false;
	}
	return super.visit(node);
}
 
开发者ID:eclipse,项目名称:eclipse.jdt.ls,代码行数:16,代码来源:ExtractMethodAnalyzer.java

示例3: visit

import org.eclipse.jdt.core.dom.Block; //导入方法依赖的package包/类
@Override
public boolean visit(MethodDeclaration node) {
  Block body = node.getBody();
  if (body == null) return false;
  Selection selection = getSelection();
  int nodeStart = body.getStartPosition();
  int nodeExclusiveEnd = nodeStart + body.getLength();
  // if selection node inside of the method body ignore method
  if (!(nodeStart < selection.getOffset() && selection.getExclusiveEnd() < nodeExclusiveEnd))
    return false;
  return super.visit(node);
}
 
开发者ID:eclipse,项目名称:che,代码行数:13,代码来源:ExtractMethodAnalyzer.java

示例4: visit

import org.eclipse.jdt.core.dom.Block; //导入方法依赖的package包/类
@Override
public boolean visit(MethodDeclaration node) {
	Block body= node.getBody();
	if (body == null)
		return false;
	Selection selection= getSelection();
	int nodeStart= body.getStartPosition();
	int nodeExclusiveEnd= nodeStart + body.getLength();
	// if selection node inside of the method body ignore method
	if (!(nodeStart < selection.getOffset() && selection.getExclusiveEnd() < nodeExclusiveEnd))
		return false;
	return super.visit(node);
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:14,代码来源:ExtractMethodAnalyzer.java

示例5: handleResourceDeclarations

import org.eclipse.jdt.core.dom.Block; //导入方法依赖的package包/类
private void handleResourceDeclarations(TryStatement tryStatement) {
	List<VariableDeclarationExpression> resources= tryStatement.resources();
	for (Iterator<VariableDeclarationExpression> iterator= resources.iterator(); iterator.hasNext();) {
		iterator.next().accept(this);
	}

	//check if the exception is thrown as a result of resource#close()
	boolean exitMarked= false;
	for (VariableDeclarationExpression variable : resources) {
		Type type= variable.getType();
		IMethodBinding methodBinding= Bindings.findMethodInHierarchy(type.resolveBinding(), "close", new ITypeBinding[0]); //$NON-NLS-1$
		if (methodBinding != null) {
			ITypeBinding[] exceptionTypes= methodBinding.getExceptionTypes();
			for (int j= 0; j < exceptionTypes.length; j++) {
				if (matches(exceptionTypes[j])) { // a close() throws the caught exception
					// mark name of resource
					for (VariableDeclarationFragment fragment : (List<VariableDeclarationFragment>) variable.fragments()) {
						SimpleName name= fragment.getName();
						fResult.add(new OccurrenceLocation(name.getStartPosition(), name.getLength(), 0, fDescription));
					}
					if (!exitMarked) {
						// mark exit position
						exitMarked= true;
						Block body= tryStatement.getBody();
						int offset= body.getStartPosition() + body.getLength() - 1; // closing bracket of try block
						fResult.add(new OccurrenceLocation(offset, 1, 0, Messages.format(SearchMessages.ExceptionOccurrencesFinder_occurrence_implicit_close_description,
								BasicElementLabels.getJavaElementName(fException.getName()))));
					}
				}
			}
		}
	}
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:34,代码来源:ExceptionOccurrencesFinder.java

示例6: handleResourceDeclarations

import org.eclipse.jdt.core.dom.Block; //导入方法依赖的package包/类
private void handleResourceDeclarations(TryStatement tryStatement) {
	if (tryStatement.getAST().apiLevel() >= AST.JLS4) {
		List<VariableDeclarationExpression> resources= tryStatement.resources();
		for (Iterator<VariableDeclarationExpression> iterator= resources.iterator(); iterator.hasNext();) {
			iterator.next().accept(this);
		}

		//check if the exception is thrown as a result of resource#close()
		boolean exitMarked= false;
		for (VariableDeclarationExpression variable : resources) {
			Type type= variable.getType();
			IMethodBinding methodBinding= Bindings.findMethodInHierarchy(type.resolveBinding(), "close", new ITypeBinding[0]); //$NON-NLS-1$
			if (methodBinding != null) {
				ITypeBinding[] exceptionTypes= methodBinding.getExceptionTypes();
				for (int j= 0; j < exceptionTypes.length; j++) {
					if (matches(exceptionTypes[j])) { // a close() throws the caught exception
						// mark name of resource
						for (VariableDeclarationFragment fragment : (List<VariableDeclarationFragment>) variable.fragments()) {
							SimpleName name= fragment.getName();
							fResult.add(new OccurrenceLocation(name.getStartPosition(), name.getLength(), 0, fDescription));
						}
						if (!exitMarked) {
							// mark exit position
							exitMarked= true;
							Block body= tryStatement.getBody();
							int offset= body.getStartPosition() + body.getLength() - 1; // closing bracket of try block
							fResult.add(new OccurrenceLocation(offset, 1, 0, Messages.format(SearchMessages.ExceptionOccurrencesFinder_occurrence_implicit_close_description,
									BasicElementLabels.getJavaElementName(fException.getName()))));
						}
					}
				}
			}
		}
	}
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion-Juno38,代码行数:36,代码来源:ExceptionOccurrencesFinder.java

示例7: visit

import org.eclipse.jdt.core.dom.Block; //导入方法依赖的package包/类
@Override
public boolean visit(Block node) {
	fScopes.add(fScope);
	fScope = new Scope(fScope, node.getStartPosition(), node.getLength());
	return true;
}
 
开发者ID:eclipse,项目名称:eclipse.jdt.ls,代码行数:7,代码来源:CodeScopeBuilder.java

示例8: visit

import org.eclipse.jdt.core.dom.Block; //导入方法依赖的package包/类
@Override
public boolean visit(Block node) {
  fScopes.add(fScope);
  fScope = new Scope(fScope, node.getStartPosition(), node.getLength());
  return true;
}
 
开发者ID:eclipse,项目名称:che,代码行数:7,代码来源:CodeScopeBuilder.java

示例9: visit

import org.eclipse.jdt.core.dom.Block; //导入方法依赖的package包/类
@Override
public boolean visit(Block node) {
	fScopes.add(fScope);
	fScope= new Scope(fScope, node.getStartPosition(), node.getLength());
	return true;
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:7,代码来源:CodeScopeBuilder.java


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