This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

View | Details | Raw Unified | Return to bug 146602
Collapse All | Expand All

(-)java.editor/src/org/netbeans/modules/editor/java/SelectCodeElementAction.java (+17 lines)
Lines 224-229 Link Here
224
            positions.add(new SelectionInfo(caretPos, caretPos));
224
            positions.add(new SelectionInfo(caretPos, caretPos));
225
            if (target.getDocument() instanceof BaseDocument) {
225
            if (target.getDocument() instanceof BaseDocument) {
226
                try {
226
                try {
227
                    //as a nice side effect it also supports word selection within string literals
228
                    //"foo b|ar" -> bar
227
                    int block[] = org.netbeans.editor.Utilities.getIdentifierBlock((BaseDocument) target.getDocument(), caretPos);
229
                    int block[] = org.netbeans.editor.Utilities.getIdentifierBlock((BaseDocument) target.getDocument(), caretPos);
228
                    if (block != null) {
230
                    if (block != null) {
229
                        positions.add(new SelectionInfo(block[0], block[1]));
231
                        positions.add(new SelectionInfo(block[0], block[1]));
Lines 238-243 Link Here
238
                int endPos = (int)sp.getEndPosition(tp.getCompilationUnit(), tree);
240
                int endPos = (int)sp.getEndPosition(tp.getCompilationUnit(), tree);
239
                positions.add(new SelectionInfo(startPos, endPos));
241
                positions.add(new SelectionInfo(startPos, endPos));
240
		
242
		
243
                //support content selection within the string literal too
244
                //"A|BC" -> ABC
245
                if (tree.getKind() == Tree.Kind.STRING_LITERAL) {
246
                    positions.add(new SelectionInfo(startPos + 1, endPos - 1));
247
                }
248
                //support content selection within the {}-block too
249
                //{A|BC} -> ABC 
250
                if (tree.getKind() == Tree.Kind.BLOCK) {
251
                    positions.add(new SelectionInfo(startPos + 1, endPos - 1));
252
                }
253
                
241
		//Support selection of JavaDoc
254
		//Support selection of JavaDoc
242
		int docBegin = Integer.MAX_VALUE;
255
		int docBegin = Integer.MAX_VALUE;
243
                for (Comment comment : treeUtilities.getComments(tree, true)) {
256
                for (Comment comment : treeUtilities.getComments(tree, true)) {
Lines 281-289 Link Here
281
                        endOffset = NbDocument.findLineOffset(doc, NbDocument.findLineNumber(doc, selectionInfo.getEndOffset()) + 1);
294
                        endOffset = NbDocument.findLineOffset(doc, NbDocument.findLineNumber(doc, selectionInfo.getEndOffset()) + 1);
282
                    } catch (IndexOutOfBoundsException ioobe) {}
295
                    } catch (IndexOutOfBoundsException ioobe) {}
283
                    SelectionInfo next = it.hasNext() ? it.next() : null;
296
                    SelectionInfo next = it.hasNext() ? it.next() : null;
297
                    final boolean isEmptySelection = selectionInfo.startOffset == selectionInfo.endOffset;
298
                    //don't create line selection for empty selections
299
                    if (!isEmptySelection) {
284
                    if (next == null || startOffset >= next.startOffset && endOffset <= next.endOffset) {
300
                    if (next == null || startOffset >= next.startOffset && endOffset <= next.endOffset) {
285
		        orderedPositions.add(new SelectionInfo(startOffset, endOffset));
301
		        orderedPositions.add(new SelectionInfo(startOffset, endOffset));
286
                    }
302
                    }
303
                    }
287
                    selectionInfo = next;
304
                    selectionInfo = next;
288
		}
305
		}
289
	    }
306
	    }

Return to bug 146602