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


Java StringLiteral.setLiteralValue方法代码示例

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


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

示例1: createUnobservedInitStmt

import org.eclipse.jdt.core.dom.StringLiteral; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
	@Override
	public void createUnobservedInitStmt(CaptureLog log, int logRecNo) 
	{
		PostProcessor.notifyRecentlyProcessedLogRecNo(logRecNo);
		
		// NOTE: PLAIN INIT: has always one non-null param
		// TODO: use primitives
		final int    oid     = log.objectIds.get(logRecNo);
//		final String type    = log.oidClassNames.get(log.oidRecMapping.get(oid));
		final Object value   = log.params.get(logRecNo)[0];
		this.isXStreamNeeded = true;
		
		final VariableDeclarationFragment vd = ast.newVariableDeclarationFragment();
		// handling because there must always be a new instantiation statement for pseudo inits
		this.oidToVarMapping.remove(oid);
		vd.setName(ast.newSimpleName(this.createNewVarName(oid, log.oidClassNames.get(log.oidRecMapping.get(oid)), true)));
		
		final MethodInvocation methodInvocation = ast.newMethodInvocation();
		final Name name = ast.newSimpleName("XSTREAM");
		methodInvocation.setExpression(name);
		methodInvocation.setName(ast.newSimpleName("fromXML")); 
		
		final StringLiteral xmlParam = ast.newStringLiteral();
		xmlParam.setLiteralValue((String) value);
		methodInvocation.arguments().add(xmlParam);
		
//		final CastExpression castExpr = ast.newCastExpression();
//		castExpr.setType(this.createAstType(type, ast));
//		castExpr.setExpression(methodInvocation);
		
//		vd.setInitializer(castExpr);
		vd.setInitializer(methodInvocation);
		
		final VariableDeclarationStatement vs = ast.newVariableDeclarationStatement(vd);
		vs.setType(this.createAstType("Object", ast));
				
		methodBlock.statements().add(vs);
	}
 
开发者ID:EvoSuite,项目名称:evosuite,代码行数:40,代码来源:JUnitCodeGenerator.java

示例2: createUnobservedInitStmt

import org.eclipse.jdt.core.dom.StringLiteral; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
private void createUnobservedInitStmt(final int logRecNo, final Block methodBlock, final AST ast)
{
	// NOTE: PLAIN INIT: has always one non-null param
	// TODO: use primitives
	final int    oid     = this.log.objectIds.get(logRecNo);
	final String type    = this.log.oidClassNames.get(this.log.oidRecMapping.get(oid));
	final Object value   = this.log.params.get(logRecNo)[0];
	this.isXStreamNeeded = true;
	
	final VariableDeclarationFragment vd = ast.newVariableDeclarationFragment();
	// handling because there must always be a new instantiation statement for pseudo inits
	this.oidToVarMapping.remove(oid);
	vd.setName(ast.newSimpleName(this.createNewVarName(oid, type)));
	
	final MethodInvocation methodInvocation = ast.newMethodInvocation();
	final Name name = ast.newSimpleName("XSTREAM");
	methodInvocation.setExpression(name);
	methodInvocation.setName(ast.newSimpleName("fromXML")); 
	
	final StringLiteral xmlParam = ast.newStringLiteral();
	xmlParam.setLiteralValue((String) value);
	methodInvocation.arguments().add(xmlParam);
	
	final CastExpression castExpr = ast.newCastExpression();
	castExpr.setType(this.createAstType(type, ast));
	castExpr.setExpression(methodInvocation);
	
	vd.setInitializer(castExpr);
	
	final VariableDeclarationStatement vs = ast.newVariableDeclarationStatement(vd);
	vs.setType(this.createAstType(type, ast));
			
	methodBlock.statements().add(vs);
}
 
开发者ID:EvoSuite,项目名称:evosuite,代码行数:36,代码来源:CodeGenerator.java

示例3: getTypeAnnotationParams

import org.eclipse.jdt.core.dom.StringLiteral; //导入方法依赖的package包/类
private SingleMemberAnnotation getTypeAnnotationParams(ASTRewrite rewrite, TypeDeclaration typeDeclaration,
          String annotation) {
   ArrayInitializer initializer = rewrite.getAST().newArrayInitializer();

if (!typeDeclaration.resolveBinding().getQualifiedName().equals(Config.MAINCLASS)) {
	StringLiteral newStringLiteral = rewrite.getAST().newStringLiteral();
	newStringLiteral.setLiteralValue("p");

	ListRewrite listRewrite = rewrite.getListRewrite(initializer, ArrayInitializer.EXPRESSIONS_PROPERTY);
	listRewrite.insertFirst(newStringLiteral, null);
}
SingleMemberAnnotation newParamAnnotation = typeDeclaration.getAST().newSingleMemberAnnotation();
newParamAnnotation.setTypeName(rewrite.getAST().newSimpleName(annotation));
newParamAnnotation.setValue(initializer);
   return newParamAnnotation;
  }
 
开发者ID:aroog,项目名称:code,代码行数:17,代码来源:SaveAnnotations.java

示例4: declareOtherDomains

import org.eclipse.jdt.core.dom.StringLiteral; //导入方法依赖的package包/类
private void declareOtherDomains(ASTRewrite rewrite, ListRewrite listRewrite, TypeDeclaration typeDeclaration) {
	String qualifiedName = typeDeclaration.resolveBinding().getQualifiedName();
	
	OGraphFacade facade = RefinementAnalysis.getFacade();
	RefinementModel refinementModel = facade.getRefinementModel();
	List<IOtherRefinement> otherRefinements = refinementModel.getOtherRefinements();
	for(IOtherRefinement otherRefinement : otherRefinements ) {
		if (otherRefinement instanceof CreateDomain ) {
			CreateDomain createDomain = (CreateDomain)otherRefinement;
			String fullyQualifiedName = createDomain.getSrcIObject().getC().getFullyQualifiedName();
			if (fullyQualifiedName.equals(qualifiedName)) {
				 StringLiteral newStringLiteralPARAM = rewrite.getAST().newStringLiteral();
				 newStringLiteralPARAM.setLiteralValue(createDomain.getDstDomain());
				 listRewrite.insertLast(newStringLiteralPARAM, null);
			}
		}
	}
			
}
 
开发者ID:aroog,项目名称:code,代码行数:20,代码来源:SaveAnnotations.java

示例5: getTypeAnnotationDomainAssumes

import org.eclipse.jdt.core.dom.StringLiteral; //导入方法依赖的package包/类
private SingleMemberAnnotation getTypeAnnotationDomainAssumes(ASTRewrite rewrite, TypeDeclaration typeDeclaration, String annotation, String domainName) {
   ArrayInitializer initializer = rewrite.getAST().newArrayInitializer();

if (domainName != null) {
	ListRewrite listRewrite = rewrite.getListRewrite(initializer, ArrayInitializer.EXPRESSIONS_PROPERTY);
	
	StringLiteral newStringLiteral = rewrite.getAST().newStringLiteral();
	newStringLiteral.setLiteralValue(domainName);
	listRewrite.insertFirst(newStringLiteral, null);
	
	declareOtherDomains(rewrite, listRewrite, typeDeclaration);
}

SingleMemberAnnotation newParamAnnotation = typeDeclaration.getAST().newSingleMemberAnnotation();
newParamAnnotation.setTypeName(rewrite.getAST().newSimpleName(annotation));
newParamAnnotation.setValue(initializer);
   return newParamAnnotation;
  }
 
开发者ID:aroog,项目名称:code,代码行数:19,代码来源:SaveAnnotations.java

示例6: setFieldAnnotation

import org.eclipse.jdt.core.dom.StringLiteral; //导入方法依赖的package包/类
private void setFieldAnnotation(ASTRewrite rewrite, FieldDeclaration fieldDeclaration, String annotation) {
	SingleMemberAnnotation newFieldAnnotation = fieldDeclaration.getAST().newSingleMemberAnnotation();
	newFieldAnnotation.setTypeName(rewrite.getAST().newSimpleName("Domain"));
	StringLiteral newStringLiteral = rewrite.getAST().newStringLiteral();
	newStringLiteral.setLiteralValue(annotation);
	newFieldAnnotation.setValue(newStringLiteral);
	ASTNode modifier = getModifier(fieldDeclaration.modifiers());
	if (modifier != null) {
		ListRewrite paramRewrite = rewrite.getListRewrite(fieldDeclaration, FieldDeclaration.MODIFIERS2_PROPERTY);
		paramRewrite.insertAfter(newFieldAnnotation, modifier, null);
	}
	else {
		ListRewrite fieldRewrite = rewrite.getListRewrite(fieldDeclaration, FieldDeclaration.MODIFIERS2_PROPERTY);
		fieldRewrite.insertFirst(newFieldAnnotation, null);
	}

}
 
开发者ID:aroog,项目名称:code,代码行数:18,代码来源:RemoveAnnotations.java

示例7: createLiceseInLineField

import org.eclipse.jdt.core.dom.StringLiteral; //导入方法依赖的package包/类
private FieldDeclaration createLiceseInLineField(AST ast) {
	VariableDeclarationFragment vdf = ast.newVariableDeclarationFragment();
	vdf.setName(ast.newSimpleName("COPYRIGHT"));
	StringLiteral sl = ast.newStringLiteral();
	sl.setLiteralValue(license_inline);
	vdf.setInitializer(sl);
	FieldDeclaration fd = ast.newFieldDeclaration(vdf);
	fd.modifiers().addAll(ast.newModifiers(Modifier.PUBLIC | Modifier.STATIC | Modifier.FINAL));
	fd.setType(ast.newSimpleType(ast.newSimpleName("String")));
	
	return fd;
}
 
开发者ID:alexgreenbar,项目名称:open_tools,代码行数:13,代码来源:SampleAction.java

示例8: complete

import org.eclipse.jdt.core.dom.StringLiteral; //导入方法依赖的package包/类
@Override
protected void complete() throws CoreException {
	super.complete();
	ReturnStatement rStatement= fAst.newReturnStatement();
	String formatClass;
	if (getContext().is50orHigher())
		formatClass= "java.lang.String"; //$NON-NLS-1$
	else
		formatClass= "java.text.MessageFormat"; //$NON-NLS-1$
	MethodInvocation formatInvocation= createMethodInvocation(addImport(formatClass), "format", null); //$NON-NLS-1$ 
	StringLiteral literal= fAst.newStringLiteral();
	literal.setLiteralValue(buffer.toString());
	formatInvocation.arguments().add(literal);
	if (getContext().is50orHigher()) {
		formatInvocation.arguments().addAll(arguments);
	} else {
		ArrayCreation arrayCreation= fAst.newArrayCreation();
		arrayCreation.setType(fAst.newArrayType(fAst.newSimpleType(addImport("java.lang.Object")))); //$NON-NLS-1$
		ArrayInitializer initializer= fAst.newArrayInitializer();
		arrayCreation.setInitializer(initializer);
		initializer.expressions().addAll(arguments);
		formatInvocation.arguments().add(arrayCreation);
	}
	rStatement.setExpression(formatInvocation);
	toStringMethod.getBody().statements().add(rStatement);
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:27,代码来源:StringFormatGenerator.java

示例9: writeSuppressWarning

import org.eclipse.jdt.core.dom.StringLiteral; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
public void writeSuppressWarning(BodyDeclaration target) {

	AST ast = target.getAST();

	NormalAnnotation annotation = ast.newNormalAnnotation();
	annotation.setTypeName(ast.newSimpleName(SuppressWarnings.class.getSimpleName()));

	MemberValuePair memberValuePair = ast.newMemberValuePair();
	memberValuePair.setName(ast.newSimpleName("value"));
	StringLiteral stringLiteral = ast.newStringLiteral();
	stringLiteral.setLiteralValue("static-access");
	memberValuePair.setValue(stringLiteral);
	annotation.values().add(memberValuePair);
	target.modifiers().add(annotation);

}
 
开发者ID:asupdev,项目名称:asup,代码行数:18,代码来源:JDTUnitWriter.java

示例10: writeEnumField

import org.eclipse.jdt.core.dom.StringLiteral; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
public void writeEnumField(EnumConstantDeclaration enumField, QSpecialElement elem) {
	AST ast = enumField.getAST();
	NormalAnnotation normalAnnotation = ast.newNormalAnnotation();

	String name = new String("*" + enumField.getName());
	if (elem.getValue() != null && !name.equals(elem.getValue())) {
		normalAnnotation.setTypeName(ast.newSimpleName(Special.class.getSimpleName()));
		MemberValuePair memberValuePair = ast.newMemberValuePair();
		memberValuePair.setName(ast.newSimpleName("value"));
		StringLiteral stringLiteral = ast.newStringLiteral();
		stringLiteral.setLiteralValue(elem.getValue());
		memberValuePair.setValue(stringLiteral);
		normalAnnotation.values().add(memberValuePair);

		enumField.modifiers().add(normalAnnotation);
	}
}
 
开发者ID:asupdev,项目名称:asup,代码行数:19,代码来源:JDTNamedNodeWriter.java

示例11: visit

import org.eclipse.jdt.core.dom.StringLiteral; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
@Override
public boolean visit(QCommandExec statement) {

	Block block = blocks.peek();

	MethodInvocation methodInvocation = ast.newMethodInvocation();
	methodInvocation.setExpression(ast.newSimpleName("qCMD"));
	methodInvocation.setName(ast.newSimpleName("qExecute"));

	methodInvocation.arguments().add(ast.newThisExpression());

	StringLiteral stringLiteral = ast.newStringLiteral();
	stringLiteral.setLiteralValue(statement.getStatement());
	methodInvocation.arguments().add(stringLiteral);

	ExpressionStatement expressionStatement = ast.newExpressionStatement(methodInvocation);
	block.statements().add(expressionStatement);

	return super.visit(statement);
}
 
开发者ID:asupdev,项目名称:asup,代码行数:22,代码来源:JDTStatementWriter.java

示例12: setGeneratedAnnotationPart

import org.eclipse.jdt.core.dom.StringLiteral; //导入方法依赖的package包/类
private static boolean setGeneratedAnnotationPart(CompilationUnit cu, NormalAnnotation annotation, String newPartValue, int rankInComment) {
	StringLiteral oldCommentLiteral = getGeneratedAnnotationComment(annotation);
	if (oldCommentLiteral != null) {
		String[] oldCommentParts = oldCommentLiteral.getLiteralValue().split(COMMENT_SEPARATOR);
		StringBuilder newCommentSB = new StringBuilder(25).append("");
		for(int i = 0; i<oldCommentParts.length; i++) {
			if(i == rankInComment) {
				newCommentSB.append(newPartValue);
			}
			else {
				newCommentSB.append(oldCommentParts[i]);
			}
			if(i<(oldCommentParts.length-1)) {
				newCommentSB.append(COMMENT_SEPARATOR);
			}
		}
		oldCommentLiteral.setLiteralValue(newCommentSB.toString());
		
		return true;
	}
	return false;
}
 
开发者ID:awltech,项目名称:eclipse-optimus,代码行数:23,代码来源:GeneratedAnnotationHelper.java

示例13: createGetClassMethodInvocation

import org.eclipse.jdt.core.dom.StringLiteral; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
private MethodInvocation createGetClassMethodInvocation(MethodInvocation invNode, ITypeBinding[] paramTyps, AST ast) {
	MethodInvocation result = ast.newMethodInvocation();
	result.setName(ast.newSimpleName("getMethod")); //$NON-NLS-1$
	StringLiteral methName = ast.newStringLiteral();
	methName.setLiteralValue(invNode.getName().getFullyQualifiedName());
	result.arguments().add(methName);
	if (paramTyps != null && paramTyps.length > 0) {
		for (ITypeBinding paramTyp : paramTyps) {
			TypeLiteral curTyp = ast.newTypeLiteral();
			curTyp.setType(createType(paramTyp, ast));
			result.arguments().add(curTyp);
		}
	}
	return result;
}
 
开发者ID:jwloka,项目名称:reflectify,代码行数:17,代码来源:MethodInvocationProposalCreator.java

示例14: createGeneratedAnnotation

import org.eclipse.jdt.core.dom.StringLiteral; //导入方法依赖的package包/类
private SingleMemberAnnotation createGeneratedAnnotation(AST ast) {
    SingleMemberAnnotation generatedAnnotation = ast.newSingleMemberAnnotation();
    generatedAnnotation.setTypeName(ast.newSimpleName("Generated"));
    StringLiteral annotationValue = ast.newStringLiteral();
    annotationValue.setLiteralValue(StaticPreferences.PLUGIN_GENERATED_ANNOTATION_NAME);
    generatedAnnotation.setValue(annotationValue);
    return generatedAnnotation;
}
 
开发者ID:helospark,项目名称:SparkBuilderGenerator,代码行数:9,代码来源:GeneratedAnnotationPopulator.java

示例15: setParameterAnnotation

import org.eclipse.jdt.core.dom.StringLiteral; //导入方法依赖的package包/类
private void setParameterAnnotation(ASTRewrite rewrite, SingleVariableDeclaration param, String annotation) {
	SingleMemberAnnotation newParamAnnotation = param.getAST().newSingleMemberAnnotation();
	newParamAnnotation.setTypeName(rewrite.getAST().newSimpleName("Domain"));
	StringLiteral newStringLiteral = rewrite.getAST().newStringLiteral();
	newStringLiteral.setLiteralValue(annotation);
	newParamAnnotation.setValue(newStringLiteral);
	ListRewrite paramRewrite = rewrite.getListRewrite(param, SingleVariableDeclaration.MODIFIERS2_PROPERTY);
	paramRewrite.insertFirst(newParamAnnotation, null);
}
 
开发者ID:aroog,项目名称:code,代码行数:10,代码来源:RemoveAnnotations.java


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