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 262351

Summary: NullPointerException at org.netbeans.modules.javascript2.editor.JsStructureScanner.foldsJson
Product: ide Reporter: Jiri Skrivanek <jskrivanek>
Component: Features On DemandAssignee: Svata Dedic <sdedic>
Status: NEW ---    
Severity: normal CC: alexvsimon, BartK, lhochet, mmetelka, sdedic
Priority: P2    
Version: 8.2   
Hardware: All   
OS: All   
Issue Type: DEFECT Exception Reporter: 224383
Attachments: stacktrace

Description Jiri Skrivanek 2016-06-07 11:32:31 UTC
Build: NetBeans IDE Dev (Build javascript2-frameworks-1960-on-20160603)
VM: Java HotSpot(TM) 64-Bit Server VM, 25.91-b14, Java(TM) SE Runtime Environment, 1.8.0_91-b14
OS: Windows 8.1

User Comments:
jskrivanek: I did:
- create new java project
- create new JSON file from template

   at org.netbeans.modules.javascript2.editor.JsStructureScanner.foldsJson(
   at org.netbeans.modules.javascript2.editor.JsStructureScanner.folds(
   at org.netbeans.modules.csl.editor.fold.GsfFoldManager$JavaElementFoldTask.scan(
   at org.netbeans.modules.csl.editor.fold.GsfFoldManager$JavaElementFoldTask.access$100(
   at org.netbeans.modules.csl.editor.fold.GsfFoldManager$JavaElementFoldTask$
   at org.netbeans.modules.parsing.impl.TaskProcessor.callUserTask(
Comment 1 Jiri Skrivanek 2016-06-07 11:32:33 UTC
Created attachment 159979 [details]
Comment 2 Petr Pisl 2016-06-07 14:44:01 UTC
In this case the javascript features are not enabled yet. The question is, whether the javascript and json templates should be available at this moment. 

I have find out that org.netbeans.lib.lexer.LanguageManager, creates in such case NO_LANG language and store it to the cache for the text/x-json mimetype. This no language is created before the javascript functionality is enabled and because the LanguageManger cache is not cleared, the no language is keep until you will restart the ide. After enabling the js features, the other languages are created correctly. 

If you create new javascript file before enabling js features, then json works correctly, but javascript editor does not work until restart. 

So IMHO the problem is that LanguageManager is asked for the text/x-json too early and it cannot find the right provider, so it creates NO_LANG, which stores to the cache, which is not refreshed, when the enabling features is done. 

The problem appears now, because I have moved javascript functionality from IDE cluster to the webcommon cluster. 

Svato, Milo: Any ideas?
Comment 3 Svata Dedic 2016-06-17 13:34:26 UTC
Apologies; wrong categorization.

While the situation could be possibly handled in Lexer API (lexer Mime provider does not listen on Language/LanguagesEmbeddingMap changes and does not refire events), I believe the proper place to fix the issue is ergonomics: the first Lookup for e.g. Language on a MimePath should be consistent with the subsequent ones - so the lookup for the Language should trigger loading of the appropriate cluster.

Jardo - please advise.
Comment 4 Alexander Simon 2016-07-13 13:36:54 UTC
Created attachment 160369 [details]

create json file
Comment 5 Alexander Simon 2016-07-13 13:39:55 UTC
Created attachment 160371 [details]

swith editor with empty json file
Comment 6 Alexander Simon 2016-07-13 13:42:54 UTC
Created attachment 160372 [details]

type char in empty json file
Comment 7 Exceptions Reporter 2016-07-13 13:42:58 UTC
This bug already has 5 duplicates 
Comment 8 lhochet 2016-10-05 15:31:18 UTC
Created attachment 162351 [details]

opening an empty 'JSON' file
Comment 9 BartK 2017-02-12 18:57:23 UTC
Created attachment 163616 [details]

I was selecting a opened file form the dropdown at the top right of the editor panel
Comment 10 Exceptions Reporter 2017-02-12 19:00:25 UTC
This bug already has 10 duplicates 
Comment 11 Exceptions Reporter 2017-02-12 19:03:25 UTC
This bug already has 10 duplicates