Bug 262189

Summary: Error in syntax highlighting
Product: [Applications] kdevelop Reporter: Marci Kurzyna <m.kurzyna>
Component: generalAssignee: kdevelop-bugs-null
Status: RESOLVED FIXED    
Severity: normal CC: cordlandwehr
Priority: NOR    
Version: unspecified   
Target Milestone: 4.2.0   
Platform: Unlisted Binaries   
OS: Linux   
Latest Commit: Version Fixed In:
Attachments: Colors error

Description Marci Kurzyna 2011-01-05 13:08:07 UTC
Created attachment 55601 [details]
Colors error

Version:           unspecified (using KDE 4.5.4) 
OS:                Linux

KDevelop 4.1.81 w/php-plugin 1.1.81. 

Since .80 there is an error in syntax highlighting - see attached picture. Happens on bigger files usually after some position shifts (line changes, cuts, pastes etc).

Reproducible: Sometimes

Steps to Reproduce:
Edit complex file with many variables. Do some position shifts (cut/paste lines before variables so they move to other positions).

Actual Results:  
See attached pic.

Expected Results:  
Correct colours.
Comment 1 Marci Kurzyna 2011-01-05 13:12:51 UTC
See REQUEST_URL constant witch is partly coloured like $status (after some lines were added above and all lines shifted down).
Comment 2 Milian Wolff 2011-01-05 19:04:17 UTC
can you attach a test file that shows this behavior? Make sure it doesn't rely on functions/classes outside that file, i.e. it has to be standalone.

Then describe what to add/remove where and I can try to fix it.
Comment 3 Marci Kurzyna 2011-01-10 16:14:39 UTC
For simple scripts i've already tried to isolate this and it doesn't seem to hit the bug. I'll try with something bigger ASAP.
Comment 4 Marci Kurzyna 2011-01-14 14:25:30 UTC
OK - I've managed to isolate repeatable conditions (at least to some extent...). 

Bug is hit when you edit a parsed and coloured file and then have a syntax error, for instance:

$varA = ;

Editing any variables below will result in partial colouring, consider following:

1: have proper file:
$varA = 1;
$var = 2;

2: reasing varA..
$varA = ;
$var = 2;

3: ..but during the typing u see missing B on second var, so you edit:
$varA = ;
$varB = 2;  /// B is now colorless

Now sometimes when you edit varA again and fix syntax the colouring kicks in and fixes varB. But not always (even when parser is done analysing) especially combined with other document changes, line change positions etc.

However this is not the only case, i'm still trying to isolate the main problem: mixed colours in a valid document.
Comment 5 Milian Wolff 2011-01-23 18:38:13 UTC
*** Bug 264060 has been marked as a duplicate of this bug. ***
Comment 6 Milian Wolff 2011-01-23 18:41:27 UTC
@Marci: I cannot see anything wrong in the behavior you describe:

$varA = ; // parse error
$var = 2;

// now rename $var to $varB

=> B won't get highlighted.

This is expected since recovering from syntax errors is pretty hard. And the current implementation does not skip to the next semicolon and tries to recover from there. Anyways, I don't see how this is related to the issue shown in the screenshots...
Comment 7 Milian Wolff 2011-01-23 19:09:36 UTC
Git commit f2a27d7f6a3f9106f7490cd34a617d65b73697ff by Milian Wolff.
Pushed by mwolff into branch '1.2'.

force updated range when encountering variable declaration

BUG: 262189

M  +10   -4    duchain/builders/declarationbuilder.cpp     

http://commits.kde.org/41973b7c/f2a27d7f6a3f9106f7490cd34a617d65b73697ff