To: vim-dev@vim.org Subject: Patch 6.1a.026 Fcc: outbox From: Bram Moolenaar MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit ------------ Patch 6.1a.026 Problem: Indenting Java files is wrong with "throws", "extends" and "implements" clauses. Solution: Update the Java indent script. Files: runtime/indent/java.vim *** ../vim61a.025/runtime/indent/java.vim Mon Jun 18 14:32:48 2001 --- runtime/indent/java.vim Thu Feb 28 19:46:29 2002 *************** *** 1,7 **** " Vim indent file " Language: Java " Maintainer: Bram Moolenaar ! " Last Change: 2001 Jun 18 " Only load this indent file when no other was loaded. if exists("b:did_indent") --- 1,7 ---- " Vim indent file " Language: Java " Maintainer: Bram Moolenaar ! " Last Change: 2002 Feb 28 " Only load this indent file when no other was loaded. if exists("b:did_indent") *************** *** 9,16 **** endif let b:did_indent = 1 - " Java is just like C, use the built-in C indenting. - setlocal cindent - " Indent Java anonymous classes correctly. ! setlocal cinoptions+=j1 --- 9,75 ---- endif let b:did_indent = 1 " Indent Java anonymous classes correctly. ! setlocal cinoptions& cinoptions+=j1 ! ! " The "extends" and "implements" lines start off with the wrong indent. ! setlocal indentkeys& indentkeys+=0=extends indentkeys+=0=implements ! ! " Set the function to do the work. ! setlocal indentexpr=GetJavaIndent() ! ! " Only define the function once. ! if exists("*GetJavaIndent") ! finish ! endif ! ! function GetJavaIndent() ! ! " Java is just like C; use the built-in C indenting and then correct a few ! " specific cases. ! let theIndent = cindent(v:lnum) ! ! " find start of previous line, in case it was a continuation line ! let prev = v:lnum - 1 ! while prev > 1 ! if getline(prev - 1) !~ ',\s*$' ! break ! endif ! let prev = prev - 1 ! endwhile ! ! " Try to align "throws" lines for methods and "extends" and "implements" for ! " classes. ! if getline(v:lnum) =~ '^\s*\(extends\|implements\)\>' ! \ && getline(prev) !~ '^\s*\(extends\|implements\)\>' ! let theIndent = theIndent + &sw ! endif ! ! " correct for continuation lines of "throws" and "implements" ! if getline(prev) =~ '^\s*\(throws\|implements\)\>.*,\s*$' ! if getline(prev) =~ '^\s*throws' ! let amount = &sw + 7 " add length of 'throws ' ! else ! let amount = 11 " length of 'implements'. ! endif ! if getline(v:lnum - 1) !~ ',\s*$' ! let theIndent = theIndent - amount ! if theIndent < 0 ! let theIndent = 0 ! endif ! elseif prev == v:lnum - 1 ! let theIndent = theIndent + amount ! endif ! elseif getline(v:lnum - 1) =~ '^\s*throws\>' ! let theIndent = theIndent - &sw ! endif ! ! " Below a line starting with "}" never indent more. Needed for a method ! " below a method with an indented "throws" clause. ! let lnum = prevnonblank(v:lnum - 1) ! if getline(lnum) =~ '^\s*}\s*\(//.*\|/\*.*\)\=$' && indent(lnum) < theIndent ! let theIndent = indent(lnum) ! endif ! ! return theIndent ! endfunction *** ../vim61a.025/src/version.c Mon Mar 4 20:36:58 2002 --- src/version.c Mon Mar 4 20:41:24 2002 *************** *** 608,609 **** --- 608,611 ---- { /* Add new patch number below this line */ + /**/ + 26, /**/ -- hundred-and-one symptoms of being an internet addict: 129. You cancel your newspaper subscription. /// Bram Moolenaar -- Bram@moolenaar.net -- http://www.moolenaar.net \\\ /// Creator of Vim -- http://vim.sf.net -- ftp://ftp.vim.org/pub/vim \\\ \\\ Project leader for A-A-P -- http://www.a-a-p.org /// \\\ Help me helping AIDS orphans in Uganda - http://iccf-holland.org ///