1 11 package org.eclipse.jface.text; 12 13 import org.eclipse.core.runtime.Assert; 14 15 16 28 public class ConfigurableLineTracker extends AbstractLineTracker { 29 30 31 32 private String [] fDelimiters; 33 34 private DelimiterInfo fDelimiterInfo= new DelimiterInfo(); 35 36 37 43 public ConfigurableLineTracker(String [] legalLineDelimiters) { 44 Assert.isTrue(legalLineDelimiters != null && legalLineDelimiters.length > 0); 45 fDelimiters= TextUtilities.copy(legalLineDelimiters); 46 } 47 48 51 public String [] getLegalLineDelimiters() { 52 return TextUtilities.copy(fDelimiters); 53 } 54 55 58 protected DelimiterInfo nextDelimiterInfo(String text, int offset) { 59 if (fDelimiters.length > 1) { 60 int[] info= TextUtilities.indexOf(fDelimiters, text, offset); 61 if (info[0] == -1) 62 return null; 63 fDelimiterInfo.delimiterIndex= info[0]; 64 fDelimiterInfo.delimiter= fDelimiters[info[1]]; 65 } else { 66 int index= text.indexOf(fDelimiters[0], offset); 67 if (index == -1) 68 return null; 69 fDelimiterInfo.delimiterIndex= index; 70 fDelimiterInfo.delimiter= fDelimiters[0]; 71 } 72 73 fDelimiterInfo.delimiterLength= fDelimiterInfo.delimiter.length(); 74 return fDelimiterInfo; 75 } 76 } 77 | Popular Tags |