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.

Bug 45014 - lineSet.getOriginalLineNumber (line) returns -1 for lines from different lineSets
Summary: lineSet.getOriginalLineNumber (line) returns -1 for lines from different line...
Status: CLOSED FIXED
Alias: None
Product: platform
Classification: Unclassified
Component: Text (show other bugs)
Version: 4.x
Hardware: PC Windows ME/2000
: P2 blocker (vote)
Assignee: Jaroslav Tulach
URL:
Keywords:
Depends on:
Blocks: 42270
  Show dependency tree
 
Reported: 2004-06-16 15:18 UTC by Jan Jancura
Modified: 2008-12-22 19:41 UTC (History)
1 user (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
The fix that works on DocumentLine.Set but the default impl on Line.Set is not working yet. Still give it a try and review. (7.98 KB, patch)
2004-06-16 16:42 UTC, Jaroslav Tulach
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Jan Jancura 2004-06-16 15:18:39 UTC
TestCase:
    
    public void
testGetOriginalForLineFromDifferentLineSet2 ()
throws Exception {
        content = "line 1\nline 2\n";
        javax.swing.text.Document doc =
support.openDocument ();

        Line.Set lineSet1 = support.getLineSet ();
        
        doc.insertString (6, "\nnew line", null);
        support.saveDocument ();
        Line.Set lineSet2 = support.getLineSet ();
        
        Line line = lineSet2.getCurrent(2);
        
        assertEquals ("line number is 2", 2,
line.getLineNumber ());
        assertGetOriginal ("original line number
is 1", lineSet1, line, 1);
        assertGetOriginal ("original line number
is 2", lineSet2, line, 2);
        
        doc.insertString (6, "\nnew line", null);
        
        assertEquals ("line number is 3", 3,
line.getLineNumber ());
        assertGetOriginal ("original line number
is 1", lineSet1, line, 1);
        assertGetOriginal ("original line number
is 2", lineSet2, line, 2);
        
        System.out.println(doc.getText(0,
doc.getLength()));
    }
Comment 1 Jaroslav Tulach 2004-06-16 16:42:09 UTC
Created attachment 15776 [details]
The fix that works on DocumentLine.Set but the default impl on Line.Set is not working yet. Still give it a try and review.
Comment 2 Jaroslav Tulach 2004-06-16 16:43:33 UTC
Hanzi, you should learn cvs diff -u!

I think that the right solution is to share the WeakHashMap of lines
between all Line.Sets created for the same CES. Review would be nice.
Comment 3 Jaroslav Tulach 2004-06-17 10:20:07 UTC
Hanzi your unit tests not only discovered the problem of nonshared
lines between mutual LineSets, but also that the fallback
implementation in Line.Set.getOriginalLineNumber has one bug. Good
start with junit and do not be affraid to go on!

#45014: Sharing the map of lines between all linesets for one
cloneable editor support. All the unit tests were written by
jjancura@netbeans.org


/cvs/openide/src/org/openide/text/CloneableEditorSupport.java,v  <-- 
CloneableEditorSupport.java
new revision: 1.124; previous revision: 1.123
done
Checking in src/org/openide/text/DocumentLine.java;
/cvs/openide/src/org/openide/text/DocumentLine.java,v  <-- 
DocumentLine.java
new revision: 1.56; previous revision: 1.55
done
Checking in src/org/openide/text/EditorSupportLineSet.java;
/cvs/openide/src/org/openide/text/EditorSupportLineSet.java,v  <-- 
EditorSupportLineSet.java
new revision: 1.39; previous revision: 1.38
done
Checking in src/org/openide/text/Line.java;
/cvs/openide/src/org/openide/text/Line.java,v  <--  Line.java
new revision: 1.29; previous revision: 1.28
done
Processing log script arguments...
More commits to come...
Checking in test/unit/src/org/openide/text/LineSetTest.java;
/cvs/openide/test/unit/src/org/openide/text/LineSetTest.java,v  <-- 
LineSetTest.java
new revision: 1.3; previous revision: 1.2
Comment 4 Zdenek Konecny 2005-08-02 11:32:08 UTC
Closed, too old