spoon.reflect.declaration.CtEnum Java Examples
The following examples show how to use
spoon.reflect.declaration.CtEnum.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: LibParser.java From astor with GNU General Public License v2.0 | 6 votes |
public void parseFile(File name) { if(!parsedfile.contains(name.getAbsolutePath())) { parsedfile.add(name.getAbsolutePath()); for (CtClass<?> klass : this.factory.getModel().getElements(new TypeFilter<CtClass>(CtClass.class))) { if(klass.getPosition().getFile().getAbsolutePath().equals(name.getAbsolutePath())) { @SuppressWarnings("rawtypes") CtClass founded=klass; if (!classMap.containsKey(founded.getQualifiedName())) { classMap.put(founded.getQualifiedName(), founded); List<CtEnum> enumArray = founded.getElements(new TypeFilter<>(CtEnum.class)); for(int index=0; index<enumArray.size(); index++) { enumMap.put(enumArray.get(index).getQualifiedName(), enumArray.get(index)); } } break; } } } }
Example #2
Source File: ExpressionTransform.java From astor with GNU General Public License v2.0 | 6 votes |
@Override public <T> void visitCtFieldRead(CtFieldRead<T> fieldRead) { String type = fieldRead.getType().getQualifiedName(); type = type.replaceAll("\\d",""); CtEnum enumRead=enummap.get(type); @SuppressWarnings("rawtypes") CtExpression exp = null; if(enumRead==null) exp = ExpressionGenerator.fetchEXP(this.mutSupporter, this.modificationPoint, type, querytype); else exp = ExpressionGenerator.fetchENUM(enumRead, this.mutSupporter, type, querytype); if (exp != null) candidates.put(fieldRead, exp); }
Example #3
Source File: VariableAnalyzer.java From coming with MIT License | 5 votes |
private void analyzeV17_IsEnum (List<CtVariableAccess> varsAffected, Cntx<Object> context, CtClass parentClass) { try { if (parentClass == null) return; // Get all enums List<CtEnum> enums = parentClass.getElements(new TypeFilter<>(CtEnum.class)); // For each var access for (CtVariableAccess varAccess : varsAffected) { boolean isVarAccessTypeEnum = false; if (varAccess.getVariable().getType() != null && enums.contains(varAccess.getVariable().getType().getDeclaration())) { isVarAccessTypeEnum = true; } writeGroupedInfo(context, adjustIdentifyInJson(varAccess), CodeFeatures.V17_VAR_IS_ENUMERATION, (isVarAccessTypeEnum), "FEATURES_VARS"); } } catch (Throwable e) { e.printStackTrace(); } }
Example #4
Source File: LibParser.java From astor with GNU General Public License v2.0 | 4 votes |
public Map<String, CtEnum> getEnumMap() { return enumMap; }
Example #5
Source File: ExpressionGenerator.java From astor with GNU General Public License v2.0 | 4 votes |
@SuppressWarnings({ "rawtypes", "static-access", "unchecked" }) public static CtExpression fetchENUM(CtEnum enumread, MutationSupporter mutSupporter, String type, String queryname) { List<CtVariable> values =(List<CtVariable>) enumread.getEnumValues(); return fetchExpressionOnType(mutSupporter.getFactory(), values, type, queryname, true); }