Changeset 226


Ignore:
Timestamp:
11/10/02 01:07:02 (21 years ago)
Author:
piso
Message:

checkForExplicitTag()

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/j/src/org/armedbear/j/JavaTagger.java

    r216 r226  
    33 *
    44 * Copyright (C) 1998-2002 Peter Graves
    5  * $Id: JavaTagger.java,v 1.2 2002-11-09 18:17:21 piso Exp $
     5 * $Id: JavaTagger.java,v 1.3 2002-11-10 01:07:02 piso Exp $
    66 *
    77 * This program is free software; you can redistribute it and/or
     
    307307    }
    308308
    309     protected static final void skipSingleLineComment(Position pos)
    310     {
     309    protected final void skipSingleLineComment(Position pos)
     310    {
     311        checkForExplicitTag(pos);
    311312        Line next = pos.getNextLine();
    312313        if (next != null)
     
    314315        else
    315316            pos.setOffset(pos.getLineLength());
     317    }
     318
     319    private final void checkForExplicitTag(Position pos)
     320    {
     321        if (tags == null)
     322            return; // Only supported for Java and JavaScript for now.
     323        final String explicitTag =
     324            Editor.preferences().getStringProperty(Property.EXPLICIT_TAG);
     325        if (explicitTag != null && explicitTag.length() > 0) {
     326            pos = pos.copy();
     327            String s = pos.getString(); // Substring to end of line.
     328            int index = s.indexOf(explicitTag);
     329            if (index >= 0) {
     330                pos.skip(index + explicitTag.length());
     331                pos.skipWhitespace();
     332                // Now we're looking at the first character of the tag.
     333                String tag;
     334                if (pos.getChar() == '"') {
     335                    FastStringBuffer sb = new FastStringBuffer();
     336                    while (pos.next()) {
     337                        char c = pos.getChar();
     338                        if (c == '"')
     339                            break;
     340                        sb.append(c);
     341                    }
     342                    tag = sb.toString();
     343                } else {
     344                    Mode mode = buffer.getMode();
     345                    if (mode == null)
     346                        mode = JavaMode.getMode();
     347                    tag = pos.getIdentifier(mode);
     348                }
     349                pos.setOffset(0);
     350                pos.skipWhitespace();
     351                if (pos.lookingAt("//") && pos.getNextLine() != null) {
     352                    pos.moveTo(pos.getNextLine(), 0);
     353                    pos.skipWhitespace();
     354                }
     355                tags.add(new JavaTag(tag, pos, TAG_EXPLICIT, 0, currentClass));
     356            }
     357        }
    316358    }
    317359
Note: See TracChangeset for help on using the changeset viewer.