本文整理汇总了Java中org.eclipse.jdt.core.dom.Block.getLength方法的典型用法代码示例。如果您正苦于以下问题:Java Block.getLength方法的具体用法?Java Block.getLength怎么用?Java Block.getLength使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.jdt.core.dom.Block
的用法示例。
在下文中一共展示了Block.getLength方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
}
示例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);
}
示例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);
}
示例4: visit
import org.eclipse.jdt.core.dom.Block; //导入方法依赖的package包/类
public boolean visit(Initializer node) {
int lineNum = cu.getLineNumber(node.getStartPosition());
Block body = node.getBody();
int bodyLen = body.getLength();
int bodyStartLn = cu.getLineNumber(body.getStartPosition());
int bodyEndLn = cu.getLineNumber(body.getStartPosition() + bodyLen);
ASTNode parent = node.getParent();
ITypeBinding containerType = null;
if(parent instanceof AbstractTypeDeclaration) {
AbstractTypeDeclaration td = (AbstractTypeDeclaration) parent;
containerType = td.resolveBinding();
} else if(parent instanceof AnonymousClassDeclaration) {
containerType = ((AnonymousClassDeclaration) parent).resolveBinding();
} else {
throw new RuntimeException(parent.getClass().toString());
}
String className = chordClassName(containerType.getErasure());
String chordSig = "<clinit>:()[email protected]"+className;
XMLContainerObject object = new XMLContainerObject("method");
object.putAttribute("chordsig", escapeXml(chordSig));
object.putAttribute("line", Integer.toString(lineNum));
object.putAttribute("bodyStartLn", Integer.toString(bodyStartLn));
object.putAttribute("bodyEndLn", Integer.toString(bodyEndLn));
this.startObject(object);
return true;
}
示例5: 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);
}
示例6: 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()))));
}
}
}
}
}
}
示例7: 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
示例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;
}
示例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;
}
示例10: 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;
}