Lines 34-39
Link Here
|
34 |
import org.eclipse.jface.text.Region; |
34 |
import org.eclipse.jface.text.Region; |
35 |
import org.eclipse.jface.text.TextSelection; |
35 |
import org.eclipse.jface.text.TextSelection; |
36 |
import org.eclipse.jface.text.source.Annotation; |
36 |
import org.eclipse.jface.text.source.Annotation; |
|
|
37 |
import org.eclipse.jface.text.source.projection.IProjectionAnnotationTitled; |
37 |
import org.eclipse.jface.text.source.projection.IProjectionListener; |
38 |
import org.eclipse.jface.text.source.projection.IProjectionListener; |
38 |
import org.eclipse.jface.text.source.projection.IProjectionPosition; |
39 |
import org.eclipse.jface.text.source.projection.IProjectionPosition; |
39 |
import org.eclipse.jface.text.source.projection.ProjectionAnnotation; |
40 |
import org.eclipse.jface.text.source.projection.ProjectionAnnotation; |
Lines 65-70
Link Here
|
65 |
import org.eclipse.jdt.core.compiler.InvalidInputException; |
66 |
import org.eclipse.jdt.core.compiler.InvalidInputException; |
66 |
import org.eclipse.jdt.core.dom.CompilationUnit; |
67 |
import org.eclipse.jdt.core.dom.CompilationUnit; |
67 |
|
68 |
|
|
|
69 |
import org.eclipse.jdt.internal.core.util.PublicScanner.TitledRegionStruct; |
70 |
|
68 |
import org.eclipse.jdt.internal.corext.SourceRange; |
71 |
import org.eclipse.jdt.internal.corext.SourceRange; |
69 |
|
72 |
|
70 |
import org.eclipse.jdt.ui.PreferenceConstants; |
73 |
import org.eclipse.jdt.ui.PreferenceConstants; |
Lines 177-182
Link Here
|
177 |
public void addProjectionRange(JavaProjectionAnnotation annotation, Position position) { |
180 |
public void addProjectionRange(JavaProjectionAnnotation annotation, Position position) { |
178 |
fMap.put(annotation, position); |
181 |
fMap.put(annotation, position); |
179 |
} |
182 |
} |
|
|
183 |
|
184 |
/** |
185 |
* Returns the saved positions. |
186 |
* |
187 |
* @return the saved positions. |
188 |
*/ |
189 |
public Collection getPositions() { |
190 |
return fMap.values(); |
191 |
} |
180 |
|
192 |
|
181 |
/** |
193 |
/** |
182 |
* Returns <code>true</code> if header comments should be collapsed. |
194 |
* Returns <code>true</code> if header comments should be collapsed. |
Lines 222-236
Link Here
|
222 |
public boolean collapseMembers() { |
234 |
public boolean collapseMembers() { |
223 |
return fAllowCollapsing && fCollapseMembers; |
235 |
return fAllowCollapsing && fCollapseMembers; |
224 |
} |
236 |
} |
|
|
237 |
|
238 |
/** |
239 |
* Returns <code>true</code> if regions should be collapsed. |
240 |
* |
241 |
* @return <code>true</code> if regions should be collapsed |
242 |
*/ |
243 |
public boolean collapseRegions() { |
244 |
return fAllowCollapsing && fCollapseRegions; |
245 |
} |
225 |
} |
246 |
} |
226 |
|
247 |
|
227 |
/** |
248 |
/** |
228 |
* A {@link ProjectionAnnotation} for java code. |
249 |
* A {@link ProjectionAnnotation} for java code. |
229 |
*/ |
250 |
*/ |
230 |
protected static final class JavaProjectionAnnotation extends ProjectionAnnotation { |
251 |
protected static final class JavaProjectionAnnotation extends ProjectionAnnotation |
|
|
252 |
implements IProjectionAnnotationTitled { |
231 |
|
253 |
|
232 |
private IJavaElement fJavaElement; |
254 |
private IJavaElement fJavaElement; |
233 |
private boolean fIsComment; |
255 |
private boolean fIsComment; |
|
|
256 |
private boolean fIsRegion; |
257 |
private String fTitle; |
234 |
|
258 |
|
235 |
/** |
259 |
/** |
236 |
* Creates a new projection annotation. |
260 |
* Creates a new projection annotation. |
Lines 239-250
Link Here
|
239 |
* <code>false</code> to set it to expanded |
263 |
* <code>false</code> to set it to expanded |
240 |
* @param element the java element this annotation refers to |
264 |
* @param element the java element this annotation refers to |
241 |
* @param isComment <code>true</code> for a foldable comment, <code>false</code> for a |
265 |
* @param isComment <code>true</code> for a foldable comment, <code>false</code> for a |
242 |
* foldable code element |
266 |
* foldable code element. Must be <code>false</code> for a region. |
|
|
267 |
* @param title title <code>String</code> for a titled foldable region, |
268 |
* <code>null</code> for a non-titled region. |
243 |
*/ |
269 |
*/ |
244 |
public JavaProjectionAnnotation(boolean isCollapsed, IJavaElement element, boolean isComment) { |
270 |
public JavaProjectionAnnotation(boolean isCollapsed, IJavaElement element, |
|
|
271 |
boolean isComment, String title) { |
245 |
super(isCollapsed); |
272 |
super(isCollapsed); |
246 |
fJavaElement= element; |
273 |
fJavaElement= element; |
247 |
fIsComment= isComment; |
274 |
fIsComment= isComment; |
|
|
275 |
fTitle = title; |
276 |
fIsRegion= (fTitle != null); |
277 |
} |
278 |
|
279 |
/** |
280 |
* Creates a new not titled projection annotation. |
281 |
* |
282 |
* @param isCollapsed <code>true</code> to set the initial state to collapsed, |
283 |
* <code>false</code> to set it to expanded |
284 |
* @param element the java element this annotation refers to |
285 |
* @param isComment <code>true</code> for a foldable comment, <code>false</code> for a |
286 |
* foldable code element |
287 |
* @see #JavaProjectionAnnotation(boolean, IJavaElement, boolean, String) |
288 |
*/ |
289 |
public JavaProjectionAnnotation(boolean isCollapsed, IJavaElement element, boolean isComment) { |
290 |
this(isCollapsed, element, isComment, null); |
248 |
} |
291 |
} |
249 |
|
292 |
|
250 |
IJavaElement getElement() { |
293 |
IJavaElement getElement() { |
Lines 263-268
Link Here
|
263 |
fIsComment= isComment; |
306 |
fIsComment= isComment; |
264 |
} |
307 |
} |
265 |
|
308 |
|
|
|
309 |
public boolean isRegion() { |
310 |
return fIsRegion; |
311 |
} |
312 |
|
313 |
public void setIsRegion(boolean isRegion) { |
314 |
fIsRegion= isRegion; |
315 |
} |
316 |
|
317 |
/** |
318 |
* Check if the other <code>JavaProjectionAnnotation</code> |
319 |
* has the same title. |
320 |
* |
321 |
* @param annotation the other JavaProjectionAnnotation |
322 |
* @return if the titels of both objects are equal |
323 |
*/ |
324 |
public boolean equalsTitle(JavaProjectionAnnotation annotation) { |
325 |
if (this.fTitle == null) { |
326 |
return annotation.fTitle == null; |
327 |
} |
328 |
return this.fTitle.equals(annotation.fTitle); |
329 |
} |
330 |
|
266 |
/* |
331 |
/* |
267 |
* @see java.lang.Object#toString() |
332 |
* @see java.lang.Object#toString() |
268 |
*/ |
333 |
*/ |
Lines 270-276
Link Here
|
270 |
return "JavaProjectionAnnotation:\n" + //$NON-NLS-1$ |
335 |
return "JavaProjectionAnnotation:\n" + //$NON-NLS-1$ |
271 |
"\telement: \t"+ fJavaElement.toString() + "\n" + //$NON-NLS-1$ //$NON-NLS-2$ |
336 |
"\telement: \t"+ fJavaElement.toString() + "\n" + //$NON-NLS-1$ //$NON-NLS-2$ |
272 |
"\tcollapsed: \t" + isCollapsed() + "\n" + //$NON-NLS-1$ //$NON-NLS-2$ |
337 |
"\tcollapsed: \t" + isCollapsed() + "\n" + //$NON-NLS-1$ //$NON-NLS-2$ |
273 |
"\tcomment: \t" + isComment() + "\n"; //$NON-NLS-1$ //$NON-NLS-2$ |
338 |
"\tcomment: \t" + isComment() + "\n" + //$NON-NLS-1$ //$NON-NLS-2$ |
|
|
339 |
"\tregion: \t" + isRegion() + "\n"; //$NON-NLS-1$ //$NON-NLS-2$ |
340 |
} |
341 |
|
342 |
/* |
343 |
* (non-Javadoc) |
344 |
* @see java.lang.Object#hashCode() |
345 |
*/ |
346 |
public boolean equals(Object obj) { |
347 |
if (!(obj instanceof JavaProjectionAnnotation)) { |
348 |
return false; |
349 |
} |
350 |
JavaProjectionAnnotation annot = (JavaProjectionAnnotation)obj; |
351 |
return fJavaElement == annot.fJavaElement |
352 |
&& isCollapsed() == annot.isCollapsed() |
353 |
&& isComment() == annot.isComment() |
354 |
&& isRegion() == annot.isRegion() |
355 |
&& equalsTitle(annot); |
356 |
} |
357 |
|
358 |
public String getTitle() { |
359 |
return fTitle; |
360 |
} |
361 |
|
362 |
public void setTitle(String title) { |
363 |
fTitle = title; |
274 |
} |
364 |
} |
275 |
} |
365 |
} |
276 |
|
366 |
|
Lines 308-314
Link Here
|
308 |
*/ |
398 |
*/ |
309 |
private static final class MemberFilter implements Filter { |
399 |
private static final class MemberFilter implements Filter { |
310 |
public boolean match(JavaProjectionAnnotation annotation) { |
400 |
public boolean match(JavaProjectionAnnotation annotation) { |
311 |
if (!annotation.isComment() && !annotation.isMarkedDeleted()) { |
401 |
if (!annotation.isComment() && !annotation.isRegion() && !annotation.isMarkedDeleted()) { |
312 |
IJavaElement element= annotation.getElement(); |
402 |
IJavaElement element= annotation.getElement(); |
313 |
if (element instanceof IMember) { |
403 |
if (element instanceof IMember) { |
314 |
if (element.getElementType() != IJavaElement.TYPE || ((IMember) element).getDeclaringType() != null) { |
404 |
if (element.getElementType() != IJavaElement.TYPE || ((IMember) element).getDeclaringType() != null) { |
Lines 321-326
Link Here
|
321 |
} |
411 |
} |
322 |
|
412 |
|
323 |
/** |
413 |
/** |
|
|
414 |
* Matches regions |
415 |
* |
416 |
* @author jand |
417 |
*/ |
418 |
private static final class RegionFilter implements Filter { |
419 |
public boolean match(JavaProjectionAnnotation annotation) { |
420 |
if (annotation.isRegion() && !annotation.isMarkedDeleted()) { |
421 |
return true; |
422 |
} |
423 |
return false; |
424 |
} |
425 |
} |
426 |
|
427 |
/** |
324 |
* Matches java elements contained in a certain set. |
428 |
* Matches java elements contained in a certain set. |
325 |
*/ |
429 |
*/ |
326 |
private static final class JavaElementSetFilter implements Filter { |
430 |
private static final class JavaElementSetFilter implements Filter { |
Lines 334-340
Link Here
|
334 |
|
438 |
|
335 |
public boolean match(JavaProjectionAnnotation annotation) { |
439 |
public boolean match(JavaProjectionAnnotation annotation) { |
336 |
boolean stateMatch= fMatchCollapsed == annotation.isCollapsed(); |
440 |
boolean stateMatch= fMatchCollapsed == annotation.isCollapsed(); |
337 |
if (stateMatch && !annotation.isComment() && !annotation.isMarkedDeleted()) { |
441 |
if (stateMatch && !annotation.isComment() && !annotation.isMarkedDeleted() |
|
|
442 |
&& !annotation.isRegion()) { |
338 |
IJavaElement element= annotation.getElement(); |
443 |
IJavaElement element= annotation.getElement(); |
339 |
if (fSet.contains(element)) { |
444 |
if (fSet.contains(element)) { |
340 |
return true; |
445 |
return true; |
Lines 551-556
Link Here
|
551 |
} |
656 |
} |
552 |
|
657 |
|
553 |
/** |
658 |
/** |
|
|
659 |
* Projection position that will return one foldable region including the |
660 |
* titled region. |
661 |
*/ |
662 |
private static final class TitledRegionPosition extends Position implements IProjectionPosition { |
663 |
private String fTitle; |
664 |
|
665 |
TitledRegionPosition(String title, int offset, int length) { |
666 |
super(offset, length); |
667 |
fTitle = title; |
668 |
} |
669 |
|
670 |
/* |
671 |
* @see org.eclipse.jface.text.source.projection.IProjectionPosition#computeFoldingRegions(org.eclipse.jface.text.IDocument) |
672 |
*/ |
673 |
public IRegion[] computeProjectionRegions(IDocument document) throws BadLocationException { |
674 |
int firstLine= document.getLineOfOffset(offset + 0); |
675 |
int lastLine= document.getLineOfOffset(offset + length); |
676 |
|
677 |
if (firstLine < lastLine) { |
678 |
int postOffset= document.getLineOffset(firstLine + 1); |
679 |
IRegion postRegion= new Region(postOffset, offset + length - postOffset); |
680 |
return new IRegion[] { postRegion }; |
681 |
} |
682 |
|
683 |
return null; |
684 |
} |
685 |
|
686 |
/* |
687 |
* @see org.eclipse.jface.text.source.projection.IProjectionPosition#computeCaptionOffset(org.eclipse.jface.text.IDocument) |
688 |
*/ |
689 |
public int computeCaptionOffset(IDocument document) { |
690 |
return 0; |
691 |
} |
692 |
} |
693 |
|
694 |
/** |
554 |
* Projection position that will return two foldable regions: one folding away |
695 |
* Projection position that will return two foldable regions: one folding away |
555 |
* the lines before the one containing the simple name of the java element, one |
696 |
* the lines before the one containing the simple name of the java element, one |
556 |
* folding away any lines after the caption. |
697 |
* folding away any lines after the caption. |
Lines 700-711
Link Here
|
700 |
private boolean fCollapseInnerTypes= true; |
841 |
private boolean fCollapseInnerTypes= true; |
701 |
private boolean fCollapseMembers= false; |
842 |
private boolean fCollapseMembers= false; |
702 |
private boolean fCollapseHeaderComments= true; |
843 |
private boolean fCollapseHeaderComments= true; |
|
|
844 |
private boolean fCollapseRegions= true; |
703 |
|
845 |
|
704 |
/* filters */ |
846 |
/* filters */ |
705 |
/** Member filter, matches nested members (but not top-level types). */ |
847 |
/** Member filter, matches nested members (but not top-level types). */ |
706 |
private final Filter fMemberFilter = new MemberFilter(); |
848 |
private final Filter fMemberFilter = new MemberFilter(); |
707 |
/** Comment filter, matches comments. */ |
849 |
/** Comment filter, matches comments. */ |
708 |
private final Filter fCommentFilter = new CommentFilter(); |
850 |
private final Filter fCommentFilter = new CommentFilter(); |
|
|
851 |
/** Region filter, matches regions. */ |
852 |
private final Filter fRegionFilter = new RegionFilter(); |
709 |
|
853 |
|
710 |
/** |
854 |
/** |
711 |
* Reusable scanner. |
855 |
* Reusable scanner. |
Lines 870-875
Link Here
|
870 |
fCollapseJavadoc= store.getBoolean(PreferenceConstants.EDITOR_FOLDING_JAVADOC); |
1014 |
fCollapseJavadoc= store.getBoolean(PreferenceConstants.EDITOR_FOLDING_JAVADOC); |
871 |
fCollapseMembers= store.getBoolean(PreferenceConstants.EDITOR_FOLDING_METHODS); |
1015 |
fCollapseMembers= store.getBoolean(PreferenceConstants.EDITOR_FOLDING_METHODS); |
872 |
fCollapseHeaderComments= store.getBoolean(PreferenceConstants.EDITOR_FOLDING_HEADERS); |
1016 |
fCollapseHeaderComments= store.getBoolean(PreferenceConstants.EDITOR_FOLDING_HEADERS); |
|
|
1017 |
fCollapseRegions= store.getBoolean(PreferenceConstants.EDITOR_FOLDING_REGIONS); |
873 |
} |
1018 |
} |
874 |
|
1019 |
|
875 |
private void update(FoldingStructureComputationContext ctx) { |
1020 |
private void update(FoldingStructureComputationContext ctx) { |
Lines 911-926
Link Here
|
911 |
Tuple tuple= (Tuple) x.next(); |
1056 |
Tuple tuple= (Tuple) x.next(); |
912 |
JavaProjectionAnnotation existingAnnotation= tuple.annotation; |
1057 |
JavaProjectionAnnotation existingAnnotation= tuple.annotation; |
913 |
Position existingPosition= tuple.position; |
1058 |
Position existingPosition= tuple.position; |
914 |
if (newAnnotation.isComment() == existingAnnotation.isComment()) { |
1059 |
if ((newAnnotation.isComment() == existingAnnotation.isComment()) |
|
|
1060 |
&& (newAnnotation.isRegion() == existingAnnotation.isRegion())) { |
915 |
boolean updateCollapsedState= ctx.allowCollapsing() && existingAnnotation.isCollapsed() != newAnnotation.isCollapsed(); |
1061 |
boolean updateCollapsedState= ctx.allowCollapsing() && existingAnnotation.isCollapsed() != newAnnotation.isCollapsed(); |
916 |
if (!isMalformedAnonymousType && existingPosition != null && (!newPosition.equals(existingPosition) || updateCollapsedState)) { |
1062 |
if (!isMalformedAnonymousType |
|
|
1063 |
&& existingPosition != null |
1064 |
&& (!newPosition.equals(existingPosition) || updateCollapsedState |
1065 |
|| !newAnnotation.equalsTitle(existingAnnotation))) { |
917 |
existingPosition.setOffset(newPosition.getOffset()); |
1066 |
existingPosition.setOffset(newPosition.getOffset()); |
918 |
existingPosition.setLength(newPosition.getLength()); |
1067 |
existingPosition.setLength(newPosition.getLength()); |
919 |
if (updateCollapsedState) |
1068 |
existingAnnotation.setTitle(newAnnotation.getTitle()); |
|
|
1069 |
if (updateCollapsedState) { |
920 |
if (newAnnotation.isCollapsed()) |
1070 |
if (newAnnotation.isCollapsed()) |
921 |
existingAnnotation.markCollapsed(); |
1071 |
existingAnnotation.markCollapsed(); |
922 |
else |
1072 |
else |
923 |
existingAnnotation.markExpanded(); |
1073 |
existingAnnotation.markExpanded(); |
|
|
1074 |
} |
924 |
updates.add(existingAnnotation); |
1075 |
updates.add(existingAnnotation); |
925 |
} |
1076 |
} |
926 |
matched= true; |
1077 |
matched= true; |
Lines 963-969
Link Here
|
963 |
return; |
1114 |
return; |
964 |
|
1115 |
|
965 |
ctx.getScanner().setSource(source.toCharArray()); |
1116 |
ctx.getScanner().setSource(source.toCharArray()); |
966 |
computeFoldingStructure(parent.getChildren(), ctx); |
1117 |
IJavaElement[] elements = parent.getChildren(); |
|
|
1118 |
computeFoldingStructure(elements, ctx); |
1119 |
|
1120 |
if (elements.length > 0) { |
1121 |
computeRegionFolding(elements[0], ctx); |
1122 |
} |
967 |
} catch (JavaModelException x) { |
1123 |
} catch (JavaModelException x) { |
968 |
} |
1124 |
} |
969 |
} |
1125 |
} |
Lines 980-985
Link Here
|
980 |
} |
1136 |
} |
981 |
} |
1137 |
} |
982 |
} |
1138 |
} |
|
|
1139 |
|
1140 |
private void computeRegionFolding(IJavaElement element, FoldingStructureComputationContext ctx) { |
1141 |
IScanner scanner = ctx.getScanner(); |
1142 |
try { |
1143 |
scanner.readRegions(); |
1144 |
|
1145 |
// Find all regions |
1146 |
if (scanner.hasRegions()) { |
1147 |
List regionsList = scanner.getRegions(); |
1148 |
int listLen = regionsList.size(); |
1149 |
for (int i=0; i<listLen; i++) { |
1150 |
TitledRegionStruct struct = |
1151 |
(TitledRegionStruct)regionsList.get(i); |
1152 |
int posLen = struct.positionsCount; |
1153 |
int closeLen = struct.closePositionsCount; |
1154 |
for (int j=0; j<posLen; j++) { |
1155 |
if (j >= closeLen) { |
1156 |
// Adding this region nevertheless, to prevent "jumping" regions |
1157 |
addTitledRegion(element, new TitledRegion("", 0, 0), ctx); //$NON-NLS-1$ |
1158 |
} else { |
1159 |
int begin = struct.positions[j][0]; |
1160 |
int end = struct.closePositions[j][1]; |
1161 |
|
1162 |
boolean failed=false; |
1163 |
// Search for overlaps with other regions |
1164 |
Collection positions = ctx.getPositions(); |
1165 |
for (Iterator iterator = positions.iterator(); iterator.hasNext(); ) { |
1166 |
Position position = (Position)iterator.next(); |
1167 |
int positionEnd = position.offset + position.length; |
1168 |
if (position.offset < begin) { |
1169 |
if (positionEnd > begin && positionEnd < end) { |
1170 |
failed=true; |
1171 |
} |
1172 |
} else if (position.offset < end) { |
1173 |
if (positionEnd > end) { |
1174 |
failed=true; |
1175 |
} |
1176 |
} |
1177 |
} |
1178 |
if (failed) { |
1179 |
addTitledRegion(element, new TitledRegion("", 0, 0), ctx); //$NON-NLS-1$ |
1180 |
} else { |
1181 |
addTitledRegion(element, new TitledRegion(struct.getTitle(j), |
1182 |
begin, end-begin), ctx); |
1183 |
} |
1184 |
} |
1185 |
} |
1186 |
} |
1187 |
} |
1188 |
} catch (InvalidInputException e) { |
1189 |
// e.printStackTrace(); |
1190 |
} |
1191 |
} |
1192 |
|
1193 |
private void addTitledRegion(IJavaElement element, TitledRegion region, |
1194 |
FoldingStructureComputationContext ctx) { |
1195 |
IRegion normalized= alignRegion(region, ctx); |
1196 |
if (normalized != null) { |
1197 |
Position position= createTitledPosition(normalized, region.getTitle()); |
1198 |
if (position != null) { |
1199 |
ctx.addProjectionRange(new JavaProjectionAnnotation(ctx.collapseRegions(), |
1200 |
element, false, region.getTitle()), position); |
1201 |
} |
1202 |
} |
1203 |
} |
983 |
|
1204 |
|
984 |
/** |
1205 |
/** |
985 |
* Computes the folding structure for a given {@link IJavaElement java element}. Computed |
1206 |
* Computes the folding structure for a given {@link IJavaElement java element}. Computed |
Lines 1092-1098
Link Here
|
1092 |
* @param ctx the folding context |
1313 |
* @param ctx the folding context |
1093 |
* @return the regions to be folded |
1314 |
* @return the regions to be folded |
1094 |
*/ |
1315 |
*/ |
1095 |
protected final IRegion[] computeProjectionRanges(ISourceReference reference, FoldingStructureComputationContext ctx) { |
1316 |
protected final IRegion[] computeProjectionRanges(ISourceReference reference, FoldingStructureComputationContext ctx) { |
1096 |
try { |
1317 |
try { |
1097 |
ISourceRange range= reference.getSourceRange(); |
1318 |
ISourceRange range= reference.getSourceRange(); |
1098 |
if (!SourceRange.isAvailable(range)) |
1319 |
if (!SourceRange.isAvailable(range)) |
Lines 1132-1141
Link Here
|
1132 |
case ITerminalSymbols.TokenNameCOMMENT_LINE: |
1353 |
case ITerminalSymbols.TokenNameCOMMENT_LINE: |
1133 |
continue; |
1354 |
continue; |
1134 |
} |
1355 |
} |
1135 |
|
1356 |
|
1136 |
break; |
1357 |
break; |
1137 |
} |
1358 |
} |
1138 |
|
1359 |
|
1139 |
regions.add(new Region(start, shift + range.getLength() - start)); |
1360 |
regions.add(new Region(start, shift + range.getLength() - start)); |
1140 |
|
1361 |
|
1141 |
IRegion[] result= new IRegion[regions.size()]; |
1362 |
IRegion[] result= new IRegion[regions.size()]; |
Lines 1143-1148
Link Here
|
1143 |
return result; |
1364 |
return result; |
1144 |
} catch (JavaModelException e) { |
1365 |
} catch (JavaModelException e) { |
1145 |
} catch (InvalidInputException e) { |
1366 |
} catch (InvalidInputException e) { |
|
|
1367 |
} catch (Exception e) { |
1146 |
} |
1368 |
} |
1147 |
|
1369 |
|
1148 |
return new IRegion[0]; |
1370 |
return new IRegion[0]; |
Lines 1217-1222
Link Here
|
1217 |
protected final Position createMemberPosition(IRegion aligned, IMember member) { |
1439 |
protected final Position createMemberPosition(IRegion aligned, IMember member) { |
1218 |
return new JavaElementPosition(aligned.getOffset(), aligned.getLength(), member); |
1440 |
return new JavaElementPosition(aligned.getOffset(), aligned.getLength(), member); |
1219 |
} |
1441 |
} |
|
|
1442 |
|
1443 |
/** |
1444 |
* Creates a comment folding position from an |
1445 |
* {@link #alignRegion(IRegion, DefaultJavaFoldingStructureProvider.FoldingStructureComputationContext) aligned} |
1446 |
* region with a title. |
1447 |
* |
1448 |
* @param aligned |
1449 |
* @param title |
1450 |
* @return a folding position corresponding to <code>aligned</code> |
1451 |
*/ |
1452 |
protected final Position createTitledPosition(IRegion aligned, String title) { |
1453 |
return new TitledRegionPosition(title, aligned.getOffset(), aligned.getLength()); |
1454 |
} |
1220 |
|
1455 |
|
1221 |
/** |
1456 |
/** |
1222 |
* Aligns <code>region</code> to start and end at a line offset. The region's start is |
1457 |
* Aligns <code>region</code> to start and end at a line offset. The region's start is |
Lines 1360-1366
Link Here
|
1360 |
Iterator it= annotations.iterator(); |
1595 |
Iterator it= annotations.iterator(); |
1361 |
while (it.hasNext()) { |
1596 |
while (it.hasNext()) { |
1362 |
JavaProjectionAnnotation annotation= (JavaProjectionAnnotation) it.next(); |
1597 |
JavaProjectionAnnotation annotation= (JavaProjectionAnnotation) it.next(); |
1363 |
if (tuple.annotation.isComment() == annotation.isComment()) { |
1598 |
if ((tuple.annotation.isComment() == annotation.isComment()) |
|
|
1599 |
&& (tuple.annotation.isRegion() == annotation.isRegion())) { |
1364 |
Position position= positionMap == null ? ctx.getModel().getPosition(annotation) : (Position) positionMap.get(annotation); |
1600 |
Position position= positionMap == null ? ctx.getModel().getPosition(annotation) : (Position) positionMap.get(annotation); |
1365 |
if (position == null) |
1601 |
if (position == null) |
1366 |
continue; |
1602 |
continue; |
Lines 1421-1426
Link Here
|
1421 |
public final void collapseComments() { |
1657 |
public final void collapseComments() { |
1422 |
modifyFiltered(fCommentFilter, false); |
1658 |
modifyFiltered(fCommentFilter, false); |
1423 |
} |
1659 |
} |
|
|
1660 |
|
1661 |
/** |
1662 |
* Collapse all regions. |
1663 |
*/ |
1664 |
public final void collapseRegions() { |
1665 |
modifyFiltered(fRegionFilter, false); |
1666 |
} |
1424 |
|
1667 |
|
1425 |
/* |
1668 |
/* |
1426 |
* @see org.eclipse.jdt.ui.text.folding.IJavaFoldingStructureProviderExtension#collapseElements(org.eclipse.jdt.core.IJavaElement[]) |
1669 |
* @see org.eclipse.jdt.ui.text.folding.IJavaFoldingStructureProviderExtension#collapseElements(org.eclipse.jdt.core.IJavaElement[]) |