1 19 package org.netbeans.modules.javacore.parser; 20 21 import org.netbeans.modules.javacore.jmiimpl.javamodel.ParameterImpl; 22 23 27 class ParameterInfoMeasure implements Measure { 28 public static final ParameterInfoMeasure INSTANCE = new ParameterInfoMeasure(); 29 30 private static final int NAME_WEIGHT = 60; 31 private static final int TYPE_WEIGHT = 40; 32 33 34 private ParameterInfoMeasure() { 35 } 36 37 42 public int getDistance(Object refObject, Object ast) { 43 if (ast instanceof ParameterInfo) { 44 ParameterInfo astInfo = (ParameterInfo) ast; 45 ParameterImpl refInfo = (ParameterImpl) refObject; 46 int result = StringMeasure.INSTANCE.getDistance(refInfo.getName(), astInfo.name) * NAME_WEIGHT; 47 if (refInfo.isPersisted()) { 48 result += ClassNameMeasure.INSTANCE.getDistance(refInfo.getTypeRef(), astInfo.type) * TYPE_WEIGHT; 49 } 50 result/=100; 51 return result > INFINITE_DISTANCE ? INFINITE_DISTANCE : result; 52 } 53 return INFINITE_DISTANCE; 54 } 55 } 56 | Popular Tags |