Ticket #12522: static_code_analysis-einstein_collector.2.patch
File static_code_analysis-einstein_collector.2.patch, 31.7 KB (added by , 8 years ago) |
---|
-
src/org/openstreetmap/josm/data/Preferences.java
70 70 import org.openstreetmap.josm.gui.preferences.SourceEditor.ExtendedSourceEntry; 71 71 import org.openstreetmap.josm.gui.preferences.validator.ValidatorTagCheckerRulesPreference; 72 72 import org.openstreetmap.josm.gui.preferences.validator.ValidatorTagCheckerRulesPreference.RulePrefHelper; 73 import org.openstreetmap.josm.io.CachedFile; 73 74 import org.openstreetmap.josm.io.OfflineAccessException; 74 75 import org.openstreetmap.josm.io.OnlineResource; 75 76 import org.openstreetmap.josm.tools.CheckParameterUtil; … … 592 593 * Called after every put. In case of a problem, do nothing but output the error in log. 593 594 * @throws IOException if any I/O error occurs 594 595 */ 595 public synchronizedvoid save() throws IOException {596 save(getPreferenceFile(), settingsMap.entrySet().stream().filter(NO_DEFAULT_SETTINGS_ENTRY), false );596 public void save() throws IOException { 597 save(getPreferenceFile(), settingsMap.entrySet().stream().filter(NO_DEFAULT_SETTINGS_ENTRY), false, false); 597 598 } 598 599 599 public synchronizedvoid saveDefaults() throws IOException {600 save(getDefaultsCacheFile(), defaultsMap.entrySet().stream(), true );600 public void saveDefaults() throws IOException { 601 save(getDefaultsCacheFile(), defaultsMap.entrySet().stream(), true, false); 601 602 } 602 603 603 p rotected void save(File prefFile, Stream<Entry<String, Setting<?>>> settings, boolean defaults) throws IOException {604 public synchronized void save(File prefFile, Stream<Entry<String, Setting<?>>> settings, boolean defaults, boolean addTime) throws IOException { 604 605 if (!defaults) { 605 606 /* currently unused, but may help to fix configuration issues in future */ 606 607 putInteger("josm.version", Version.getInstance().getVersion()); … … 616 617 } 617 618 618 619 try (PreferencesWriter writer = new PreferencesWriter( 619 new PrintWriter(new File(prefFile + "_tmp"), StandardCharsets.UTF_8.name()), false, defaults )) {620 new PrintWriter(new File(prefFile + "_tmp"), StandardCharsets.UTF_8.name()), false, defaults, addTime)) { 620 621 writer.write(settings); 621 622 } 622 623 … … 655 656 protected void load() throws IOException, SAXException, XMLStreamException { 656 657 File pref = getPreferenceFile(); 657 658 PreferencesReader.validateXML(pref); 658 PreferencesReader reader = new PreferencesReader(pref, false );659 PreferencesReader reader = new PreferencesReader(pref, false, false); 659 660 reader.parse(); 660 661 settingsMap.clear(); 661 662 settingsMap.putAll(reader.getSettings()); … … 675 676 protected void loadDefaults() throws IOException, XMLStreamException, SAXException { 676 677 File def = getDefaultsCacheFile(); 677 678 PreferencesReader.validateXML(def); 678 PreferencesReader reader = new PreferencesReader(def, true );679 PreferencesReader reader = new PreferencesReader(def, true, true); 679 680 reader.parse(); 680 defaultsMap.clear();681 681 long minTime = System.currentTimeMillis() / 1000 - MAX_AGE_DEFAULT_PREFERENCES; 682 682 for (Entry<String, Setting<?>> e : reader.getSettings().entrySet()) { 683 683 if (e.getValue().getTime() >= minTime) { … … 686 686 } 687 687 } 688 688 689 protected void loadAvailable() throws XMLStreamException, IOException { 690 try (CachedFile cf = new CachedFile("resource://data/preferences-available.xml"); 691 Reader rd = cf.getContentReader()) { 692 PreferencesReader reader = new PreferencesReader(rd, true, false); 693 reader.parse(); 694 defaultsMap.putAll(reader.getSettings()); 695 } 696 } 697 689 698 /** 690 699 * Loads preferences from XML reader. 691 700 * @param in XML reader … … 693 702 * @throws IOException if any I/O error occurs 694 703 */ 695 704 public void fromXML(Reader in) throws XMLStreamException, IOException { 696 PreferencesReader reader = new PreferencesReader(in, false );705 PreferencesReader reader = new PreferencesReader(in, false, false); 697 706 reader.parse(); 698 707 settingsMap.clear(); 699 708 settingsMap.putAll(reader.getSettings()); … … 782 791 Main.warn(tr("Failed to initialize preferences. Failed to reset preference file to default: {0}", getPreferenceFile())); 783 792 } 784 793 } 794 try { 795 loadAvailable(); 796 } catch (XMLStreamException | IOException e) { 797 Main.error(e); 798 Main.warn(tr("Failed to load available preferences.")); 799 defaultsMap.clear(); 800 } 785 801 File def = getDefaultsCacheFile(); 786 802 if (def.exists()) { 787 803 try { … … 1473 1489 * @return XML 1474 1490 */ 1475 1491 public String toXML(boolean nopass) { 1476 return toXML(settingsMap.entrySet(), nopass, false );1492 return toXML(settingsMap.entrySet(), nopass, false, false); 1477 1493 } 1478 1494 1479 1495 /** … … 1484 1500 * regular preferences 1485 1501 * @return XML 1486 1502 */ 1487 public String toXML(Collection<Entry<String, Setting<?>>> settings, boolean nopass, boolean defaults ) {1503 public String toXML(Collection<Entry<String, Setting<?>>> settings, boolean nopass, boolean defaults, boolean addTime) { 1488 1504 try ( 1489 1505 StringWriter sw = new StringWriter(); 1490 PreferencesWriter prefWriter = new PreferencesWriter(new PrintWriter(sw), nopass, defaults )1506 PreferencesWriter prefWriter = new PreferencesWriter(new PrintWriter(sw), nopass, defaults, addTime) 1491 1507 ) { 1492 1508 prefWriter.write(settings); 1493 1509 sw.flush(); -
src/org/openstreetmap/josm/data/preferences/PreferencesReader.java
46 46 private final File file; 47 47 48 48 private final boolean defaults; 49 private final boolean expectTime; 49 50 50 51 /** 51 52 * Constructs a new {@code PreferencesReader}. … … 53 54 * @param defaults true when reading from the cache file for default preferences, 54 55 * false for the regular preferences config file 55 56 */ 56 public PreferencesReader(File file, boolean defaults ) {57 public PreferencesReader(File file, boolean defaults, boolean expectTime) { 57 58 this.defaults = defaults; 58 59 this.reader = null; 59 60 this.file = file; 61 this.expectTime = expectTime; 60 62 } 61 63 62 64 /** … … 65 67 * @param defaults true when reading from the cache file for default preferences, 66 68 * false for the regular preferences config file 67 69 */ 68 public PreferencesReader(Reader reader, boolean defaults ) {70 public PreferencesReader(Reader reader, boolean defaults, boolean expectTime) { 69 71 this.defaults = defaults; 70 72 this.reader = reader; 71 73 this.file = null; 74 this.expectTime = expectTime; 72 75 } 73 76 74 77 /** … … 176 179 setting = new StringSetting(Optional.ofNullable(parser.getAttributeValue(null, "value")) 177 180 .orElseThrow(() -> new XMLStreamException(tr("value expected"), parser.getLocation()))); 178 181 } 179 if ( defaults) {182 if (expectTime) { 180 183 setting.setTime(Math.round(Double.parseDouble(parser.getAttributeValue(null, "time")))); 181 184 } 182 185 settings.put(parser.getAttributeValue(null, "key"), setting); … … 210 213 private void parseToplevelList() throws XMLStreamException { 211 214 String key = parser.getAttributeValue(null, "key"); 212 215 Long time = null; 213 if ( defaults) {216 if (expectTime) { 214 217 time = Math.round(Double.parseDouble(parser.getAttributeValue(null, "time"))); 215 218 } 216 219 String name = parser.getLocalName(); … … 231 234 setting = new ListSetting(null); 232 235 break; 233 236 } 234 setting.setTime(time); 235 settings.put(key, setting); 237 if (expectTime) { 238 setting.setTime(time); 239 settings.put(key, setting); 240 } 236 241 jumpToEnd(); 237 242 } else { 238 243 while (true) { … … 286 291 break; 287 292 } 288 293 } 289 if ( defaults) {294 if (expectTime) { 290 295 setting.setTime(time); 291 296 } 292 297 settings.put(key, setting); -
src/org/openstreetmap/josm/data/preferences/PreferencesWriter.java
19 19 public class PreferencesWriter extends XmlWriter implements SettingVisitor { 20 20 private final boolean noPassword; 21 21 private final boolean defaults; 22 private final boolean addTime; 22 23 private String key; 23 24 24 25 /** … … 27 28 * @param noPassword if password must be excluded 28 29 * @param defaults true, if default values are converted to XML, false for regular preferences 29 30 */ 30 public PreferencesWriter(PrintWriter out, boolean noPassword, boolean defaults ) {31 public PreferencesWriter(PrintWriter out, boolean noPassword, boolean defaults, boolean addTime) { 31 32 super(out); 32 33 this.noPassword = noPassword; 33 34 this.defaults = defaults; 35 this.addTime = addTime; 34 36 } 35 37 36 38 /** … … 67 69 } 68 70 69 71 private void addTime(Setting<?> setting) { 70 if ( defaults) {72 if (addTime) { 71 73 out.write("' time='" + Optional.ofNullable(setting.getTime()).orElseThrow(IllegalStateException::new)); 72 74 } 73 75 } -
src/org/openstreetmap/josm/gui/dialogs/changeset/query/TimeRestrictionPanel.java
293 293 * Remember settings in preferences. 294 294 */ 295 295 public void rememberSettings() { 296 String prefRoot = "changeset-query.advanced.time-restrictions";296 final String prefRoot = "changeset-query.advanced.time-restrictions"; 297 297 if (rbClosedAfter.isSelected()) { 298 298 Main.pref.put(prefRoot + ".query-type", "closed-after"); 299 299 } else if (rbClosedAfterAndCreatedBefore.isSelected()) { … … 311 311 * Restore settings from preferences. 312 312 */ 313 313 public void restoreFromSettings() { 314 String prefRoot = "changeset-query.advanced.open-restrictions";314 final String prefRoot = "changeset-query.advanced.open-restrictions"; 315 315 String v = Main.pref.get(prefRoot + ".query-type", "closed-after"); 316 316 rbClosedAfter.setSelected("closed-after".equals(v)); 317 317 rbClosedAfterAndCreatedBefore.setSelected("closed-after-created-before".equals(v)); -
scripts/BuildProjectionDefinitions.java
45 45 46 46 /** 47 47 * Program entry point 48 * @param args command line arguments (not used)48 * @param args command line arguments: 1st argument - base directory 49 49 * @throws IOException if any I/O error occurs 50 50 */ 51 51 public static void main(String[] args) throws IOException { -
scripts/PreferencesCollector.java
1 // License: GPL. For details, see LICENSE file. 2 import java.awt.Color; 3 import java.io.File; 4 import java.io.IOException; 5 import java.lang.reflect.Executable; 6 import java.lang.reflect.Method; 7 import java.util.Collection; 8 import java.util.HashMap; 9 import java.util.List; 10 import java.util.Map; 11 import java.util.SortedMap; 12 import java.util.TreeMap; 13 14 import org.openstreetmap.josm.Main; 15 import org.openstreetmap.josm.data.Preferences; 16 import org.openstreetmap.josm.data.preferences.BooleanProperty; 17 import org.openstreetmap.josm.data.preferences.CollectionProperty; 18 import org.openstreetmap.josm.data.preferences.ColorProperty; 19 import org.openstreetmap.josm.data.preferences.DoubleProperty; 20 import org.openstreetmap.josm.data.preferences.EnumProperty; 21 import org.openstreetmap.josm.data.preferences.IntegerProperty; 22 import org.openstreetmap.josm.data.preferences.ListListSetting; 23 import org.openstreetmap.josm.data.preferences.ListSetting; 24 import org.openstreetmap.josm.data.preferences.LongProperty; 25 import org.openstreetmap.josm.data.preferences.MapListSetting; 26 import org.openstreetmap.josm.data.preferences.Setting; 27 import org.openstreetmap.josm.data.preferences.StringProperty; 28 import org.openstreetmap.josm.data.preferences.StringSetting; 29 import org.openstreetmap.josm.data.preferences.StrokeProperty; 30 import org.openstreetmap.josm.tools.I18n; 31 32 import spoon.Launcher; 33 import spoon.processing.AbstractProcessor; 34 import spoon.reflect.code.BinaryOperatorKind; 35 import spoon.reflect.code.CtAbstractInvocation; 36 import spoon.reflect.code.CtBinaryOperator; 37 import spoon.reflect.code.CtConstructorCall; 38 import spoon.reflect.code.CtExpression; 39 import spoon.reflect.code.CtFieldRead; 40 import spoon.reflect.code.CtInvocation; 41 import spoon.reflect.code.CtLiteral; 42 import spoon.reflect.code.CtUnaryOperator; 43 import spoon.reflect.code.CtVariableRead; 44 import spoon.reflect.code.UnaryOperatorKind; 45 import spoon.reflect.declaration.CtClass; 46 import spoon.reflect.declaration.CtElement; 47 import spoon.reflect.declaration.CtField; 48 import spoon.reflect.declaration.CtVariable; 49 import spoon.reflect.declaration.ModifierKind; 50 import spoon.reflect.eval.PartialEvaluator; 51 import spoon.reflect.reference.CtExecutableReference; 52 import spoon.reflect.reference.CtFieldReference; 53 import spoon.reflect.reference.CtVariableReference; 54 import spoon.reflect.visitor.filter.AbstractFilter; 55 import spoon.support.SpoonClassNotFoundException; 56 57 public class PreferencesCollector extends AbstractProcessor<CtAbstractInvocation> { 58 59 public SortedMap<String, Setting<?>> settingsMap = new TreeMap<>(); 60 public int numNull = 0; 61 62 public static void main(String[] args) { 63 String baseDir = args[0]; 64 Launcher spoon = new Launcher(); 65 spoon.addInputResource(baseDir + "/src/org/openstreetmap/josm"); 66 spoon.buildModel(); 67 PreferencesCollector coll = new PreferencesCollector(); 68 for (CtAbstractInvocation inv : spoon.getFactory().Package().getRootPackage().getElements(new AbstractFilter<CtAbstractInvocation>() { 69 @Override 70 public boolean matches(CtAbstractInvocation element) { 71 return element instanceof CtInvocation || element instanceof CtConstructorCall; 72 } 73 })) { 74 coll.process(inv); 75 } 76 try { 77 System.err.println("number of unique recognized keys: " + coll.settingsMap.keySet().size()); 78 System.err.println("number of unrecognized keys (with duplicates): " + coll.numNull); 79 Main.pref.save(new File(baseDir + "/data/preferences-available.xml"), coll.settingsMap.entrySet().stream(), true, false); 80 } catch (IOException ex) { 81 throw new RuntimeException(ex); 82 } 83 } 84 85 @Override 86 public void process(CtAbstractInvocation element) { 87 Map<Executable, Setting<?>> prefExecutables = new HashMap<>(); 88 try { 89 // don't include Preferences.getInteger(String key, String specName, int def) as it 90 // is usually called with non-constant parameter specName 91 prefExecutables.put(Preferences.class.getMethod("get", String.class), new StringSetting(null)); 92 prefExecutables.put(Preferences.class.getMethod("get", String.class, String.class), new StringSetting(null)); 93 prefExecutables.put(Preferences.class.getMethod("getCollection", String.class), new ListSetting(null)); 94 prefExecutables.put(Preferences.class.getMethod("getCollection", String.class, Collection.class), new ListSetting(null)); 95 prefExecutables.put(Preferences.class.getMethod("getArray", String.class), new ListListSetting(null)); 96 prefExecutables.put(Preferences.class.getMethod("getArray", String.class, Collection.class), new ListListSetting(null)); 97 prefExecutables.put(Preferences.class.getMethod("getBoolean", String.class), new StringSetting(null)); 98 prefExecutables.put(Preferences.class.getMethod("getBoolean", String.class, boolean.class), new StringSetting(null)); 99 prefExecutables.put(Preferences.class.getMethod("getInteger", String.class, int.class), new StringSetting(null)); 100 prefExecutables.put(Preferences.class.getMethod("getDouble", String.class, double.class), new StringSetting(null)); 101 prefExecutables.put(Preferences.class.getMethod("getListOfStructs", String.class, Collection.class), new MapListSetting(null)); 102 prefExecutables.put(Preferences.class.getMethod("getListOfStructs", String.class, Class.class), new MapListSetting(null)); 103 prefExecutables.put(Preferences.class.getMethod("getListOfStructs", String.class, Collection.class, Class.class), new MapListSetting(null)); 104 prefExecutables.put(Preferences.class.getMethod("getLong", String.class, long.class), new StringSetting(null)); 105 prefExecutables.put(StringProperty.class.getConstructor(String.class, String.class), new StringSetting(null)); 106 prefExecutables.put(IntegerProperty.class.getConstructor(String.class, int.class), new StringSetting(null)); 107 prefExecutables.put(LongProperty.class.getConstructor(String.class, long.class), new StringSetting(null)); 108 prefExecutables.put(BooleanProperty.class.getConstructor(String.class, boolean.class), new StringSetting(null)); 109 prefExecutables.put(DoubleProperty.class.getConstructor(String.class, double.class), new StringSetting(null)); 110 prefExecutables.put(CollectionProperty.class.getConstructor(String.class, Collection.class), new ListSetting(null)); 111 prefExecutables.put(StrokeProperty.class.getConstructor(String.class, String.class), new StringSetting(null)); 112 prefExecutables.put(EnumProperty.class.getConstructor(String.class, Class.class, Enum.class), new StringSetting(null)); 113 prefExecutables.put(ColorProperty.class.getConstructor(String.class, String.class), new StringSetting(null)); 114 prefExecutables.put(ColorProperty.class.getConstructor(String.class, Color.class), new StringSetting(null)); 115 } catch (NoSuchMethodException | SecurityException ex) { 116 throw new RuntimeException(ex); 117 } 118 CtExecutableReference exec = element.getExecutable(); 119 Executable realExec = null; 120 if (element instanceof CtInvocation) { 121 realExec = exec.getActualMethod(); 122 } else if (element instanceof CtConstructorCall) { 123 try { 124 realExec = exec.getActualConstructor(); 125 } catch (SpoonClassNotFoundException cnf) { 126 // it seems to have trouble with certain nested inner / anonymous classes 127 } 128 } else throw new AssertionError(); 129 130 Setting setting = prefExecutables.get(realExec); 131 if (setting != null) { 132 List<CtExpression<?>> args = element.getArguments(); 133 CtExpression key = args.get(0); 134 StaticCodeEvaluator eval = new StaticCodeEvaluator(); 135 eval.evaluate(key); 136 String strKey = eval.getResult(); 137 if (strKey != null) { 138 // fix ColorProperty 139 Class klass = realExec.getDeclaringClass(); 140 if (klass.equals(ColorProperty.class)) { 141 strKey = ColorProperty.getColorKey(strKey); 142 } 143 144 // add default value, if possilbe 145 if (setting instanceof StringSetting && args.size() >= 2) { 146 CtExpression defaultValue = args.get(args.size() - 1); 147 StaticCodeEvaluator eval2 = new StaticCodeEvaluator(); 148 eval2.evaluate(defaultValue); 149 String strDefault = eval2.getResult(); 150 if (strDefault != null) { 151 setting = new StringSetting(strDefault); 152 } else { 153 System.err.println("=== default value extraction failed!"); 154 System.err.println("file: "+element.getPosition().getLine()+":"+element.getPosition().getColumn() +element.getPosition().getFile()); 155 System.err.println("v: "+defaultValue.getClass()+ " "+ defaultValue); 156 System.err.println(eval.getErrorLog()); 157 } 158 } 159 settingsMap.put(strKey, setting); 160 } else { 161 System.err.println("=== key extraction failed!"); 162 System.err.println("file: "+element.getPosition().getLine()+":"+element.getPosition().getColumn() +element.getPosition().getFile()); 163 System.err.println("exec: "+element.getExecutable()); 164 System.err.println("args: "+element.getArguments()); 165 System.err.println(eval.getErrorLog()); 166 numNull++; 167 } 168 } 169 } 170 171 public static Class determineClass(CtElement element) { 172 CtClass klass = element.getParent(CtClass.class); 173 if (klass == null) 174 return null; 175 return klass.getActualClass(); 176 } 177 178 public static class StaticCodeEvaluator implements PartialEvaluator { 179 180 private String result; 181 private StringBuilder sb = new StringBuilder(); 182 183 private final Method marktr; 184 185 public StaticCodeEvaluator() { 186 try { 187 marktr = I18n.class.getMethod("marktr", String.class); 188 } catch (NoSuchMethodException | SecurityException ex) { 189 throw new RuntimeException(); 190 } 191 } 192 193 @Override 194 public <R extends CtElement> R evaluate(R element) { 195 Object oResult = evalWrk(element, 0); 196 if (oResult != null) { 197 this.result = oResult.toString(); 198 } 199 return null; 200 } 201 202 protected Object evalWrk(CtElement element, int lvl) { 203 lvl++; 204 if (lvl > 10) { 205 log("maximum recursion level exceeded!"); 206 return null; 207 } 208 if (element instanceof CtLiteral) { 209 return eval((CtLiteral) element, lvl); 210 } else if (element instanceof CtFieldRead) { 211 return eval((CtFieldRead) element, lvl); 212 } else if (element instanceof CtVariableRead) { 213 return eval((CtVariableRead) element, lvl); 214 } else if (element instanceof CtUnaryOperator) { 215 return eval((CtUnaryOperator) element, lvl); 216 } else if (element instanceof CtBinaryOperator) { 217 return eval((CtBinaryOperator) element, lvl); 218 } else if (element instanceof CtInvocation) { 219 return eval((CtInvocation) element, lvl); 220 } else { 221 log("cannot handle "+element.getClass()+ " "+element); 222 return null; 223 } 224 } 225 226 public String getResult() { 227 return result; 228 } 229 230 public String getErrorLog() { 231 return sb.toString(); 232 } 233 234 protected Object eval(CtLiteral literal, int lvl) { 235 return literal.getValue(); 236 } 237 238 protected Object eval(CtFieldRead frr, int lvl) { 239 CtFieldReference fr = frr.getVariable(); 240 String d = ""; 241 if (fr.isFinal()) { 242 d += "final "; 243 } 244 if (fr.isStatic()) { 245 d += "static "; 246 } 247 log(" getKey qualified name - "+fr.getQualifiedName()); 248 CtField fld = fr.getDeclaration(); 249 if (fr.isFinal() && fr.isStatic() && fld != null) { 250 CtExpression def = fld.getDefaultExpression(); 251 if (def == null) throw new AssertionError(); 252 log(" getKey default expression: "+def.getClass()); 253 return this.evalWrk(def, lvl); 254 } 255 log(" getKey result: "+d+" "+fld); 256 return null; 257 } 258 259 protected Object eval(CtVariableRead vr, int lvl) { 260 CtVariableReference vref = vr.getVariable(); 261 CtVariable var = vref.getDeclaration(); 262 if (!var.getModifiers().contains(ModifierKind.FINAL)) { 263 log("non-final variable: "+var.getSimpleName()); 264 return null; 265 } 266 CtExpression def = var.getDefaultExpression(); 267 if (def == null) { 268 log("no initializer for variable: "+var.getSimpleName()); 269 return null; 270 } 271 return evalWrk(def, lvl); 272 } 273 274 protected Object eval(CtUnaryOperator uo, int lvl) { 275 if (uo.getKind() != UnaryOperatorKind.NEG) { 276 log("cannot handle unary operator: "+uo.getKind()); 277 return null; 278 } 279 Object arg = evalWrk(uo.getOperand(), lvl); 280 if (arg == null) return null; 281 if (arg instanceof Integer) { 282 return - ((Integer) arg); 283 } else if (arg instanceof Long) { 284 return - ((Long) arg); 285 } else if (arg instanceof Float) { 286 return - ((Float) arg); 287 } else if (arg instanceof Double) { 288 return - ((Double) arg); 289 } else { 290 log("cannot handle type "+arg.getClass()+" of value "+arg); 291 return null; 292 } 293 } 294 295 protected Object eval(CtBinaryOperator bo, int lvl) { 296 if (bo.getKind() != BinaryOperatorKind.PLUS) { 297 log("cannot handle binary operator: "+bo.getKind()); 298 return null; 299 } 300 Object left = evalWrk(bo.getLeftHandOperand(), lvl); 301 if (left != null && left instanceof String) { 302 Object right = evalWrk(bo.getRightHandOperand(), lvl); 303 if (right != null && right instanceof String) { 304 return ((String) left) + ((String) right); 305 } 306 } 307 return null; 308 } 309 310 protected Object eval(CtInvocation inv, int lvl) { 311 if (inv.toString().equals("(getClass().getName())")) { 312 return determineClass(inv).getCanonicalName(); 313 } 314 CtExecutableReference eref = inv.getExecutable(); 315 Method m = eref.getActualMethod(); 316 if (marktr.equals(m)) { 317 List<CtExpression<?>> args = inv.getArguments(); 318 CtExpression arg = args.get(0); 319 return this.evalWrk(arg, lvl); 320 } 321 log("cannot handle CtInvocation: "+inv); 322 return null; 323 } 324 325 protected void log(String msg) { 326 sb.append(msg + "\n"); 327 } 328 } 329 } -
build.xml
Property changes on: scripts/PreferencesCollector.java ___________________________________________________________________ Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property
22 22 <property name="dist.dir" location="${base.dir}/dist"/> 23 23 <property name="javacc.home" location="${base.dir}/tools"/> 24 24 <property name="mapcss.dir" location="${src.dir}/org/openstreetmap/josm/gui/mappaint/mapcss"/> 25 <property name=" proj-build.dir" location="${base.dir}/build2"/>25 <property name="build-phase2.dir" location="${base.dir}/build2"/> 26 26 <property name="epsg.output" location="${base.dir}/data/projection/custom-epsg"/> 27 <property name="einstein.output" location="${base.dir}/data/preferences-available.xml"/> 27 28 <property name="groovy.jar" location="${base.dir}/tools/groovy-all-2.4.8.jar"/> 28 29 <property name="error_prone_ant.jar" location="${base.dir}/tools/error_prone_ant-2.0.18.jar"/> 29 30 <property name="javac.compiler" value="com.google.errorprone.ErrorProneAntCompilerAdapter" /> … … 354 355 </target> 355 356 <target name="clean" depends="init-properties"> 356 357 <delete dir="${build.dir}"/> 357 <delete dir="${ proj-build.dir}"/>358 <delete dir="${build-phase2.dir}"/> 358 359 <delete dir="${dist.dir}"/> 359 360 <delete dir="${mapcss.dir}/parsergen"/> 360 361 <delete file="${src.dir}/org/w3/_2001/xmlschema/Adapter1.java"/> 361 362 <delete dir="${src.dir}/org/openstreetmap/josm/data/imagery/types"/> 362 363 <delete file="${epsg.output}"/> 364 <delete file="${einstein.output}"/> 363 365 </target> 364 366 <macrodef name="init-test-preferences"> 365 367 <attribute name="testfamily"/> … … 790 792 --> 791 793 <target name="epsg-compile" depends="init-properties"> 792 794 <property name="proj-classpath" location="${build.dir}"/> 793 <mkdir dir="${ proj-build.dir}"/>794 <javac sourcepath="" srcdir="${base.dir}/scripts" failonerror="true"795 destdir="${ proj-build.dir}" target="1.8" source="1.8" debug="on"795 <mkdir dir="${build-phase2.dir}"/> 796 <javac sourcepath="" srcdir="${base.dir}/scripts" includes="BuildProjectionDefinitions.java" failonerror="true" 797 destdir="${build-phase2.dir}" target="1.8" source="1.8" debug="on" 796 798 includeantruntime="false" createMissingPackageInfoClass="false" 797 799 encoding="UTF-8" classpath="${proj-classpath}"> 798 800 </javac> … … 807 809 <classpath> 808 810 <pathelement path="${base.dir}"/> 809 811 <pathelement path="${proj-classpath}"/> 810 <pathelement path="${ proj-build.dir}"/>812 <pathelement path="${build-phase2.dir}"/> 811 813 </classpath> 812 814 <arg value="${base.dir}"/> 813 815 </java> 814 816 </target> 817 <target name="einstein-compile" depends="init-properties"> 818 <mkdir dir="${build-phase2.dir}"/> 819 <javac sourcepath="" srcdir="${base.dir}/scripts" failonerror="true" 820 destdir="${build-phase2.dir}" target="1.8" source="1.8" debug="on" 821 includeantruntime="false" createMissingPackageInfoClass="false" 822 encoding="UTF-8"> 823 <classpath> 824 <pathelement path="${base.dir}/tools/spoon-core-5.5.0-jar-with-dependencies.jar"/> 825 <pathelement path="${build.dir}"/> 826 </classpath> 827 </javac> 828 </target> 829 <target name="einstein" depends="einstein-compile"> 830 <touch file="${einstein.output}"/> 831 <java classname="PreferencesCollector" failonerror="true" fork="true"> 832 <sysproperty key="java.awt.headless" value="true"/> 833 <classpath> 834 <pathelement path="${base.dir}/tools/spoon-core-5.5.0-jar-with-dependencies.jar"/> 835 <pathelement path="${build.dir}"/> 836 <pathelement path="${build-phase2.dir}"/> 837 </classpath> 838 <arg value="${base.dir}"/> 839 </java> 840 </target> 815 841 </project>