~ubuntu-branches/ubuntu/lucid/jedit/lucid

« back to all changes in this revision

Viewing changes to jEdit/macros/Java/Java_File_Save.bsh

  • Committer: Bazaar Package Importer
  • Author(s): Daniel Hahler
  • Date: 2008-03-18 22:18:17 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20080318221817-8pvhmkoy8nkdghy2
Tags: 4.3~pre13.dfsg-0ubuntu1
* New upstream bugfix release (LP: #203713)
* debian/control, debian/rules:
  replace icedtea-java7 references with openjdk-6 references (LP: #203636)
* Reworked (and renamed) patches:
  - 01-debian-menu-file.patch: partly applied upstream
  - 02-desktop-file-icon-file.patch: incorporate previous inline change
    (icon path)
* 03-svn-php_mode_fix_special_comment.patch: Fix regression for special
  comments ("/**/") in PHP mode; can be dropped with the next release.

Show diffs side-by-side

added added

removed removed

Lines of Context:
32
32
 *  08-Jun-04: If an infinite loop is hit (1000 iterations) in the comment
33
33
 *           : parsing, it now opens the default save dialog, rather than
34
34
 *           : just returning.
35
 
 * $Id: Java_File_Save.bsh 5066 2004-06-26 19:10:58Z spestov $
 
35
 * $Id: Java_File_Save.bsh 12063 2008-03-02 06:58:51Z k_satoda $
36
36
 */
37
37
 
38
38
 
51
51
      
52
52
      // At most, check the first 250 lines - this sounds reasonable to me
53
53
      int maxLine = Math.min(buffer.getLineCount(),250);
54
 
      import gnu.regexp.RE;
55
 
      import gnu.regexp.REMatch;
 
54
      import java.util.regex.Pattern;
 
55
      import java.util.regex.Matcher;
56
56
      // Build the regex - based on the offical java language spec.
57
 
      RE regex = new RE("^\\s*(public|protected|private|static|abstract|final|native|synchronized|transient|volatile|strictfp)?\\s*(class|interface)\\s*([^ {/]*)");
58
 
      int regexMinimum = regex.getMinimumLength();
 
57
      Pattern regex = Pattern.compile("^\\s*(public|protected|private|static|abstract|final|native|synchronized|transient|volatile|strictfp)?\\s*(class|interface)\\s*([^ {/]*)");
59
58
      boolean inComment = false;
60
59
      for(int i=0;i<maxLine;i++)
61
60
      {
105
104
                        // We now know if the remainder of the line is in a comment or not
106
105
         if (!inComment)
107
106
         {
108
 
            // Ignore lines that are too short for the regex
109
 
            if (txt.length() < regexMinimum)
110
 
               continue;
111
 
            REMatch match = regex.getMatch(txt);
112
 
            // See if it matches
113
 
            if (match!=null)
 
107
            Matcher matcher = regex.matcher(txt);
 
108
            if (matcher.matches())
114
109
            {
115
 
               int startIndex = match.getStartIndex(3);
116
 
               int endIndex = match.getEndIndex(3);
117
110
               // Extract the class/interface name
118
 
               name = txt.substring(startIndex,endIndex)+".java";
 
111
               name = matcher.group(3)+".java";
119
112
               break;
120
113
            }
121
114
         }