本文整理汇总了Java中org.aikodi.chameleon.oo.variable.VariableDeclaration类的典型用法代码示例。如果您正苦于以下问题:Java VariableDeclaration类的具体用法?Java VariableDeclaration怎么用?Java VariableDeclaration使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
VariableDeclaration类属于org.aikodi.chameleon.oo.variable包,在下文中一共展示了VariableDeclaration类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: visitField
import org.aikodi.chameleon.oo.variable.VariableDeclaration; //导入依赖的package包/类
@Override
public FieldVisitor visitField(int access, String name, String desc, String signature, Object value) {
if(! isSynthetic(access)) {
MemberVariableDeclarator decl = new MemberVariableDeclarator();
decl.addModifiers(accessToFieldModifier(access));
VariableDeclaration declaration = new JavaVariableDeclaration(name);
decl.add(declaration);
if(signature != null) {
new SignatureReader(signature).accept(new FieldSignatureExtractor(decl,language()));
} else {
new SignatureReader(desc).accept(new FieldSignatureExtractor(decl,language()));
}
_type.add(decl);
}
return null;
}
示例2: replaceFields
import org.aikodi.chameleon.oo.variable.VariableDeclaration; //导入依赖的package包/类
protected void replaceFields(Document javaDocument) throws LookupException {
javaDocument.apply(new Action<MemberVariableDeclarator,LookupException>(MemberVariableDeclarator.class) {
/**
* @throws LookupException
* @{inheritDoc}
*/
@Override
public void doPerform(MemberVariableDeclarator javaMemberVariableDeclarator) throws LookupException {
VariableDeclaration variableDeclaration = javaMemberVariableDeclarator.variableDeclarations().get(0);
replaceFieldReferences(javaDocument, variableDeclaration);
Method getter = createGetterTemplate(javaMemberVariableDeclarator);
getter.addModifier(new Abstract());
getter.addModifier(new Public());
javaMemberVariableDeclarator.replaceWith(getter);
Method setter = createSetterTemplate(javaMemberVariableDeclarator);
setter.addModifier(new Abstract());
setter.addModifier(new Public());
getter.nearestAncestor(Type.class).add(setter);
}
} );
}
示例3: toCodeVariableDeclarator
import org.aikodi.chameleon.oo.variable.VariableDeclaration; //导入依赖的package包/类
public String toCodeVariableDeclarator(VariableDeclarator local) {
final StringBuffer result = new StringBuffer();
List modifiers = local.modifiers();
if (modifiers.size() != 0) {
new Visitor() {
public void visit(Object o) {
result.append(toCodeModifier((Modifier)o) + " ");
}
}.applyTo(modifiers);
}
result.append(toCode(local.typeReference()));
result.append(" ");
boolean first = true;
for(VariableDeclaration element: local.variableDeclarations()) {
// LocalVariable variable = (LocalVariable)element;
if (!first) {
result.append(", ");
}
else {
first = false;
}
result.append(element.name());
Expression initCode = element.initialization();
if (initCode != null) {
result.append(" = ");
result.append(toCode(initCode));
}
}
return result.toString();
}
示例4: processFields
import org.aikodi.chameleon.oo.variable.VariableDeclaration; //导入依赖的package包/类
protected void processFields(Class clazz, Type type) {
for(Field field: clazz.getDeclaredFields()) {
TypeReference tref = toRef(field.getType());
MemberVariableDeclarator decl = new MemberVariableDeclarator(tref);
decl.add(new VariableDeclaration(field.getName()));
for(org.aikodi.chameleon.core.modifier.Modifier mod: getModifiers(field.getModifiers())) {
decl.addModifier(mod);
}
type.add(decl);
}
}
示例5: createSetterTemplate
import org.aikodi.chameleon.oo.variable.VariableDeclaration; //导入依赖的package包/类
protected Method createSetterTemplate(MemberVariableDeclarator d) {
VariableDeclaration variableDeclaration = d.variableDeclarations().get(0);
ObjectOrientedFactory factory = java(d).plugin(ObjectOrientedFactory.class);
TypeReference fieldType = d.clone(d.typeReference());
Method result = factory.createNormalMethod(setterName(variableDeclaration), java(d).createTypeReference("void"));
result.header().addFormalParameter(new FormalParameter("value", fieldType));
return result;
}
示例6: addFields
import org.aikodi.chameleon.oo.variable.VariableDeclaration; //导入依赖的package包/类
private void addFields(Type javaType, Type jloType) throws LookupException {
Set<Type> allSuperTypes = jloType.getSelfAndAllSuperTypesView();
List<RegularMemberVariable> collect = allSuperTypes.stream().<RegularMemberVariable>flatMap(x -> {
try {
return x.localMembers(RegularMemberVariable.class).stream();
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
throw new ChameleonProgrammerException(e);
}
}).collect(Collectors.toList());
for(RegularMemberVariable v : collect) {
MemberVariableDeclarator jloMemberVariableDeclarator = v.nearestAncestor(MemberVariableDeclarator.class);
MemberVariableDeclarator f = new MemberVariableDeclarator(clone(jloMemberVariableDeclarator.typeReference()));
VariableDeclaration variableDeclaration = (VariableDeclaration) v.origin();
String fieldName = fieldName(variableDeclaration);
// Util.debug(fieldName.contains(IMPLEMENTATION_SUFFIX));
f.add(new VariableDeclaration(fieldName));
f.addModifier(new Private());
javaType.add(f);
Method getter = createGetterTemplate(jloMemberVariableDeclarator);
createGetterImplementation(fieldName, getter);
javaType.add(getter);
Method setter = createSetterTemplate(jloMemberVariableDeclarator);
setter.addModifier(new Public());
Block setterBody = new Block();
setter.setImplementation(new RegularImplementation(setterBody));
setterBody.addStatement(new StatementExpression(new AssignmentExpression(new NameExpression(fieldName), new NameExpression("value"))));
javaType.add(setter);
}
}
示例7: NonPrivateNonFinalField
import org.aikodi.chameleon.oo.variable.VariableDeclaration; //导入依赖的package包/类
public NonPrivateNonFinalField() {
super(VariableDeclaration.class, Valid.create());
}
示例8: PublicFieldViolation
import org.aikodi.chameleon.oo.variable.VariableDeclaration; //导入依赖的package包/类
public PublicFieldViolation() {
super(VariableDeclaration.class, Valid.create());
}
示例9: fieldDeclaration
import org.aikodi.chameleon.oo.variable.VariableDeclaration; //导入依赖的package包/类
public final Java_JavaP.fieldDeclaration_return fieldDeclaration() throws RecognitionException {
Java_JavaP.fieldDeclaration_return retval = new Java_JavaP.fieldDeclaration_return();
retval.start = input.LT(1);
int fieldDeclaration_StartIndex = input.index();
Object root_0 = null;
Token char_literal38=null;
Java_JavaP.type_return ref = null;
Java_JavaP.variableDeclarators_return decls = null;
Object char_literal38_tree=null;
try {
if ( state.backtracking>0 && alreadyParsedRule(input, 36) ) { return retval; }
// JavaP.g:745:5: (ref= type decls= variableDeclarators ';' )
// JavaP.g:745:9: ref= type decls= variableDeclarators ';'
{
root_0 = (Object)adaptor.nil();
pushFollow(FOLLOW_type_in_fieldDeclaration2490);
ref=type();
state._fsp--;
if (state.failed) return retval;
if ( state.backtracking==0 ) adaptor.addChild(root_0, ref.getTree());
if ( state.backtracking==0 ) {
retval.element = new MemberVariableDeclarator(ref.element);
}
pushFollow(FOLLOW_variableDeclarators_in_fieldDeclaration2496);
decls=variableDeclarators();
state._fsp--;
if (state.failed) return retval;
if ( state.backtracking==0 ) adaptor.addChild(root_0, decls.getTree());
if ( state.backtracking==0 ) {
for(VariableDeclaration decl: decls.element) {retval.element.add(decl);}
}
char_literal38=(Token)match(input,48,FOLLOW_48_in_fieldDeclaration2500); if (state.failed) return retval;
if ( state.backtracking==0 ) {
char_literal38_tree = (Object)adaptor.create(char_literal38);
adaptor.addChild(root_0, char_literal38_tree);
}
}
retval.stop = input.LT(-1);
if ( state.backtracking==0 ) {
retval.tree = (Object)adaptor.rulePostProcessing(root_0);
adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);
}
}
catch (RecognitionException re) {
reportError(re);
recover(input,re);
retval.tree = (Object)adaptor.errorNode(input, retval.start, input.LT(-1), re);
}
finally {
if ( state.backtracking>0 ) { memoize(input, 36, fieldDeclaration_StartIndex); }
}
return retval;
}
示例10: annotationConstantRest
import org.aikodi.chameleon.oo.variable.VariableDeclaration; //导入依赖的package包/类
public final Java_JavaP.annotationConstantRest_return annotationConstantRest(TypeReference type) throws RecognitionException {
Java_JavaP.annotationConstantRest_return retval = new Java_JavaP.annotationConstantRest_return();
retval.start = input.LT(1);
int annotationConstantRest_StartIndex = input.index();
Object root_0 = null;
Java_JavaP.variableDeclarators_return decls = null;
try {
if ( state.backtracking>0 && alreadyParsedRule(input, 88) ) { return retval; }
// JavaP.g:1243:5: (decls= variableDeclarators )
// JavaP.g:1243:9: decls= variableDeclarators
{
root_0 = (Object)adaptor.nil();
pushFollow(FOLLOW_variableDeclarators_in_annotationConstantRest5454);
decls=variableDeclarators();
state._fsp--;
if (state.failed) return retval;
if ( state.backtracking==0 ) adaptor.addChild(root_0, decls.getTree());
if ( state.backtracking==0 ) {
retval.element = new MemberVariableDeclarator(type);
for(VariableDeclaration decl: decls.element) {
retval.element.add(decl);
}
}
}
retval.stop = input.LT(-1);
if ( state.backtracking==0 ) {
retval.tree = (Object)adaptor.rulePostProcessing(root_0);
adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);
}
}
catch (RecognitionException re) {
reportError(re);
recover(input,re);
retval.tree = (Object)adaptor.errorNode(input, retval.start, input.LT(-1), re);
}
finally {
if ( state.backtracking>0 ) { memoize(input, 88, annotationConstantRest_StartIndex); }
}
return retval;
}
示例11: localVariableDeclaration
import org.aikodi.chameleon.oo.variable.VariableDeclaration; //导入依赖的package包/类
public final Java_JavaP.localVariableDeclaration_return localVariableDeclaration() throws RecognitionException {
Java_JavaP.localVariableDeclaration_return retval = new Java_JavaP.localVariableDeclaration_return();
retval.start = input.LT(1);
int localVariableDeclaration_StartIndex = input.index();
Object root_0 = null;
Java_JavaP.variableModifiers_return mods = null;
Java_JavaP.type_return ref = null;
Java_JavaP.variableDeclarators_return decls = null;
try {
if ( state.backtracking>0 && alreadyParsedRule(input, 93) ) { return retval; }
// JavaP.g:1273:5: (mods= variableModifiers ref= type decls= variableDeclarators )
// JavaP.g:1273:9: mods= variableModifiers ref= type decls= variableDeclarators
{
root_0 = (Object)adaptor.nil();
pushFollow(FOLLOW_variableModifiers_in_localVariableDeclaration5637);
mods=variableModifiers();
state._fsp--;
if (state.failed) return retval;
if ( state.backtracking==0 ) adaptor.addChild(root_0, mods.getTree());
pushFollow(FOLLOW_type_in_localVariableDeclaration5641);
ref=type();
state._fsp--;
if (state.failed) return retval;
if ( state.backtracking==0 ) adaptor.addChild(root_0, ref.getTree());
if ( state.backtracking==0 ) {
retval.element = new LocalVariableDeclarator(ref.element);
}
pushFollow(FOLLOW_variableDeclarators_in_localVariableDeclaration5647);
decls=variableDeclarators();
state._fsp--;
if (state.failed) return retval;
if ( state.backtracking==0 ) adaptor.addChild(root_0, decls.getTree());
if ( state.backtracking==0 ) {
for(VariableDeclaration decl: decls.element) {retval.element.add(decl);}
}
if ( state.backtracking==0 ) {
for(Modifier mod : mods.element) {retval.element.addModifier(mod);}
}
}
retval.stop = input.LT(-1);
if ( state.backtracking==0 ) {
retval.tree = (Object)adaptor.rulePostProcessing(root_0);
adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);
}
}
catch (RecognitionException re) {
reportError(re);
recover(input,re);
retval.tree = (Object)adaptor.errorNode(input, retval.start, input.LT(-1), re);
}
finally {
if ( state.backtracking>0 ) { memoize(input, 93, localVariableDeclaration_StartIndex); }
}
return retval;
}
示例12: fieldName
import org.aikodi.chameleon.oo.variable.VariableDeclaration; //导入依赖的package包/类
protected String fieldName(VariableDeclaration variableDeclaration) {
return "field$"+declarationName(variableDeclaration);
}
示例13: declarationName
import org.aikodi.chameleon.oo.variable.VariableDeclaration; //导入依赖的package包/类
private String declarationName(VariableDeclaration variableDeclaration) {
return variableDeclaration.origin().nearestAncestor(Type.class).name()+"$"+variableDeclaration.name();
}
示例14: getterName
import org.aikodi.chameleon.oo.variable.VariableDeclaration; //导入依赖的package包/类
protected String getterName(VariableDeclaration variableDeclaration) {
return "get$"+declarationName(variableDeclaration);
}
示例15: setterName
import org.aikodi.chameleon.oo.variable.VariableDeclaration; //导入依赖的package包/类
protected String setterName(VariableDeclaration variableDeclaration) {
return "set$"+declarationName(variableDeclaration);
}