spoon.reflect.code.CtLiteral Java Examples
The following examples show how to use
spoon.reflect.code.CtLiteral.
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: PatchGenerator.java From astor with GNU General Public License v2.0 | 6 votes |
public List<Transformation> process(ModificationPoint modificationPoint, LiteralPlaceholder literalPlaceholder) { List<Transformation> transformation = new ArrayList<>(); /// List<Ingredient> ingredients = getSpace(modificationPoint.getProgramVariant()) .getIngredients(modificationPoint.getCodeElement()); logger.debug("Ingredients lit (" + ingredients.size() + ") " + ingredients); // logger.debug("Placeholder vars "+ // varplaceholder.getPalceholders().keySet().size()); for (Ingredient ctCodeElement : ingredients) { CtLiteral literal4Space = (CtLiteral) ctCodeElement.getCode(); if (literal4Space.getType().isSubtypeOf(literalPlaceholder.getAffected().getType())) { Transformation t = new LiteralTransformation(literalPlaceholder, literalPlaceholder.getAffected(), literal4Space.getValue()); transformation.add(t); } } return transformation; }
Example #2
Source File: VariablesInSuspiciousCollector.java From nopol with GNU General Public License v2.0 | 6 votes |
/** * get all dependencies added by a CtTypedElement * * @param element * @return all dependencies added by element */ private List<CtTypeReference<?>> getDependencies(CtTypedElement<?> element) { List<CtTypeReference<?>> listDependencies = new ArrayList<>(); // Literal if (element instanceof CtAnnotation) { return listDependencies; } if (element instanceof CtLiteral<?>) { CtLiteral<?> literal = (CtLiteral<?>) element; literal.getValue(); if (literal.getValue() instanceof CtTypeReference<?>) { listDependencies.add((CtTypeReference<?>) literal.getValue()); } else if (literal.getValue() instanceof CtTypedElement<?>) { listDependencies.add(((CtTypedElement<?>) literal.getValue()) .getType()); } } // method invocation if (element instanceof CtInvocation<?>) { CtInvocation<?> invocation = (CtInvocation<?>) element; // the class of the method listDependencies.add(invocation.getExecutable().getDeclaringType()); } listDependencies.add(element.getType()); return listDependencies; }
Example #3
Source File: PatchGenerator.java From astor with GNU General Public License v2.0 | 6 votes |
public List<Transformation> process(ModificationPoint modificationPoint, VarLiPlaceholder varLiPlaceholder) { List<Transformation> transformation = new ArrayList<>(); List<Ingredient> ingredients = getSpace(modificationPoint.getProgramVariant()) .getIngredients(modificationPoint.getCodeElement()); logger.debug("Ingredients lit (" + ingredients.size() + ") " + ingredients); for (Ingredient ctCodeElement : ingredients) { CtLiteral literal4Space = (CtLiteral) ctCodeElement.getCode(); if (literal4Space.getType().isSubtypeOf(varLiPlaceholder.getAffectedVariable().getType())) { Transformation t = new VarLiTransformation(varLiPlaceholder, varLiPlaceholder.getAffectedVariable(), literal4Space.clone()); transformation.add(t); } } return transformation; }
Example #4
Source File: ConditionRemoveTransform.java From astor with GNU General Public License v2.0 | 6 votes |
@SuppressWarnings({ "rawtypes", "static-access" }) @Override public <T> void visitCtBinaryOperator(CtBinaryOperator<T> operator) { super.visitCtBinaryOperator(operator); if(operator.getKind()==BinaryOperatorKind.AND||operator.getKind()==BinaryOperatorKind.OR) { CtExpression right = operator.getRightHandOperand(); operator.setKind(BinaryOperatorKind.AND); CtLiteral<Boolean> literalvalue = this.mutSupporter.getFactory().Core().createLiteral(); Boolean bval=true; literalvalue.setValue(bval); operator.setRightHandOperand(literalvalue); saveSketchAndSynthesize(); operator.setRightHandOperand(right); resoreDiskFile(); CtExpression left = operator.getLeftHandOperand(); operator.setKind(BinaryOperatorKind.AND); operator.setLeftHandOperand(literalvalue); saveSketchAndSynthesize(); operator.setLeftHandOperand(left); resoreDiskFile(); } }
Example #5
Source File: ConditionRemoveTransform.java From astor with GNU General Public License v2.0 | 6 votes |
@SuppressWarnings({ "static-access", "rawtypes", "unchecked" }) public void visitCtIf(CtIf ifElement) { super.visitCtIf(ifElement); CtExpression cond = ifElement.getCondition(); CtLiteral<Boolean> literalvalue = this.mutSupporter.getFactory().Core().createLiteral(); Boolean bval=false; literalvalue.setValue(bval); CtBinaryOperator<?> newcond = this.mutSupporter.getFactory().Core().createBinaryOperator(); newcond.setKind(BinaryOperatorKind.AND); newcond.setRightHandOperand(literalvalue); newcond.setLeftHandOperand(cond); ifElement.setCondition((CtExpression<Boolean>) newcond); saveSketchAndSynthesize(); ifElement.setCondition(cond); resoreDiskFile(); }
Example #6
Source File: ClassCollector.java From nopol with GNU General Public License v2.0 | 6 votes |
/** * get all dependencies added by a CtTypedElement * * @param element * @return all dependencies added by element */ private List<CtTypeReference<?>> getDependencies(CtTypedElement<?> element) { List<CtTypeReference<?>> listDependencies = new ArrayList<>(); // Literal if (element instanceof CtAnnotation) { return listDependencies; } if (element instanceof CtLiteral<?>) { CtLiteral<?> literal = (CtLiteral<?>) element; literal.getValue(); if (literal.getValue() instanceof CtTypeReference<?>) { listDependencies.add((CtTypeReference<?>) literal.getValue()); } else if (literal.getValue() instanceof CtTypedElement<?>) { listDependencies.add(((CtTypedElement<?>) literal.getValue()) .getType()); } } // method invocation if (element instanceof CtInvocation<?>) { CtInvocation<?> invocation = (CtInvocation<?>) element; // the class of the method listDependencies.add(invocation.getExecutable().getDeclaringType()); } listDependencies.add(element.getType()); return listDependencies; }
Example #7
Source File: AbstractCodeAnalyzer.java From coming with MIT License | 6 votes |
public static String[] getLiteralTypeAndValue(CtLiteral inputLiteral) { String[] literaltypeandvalue = new String[2]; if (inputLiteral.toString().trim().startsWith("'")) { literaltypeandvalue[0] = "char"; literaltypeandvalue[1] = inputLiteral.getValue().toString(); } else if (inputLiteral.toString().trim().startsWith("\"")) { literaltypeandvalue[0] = "string"; literaltypeandvalue[1] = inputLiteral.getValue().toString(); } else if (inputLiteral.toString().indexOf("null") != -1) { literaltypeandvalue[0] = "null"; literaltypeandvalue[1] = "null"; } else { if (inputLiteral.getValue().toString().equals("true") || inputLiteral.getValue().toString().equals("false")) { literaltypeandvalue[0] = "boolean"; literaltypeandvalue[1] = inputLiteral.getValue().toString(); } else { literaltypeandvalue[0] = "numerical"; literaltypeandvalue[1] = inputLiteral.getValue().toString(); } } return literaltypeandvalue; }
Example #8
Source File: ExpressionIngredientSpaceProcessor.java From astor with GNU General Public License v2.0 | 5 votes |
@Override public void process(CtExpression element) { if (element instanceof CtAssignment || element instanceof CtNewArray || element instanceof CtTypeAccess || element instanceof CtVariableAccess || element instanceof CtLiteral) return; if (element.getType() != null) this.add(element); }
Example #9
Source File: VarLiTransformation.java From astor with GNU General Public License v2.0 | 5 votes |
public VarLiTransformation(VarLiPlaceholder varLiPlaceholder, CtVariableAccess previousVariable, CtLiteral newLiteral) { super(); this.varLiPlaceholder = varLiPlaceholder; this.previousVariable = previousVariable; this.newLiteral = newLiteral; }
Example #10
Source File: LiteralPlaceholderGenerator.java From astor with GNU General Public License v2.0 | 5 votes |
@Override public List<LiteralPlaceholder> createTOS(T ingredientSource) { List<LiteralPlaceholder> results = new ArrayList<>(); boolean mustclone = false; List<CtLiteral> literals = ip.createFixSpace(ingredientSource, mustclone); for (CtLiteral ctLiteral : literals) { //TODO: int i = 0; LiteralPlaceholder lp = new LiteralPlaceholder("_l_"+ctLiteral.getType().getSimpleName()+"_"+i, ctLiteral); results.add(lp); } return results; }
Example #11
Source File: ExpressionTransform.java From astor with GNU General Public License v2.0 | 5 votes |
@SuppressWarnings("rawtypes") @Override public <T> void visitCtLiteral(CtLiteral<T> literal) { CtExpression exp = null; if(literal.getValue()!=null) { if(literal.getValue().toString().toLowerCase().equals("true")|| literal.getValue().toString().toLowerCase().equals("false")) { exp = ExpressionGenerator.fetchEXP(this.mutSupporter, this.modificationPoint, "boolean", querytype); if (exp != null) candidates.put(literal, exp); } } }
Example #12
Source File: CodeElementInfo.java From coming with MIT License | 5 votes |
private void setLiteralsFromFaultyLine() { if (elementToStudy != null) literalsFromFaultyLine = elementToStudy.getElements(e -> (e instanceof CtLiteral)).stream() .map(CtLiteral.class::cast).collect(Collectors.toList()); else literalsFromFaultyLine = null; }
Example #13
Source File: DynamothConstantCollector.java From nopol with GNU General Public License v2.0 | 5 votes |
@Override public void process(CtLiteral ctLiteral) { Literal constant = AccessFactory.literal(ctLiteral.getValue(), nopolContext); if (candidates.add(constant)) { logger.debug("[data] " + constant); } }
Example #14
Source File: DynamothConstantCollector.java From nopol with GNU General Public License v2.0 | 5 votes |
@Override public boolean isToBeProcessed(CtLiteral candidate) { CtMethod parent = candidate.getParent(CtMethod.class); Object value = candidate.getValue(); if (parent == null) { return false; } else if (value instanceof Boolean || value == null) { return false; } return (this.buggyMethod == null || parent.getSimpleName().equals(this.buggyMethod)) && Number.class.isAssignableFrom(value.getClass()); }
Example #15
Source File: DefaultConstantCollector.java From nopol with GNU General Public License v2.0 | 5 votes |
@Override public boolean isToBeProcessed(CtLiteral candidate) { if (candidate.getValue() instanceof Boolean) { return false; } Object value = candidate.getValue(); if (value == null) { return false; } //Processing only Long and Integer return Long.class.isAssignableFrom(value.getClass()) || Integer.class.isAssignableFrom(value.getClass()); }
Example #16
Source File: StatementDeletionMetaMutator.java From metamutator with GNU General Public License v3.0 | 5 votes |
private void SetElseStatementWithReturn(CtIf ifStatement){ //search the first parent method CtMethod parentMethod = ifStatement.getParent(CtMethod.class); //we go out of while with null of a CtMethod. If null, return without method in parents...? if(parentMethod == null){ return; } //create returned expression from template. CtLiteral returnedExpression = null; Class classOfReturn = parentMethod.getType().getActualClass(); if(PrimitiveTemplateExpressions.containsKey(classOfReturn)){ CtLiteral templateExpression = PrimitiveTemplateExpressions.get(classOfReturn); returnedExpression = getFactory().Core().clone(templateExpression); }else{ returnedExpression = new CtLiteralImpl().setValue(null); } CtReturn theReturn = getFactory().Core().createReturn(); theReturn.setReturnedExpression(returnedExpression); CtBlock elseBlock = ifStatement.getElseStatement(); if(elseBlock == null){ elseBlock = getFactory().Core().createBlock(); } elseBlock.addStatement(theReturn); ifStatement.setElseStatement(elseBlock); }
Example #17
Source File: VariableResolver.java From astor with GNU General Public License v2.0 | 4 votes |
public static List<CtLiteral> collectLiteralsNoString(CtElement element) { List<CtLiteral> literalsValues = new ArrayList<>(); CtScanner scanner = new CtScanner() { @Override public <T> void visitCtLiteral(CtLiteral<T> literal) { super.visitCtLiteral(literal); if (!literalsValues.contains(literal) && !"String".equals(literal.getType().getSimpleName())) literalsValues.add(literal); } }; scanner.scan(element); return literalsValues; }
Example #18
Source File: VariableResolver.java From astor with GNU General Public License v2.0 | 4 votes |
public static List<CtLiteral> collectLiterals(CtElement element) { List<CtLiteral> literalsValues = new ArrayList<>(); CtScanner scanner = new CtScanner() { @Override public <T> void visitCtLiteral(CtLiteral<T> literal) { super.visitCtLiteral(literal); if (!literalsValues.contains(literal)) literalsValues.add(literal); } }; scanner.scan(element); return literalsValues; }
Example #19
Source File: DataCombinerSpoon.java From astor with GNU General Public License v2.0 | 4 votes |
@SuppressWarnings({ "rawtypes", "unchecked" }) public CtExpression create(Operator operator, List<CtExpression> expressions, NopolContext nopolContext) { switch (expressions.size()) { case 1: // return create((UnaryOperator) operator, expressions.get(0), nopolContext); CtUnaryOperatorImpl unaryOp = new CtUnaryOperatorImpl<>(); unaryOp.setKind(((UnaryOperatorSpoon) operator).getOp()); unaryOp.setOperand(expressions.get(0)); Class aClassReturnOp1 = operator.getReturnType(); CtClass ctofClass1 = getCtClassFromClass(aClassReturnOp1); // Put the type if (ctofClass1 != null) unaryOp.setType(ctofClass1.getReference()); else { System.out.println("We could not determine the ct class of " + aClassReturnOp1.getSimpleName()); } return unaryOp; case 2: if (expressions.get(0) instanceof CtLiteral && expressions.get(1) instanceof CtLiteral) return null; // return create((BinaryOperator) operator, expressions.get(0), // expressions.get(1), nopolContext); CtBinaryOperatorImpl op = new CtBinaryOperatorImpl<>(); op.setKind(((BinaryOperatorSpoon) operator).getOpKind()); op.setLeftHandOperand((CtExpression) expressions.get(0)); op.setRightHandOperand((CtExpression) expressions.get(1)); // Class aClassReturnOp = operator.getReturnType(); CtClass ctofClass = getCtClassFromClass(aClassReturnOp); // Put the type if (ctofClass != null) op.setType(ctofClass.getReference()); else { System.out.println("We could not determine the ct class of " + aClassReturnOp.getSimpleName()); } return op; default: throw new IllegalArgumentException( "Combination expression with " + expressions.size() + " is not supported"); } }
Example #20
Source File: LabelFinder.java From gumtree-spoon-ast-diff with Apache License 2.0 | 4 votes |
@Override public <T> void visitCtLiteral(CtLiteral<T> literal) { label = literal.toString(); }
Example #21
Source File: StatementDeletionMetaMutator.java From metamutator with GNU General Public License v3.0 | 4 votes |
private void mutateOperator(final CtStatement expression) { /*if (alreadyInHotsSpot(expression)) { System.out .println(String .format("Expression '%s' ignored because it is included in previous hot spot", expression)); return; }*/ int thisIndex = ++selectorIndex; ACTIVABLE kind = ACTIVABLE.ENABLED; String expressionContent = String.format("("+ PREFIX + "%s.is(%s))", thisIndex, kind.getClass().getCanonicalName()+"."+kind.name()); //create IfChoice with right condition CtIf ifChoice = getFactory().Core().createIf(); CtCodeSnippetExpression expIf = getFactory().Code().createCodeSnippetExpression(expressionContent); ifChoice.setCondition(expIf); //create block from a clone of expression CtStatement exp2 = getFactory().Core().clone(expression); CtBlock thenBlock = getFactory().Code().createCtBlock(exp2); //set if and replace the expression with the new if ifChoice.setThenStatement(thenBlock); expression.replace(ifChoice); //to be sure ifChoice.getParent().updateAllParentsBelow(); //if there are return or throws, set else with value of return. Filter<CtCFlowBreak> filterReturn = new ReturnOrThrowFilter(); if(!thenBlock.getElements(filterReturn).isEmpty()){ SetElseStatementWithReturn(ifChoice); } //to avoid to delete assignement in statement, we assign a default value to all local variable. Filter<CtLocalVariable> filterLocalVariable = new TypeFilter<CtLocalVariable>(CtLocalVariable.class); CtMethod method = ifChoice.getParent(CtMethod.class); if(method != null && !method.getElements(filterLocalVariable).isEmpty()){ for(CtLocalVariable var : method.getElements(filterLocalVariable)){ if(var.getAssignment() == null){ //create right side expression from template. Class classOfAssignment = var.getType().getActualClass(); CtLiteral rightHand = null; //Particular case of ForEach (int x : numbers) can't be (int x = 0 : numbers) if(var.getParent() instanceof CtForEach){ continue; } if(PrimitiveTemplateExpressions.containsKey(classOfAssignment)){ CtLiteral templateExpression = PrimitiveTemplateExpressions.get(classOfAssignment); rightHand = getFactory().Core().clone(templateExpression); }else{ rightHand = getFactory().createLiteral().setValue(null); } var.setAssignment(rightHand); } } } Selector.generateSelector(expression, ACTIVABLE.ENABLED, thisIndex, ActivableSet, PREFIX); //hotSpots.add(expression); }
Example #22
Source File: ConstReplacementOp.java From astor with GNU General Public License v2.0 | 4 votes |
@Override public boolean checkTargetCompatibility(CtElement target) { return target instanceof CtLiteral; }
Example #23
Source File: ConstReplacementOp.java From astor with GNU General Public License v2.0 | 4 votes |
@Override public List<MetaOperatorInstance> createMetaOperatorInstances(ModificationPoint modificationPoint) { MetaOperatorInstance opMega = new MetaOperatorInstance(this, MetaGenerator.getNewIdentifier()); List<OperatorInstance> opsOfVariant = new ArrayList(); List<MetaOperatorInstance> opsMega = new ArrayList(); Map<Integer, Ingredient> ingredientOfMapped = new HashMap<>(); List<CtLiteral> literalsInModificationPoints = null; if (targetElement == null) { literalsInModificationPoints = modificationPoint.getCodeElement() .getElements(new TypeFilter<>(CtLiteral.class)); } else { literalsInModificationPoints = new ArrayList<>(); literalsInModificationPoints.add((CtLiteral) targetElement); } List<CtLiteral> getAllLiteralsFromClass = modificationPoint.getCtClass() .getElements(new TypeFilter<>(CtLiteral.class)).stream().distinct().collect(Collectors.toList()); log.debug("\nModifcationPoint: \n" + modificationPoint); int variableCounter = 0; for (CtLiteral variableAccessToReplace : literalsInModificationPoints) { // The return type of the new method correspond to the type of variable to // change CtTypeReference returnType = variableAccessToReplace.getType(); List<Ingredient> ingredients = this.computeIngredientsFromLiteralsToReplace(modificationPoint, variableAccessToReplace, getAllLiteralsFromClass); if (ingredients.isEmpty()) { // Nothing to replace continue; } // The parameters to be included in the new method List<CtVariableAccess> varsToBeParameters = ingredients.stream() .filter(e -> e.getCode() instanceof CtVariableAccess).map(e -> e.getCode()) .map(CtVariableAccess.class::cast).collect(Collectors.toList()); // The variable to be replaced must also be a parameter // List of parameters List<CtParameter<?>> parameters = new ArrayList<>(); List<CtExpression<?>> realParameters = new ArrayList<>(); for (CtVariableAccess ctVariableAccess : varsToBeParameters) { // the parent is null, it is setter latter CtParameter pari = MutationSupporter.getFactory().createParameter(null, ctVariableAccess.getType(), ctVariableAccess.getVariable().getSimpleName()); parameters.add(pari); realParameters.add(ctVariableAccess.clone().setPositions(new NoSourcePosition())); } variableCounter++; MetaGenerator.createMetaForSingleElement(opMega, modificationPoint, variableAccessToReplace, variableCounter, ingredients, parameters, realParameters, returnType, opsOfVariant, ingredientOfMapped); } // End variable opMega.setOperatorInstances(opsOfVariant); opMega.setAllIngredients(ingredientOfMapped); opMega.setOperationApplied(this); opMega.setOriginal(modificationPoint.getCodeElement()); opMega.setModificationPoint(modificationPoint); opsMega.add(opMega); return opsMega; }
Example #24
Source File: LiteralTransformation.java From astor with GNU General Public License v2.0 | 4 votes |
public LiteralTransformation(LiteralPlaceholder literalPlaceholder, CtLiteral target, Object newValue) { super(); this.literalPlaceholder = literalPlaceholder; this.target = target; this.newValue = newValue; }
Example #25
Source File: LiteralPlaceholder.java From astor with GNU General Public License v2.0 | 4 votes |
public CtLiteral getAffected() { return affected; }
Example #26
Source File: LiteralPlaceholder.java From astor with GNU General Public License v2.0 | 4 votes |
public LiteralPlaceholder(Object newValue, CtLiteral affected) { super(); this.placeholder_name = newValue; this.affected = affected; }
Example #27
Source File: LiteralsProcessor.java From astor with GNU General Public License v2.0 | 4 votes |
@Override public void process(CtLiteral element) { add(element); }
Example #28
Source File: OriginalFeatureExtractor.java From coming with MIT License | 4 votes |
private EnumSet<ValueFeature> getValueFeature(final String valueStr, final Repair repair, Map<String, CtElement> valueExprInfo) { EnumSet<ValueFeature> valueFeatures = EnumSet.noneOf(ValueFeature.class); if (repair.oldRExpr != null && repair.newRExpr != null) { String oldStr = repair.oldRExpr.toString(); String newStr = repair.newRExpr.toString(); if (valueStr.equals(newStr)) valueFeatures.add(ValueFeature.MODIFIED_VF); // I can not figure out the meaning of MODIFIED_SIMILAR_VF if (oldStr.length() > 0 && newStr.length() > 0) { double ratio = ((double)oldStr.length()) / newStr.length(); if (ratio > 0.5 && ratio < 2 && oldStr.length() > 3 && newStr.length() > 3) if (oldStr.contains(newStr) || newStr.contains(oldStr)) valueFeatures.add(ValueFeature.MODIFIED_SIMILAR_VF); } } CtElement element = repair.dstElem; if (element != null) { CtMethod FD = element.getParent(new TypeFilter<>(CtMethod.class)); if (FD != null) { for (Object parameter: FD.getParameters()) { if (parameter instanceof CtParameter) { CtParameter VD = (CtParameter) parameter; if (VD.getSimpleName().equals(valueStr)) valueFeatures.add(ValueFeature.FUNC_ARGUMENT_VF); } } } } assert(valueExprInfo.containsKey(valueStr)); CtElement E = valueExprInfo.get(valueStr); if (E instanceof CtVariableAccess || E instanceof CtArrayAccess || E instanceof CtLocalVariable) { if (E instanceof CtLocalVariable) { valueFeatures.add(ValueFeature.LOCAL_VARIABLE_VF); } else { valueFeatures.add(ValueFeature.GLOBAL_VARIABLE_VF); } } else if (E instanceof CtExecutableReference){ // just make CALLEE_AF be meaningful if (((CtExecutableReference) E).getParameters().size() > 0){ valueFeatures.add(ValueFeature.LOCAL_VARIABLE_VF); } } else if (E instanceof CtIf){ // just make R_STMT_COND_AF be meaningful valueFeatures.add(ValueFeature.LOCAL_VARIABLE_VF); } // if (E instanceof CtVariable) { // if (E instanceof CtLocalVariable) // valueFeatures.add(SchemaFeature.LOCAL_VARIABLE_VF); // else // valueFeatures.add(SchemaFeature.GLOBAL_VARIABLE_VF); // } else if (E instanceof CtVariableReference) { // if (E instanceof CtLocalVariableReference) // valueFeatures.add(SchemaFeature.LOCAL_VARIABLE_VF); // else // valueFeatures.add(SchemaFeature.GLOBAL_VARIABLE_VF); // } if (valueStr.contains("length") || valueStr.contains("size")) valueFeatures.add(ValueFeature.SIZE_LITERAL_VF); if (E.getElements(new TypeFilter<>(CtField.class)).size() > 0) valueFeatures.add(ValueFeature.MEMBER_VF); if (E instanceof CtLiteral) { Object value = ((CtLiteral)E).getValue(); if (value instanceof String) { valueFeatures.add(ValueFeature.STRING_LITERAL_VF); } else if (value instanceof Integer) { // ? if ((Integer) value == 0) { valueFeatures.add(ValueFeature.ZERO_CONST_VF); } else { valueFeatures.add(ValueFeature.NONZERO_CONST_VF); } } } return valueFeatures; }
Example #29
Source File: VariableResolver.java From coming with MIT License | 4 votes |
public static List<CtLiteral> collectLiteralsNoString(CtElement element) { List<CtLiteral> literalsValues = new ArrayList<>(); CtScanner scanner = new CtScanner() { @Override public <T> void visitCtLiteral(CtLiteral<T> literal) { super.visitCtLiteral(literal); if (!literalsValues.contains(literal) && !"String".equals(literal.getType().getSimpleName())) literalsValues.add(literal); } }; scanner.scan(element); return literalsValues; }
Example #30
Source File: VariableResolver.java From coming with MIT License | 4 votes |
public static List<CtLiteral> collectLiterals(CtElement element) { List<CtLiteral> literalsValues = new ArrayList<>(); CtScanner scanner = new CtScanner() { @Override public <T> void visitCtLiteral(CtLiteral<T> literal) { super.visitCtLiteral(literal); if (!literalsValues.contains(literal)) literalsValues.add(literal); } }; scanner.scan(element); return literalsValues; }