本文整理汇总了Java中org.eclipse.jdt.core.dom.NullLiteral类的典型用法代码示例。如果您正苦于以下问题:Java NullLiteral类的具体用法?Java NullLiteral怎么用?Java NullLiteral使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
NullLiteral类属于org.eclipse.jdt.core.dom包,在下文中一共展示了NullLiteral类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: analyze
import org.eclipse.jdt.core.dom.NullLiteral; //导入依赖的package包/类
/**
* @param expression
*/
public void analyze(Expression expression) {
// param == null, null == param
if (expression.getNodeType() == ASTNode.NULL_LITERAL) {
setNullLiteral((NullLiteral) expression);
} else if (expression.getNodeType() == ASTNode.SIMPLE_NAME) {
setSimpleName((SimpleName) expression);
} else if (expression.getNodeType() == ASTNode.NUMBER_LITERAL) {
setNumberLiteral((NumberLiteral) expression);
} else if (expression.getNodeType() == ASTNode.PREFIX_EXPRESSION) {
setPrefixExpression((PrefixExpression) expression);
} else if (expression.getNodeType() == ASTNode.POSTFIX_EXPRESSION) {
setPostfixExpression((PostfixExpression) expression);
} else if (expression.getNodeType() == ASTNode.PARENTHESIZED_EXPRESSION
|| expression.getNodeType() == ASTNode.INFIX_EXPRESSION
|| expression.getNodeType() == ASTNode.METHOD_INVOCATION) {
// addTestCasesToMerge(processIfExpressions(expression,
// tmlMethod));
} else {
// TODO
System.out.println("Expression could not be analyzed: "
+ expression.getNodeType() + ". Expression: "
+ expression.toString());
}
}
示例2: getAssignedValue
import org.eclipse.jdt.core.dom.NullLiteral; //导入依赖的package包/类
private Expression getAssignedValue(ParameterObjectFactory pof, String parameterName, IJavaProject javaProject, RefactoringStatus status, ASTRewrite rewrite, ParameterInfo pi, boolean useSuper, ITypeBinding typeBinding, Expression qualifier, ASTNode replaceNode, ITypeRoot typeRoot) {
AST ast= rewrite.getAST();
boolean is50OrHigher= JavaModelUtil.is50OrHigher(javaProject);
Expression assignedValue= handleSimpleNameAssignment(replaceNode, pof, parameterName, ast, javaProject, useSuper);
if (assignedValue == null) {
NullLiteral marker= qualifier == null ? null : ast.newNullLiteral();
Expression fieldReadAccess= pof.createFieldReadAccess(pi, parameterName, ast, javaProject, useSuper, marker);
assignedValue= GetterSetterUtil.getAssignedValue(replaceNode, rewrite, fieldReadAccess, typeBinding, is50OrHigher);
boolean markerReplaced= replaceMarker(rewrite, qualifier, assignedValue, marker);
if (markerReplaced) {
switch (qualifier.getNodeType()) {
case ASTNode.METHOD_INVOCATION:
case ASTNode.CLASS_INSTANCE_CREATION:
case ASTNode.SUPER_METHOD_INVOCATION:
case ASTNode.PARENTHESIZED_EXPRESSION:
status.addWarning(RefactoringCoreMessages.ExtractClassRefactoring_warning_semantic_change, JavaStatusContext.create(typeRoot, replaceNode));
break;
}
}
}
return assignedValue;
}
示例3: replaceMarker
import org.eclipse.jdt.core.dom.NullLiteral; //导入依赖的package包/类
private boolean replaceMarker(final ASTRewrite rewrite, final Expression qualifier, Expression assignedValue, final NullLiteral marker) {
class MarkerReplacer extends ASTVisitor {
private boolean fReplaced= false;
@Override
public boolean visit(NullLiteral node) {
if (node == marker) {
rewrite.replace(node, rewrite.createCopyTarget(qualifier), null);
fReplaced= true;
return false;
}
return true;
}
}
if (assignedValue != null && qualifier != null) {
MarkerReplacer visitor= new MarkerReplacer();
assignedValue.accept(visitor);
return visitor.fReplaced;
}
return false;
}
示例4: checkExpression
import org.eclipse.jdt.core.dom.NullLiteral; //导入依赖的package包/类
private RefactoringStatus checkExpression() throws JavaModelException {
Expression selectedExpression= getSelectedExpression().getAssociatedExpression();
if (selectedExpression != null) {
final ASTNode parent= selectedExpression.getParent();
if (selectedExpression instanceof NullLiteral) {
return RefactoringStatus.createFatalErrorStatus(RefactoringCoreMessages.ExtractTempRefactoring_null_literals);
} else if (selectedExpression instanceof ArrayInitializer) {
return RefactoringStatus.createFatalErrorStatus(RefactoringCoreMessages.ExtractTempRefactoring_array_initializer);
} else if (selectedExpression instanceof Assignment) {
if (parent instanceof Expression && !(parent instanceof ParenthesizedExpression))
return RefactoringStatus.createFatalErrorStatus(RefactoringCoreMessages.ExtractTempRefactoring_assignment);
else
return null;
} else if (selectedExpression instanceof SimpleName) {
if ((((SimpleName) selectedExpression)).isDeclaration())
return RefactoringStatus.createFatalErrorStatus(RefactoringCoreMessages.ExtractTempRefactoring_names_in_declarations);
if (parent instanceof QualifiedName && selectedExpression.getLocationInParent() == QualifiedName.NAME_PROPERTY || parent instanceof FieldAccess && selectedExpression.getLocationInParent() == FieldAccess.NAME_PROPERTY)
return RefactoringStatus.createFatalErrorStatus(RefactoringCoreMessages.ExtractTempRefactoring_select_expression);
} else if (selectedExpression instanceof VariableDeclarationExpression && parent instanceof TryStatement) {
return RefactoringStatus.createFatalErrorStatus(RefactoringCoreMessages.ExtractTempRefactoring_resource_in_try_with_resources);
}
}
return null;
}
示例5: checkExpression
import org.eclipse.jdt.core.dom.NullLiteral; //导入依赖的package包/类
private RefactoringStatus checkExpression() throws JavaModelException {
RefactoringStatus result= new RefactoringStatus();
result.merge(checkExpressionBinding());
if(result.hasFatalError())
return result;
checkAllStaticFinal();
IExpressionFragment selectedExpression= getSelectedExpression();
Expression associatedExpression= selectedExpression.getAssociatedExpression();
if (associatedExpression instanceof NullLiteral)
result.merge(RefactoringStatus.createFatalErrorStatus(RefactoringCoreMessages.ExtractConstantRefactoring_null_literals));
else if (!ConstantChecks.isLoadTimeConstant(selectedExpression))
result.merge(RefactoringStatus.createFatalErrorStatus(RefactoringCoreMessages.ExtractConstantRefactoring_not_load_time_constant));
else if (associatedExpression instanceof SimpleName) {
if (associatedExpression.getParent() instanceof QualifiedName && associatedExpression.getLocationInParent() == QualifiedName.NAME_PROPERTY
|| associatedExpression.getParent() instanceof FieldAccess && associatedExpression.getLocationInParent() == FieldAccess.NAME_PROPERTY)
return RefactoringStatus.createFatalErrorStatus(RefactoringCoreMessages.ExtractConstantRefactoring_select_expression);
}
return result;
}
示例6: checkExpression
import org.eclipse.jdt.core.dom.NullLiteral; //导入依赖的package包/类
private RefactoringStatus checkExpression() throws JavaModelException {
Expression selectedExpression = getSelectedExpression().getAssociatedExpression();
if (selectedExpression != null) {
final ASTNode parent = selectedExpression.getParent();
if (selectedExpression instanceof NullLiteral) {
return RefactoringStatus.createFatalErrorStatus(
RefactoringCoreMessages.ExtractTempRefactoring_null_literals);
} else if (selectedExpression instanceof ArrayInitializer) {
return RefactoringStatus.createFatalErrorStatus(
RefactoringCoreMessages.ExtractTempRefactoring_array_initializer);
} else if (selectedExpression instanceof Assignment) {
if (parent instanceof Expression && !(parent instanceof ParenthesizedExpression))
return RefactoringStatus.createFatalErrorStatus(
RefactoringCoreMessages.ExtractTempRefactoring_assignment);
else return null;
} else if (selectedExpression instanceof SimpleName) {
if ((((SimpleName) selectedExpression)).isDeclaration())
return RefactoringStatus.createFatalErrorStatus(
RefactoringCoreMessages.ExtractTempRefactoring_names_in_declarations);
if (parent instanceof QualifiedName
&& selectedExpression.getLocationInParent() == QualifiedName.NAME_PROPERTY
|| parent instanceof FieldAccess
&& selectedExpression.getLocationInParent() == FieldAccess.NAME_PROPERTY)
return RefactoringStatus.createFatalErrorStatus(
RefactoringCoreMessages.ExtractTempRefactoring_select_expression);
} else if (selectedExpression instanceof VariableDeclarationExpression
&& parent instanceof TryStatement) {
return RefactoringStatus.createFatalErrorStatus(
RefactoringCoreMessages.ExtractTempRefactoring_resource_in_try_with_resources);
}
}
return null;
}
示例7: checkExpression
import org.eclipse.jdt.core.dom.NullLiteral; //导入依赖的package包/类
private RefactoringStatus checkExpression() throws JavaModelException {
RefactoringStatus result = new RefactoringStatus();
result.merge(checkExpressionBinding());
if (result.hasFatalError()) return result;
checkAllStaticFinal();
IExpressionFragment selectedExpression = getSelectedExpression();
Expression associatedExpression = selectedExpression.getAssociatedExpression();
if (associatedExpression instanceof NullLiteral)
result.merge(
RefactoringStatus.createFatalErrorStatus(
RefactoringCoreMessages.ExtractConstantRefactoring_null_literals));
else if (!ConstantChecks.isLoadTimeConstant(selectedExpression))
result.merge(
RefactoringStatus.createFatalErrorStatus(
RefactoringCoreMessages.ExtractConstantRefactoring_not_load_time_constant));
else if (associatedExpression instanceof SimpleName) {
if (associatedExpression.getParent() instanceof QualifiedName
&& associatedExpression.getLocationInParent() == QualifiedName.NAME_PROPERTY
|| associatedExpression.getParent() instanceof FieldAccess
&& associatedExpression.getLocationInParent() == FieldAccess.NAME_PROPERTY)
return RefactoringStatus.createFatalErrorStatus(
RefactoringCoreMessages.ExtractConstantRefactoring_select_expression);
}
return result;
}
示例8: retrieveVariableReference
import org.eclipse.jdt.core.dom.NullLiteral; //导入依赖的package包/类
private VariableReference retrieveVariableReference(NullLiteral nullLiteral,
Class<?> varType) {
if (varType == null) {
varType = retrieveTypeClass(nullLiteral.getParent());
}
PrimitiveStatement<?> nullAssignment = new NullStatement(testCase.getReference(),
varType);
testCase.addStatement(nullAssignment);
return nullAssignment.getReturnValue();
}
示例9: checkExpression
import org.eclipse.jdt.core.dom.NullLiteral; //导入依赖的package包/类
private RefactoringStatus checkExpression() {
//TODO: adjust error messages (or generalize for all refactorings on expression-selections?)
Expression selectedExpression= fSelectedExpression;
if (selectedExpression instanceof Name && selectedExpression.getParent() instanceof ClassInstanceCreation)
return RefactoringStatus.createFatalErrorStatus(RefactoringCoreMessages.ExtractTempRefactoring_name_in_new);
//TODO: let's just take the CIC automatically (no ambiguity -> no problem -> no dialog ;-)
if (selectedExpression instanceof NullLiteral) {
return RefactoringStatus.createFatalErrorStatus(RefactoringCoreMessages.ExtractTempRefactoring_null_literals);
} else if (selectedExpression instanceof ArrayInitializer) {
return RefactoringStatus.createFatalErrorStatus(RefactoringCoreMessages.ExtractTempRefactoring_array_initializer);
} else if (selectedExpression instanceof Assignment) {
if (selectedExpression.getParent() instanceof Expression)
return RefactoringStatus.createFatalErrorStatus(RefactoringCoreMessages.ExtractTempRefactoring_assignment);
else
return null;
} else if (selectedExpression instanceof SimpleName){
if ((((SimpleName)selectedExpression)).isDeclaration())
return RefactoringStatus.createFatalErrorStatus(RefactoringCoreMessages.ExtractTempRefactoring_names_in_declarations);
if (selectedExpression.getParent() instanceof QualifiedName && selectedExpression.getLocationInParent() == QualifiedName.NAME_PROPERTY
|| selectedExpression.getParent() instanceof FieldAccess && selectedExpression.getLocationInParent() == FieldAccess.NAME_PROPERTY)
return RefactoringStatus.createFatalErrorStatus(RefactoringCoreMessages.ExtractTempRefactoring_select_expression);
}
return null;
}
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:29,代码来源:IntroduceParameterRefactoring.java
示例10: nullLiteral
import org.eclipse.jdt.core.dom.NullLiteral; //导入依赖的package包/类
public NullLiteral nullLiteral() {
return ast.get().newNullLiteral();
}
示例11: endVisit
import org.eclipse.jdt.core.dom.NullLiteral; //导入依赖的package包/类
@Override
public void endVisit(NullLiteral node) {
// Leaf node.
}
示例12: setNullLiteral
import org.eclipse.jdt.core.dom.NullLiteral; //导入依赖的package包/类
public void setNullLiteral(NullLiteral nullLiteral) {
this.expressionOrder.put(nullLiteral, filledCount++);
this.nullLiterals.add(nullLiteral);
}
示例13: endVisit
import org.eclipse.jdt.core.dom.NullLiteral; //导入依赖的package包/类
/** {@inheritDoc} */
@Override
public void endVisit(NullLiteral node) {
logger.warn("Method endVisitNullLiteral for " + node + " for " + node + " not implemented!");
super.endVisit(node);
}
示例14: visit
import org.eclipse.jdt.core.dom.NullLiteral; //导入依赖的package包/类
/** {@inheritDoc} */
@Override
public boolean visit(NullLiteral node) {
logger.warn("Method visitNullLiteral for " + node + " not implemented!");
return super.visit(node);
}
示例15: visit
import org.eclipse.jdt.core.dom.NullLiteral; //导入依赖的package包/类
@Override
public boolean visit(final NullLiteral node) {
return false;
}