[ phpeclipse-Bugs-1033591 ] Tasks not reporting corrent line number in task view
"SourceForge.net" <[email protected]> Wed, 21 Mar 2007 20:02:11 -0700
| Newsgroups | gmane.comp.ide.eclipse.phpeclipse.devel |
|---|---|
| Message-ID | <[email protected]> |
Bugs item #1033591, was opened at 2004-09-23 16:07
Message generated for change (Comment added) made by scorphus
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=484801&aid=1033591&group_id=57621
Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: PHP Editor
Group: None
Status: Open
Resolution: Accepted
Priority: 5
Private: No
Submitted By: Nick Gushlow (gushy)
Assigned to: Nobody/Anonymous (nobody)
Summary: Tasks not reporting corrent line number in task view
Initial Comment:
Tasks read from comments in the code do not show the
right line number (although clicking them takes you to
the correct line).
----------------------------------------------------------------------
Comment By: Pablo Aguiar (scorphus)
Date: 2007-03-22 00:02
Message:
Logged In: YES
user_id=987242
Originator: NO
This bug goes unnoticed when editing files with CRLF (\r\n) for newlines,
which is the case of text files on Windows. When the newline is represented
either with LF (Unix-like systems, Mac OS X and others) or CR (Mac OS up to
9) the Tasks view (and also the Problems view) doesn't show correct line
numbers for some cases of files (with blank lines, or with lines of white
spaces, and other cases you can experiment...).
The solution to this bug is quite simple although it was a bit hard to
find.
The array (Scanner::lineEnds) that holds positions of every eol (end of
line) in the text is incorrectly generated by Scanner::pushLineSeparator()
- that fills the array - and Scanner::getNextToken() - where the bug
resides: whenever there is a '\r' (CR) or '\n' (LF) the a new character
gets read from the Scanner::source right after entering the first while
loop, that causes the previously character read just before to be missed.
Suppose the occurrence of two newlines on the code. As of the case with
'...\r\n\r\n...' (Windows) the first '\n' is missed, but the first newline
was already counted and that's because line-numbering won't get messed up
on the tasks view. But in case of two newlines on a Unix text file
('...\n\n...') the missed LF represents another newline.
It's a pretty silly bug :) and the solution is simple: read the new
character from Scanner::source at the end of the while loop.
Here is the patch:
[patch]
Index: Scanner.java
===================================================================
RCS file:
/cvsroot/phpeclipse/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/parser/Scanner.java,v
retrieving revision 1.61
diff -u -r1.61 Scanner.java
--- Scanner.java 17 Mar 2007 13:54:41 -0000 1.61
+++ Scanner.java 22 Mar 2007 01:20:22 -0000
@@ -1438,8 +1438,6 @@
while ((currentCharacter == ' ')
|| Character.isWhitespace(currentCharacter)) {
- startPosition = currentPosition;
- currentCharacter = source[currentPosition++];
if ((currentCharacter == '\r')
|| (currentCharacter == '\n')) {
checkNonExternalizeString();
@@ -1449,6 +1447,8 @@
currentLine = null;
}
}
+ startPosition = currentPosition;
+ currentCharacter = source[currentPosition++];
}
if (tokenizeWhiteSpace
&& (whiteStart != currentPosition - 1)) {
[/patch]
Hope to solve more bugs!
Regards,
Pablo.
----------------------------------------------------------------------
Comment By: Jim (samage)
Date: 2006-11-07 04:19
Message:
Logged In: YES
user_id=1639026
I've confirmed this bug.
I've also created a small test page to use:
-----8<--------------
<?php
include_once("file.php");
function getDate()
{
//This is the data to retrieve
if (count($this->arrData)> 0)
{
//TODO: handle this condition
print_r($this->$arrData);
}
//TODO: what about an error condition?
}
function getPageFooter()
{
// TODO: implement stub getPageFooter();
die ("getPageFooter not implemented");
}
//TODO: last item
//TODO: not quite
?>
-----8<--------8<-------
TODO Items are on lines 10, 13, 18, 21 and 22.
They are reported to be on 4, 6, 8, 10 and 11.
Confirmed with Eclipse 3.2.1 using phpEclipse 1.1.8 on
Ubuntu. (Sun jdk 1.5)
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=484801&aid=1033591&group_id=57621
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV