Bug 262189 - Error in syntax highlighting
Summary: Error in syntax highlighting
Status: RESOLVED FIXED
Alias: None
Product: kdevelop
Classification: Applications
Component: general (show other bugs)
Version: unspecified
Platform: Unlisted Binaries Linux
: NOR normal
Target Milestone: 4.2.0
Assignee: kdevelop-bugs-null
URL:
Keywords:
: 264060 (view as bug list)
Depends on:
Blocks:
 
Reported: 2011-01-05 13:08 UTC by Marci Kurzyna
Modified: 2011-01-23 19:09 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments
Colors error (11.52 KB, image/png)
2011-01-05 13:08 UTC, Marci Kurzyna
Details

Note You need to log in before you can comment on or make changes to this bug.
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