|
Link Here
|
| 24 |
import org.eclipse.jface.text.ITypedRegion; |
24 |
import org.eclipse.jface.text.ITypedRegion; |
| 25 |
import org.eclipse.jface.text.Region; |
25 |
import org.eclipse.jface.text.Region; |
| 26 |
import org.eclipse.jface.text.TextUtilities; |
26 |
import org.eclipse.jface.text.TextUtilities; |
|
|
27 |
import org.eclipse.jface.text.TextViewer; |
| 27 |
import org.eclipse.jface.text.source.ISourceViewer; |
28 |
import org.eclipse.jface.text.source.ISourceViewer; |
| 28 |
import org.eclipse.jface.text.source.SourceViewerConfiguration; |
29 |
import org.eclipse.jface.text.source.SourceViewerConfiguration; |
| 29 |
import org.eclipse.jface.viewers.ISelection; |
30 |
import org.eclipse.jface.viewers.ISelection; |
|
Link Here
|
| 173 |
* Creates a region describing the text block (something that starts at |
174 |
* Creates a region describing the text block (something that starts at |
| 174 |
* the beginning of a line) completely containing the current selection. |
175 |
* the beginning of a line) completely containing the current selection. |
| 175 |
* |
176 |
* |
|
|
177 |
* Note, the implementation has to match {@link TextViewer}.getTextBlockFromSelection(). |
| 178 |
* |
| 176 |
* @param selection The selection to use |
179 |
* @param selection The selection to use |
| 177 |
* @param document The document |
180 |
* @param document The document |
| 178 |
* @return the region describing the text block comprising the given selection |
181 |
* @return the region describing the text block comprising the given selection |
| 179 |
*/ |
182 |
*/ |
| 180 |
private IRegion getTextBlockFromSelection(ITextSelection selection, IDocument document) { |
183 |
private IRegion getTextBlockFromSelection(ITextSelection selection, IDocument document) { |
| 181 |
try { |
184 |
try { |
| 182 |
IRegion line= document.getLineInformationOfOffset(selection.getOffset()); |
185 |
// Until https://bugs.eclipse.org/bugs/show_bug.cgi?id=325438 is fixed, work around it |
| 183 |
int length= selection.getLength() == 0 ? |
186 |
int start= document.getLineOffset(selection.getStartLine()); |
| 184 |
line.getLength() : selection.getLength() + (selection.getOffset() - line.getOffset()); |
187 |
int endLine= selection.getEndLine(); |
| 185 |
return new Region(line.getOffset(), length); |
188 |
IRegion endLineInfo= document.getLineInformation(endLine); |
|
|
189 |
int end= endLineInfo.getOffset() + endLineInfo.getLength(); |
| 190 |
return new Region(start, end - start); |
| 191 |
|
| 192 |
// IRegion line= document.getLineInformationOfOffset(selection.getOffset()); |
| 193 |
// int length= selection.getLength() == 0 ? |
| 194 |
// line.getLength() : selection.getLength() + (selection.getOffset() - line.getOffset()); |
| 195 |
// return new Region(line.getOffset(), length); |
| 186 |
|
196 |
|
| 187 |
} catch (BadLocationException e) { |
197 |
} catch (BadLocationException e) { |
| 188 |
CUIPlugin.log(e); // Should not happen |
198 |
CUIPlugin.log(e); // Should not happen |
|
Link Here
|
| 298 |
|
308 |
|
| 299 |
String[] types= configuration.getConfiguredContentTypes(sourceViewer); |
309 |
String[] types= configuration.getConfiguredContentTypes(sourceViewer); |
| 300 |
Map<String, String[]> prefixesMap= new HashMap<String, String[]>(types.length); |
310 |
Map<String, String[]> prefixesMap= new HashMap<String, String[]>(types.length); |
| 301 |
for (int i= 0; i < types.length; i++) { |
311 |
for (String type : types) { |
| 302 |
String type= types[i]; |
|
|
| 303 |
String[] prefixes= configuration.getDefaultPrefixes(sourceViewer, type); |
312 |
String[] prefixes= configuration.getDefaultPrefixes(sourceViewer, type); |
| 304 |
if (prefixes != null && prefixes.length > 0) { |
313 |
if (prefixes != null && prefixes.length > 0) { |
| 305 |
int emptyPrefixes= 0; |
314 |
int emptyPrefixes= 0; |
| 306 |
for (int j= 0; j < prefixes.length; j++) { |
315 |
for (String prefixe : prefixes) { |
| 307 |
if (prefixes[j].length() == 0) |
316 |
if (prefixe.length() == 0) |
| 308 |
emptyPrefixes++; |
317 |
emptyPrefixes++; |
| 309 |
} |
318 |
} |
| 310 |
|
319 |
|