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


Java NormalAnnotation.setTypeName方法代码示例

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


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

示例1: getRewrite

import org.eclipse.jdt.core.dom.NormalAnnotation; //导入方法依赖的package包/类
@Override
protected ASTRewrite getRewrite() throws CoreException {
  AST ast = fAnnotation.getAST();

  ASTRewrite rewrite = ASTRewrite.create(ast);
  createImportRewrite((CompilationUnit) fAnnotation.getRoot());

  ListRewrite listRewrite;
  if (fAnnotation instanceof NormalAnnotation) {
    listRewrite = rewrite.getListRewrite(fAnnotation, NormalAnnotation.VALUES_PROPERTY);
  } else {
    NormalAnnotation newAnnotation = ast.newNormalAnnotation();
    newAnnotation.setTypeName((Name) rewrite.createMoveTarget(fAnnotation.getTypeName()));
    rewrite.replace(fAnnotation, newAnnotation, null);

    listRewrite = rewrite.getListRewrite(newAnnotation, NormalAnnotation.VALUES_PROPERTY);
  }
  addMissingAtributes(fAnnotation.resolveTypeBinding(), listRewrite);

  return rewrite;
}
 
开发者ID:eclipse,项目名称:che,代码行数:22,代码来源:MissingAnnotationAttributesProposal.java

示例2: getRewrite

import org.eclipse.jdt.core.dom.NormalAnnotation; //导入方法依赖的package包/类
@Override
protected ASTRewrite getRewrite() throws CoreException {
	AST ast= fAnnotation.getAST();

	ASTRewrite rewrite= ASTRewrite.create(ast);
	createImportRewrite((CompilationUnit) fAnnotation.getRoot());

	ListRewrite listRewrite;
	if (fAnnotation instanceof NormalAnnotation) {
		listRewrite= rewrite.getListRewrite(fAnnotation, NormalAnnotation.VALUES_PROPERTY);
	} else {
		NormalAnnotation newAnnotation= ast.newNormalAnnotation();
		newAnnotation.setTypeName((Name) rewrite.createMoveTarget(fAnnotation.getTypeName()));
		rewrite.replace(fAnnotation, newAnnotation, null);

		listRewrite= rewrite.getListRewrite(newAnnotation, NormalAnnotation.VALUES_PROPERTY);
	}
	addMissingAtributes(fAnnotation.resolveTypeBinding(), listRewrite);

	return rewrite;
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:22,代码来源:MissingAnnotationAttributesProposal.java

示例3: writeSuppressWarning

import org.eclipse.jdt.core.dom.NormalAnnotation; //导入方法依赖的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

示例4: writeEnumField

import org.eclipse.jdt.core.dom.NormalAnnotation; //导入方法依赖的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

示例5: writeProgramAnnotation

import org.eclipse.jdt.core.dom.NormalAnnotation; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
public void writeProgramAnnotation(QProgram program) {
	QConversion conversion = program.getFacet(QConversion.class);
	if (conversion != null) {
		MarkerAnnotation conversionAnnotation = getAST().newMarkerAnnotation();

		switch (conversion.getStatus()) {
		case POSSIBLE:
			break;
		case SUPPORTED:
			writeImport(Supported.class);
			conversionAnnotation.setTypeName(getAST().newSimpleName(Supported.class.getSimpleName()));
			getTarget().modifiers().add(conversionAnnotation);
			break;
		case TODO:
			writeImport(ToDo.class);
			conversionAnnotation.setTypeName(getAST().newSimpleName(ToDo.class.getSimpleName()));
			getTarget().modifiers().add(conversionAnnotation);
			break;
		case UNSUPPORTED:
			writeImport(Unsupported.class);
			conversionAnnotation.setTypeName(getAST().newSimpleName(Unsupported.class.getSimpleName()));
			getTarget().modifiers().add(conversionAnnotation);
			break;
		}
	}

	// @Program(name=)
	NormalAnnotation programAnnotation = getAST().newNormalAnnotation();
	programAnnotation.setTypeName(getAST().newSimpleName(Program.class.getSimpleName()));
	MemberValuePair memberValuePair = getAST().newMemberValuePair();
	memberValuePair.setName(getAST().newSimpleName("name"));
	StringLiteral stringLiteral = getAST().newStringLiteral();
	stringLiteral.setLiteralValue(program.getName());
	memberValuePair.setValue(stringLiteral);
	programAnnotation.values().add(memberValuePair);

	getTarget().modifiers().add(0, programAnnotation);
}
 
开发者ID:asupdev,项目名称:asup,代码行数:40,代码来源:JDTProgramWriter.java

示例6: before

import org.eclipse.jdt.core.dom.NormalAnnotation; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
@Override
public void before(CaptureLog log) {
	ast = AST.newAST(AST.JLS3);
	cu = ast.newCompilationUnit();

	// package declaration
	final PackageDeclaration p1 = ast.newPackageDeclaration();
	p1.setName(ast.newName(packageName.split("\\.")));
	cu.setPackage(p1);

	// import specifications
	ImportDeclaration id = ast.newImportDeclaration();
	id.setName(ast.newName(new String[] { "org", "junit", "Test" }));
	cu.imports().add(id);
	
	// class declaration
	td = ast.newTypeDeclaration();
	td.setName(ast.newSimpleName(cuName));
	td.modifiers().add(ast.newModifier(Modifier.ModifierKeyword.PUBLIC_KEYWORD));
	cu.types().add(td);
	

	
	// test method construction
	final MethodDeclaration md = ast.newMethodDeclaration();
	md.setName(ast.newSimpleName("test"));
	md.thrownExceptions().add(ast.newSimpleName("Exception"));

	
	
	// sets @Test annotation to test method
	final NormalAnnotation annotation = ast.newNormalAnnotation();
	annotation.setTypeName(ast.newSimpleName("Test"));
	md.modifiers().add(annotation);
	
	// sets method to public
	md.modifiers().add(ast.newModifier(Modifier.ModifierKeyword.PUBLIC_KEYWORD));
	td.bodyDeclarations().add(md);
	
	methodBlock = ast.newBlock();
	md.setBody(methodBlock);
	
}
 
开发者ID:EvoSuite,项目名称:evosuite,代码行数:45,代码来源:JUnitCodeGenerator.java

示例7: writeProgramAnnotation

import org.eclipse.jdt.core.dom.NormalAnnotation; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
public void writeProgramAnnotation(QProgram program) {
	QConversion conversion = program.getFacet(QConversion.class);
	if (conversion != null) {
		MarkerAnnotation conversionAnnotation = getAST().newMarkerAnnotation();

		switch (conversion.getStatus()) {
		case POSSIBLE:
			break;
		case SUPPORTED:
			writeImport(Supported.class);
			conversionAnnotation.setTypeName(getAST().newSimpleName(Supported.class.getSimpleName()));
			getTarget().modifiers().add(conversionAnnotation);
			break;
		case TODO:
			writeImport(ToDo.class);
			conversionAnnotation.setTypeName(getAST().newSimpleName(ToDo.class.getSimpleName()));
			getTarget().modifiers().add(conversionAnnotation);
			break;
		case UNSUPPORTED:
			writeImport(Unsupported.class);
			conversionAnnotation.setTypeName(getAST().newSimpleName(Unsupported.class.getSimpleName()));
			getTarget().modifiers().add(conversionAnnotation);
			break;
		}
	}

	// @Program(name=)
	NormalAnnotation programAnnotation = getAST().newNormalAnnotation();
	programAnnotation.setTypeName(getAST().newSimpleName(Program.class.getSimpleName()));
	MemberValuePair memberValuePair = getAST().newMemberValuePair();
	memberValuePair.setName(getAST().newSimpleName("name"));
	StringLiteral stringLiteral = getAST().newStringLiteral();
	stringLiteral.setLiteralValue(program.getName());
	memberValuePair.setValue(stringLiteral);
	programAnnotation.values().add(memberValuePair);

	getTarget().modifiers().add(0, programAnnotation);
	
	// @Test(category = "", object = "")
	programAnnotation = getAST().newNormalAnnotation();
	programAnnotation.setTypeName(getAST().newSimpleName(Test.class.getSimpleName()));

	MemberValuePair categoryValuePair = getAST().newMemberValuePair();
	categoryValuePair.setName(getAST().newSimpleName("category"));
	stringLiteral = getAST().newStringLiteral();
	stringLiteral.setLiteralValue("ILDATA");
	categoryValuePair.setValue(stringLiteral);
	programAnnotation.values().add(categoryValuePair);

	MemberValuePair objectValuePair = getAST().newMemberValuePair();
	objectValuePair.setName(getAST().newSimpleName("object"));
	stringLiteral = getAST().newStringLiteral();
	stringLiteral.setLiteralValue(program.getName());
	objectValuePair.setValue(stringLiteral);
	programAnnotation.values().add(objectValuePair);
	
	getTarget().modifiers().add(1, programAnnotation);
}
 
开发者ID:asupdev,项目名称:asup,代码行数:60,代码来源:JDTProgramTestWriter.java


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