Ignore:
Timestamp:
13.02.2010 17:05:37 (2 years ago)
Author:
jttt
Message:

Fix #4519 JOSM doesn't show nor find token (negative) IDs

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/actions/search/PushbackTokenizer.java

    r2863 r2973  
    1515    private Token currentToken; 
    1616    private String currentText; 
     17    private long currentNumber; 
    1718    private int c; 
    1819 
     
    2526        NOT(marktr("<not>")), OR(marktr("<or>")), LEFT_PARENT(marktr("<left parent>")), 
    2627        RIGHT_PARENT(marktr("<right parent>")), COLON(marktr("<colon>")), EQUALS(marktr("<equals>")), 
    27         KEY(marktr("<key>")), QUESTION_MARK(marktr("<question mark>")), EOF(marktr("<end-of-file>")); 
     28        KEY(marktr("<key>")), QUESTION_MARK(marktr("<question mark>")), NUMBER(marktr("<number>")), 
     29        EOF(marktr("<end-of-file>")); 
    2830 
    2931        private Token(String name) { 
     
    4648            throw new RuntimeException(e.getMessage(), e); 
    4749        } 
     50    } 
     51 
     52    private long getNumber() { 
     53        long result = 0; 
     54        while (Character.isDigit(c)) { 
     55            result = result * 10 + (c - '0'); 
     56            getChar(); 
     57        } 
     58        return result; 
    4859    } 
    4960 
     
    7889        case '-': 
    7990            getChar(); 
    80             return Token.NOT; 
     91            if (Character.isDigit(c)) { 
     92                currentNumber = -1 * getNumber(); 
     93                return Token.NUMBER; 
     94            } else 
     95                return Token.NOT; 
    8196        case '(': 
    8297            getChar(); 
     
    111126        default: 
    112127        { 
     128            if (Character.isDigit(c)) { 
     129                currentNumber = getNumber(); 
     130                return Token.NUMBER; 
     131            } 
     132 
    113133            StringBuilder s = new StringBuilder(); 
    114134            while (!(c == -1 || Character.isWhitespace(c) || c == '"'|| c == ':' || c == '(' || c == ')' || c == '|' || c == '=' || c == '?')) { 
     
    149169    } 
    150170 
     171    public long readNumber(String errorMessage) throws ParseError { 
     172        if (nextToken() == Token.NUMBER) 
     173            return currentNumber; 
     174        else 
     175            throw new ParseError(errorMessage); 
     176    } 
     177 
    151178    public String getText() { 
    152179        return currentText; 
Note: See TracChangeset for help on using the changeset viewer.