Changeset 8694 in osm for applications/editors


Ignore:
Timestamp:
2008-07-03T18:04:39+02:00 (16 years ago)
Author:
stoecker
Message:

added some more key checks (including keys with spaces inside)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • applications/editors/josm/plugins/validator/src/org/openstreetmap/josm/plugins/validator/tests/SpellCheck.java

    r6387 r8694  
    215215                checkPrimitive(w);
    216216        }
    217        
     217
    218218        /**
    219219         * Checks the spelling of the primitive properties
     
    223223        {
    224224            // Just a collection to know if a primitive has been already marked with error
    225         Bag<OsmPrimitive, String> withErrors = new Bag<OsmPrimitive, String>();
    226        
    227         Map<String, String> props = (p.keys == null) ? Collections.<String, String>emptyMap() : p.keys;
     225                Bag<OsmPrimitive, String> withErrors = new Bag<OsmPrimitive, String>();
     226
     227                Map<String, String> props = (p.keys == null) ? Collections.<String, String>emptyMap() : p.keys;
    228228                for(Entry<String, String> prop: props.entrySet() )
    229229                {
     
    237237                        if( checkKeys && spellCheckKeyData.containsKey(key) && !withErrors.contains(p, "IPK"))
    238238                        {
    239                                 errors.add( new TestError(this, Severity.WARNING, tr("Invalid property keys"), p, INVALID_KEY) );
     239                                errors.add( new TestError(this, Severity.WARNING, tr("Invalid property key ''{0}''", key), p, INVALID_KEY) );
    240240                                withErrors.add(p, "IPK");
    241241                        }
    242             if( checkValues && value != null && value.length() > 0 && spellCheckValueData != null)
    243             {
    244                 List<String> values = spellCheckValueData.get(key);
    245                 if( values != null && !values.contains(prop.getValue()) && !withErrors.contains(p, "UPV"))
    246                 {
    247                     errors.add( new TestError(this, Severity.OTHER, tr("Unknown property values"), p, INVALID_VALUE) );
    248                     withErrors.add(p, "UPV");
    249                 }
    250             }
    251             if( checkFixmes && value != null && value.length() > 0 )
    252             {
    253                 if( (value.contains("FIXME") || key.contains("todo") || key.contains("fixme"))
    254                                   && !withErrors.contains(p, "FIXME"))
    255                 {
    256                     errors.add( new TestError(this, Severity.OTHER, tr("FIXMES"), p, FIXME) );
    257                     withErrors.add(p, "FIXME");
    258                 }
    259             }
    260                 }
    261         }
    262        
     242                        if( checkKeys && key.indexOf(" ") >= 0 && !withErrors.contains(p, "IPK"))
     243                        {
     244                                errors.add( new TestError(this, Severity.WARNING, tr("Invalid white space in property key ''{0}''", key), p, INVALID_KEY) );
     245                                withErrors.add(p, "IPK");
     246                        }
     247                        if( checkValues && value != null && (value.startsWith(" ") || value.endsWith(" ")) && !withErrors.contains(p, "SPACE"))
     248                        {
     249                                errors.add( new TestError(this, Severity.OTHER, tr("Property values start or end with white space"), p, INVALID_VALUE) );
     250                                withErrors.add(p, "SPACE");
     251                        }
     252                        if( checkValues && value != null && value.length() > 0 && spellCheckValueData != null)
     253                        {
     254                                List<String> values = spellCheckValueData.get(key);
     255                                if( values != null && !values.contains(prop.getValue()) && !withErrors.contains(p, "UPV"))
     256                                {
     257                                        errors.add( new TestError(this, Severity.OTHER, tr("Unknown property values"), p, INVALID_VALUE) );
     258                                        withErrors.add(p, "UPV");
     259                                }
     260                        }
     261                        if( checkFixmes && value != null && value.length() > 0 )
     262                        {
     263                                if( (value.contains("FIXME") || value.contains("check and delete") || key.contains("todo") || key.contains("fixme"))
     264                                && !withErrors.contains(p, "FIXME"))
     265                                {
     266                                        errors.add( new TestError(this, Severity.OTHER, tr("FIXMES"), p, FIXME) );
     267                                        withErrors.add(p, "FIXME");
     268                                }
     269                        }
     270                }
     271        }
     272
    263273        /**
    264274         * Parse an anotation preset from a stream
Note: See TracChangeset for help on using the changeset viewer.