Java 类org.eclipse.jdt.core.dom.ThrowStatement 实例源码
项目:eclipse.jdt.ls
文件:NecessaryParenthesesChecker.java
private static boolean locationNeedsParentheses(StructuralPropertyDescriptor locationInParent) {
if (locationInParent instanceof ChildListPropertyDescriptor && locationInParent != InfixExpression.EXTENDED_OPERANDS_PROPERTY) {
// e.g. argument lists of MethodInvocation, ClassInstanceCreation, dimensions of ArrayCreation ...
return false;
}
if (locationInParent == VariableDeclarationFragment.INITIALIZER_PROPERTY
|| locationInParent == SingleVariableDeclaration.INITIALIZER_PROPERTY
|| locationInParent == ReturnStatement.EXPRESSION_PROPERTY
|| locationInParent == EnhancedForStatement.EXPRESSION_PROPERTY
|| locationInParent == ForStatement.EXPRESSION_PROPERTY
|| locationInParent == WhileStatement.EXPRESSION_PROPERTY
|| locationInParent == DoStatement.EXPRESSION_PROPERTY
|| locationInParent == AssertStatement.EXPRESSION_PROPERTY
|| locationInParent == AssertStatement.MESSAGE_PROPERTY
|| locationInParent == IfStatement.EXPRESSION_PROPERTY
|| locationInParent == SwitchStatement.EXPRESSION_PROPERTY
|| locationInParent == SwitchCase.EXPRESSION_PROPERTY
|| locationInParent == ArrayAccess.INDEX_PROPERTY
|| locationInParent == ThrowStatement.EXPRESSION_PROPERTY
|| locationInParent == SynchronizedStatement.EXPRESSION_PROPERTY
|| locationInParent == ParenthesizedExpression.EXPRESSION_PROPERTY) {
return false;
}
return true;
}
项目:che
文件:NecessaryParenthesesChecker.java
private static boolean locationNeedsParentheses(StructuralPropertyDescriptor locationInParent) {
if (locationInParent instanceof ChildListPropertyDescriptor
&& locationInParent != InfixExpression.EXTENDED_OPERANDS_PROPERTY) {
// e.g. argument lists of MethodInvocation, ClassInstanceCreation, dimensions of ArrayCreation
// ...
return false;
}
if (locationInParent == VariableDeclarationFragment.INITIALIZER_PROPERTY
|| locationInParent == SingleVariableDeclaration.INITIALIZER_PROPERTY
|| locationInParent == ReturnStatement.EXPRESSION_PROPERTY
|| locationInParent == EnhancedForStatement.EXPRESSION_PROPERTY
|| locationInParent == ForStatement.EXPRESSION_PROPERTY
|| locationInParent == WhileStatement.EXPRESSION_PROPERTY
|| locationInParent == DoStatement.EXPRESSION_PROPERTY
|| locationInParent == AssertStatement.EXPRESSION_PROPERTY
|| locationInParent == AssertStatement.MESSAGE_PROPERTY
|| locationInParent == IfStatement.EXPRESSION_PROPERTY
|| locationInParent == SwitchStatement.EXPRESSION_PROPERTY
|| locationInParent == SwitchCase.EXPRESSION_PROPERTY
|| locationInParent == ArrayAccess.INDEX_PROPERTY
|| locationInParent == ThrowStatement.EXPRESSION_PROPERTY
|| locationInParent == SynchronizedStatement.EXPRESSION_PROPERTY
|| locationInParent == ParenthesizedExpression.EXPRESSION_PROPERTY) {
return false;
}
return true;
}
项目:evosuite
文件:TestExtractingVisitor.java
/** {@inheritDoc} */
@Override
public void endVisit(ClassInstanceCreation instanceCreation) {
if (instanceCreation.getParent() instanceof ThrowStatement) {
logger.warn("Ignoring throw statements!");
return;
}
List<?> paramTypes = Arrays.asList(instanceCreation.resolveConstructorBinding().getParameterTypes());
List<?> paramValues = instanceCreation.arguments();
Constructor<?> constructor = retrieveConstructor(instanceCreation.getType(),
paramTypes, paramValues);
List<VariableReference> params = convertParams(instanceCreation.arguments(),
paramTypes);
VariableReference retVal = retrieveVariableReference(instanceCreation, null);
retVal.setOriginalCode(instanceCreation.toString());
ConstructorStatement statement = new ValidConstructorStatement(
testCase.getReference(), constructor, retVal, params);
testCase.addStatement(statement);
}
项目:Eclipse-Postfix-Code-Completion
文件:NecessaryParenthesesChecker.java
private static boolean locationNeedsParentheses(StructuralPropertyDescriptor locationInParent) {
if (locationInParent instanceof ChildListPropertyDescriptor && locationInParent != InfixExpression.EXTENDED_OPERANDS_PROPERTY) {
// e.g. argument lists of MethodInvocation, ClassInstanceCreation, dimensions of ArrayCreation ...
return false;
}
if (locationInParent == VariableDeclarationFragment.INITIALIZER_PROPERTY
|| locationInParent == SingleVariableDeclaration.INITIALIZER_PROPERTY
|| locationInParent == ReturnStatement.EXPRESSION_PROPERTY
|| locationInParent == EnhancedForStatement.EXPRESSION_PROPERTY
|| locationInParent == ForStatement.EXPRESSION_PROPERTY
|| locationInParent == WhileStatement.EXPRESSION_PROPERTY
|| locationInParent == DoStatement.EXPRESSION_PROPERTY
|| locationInParent == AssertStatement.EXPRESSION_PROPERTY
|| locationInParent == AssertStatement.MESSAGE_PROPERTY
|| locationInParent == IfStatement.EXPRESSION_PROPERTY
|| locationInParent == SwitchStatement.EXPRESSION_PROPERTY
|| locationInParent == SwitchCase.EXPRESSION_PROPERTY
|| locationInParent == ArrayAccess.INDEX_PROPERTY
|| locationInParent == ThrowStatement.EXPRESSION_PROPERTY
|| locationInParent == SynchronizedStatement.EXPRESSION_PROPERTY
|| locationInParent == ParenthesizedExpression.EXPRESSION_PROPERTY) {
return false;
}
return true;
}
项目:Eclipse-Postfix-Code-Completion-Juno38
文件:NecessaryParenthesesChecker.java
private static boolean locationNeedsParentheses(StructuralPropertyDescriptor locationInParent) {
if (locationInParent instanceof ChildListPropertyDescriptor && locationInParent != InfixExpression.EXTENDED_OPERANDS_PROPERTY) {
// e.g. argument lists of MethodInvocation, ClassInstanceCreation, dimensions of ArrayCreation ...
return false;
}
if (locationInParent == VariableDeclarationFragment.INITIALIZER_PROPERTY
|| locationInParent == SingleVariableDeclaration.INITIALIZER_PROPERTY
|| locationInParent == ReturnStatement.EXPRESSION_PROPERTY
|| locationInParent == EnhancedForStatement.EXPRESSION_PROPERTY
|| locationInParent == ForStatement.EXPRESSION_PROPERTY
|| locationInParent == WhileStatement.EXPRESSION_PROPERTY
|| locationInParent == DoStatement.EXPRESSION_PROPERTY
|| locationInParent == AssertStatement.EXPRESSION_PROPERTY
|| locationInParent == AssertStatement.MESSAGE_PROPERTY
|| locationInParent == IfStatement.EXPRESSION_PROPERTY
|| locationInParent == SwitchStatement.EXPRESSION_PROPERTY
|| locationInParent == SwitchCase.EXPRESSION_PROPERTY
|| locationInParent == ArrayAccess.INDEX_PROPERTY
|| locationInParent == ThrowStatement.EXPRESSION_PROPERTY
|| locationInParent == SynchronizedStatement.EXPRESSION_PROPERTY
|| locationInParent == ParenthesizedExpression.EXPRESSION_PROPERTY) {
return false;
}
return true;
}
项目:eclipse.jdt.ls
文件:FlowAnalyzer.java
@Override
public void endVisit(ThrowStatement node) {
if (skipNode(node)) {
return;
}
ThrowFlowInfo info = createThrow();
setFlowInfo(node, info);
Expression expression = node.getExpression();
info.merge(getFlowInfo(expression), fFlowContext);
}
项目:eclipse.jdt.ls
文件:ExceptionAnalyzer.java
@Override
public boolean visit(ThrowStatement node) {
ITypeBinding exception = node.getExpression().resolveTypeBinding();
if (exception == null) {
return true;
}
addException(exception, node.getAST());
return true;
}
项目:eclipse.jdt.ls
文件:ExceptionAnalyzer.java
@Override
public boolean visit(ThrowStatement node) {
ITypeBinding exception = node.getExpression().resolveTypeBinding();
if (!isSelected(node) || exception == null || Bindings.isRuntimeException(exception)) {
return true;
}
addException(exception, node.getAST());
return true;
}
项目:che
文件:ExceptionAnalyzer.java
@Override
public boolean visit(ThrowStatement node) {
ITypeBinding exception = node.getExpression().resolveTypeBinding();
if (exception == null) // Safety net for null bindings when compiling fails.
return true;
addException(exception, node.getAST());
return true;
}
项目:che
文件:FullConstraintCreator.java
@Override
public ITypeConstraint[] create(ThrowStatement node) {
ConstraintVariable nameVariable =
fConstraintVariableFactory.makeExpressionOrTypeVariable(node.getExpression(), getContext());
ITypeBinding throwable =
node.getAST().resolveWellKnownType("java.lang.Throwable"); // $NON-NLS-1$
return fTypeConstraintFactory.createSubtypeConstraint(
nameVariable, fConstraintVariableFactory.makeRawBindingVariable(throwable));
}
项目:che
文件:ExceptionAnalyzer.java
@Override
public boolean visit(ThrowStatement node) {
ITypeBinding exception = node.getExpression().resolveTypeBinding();
if (!isSelected(node)
|| exception == null
|| Bindings.isRuntimeException(
exception)) // Safety net for null bindings when compiling fails.
return true;
addException(exception, node.getAST());
return true;
}
项目:Convert-For-Each-Loop-to-Lambda-Expression-Eclipse-Plugin
文件:EnhancedForStatementVisitor.java
@Override
public boolean visit(ThrowStatement node) {
ITypeBinding thrownExceptionType = node.getExpression().resolveTypeBinding();
try {
handleException(node, thrownExceptionType);
} catch (JavaModelException e) {
throw new RuntimeException(e);
}
return super.visit(node);
}
项目:jdt2famix
文件:AstVisitor.java
@Override
public boolean visit(ThrowStatement node) {
ITypeBinding binding = node.getExpression().resolveTypeBinding();
if (binding != null) {
ThrownException thrownException = new ThrownException();
Type thrownType = importer.ensureTypeFromTypeBinding(binding);
thrownException.setExceptionClass((com.feenk.jdt2famix.model.famix.Class) thrownType);
thrownException.setDefiningMethod((Method) importer.topOfContainerStack());
importer.repository().add(thrownException);
}
return true;
}
项目:Eclipse-Postfix-Code-Completion
文件:FlowAnalyzer.java
@Override
public void endVisit(ThrowStatement node) {
if (skipNode(node))
return;
ThrowFlowInfo info= createThrow();
setFlowInfo(node, info);
Expression expression= node.getExpression();
info.merge(getFlowInfo(expression), fFlowContext);
}
项目:Eclipse-Postfix-Code-Completion
文件:ExceptionAnalyzer.java
@Override
public boolean visit(ThrowStatement node) {
ITypeBinding exception= node.getExpression().resolveTypeBinding();
if (exception == null) // Safety net for null bindings when compiling fails.
return true;
addException(exception, node.getAST());
return true;
}
项目:Eclipse-Postfix-Code-Completion
文件:FullConstraintCreator.java
@Override
public ITypeConstraint[] create(ThrowStatement node) {
ConstraintVariable nameVariable= fConstraintVariableFactory.makeExpressionOrTypeVariable(node.getExpression(), getContext());
ITypeBinding throwable= node.getAST().resolveWellKnownType("java.lang.Throwable"); //$NON-NLS-1$
return fTypeConstraintFactory.createSubtypeConstraint(
nameVariable,
fConstraintVariableFactory.makeRawBindingVariable(throwable));
}
项目:Eclipse-Postfix-Code-Completion
文件:ExceptionAnalyzer.java
@Override
public boolean visit(ThrowStatement node) {
ITypeBinding exception= node.getExpression().resolveTypeBinding();
if (!isSelected(node) || exception == null || Bindings.isRuntimeException(exception)) // Safety net for null bindings when compiling fails.
return true;
addException(exception, node.getAST());
return true;
}
项目:Eclipse-Postfix-Code-Completion
文件:ExceptionOccurrencesFinder.java
@Override
public boolean visit(ThrowStatement node) {
if (matches(node.getExpression().resolveTypeBinding())) {
// mark 'throw'
fResult.add(new OccurrenceLocation(node.getStartPosition(), 5, 0, fDescription));
}
return super.visit(node);
}
项目:Eclipse-Postfix-Code-Completion
文件:MethodExitsFinder.java
@Override
public boolean visit(ThrowStatement node) {
ITypeBinding exception= node.getExpression().resolveTypeBinding();
if (isExitPoint(exception)) {
// mark 'throw'
fResult.add(new OccurrenceLocation(node.getStartPosition(), 5, 0, fExitDescription));
}
return true;
}
项目:parichayana
文件:CatchClauseVisitor.java
public boolean visit(ThrowStatement node){
////////////////////////////THROWS NULL-POINTER-EXCEPTION/////////////////////////////////////////////
if(node.getExpression().toString().contains("NullPointerException")){
//ParichayanaActivator.logInfo("THROW CLAUSE : " + node.getExpression());
ParichayanaActivator.logInfo("_________________________________________________________________________________");
ParichayanaActivator.logInfo("FILE NAME : " + getName(unit) + "\n");
ParichayanaActivator.logInfo("THROW CLAUSE : " + node);
ParichayanaActivator.logInfo(Constants.ANTI_PATTERN_TNPE_MESSAGE);
ParichayanaActivator.logInfo("_________________________________________________________________________________");
try {
createMarker(unit, Constants.ANTI_PATTERN_TNPE_MESSAGE, IMarker.SEVERITY_WARNING, Constants.TNPE_MARKER_ID, node.getStartPosition(), node.getLength());
} catch (CoreException ex) {
ParichayanaActivator.log(ex);
}
//writer.println("_________________________________________________________________________________");
writer.println(linenumber + " FILE NAME : " + getName(unit) + "\n");
linenumber++;
writer.println(linenumber + " THROW CLAUSE : " + node);
linenumber++;
writer.println(linenumber + Constants.ANTI_PATTERN_TNPE_MESSAGE);
linenumber++;
writer.println("_________________________________________________________________________________");
numtnpe++;
}
return true;
///////////////////////////////////////////////////////////////////////////////////////////////////////////
}
项目:Eclipse-Postfix-Code-Completion-Juno38
文件:FlowAnalyzer.java
@Override
public void endVisit(ThrowStatement node) {
if (skipNode(node))
return;
ThrowFlowInfo info= createThrow();
setFlowInfo(node, info);
Expression expression= node.getExpression();
info.merge(getFlowInfo(expression), fFlowContext);
}
项目:Eclipse-Postfix-Code-Completion-Juno38
文件:ExceptionAnalyzer.java
@Override
public boolean visit(ThrowStatement node) {
ITypeBinding exception= node.getExpression().resolveTypeBinding();
if (exception == null) // Safety net for null bindings when compiling fails.
return true;
addException(exception);
return true;
}
项目:Eclipse-Postfix-Code-Completion-Juno38
文件:ExceptionAnalyzer.java
@Override
public boolean visit(ThrowStatement node) {
ITypeBinding exception= node.getExpression().resolveTypeBinding();
if (!isSelected(node) || exception == null || Bindings.isRuntimeException(exception)) // Safety net for null bindings when compiling fails.
return true;
addException(exception);
return true;
}
项目:Eclipse-Postfix-Code-Completion-Juno38
文件:ASTFlattener.java
@Override
public boolean visit(ThrowStatement node) {
this.fBuffer.append("throw ");//$NON-NLS-1$
node.getExpression().accept(this);
this.fBuffer.append(";");//$NON-NLS-1$
return false;
}
项目:Eclipse-Postfix-Code-Completion-Juno38
文件:ExceptionOccurrencesFinder.java
@Override
public boolean visit(ThrowStatement node) {
if (matches(node.getExpression().resolveTypeBinding())) {
// mark 'throw'
fResult.add(new OccurrenceLocation(node.getStartPosition(), 5, 0, fDescription));
}
return super.visit(node);
}
项目:Eclipse-Postfix-Code-Completion-Juno38
文件:MethodExitsFinder.java
@Override
public boolean visit(ThrowStatement node) {
ITypeBinding exception= node.getExpression().resolveTypeBinding();
if (isExitPoint(exception)) {
// mark 'throw'
fResult.add(new OccurrenceLocation(node.getStartPosition(), 5, 0, fExitDescription));
}
return true;
}
项目:Eclipse-Postfix-Code-Completion-Juno38
文件:NaiveASTFlattener.java
public boolean visit(ThrowStatement node) {
printIndent();
this.buffer.append("throw ");//$NON-NLS-1$
node.getExpression().accept(this);
this.buffer.append(";\n");//$NON-NLS-1$
return false;
}
项目:jive
文件:StatementVisitor.java
/**
* An exception throw does not introduce a control or a data dependence. Perhaps there's something
* that can be done here to improve processing at run-time.
*
* 'throw' Expression ';'
*/
@Override
public boolean visit(final ThrowStatement node)
{
// do not visit children
return false;
}
项目:j2d
文件:J2dVisitor.java
@Override
public boolean visit(ThrowStatement node) {
//System.out.println("Found: " + node.getClass());
print("throw ");
node.getExpression().accept(this);
println(";");
return false;
}
项目:eclipse.jdt.ls
文件:AbstractExceptionAnalyzer.java
@Override
public abstract boolean visit(ThrowStatement node);
项目:che
文件:ControlStatementsFix.java
private static boolean satisfiesPrecondition(
Statement controlStatement,
ChildPropertyDescriptor childDescriptor,
boolean onlyReturnAndThrows,
boolean cleanUpCheck) {
Object child = controlStatement.getStructuralProperty(childDescriptor);
if (!(child instanceof Block)) return false;
Block block = (Block) child;
List<Statement> list = block.statements();
if (list.size() != 1) return false;
ASTNode singleStatement = list.get(0);
if (onlyReturnAndThrows)
if (!(singleStatement instanceof ReturnStatement)
&& !(singleStatement instanceof ThrowStatement)) return false;
if (controlStatement instanceof IfStatement) {
// if (true) {
// while (true)
// if (false)
// ;
// } else
// ;
if (((IfStatement) controlStatement).getThenStatement() != child)
return true; // can always remove blocks in else part
IfStatement ifStatement = (IfStatement) controlStatement;
if (ifStatement.getElseStatement() == null)
return true; // can always remove if no else part
return !hasUnblockedIf((Statement) singleStatement, onlyReturnAndThrows, cleanUpCheck);
} else {
// if (true)
// while (true) {
// if (false)
// ;
// }
// else
// ;
if (!hasUnblockedIf((Statement) singleStatement, onlyReturnAndThrows, cleanUpCheck))
return true;
ASTNode currentChild = controlStatement;
ASTNode parent = currentChild.getParent();
while (true) {
Statement body = null;
if (parent instanceof IfStatement) {
body = ((IfStatement) parent).getThenStatement();
if (body == currentChild
&& ((IfStatement) parent).getElseStatement()
!= null) // ->currentChild is an unblocked then part
return false;
} else if (parent instanceof WhileStatement) {
body = ((WhileStatement) parent).getBody();
} else if (parent instanceof DoStatement) {
body = ((DoStatement) parent).getBody();
} else if (parent instanceof ForStatement) {
body = ((ForStatement) parent).getBody();
} else if (parent instanceof EnhancedForStatement) {
body = ((EnhancedForStatement) parent).getBody();
} else {
return true;
}
if (body != currentChild) // ->parents child is a block
return true;
currentChild = parent;
parent = currentChild.getParent();
}
}
}
项目:che
文件:AbstractExceptionAnalyzer.java
@Override
public abstract boolean visit(ThrowStatement node);
项目:evosuite
文件:LoggingVisitor.java
/** {@inheritDoc} */
@Override
public void endVisit(ThrowStatement node) {
logger.warn("Method endVisitThrowStatement for " + node + " for " + node + " not implemented!");
super.endVisit(node);
}
项目:evosuite
文件:LoggingVisitor.java
/** {@inheritDoc} */
@Override
public boolean visit(ThrowStatement node) {
logger.warn("Method visitThrowStatement for " + node + " not implemented!");
return super.visit(node);
}
项目:Beagle
文件:BreakingStatementDetector.java
@Override
public boolean visit(final ThrowStatement node) {
return this.found();
}
项目:Beagle
文件:NotRecursingAstVisitor.java
@Override
public boolean visit(final ThrowStatement node) {
return false;
}
项目:Beagle
文件:InstrumentableAstNodeLister.java
@Override
public boolean visit(final ThrowStatement node) {
return this.visitInstrumentable(node);
}
项目:Eclipse-Postfix-Code-Completion
文件:AstMatchingNodeFinder.java
@Override
public boolean visit(ThrowStatement node) {
if (node.subtreeMatch(fMatcher, fNodeToMatch))
return matches(node);
return super.visit(node);
}
项目:Eclipse-Postfix-Code-Completion
文件:ConstraintCollector.java
@Override
public boolean visit(ThrowStatement node) {
add(fCreator.create(node));
return true;
}
项目:Eclipse-Postfix-Code-Completion
文件:AbstractExceptionAnalyzer.java
@Override
public abstract boolean visit(ThrowStatement node);