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


Java NullLiteral类代码示例

本文整理汇总了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());
    }
}
 
开发者ID:junit-tools-team,项目名称:junit-tools,代码行数:28,代码来源:TestCasesGenerator.java

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

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

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

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

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

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

示例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();
}
 
开发者ID:EvoSuite,项目名称:evosuite,代码行数:11,代码来源:TestExtractingVisitor.java

示例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();
}
 
开发者ID:opaluchlukasz,项目名称:junit2spock,代码行数:4,代码来源:ASTNodeFactory.java

示例11: endVisit

import org.eclipse.jdt.core.dom.NullLiteral; //导入依赖的package包/类
@Override
public void endVisit(NullLiteral node) {
	// Leaf node.
}
 
开发者ID:eclipse,项目名称:eclipse.jdt.ls,代码行数:5,代码来源:FlowAnalyzer.java

示例12: setNullLiteral

import org.eclipse.jdt.core.dom.NullLiteral; //导入依赖的package包/类
public void setNullLiteral(NullLiteral nullLiteral) {
    this.expressionOrder.put(nullLiteral, filledCount++);
    this.nullLiterals.add(nullLiteral);
}
 
开发者ID:junit-tools-team,项目名称:junit-tools,代码行数:5,代码来源:TestCasesGenerator.java

示例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);
}
 
开发者ID:EvoSuite,项目名称:evosuite,代码行数:7,代码来源:LoggingVisitor.java

示例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);
}
 
开发者ID:EvoSuite,项目名称:evosuite,代码行数:7,代码来源:LoggingVisitor.java

示例15: visit

import org.eclipse.jdt.core.dom.NullLiteral; //导入依赖的package包/类
@Override
public boolean visit(final NullLiteral node) {
	return false;
}
 
开发者ID:Beagle-PSE,项目名称:Beagle,代码行数:5,代码来源:NotRecursingAstVisitor.java


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