Changeset 8581


Ignore:
Timestamp:
02/16/05 11:22:31 (16 years ago)
Author:
piso
Message:

indentRescue()

File:
1 edited

Legend:

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

    r2 r8581  
    44 * Copyright (C) 2002 Jens Luedicke <jens@irs-net.com>
    55 * based on PythonIndenter.java
    6  * $Id: RubyIndenter.java,v 1.1.1.1 2002-09-24 16:08:22 piso Exp $
     6 * Copyright (C) 2005 Peter Graves
     7 * $Id: RubyIndenter.java,v 1.2 2005-02-16 11:22:31 piso Exp $
    78 *
    89 * This program is free software; you can redistribute it and/or
     
    4748        if (lineFirst.equals("end"))
    4849            return indentEnd();
     50        if (lineFirst.equals("rescue"))
     51            return indentRescue();
    4952        final Line model = findModel(line);
    5053        if (model == null)
     
    6265        final String[] indentAfter = {
    6366            "begin", "class", "def", "if", "else", "elsif",
    64             "for", "module", "unless", "when", "while"
     67            "for", "module", "rescue", "unless", "when", "while"
    6568        };
    6669        if (Utilities.isOneOf(modelFirst, indentAfter))
     
    112115    }
    113116
     117    private int indentRescue()
     118    {
     119        for (Line model = line.previous(); model != null; model = model.previous()) {
     120            if (model.isBlank() || model.trim().startsWith("#"))
     121                continue;
     122            String modelFirst = getFirstIdentifier(model);
     123            if (modelFirst.equals("begin"))
     124                return buffer.getIndentation(model);
     125            return Math.max(buffer.getIndentation(model) - indentSize, 0);
     126        }
     127        return 0;
     128    }
     129
    114130    // Return last non-blank line before this one.
    115131    private static Line findModel(Line line)
Note: See TracChangeset for help on using the changeset viewer.