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 114747

Summary: BaseDocument should be created rather for mimeType or EditorKit instance than for kitClass
Product: xml Reporter: Marek Fukala <mfukala>
Component: Text-EditAssignee: Samaresh Panda <samaresh>
Status: RESOLVED FIXED    
Severity: blocker CC: err, jjancura, mkrauskopf, mmetelka, pjiricka, vstejskal
Priority: P3 Keywords: API
Version: 6.x   
Hardware: All   
OS: All   
Issue Type: DEFECT Exception Reporter:
Bug Depends on: 145026    
Bug Blocks: 113003, 114234, 114304    
Attachments: The stactrace of the language initialization invoked from opened editor (should normally never happen since it is cached based on the mimetype)

Description Marek Fukala 2007-09-05 12:32:10 UTC
Currently the BaseDocument constructor takes a kit's class argument and then get the kit instance by
BaseKit.getKit(kitClass). This approach doesn't work for Schlieman's languages which has one shared kit class -
LanguagesEditorKit. The LEK takes a mimetype as an argument of its constructor and then properly returns
getContentType(). The problem is in the BaseKit.getKit() method which doesn't work with the content type but uses JUST
kit class. So it might happen that some BaseDocument-s for Schlieman editor's like javascript or css has wrong kit! 

I found this issue when playing with issue #114234 (First keystroke is very slow). Sometimes it happens that after first
keystroke the editor gets frozen for some time. This seems to be mainly caused by this issue.

The attached threaddump shows that the LanguagesManager.getLanguage() is called from the editor after the keystroke. Bad
thing is that the method doesn't return already initialized language, and instead of that it initializes the given
language. The reason for this is that the mimeType of the LEK is not text/x-css but for example text/x-jsp or
text/x-javascript (this is random) so these languages are initialized which involves many filesystem registrations and
hence xml files saves. The biggest hotspot seems to be save of the language's colorings - this involves some xml
parsing, xslt transformations and files save. Very very slow...

This issue also may cause some other problems resulting from the fact that the kit's mimetype may be wrong. IMHO this
needs to be fixed soon since this is a big problem for Schlieman based languages or languages using Schlieman features.
Comment 1 Marek Fukala 2007-09-05 12:33:31 UTC
Created attachment 48154 [details]
The stactrace of the language initialization invoked from opened editor (should normally never happen since it is cached based on the mimetype)
Comment 2 Vitezslav Stejskal 2007-09-05 15:08:22 UTC
Nasty, I'll try to fix it somehow.
Comment 3 Marek Fukala 2007-09-24 15:43:19 UTC
*** Issue 114234 has been marked as a duplicate of this issue. ***
Comment 4 Marek Fukala 2007-09-24 15:45:59 UTC
So what about the following proposed fix?????

Index: editor/libsrc/org/netbeans/editor/BaseDocument.java
===================================================================
RCS file: /cvs/editor/libsrc/org/netbeans/editor/BaseDocument.java,v
retrieving revision 1.146
diff -u -u -r1.146 BaseDocument.java
--- editor/libsrc/org/netbeans/editor/BaseDocument.java 17 Sep 2007 17:32:13 -0000      1.146
+++ editor/libsrc/org/netbeans/editor/BaseDocument.java 24 Sep 2007 14:44:28 -0000
@@ -430,11 +430,10 @@
     }
 
     Syntax getFreeSyntax() {
-        BaseKit kit = BaseKit.getKit(kitClass);
         synchronized (Settings.class) {
             int cnt = syntaxList.size();
             return (cnt > 0) ? (Syntax)syntaxList.remove(cnt - 1)
-                   : kit.createSyntax(this);
+                   : BaseKit.getKit(kitClass).createSyntax(this);
         }
     }
 
Comment 5 Vitezslav Stejskal 2007-09-25 10:33:48 UTC
The patch is ok, but it does not fix this issue. Thanks anyway
Comment 6 Vitezslav Stejskal 2007-10-04 16:11:08 UTC
The problem shown by the stacktrace here and in #114234 was caused by by an improper use of the old editor settings
infrastructure, which can't handle languages that do not use unique EditorKit implementation class. This the case of all
Schliemann based languages as they all use LanguagesEditorKit. Therefore Schliemann should not use old settings infra
for any mime type related settings.

The fact that not all editor settings can be initialized and accessed in a mime type friendly way is a know deficiency
and will be addressed as soon as we can, see issue #90403. I'm leaving this open, because BaseDocument the issue is
generally valid - BaseDocument should really use mime type or editor kit directly.

The following changes fix the problem in Schliemann, performance should now be better and the identifiers recognition
(for languages that need one) should work properly.

Checking in LanguagesEditorKit.java;
/cvs/languages/engine/src/org/netbeans/modules/languages/dataobject/LanguagesEditorKit.java,v  <--  LanguagesEditorKit.java
new revision: 1.23; previous revision: 1.22
done
Checking in Install.java;
/cvs/languages/engine/src/org/netbeans/modules/languages/dataobject/Install.java,v  <--  Install.java
new revision: 1.3; previous revision: 1.2
done
Comment 7 mgoe 2008-08-22 15:41:48 UTC
When trying to get a code completion in an xml file based on a xml schema the warnings below are printed. Code 
completion does not work reliably. Sometimes a code completion is offered sometimes a tooltip with "No suggestions" is 
displayed. Is there any chance that this will be fixed in 6.5?

FINE [org.netbeans.editor.BaseDocument]
java.lang.Throwable: Using deprecated document construction for org.netbeans.editor.BaseDocument, see 
http://www.netbeans.org/nonav/issues/show_bug.cgi?id=114747. Use -J-Dorg.netbeans.editor.BaseDocument.level=500 to see 
the stacktrace.
        at org.netbeans.editor.BaseDocument.<init>(BaseDocument.java:468)
        at org.netbeans.modules.xml.xdm.xam.XDMAccessProvider.loadSwingDocument(XDMAccessProvider.java:72)
        at 
org.netbeans.modules.xml.schema.completion.RuntimeCatalogModel.createModelSource(RuntimeCatalogModel.java:108)
        at org.netbeans.modules.xml.schema.completion.RuntimeCatalogModel.getModelSource(RuntimeCatalogModel.java:98)
        at 
org.netbeans.modules.xml.retriever.catalog.impl.CatalogModelImpl.getModelSourceFromSystemWideCatalog(CatalogModelImpl.java:738)
        at 
org.netbeans.modules.xml.retriever.catalog.impl.CatalogModelImpl.doGetModelSource(CatalogModelImpl.java:200)
        at org.netbeans.modules.xml.retriever.catalog.impl.CatalogModelImpl.getModelSource(CatalogModelImpl.java:163)
        at 
org.netbeans.modules.xml.schema.completion.util.DefaultModelProvider.getCompletionModel(DefaultModelProvider.java:114)
        at 
org.netbeans.modules.xml.schema.completion.util.CompletionContextImpl.specialCompletion(CompletionContextImpl.java:624)
        at 
org.netbeans.modules.xml.schema.completion.util.CompletionContextImpl.initModels(CompletionContextImpl.java:594)
        at org.netbeans.modules.xml.schema.completion.CompletionQuery.getCompletionItems(CompletionQuery.java:103)
        at org.netbeans.modules.xml.schema.completion.CompletionQuery.query(CompletionQuery.java:87)
        at org.netbeans.spi.editor.completion.support.AsyncCompletionTask.run(AsyncCompletionTask.java:218)
        at org.openide.util.RequestProcessor$Task.run(RequestProcessor.java:572)
        at org.openide.util.RequestProcessor$Processor.run(RequestProcessor.java:997)
ADD DocumentListener to 0 present: org.netbeans.modules.xml.xam.dom.AbstractDocumentModel$WeakDocumentListener@bcff11
FINE [org.netbeans.editor.BaseDocument]
java.lang.Throwable: Using deprecated document construction for org.netbeans.editor.BaseDocument, see 
http://www.netbeans.org/nonav/issues/show_bug.cgi?id=114747. Use -J-Dorg.netbeans.editor.BaseDocument.level=500 to see 
the stacktrace.
        at org.netbeans.editor.BaseDocument.<init>(BaseDocument.java:468)
        at org.netbeans.modules.xml.xdm.xam.XDMAccessProvider.loadSwingDocument(XDMAccessProvider.java:72)
        at 
org.netbeans.modules.xml.schema.completion.RuntimeCatalogModel.createModelSource(RuntimeCatalogModel.java:108)
        at org.netbeans.modules.xml.schema.completion.RuntimeCatalogModel.getModelSource(RuntimeCatalogModel.java:98)
        at 
org.netbeans.modules.xml.retriever.catalog.impl.CatalogModelImpl.getModelSourceFromSystemWideCatalog(CatalogModelImpl.java:738)
        at 
org.netbeans.modules.xml.retriever.catalog.impl.CatalogModelImpl.doGetModelSource(CatalogModelImpl.java:200)
        at org.netbeans.modules.xml.retriever.catalog.impl.CatalogModelImpl.getModelSource(CatalogModelImpl.java:163)
        at 
org.netbeans.modules.xml.schema.completion.util.DefaultModelProvider.getCompletionModel(DefaultModelProvider.java:114)
        at 
org.netbeans.modules.xml.schema.completion.util.CompletionContextImpl.specialCompletion(CompletionContextImpl.java:624)
        at 
org.netbeans.modules.xml.schema.completion.util.CompletionContextImpl.initModels(CompletionContextImpl.java:594)
        at org.netbeans.modules.xml.schema.completion.CompletionQuery.getCompletionItems(CompletionQuery.java:103)
        at org.netbeans.modules.xml.schema.completion.CompletionQuery.query(CompletionQuery.java:87)
        at org.netbeans.spi.editor.completion.support.AsyncCompletionTask.run(AsyncCompletionTask.java:218)
        at org.openide.util.RequestProcessor$Task.run(RequestProcessor.java:572)
        at org.openide.util.RequestProcessor$Processor.run(RequestProcessor.java:997)
ADD DocumentListener to 0 present: org.netbeans.modules.xml.xam.dom.AbstractDocumentModel$WeakDocumentListener@17d565c
FINE [org.netbeans.editor.BaseDocument]
java.lang.Throwable: Using deprecated document construction for org.netbeans.editor.BaseDocument, see 
http://www.netbeans.org/nonav/issues/show_bug.cgi?id=114747. Use -J-Dorg.netbeans.editor.BaseDocument.level=500 to see 
the stacktrace.
        at org.netbeans.editor.BaseDocument.<init>(BaseDocument.java:468)
        at org.netbeans.modules.xml.xdm.xam.XDMAccessProvider.loadSwingDocument(XDMAccessProvider.java:72)
        at 
org.netbeans.modules.xml.schema.completion.RuntimeCatalogModel.createModelSource(RuntimeCatalogModel.java:108)
        at org.netbeans.modules.xml.schema.completion.RuntimeCatalogModel.getModelSource(RuntimeCatalogModel.java:98)
        at 
org.netbeans.modules.xml.retriever.catalog.impl.CatalogModelImpl.getModelSourceFromSystemWideCatalog(CatalogModelImpl.java:738)
        at 
org.netbeans.modules.xml.retriever.catalog.impl.CatalogModelImpl.doGetModelSource(CatalogModelImpl.java:200)
        at org.netbeans.modules.xml.retriever.catalog.impl.CatalogModelImpl.getModelSource(CatalogModelImpl.java:163)
        at 
org.netbeans.modules.xml.schema.completion.util.DefaultModelProvider.getCompletionModel(DefaultModelProvider.java:114)
        at 
org.netbeans.modules.xml.schema.completion.util.CompletionContextImpl.specialCompletion(CompletionContextImpl.java:624)
        at 
org.netbeans.modules.xml.schema.completion.util.CompletionContextImpl.initModels(CompletionContextImpl.java:594)
        at org.netbeans.modules.xml.schema.completion.CompletionQuery.getCompletionItems(CompletionQuery.java:103)
        at org.netbeans.modules.xml.schema.completion.CompletionQuery.query(CompletionQuery.java:87)
        at org.netbeans.spi.editor.completion.support.AsyncCompletionTask.run(AsyncCompletionTask.java:218)
        at org.openide.util.RequestProcessor$Task.run(RequestProcessor.java:572)
        at org.openide.util.RequestProcessor$Processor.run(RequestProcessor.java:997)
ADD DocumentListener to 0 present: org.netbeans.modules.xml.xam.dom.AbstractDocumentModel$WeakDocumentListener@1582a88
FINE [org.netbeans.editor.BaseDocument]
java.lang.Throwable: Using deprecated document construction for org.netbeans.editor.BaseDocument, see 
http://www.netbeans.org/nonav/issues/show_bug.cgi?id=114747. Use -J-Dorg.netbeans.editor.BaseDocument.level=500 to see 
the stacktrace.
        at org.netbeans.editor.BaseDocument.<init>(BaseDocument.java:468)
        at org.netbeans.modules.xml.xdm.xam.XDMAccessProvider.loadSwingDocument(XDMAccessProvider.java:72)
        at 
org.netbeans.modules.xml.schema.completion.RuntimeCatalogModel.createModelSource(RuntimeCatalogModel.java:108)
        at org.netbeans.modules.xml.schema.completion.RuntimeCatalogModel.getModelSource(RuntimeCatalogModel.java:98)
        at 
org.netbeans.modules.xml.retriever.catalog.impl.CatalogModelImpl.getModelSourceFromSystemWideCatalog(CatalogModelImpl.java:738)
        at 
org.netbeans.modules.xml.retriever.catalog.impl.CatalogModelImpl.doGetModelSource(CatalogModelImpl.java:200)
        at org.netbeans.modules.xml.retriever.catalog.impl.CatalogModelImpl.getModelSource(CatalogModelImpl.java:163)
        at 
org.netbeans.modules.xml.schema.completion.util.DefaultModelProvider.getCompletionModel(DefaultModelProvider.java:114)
        at 
org.netbeans.modules.xml.schema.completion.util.CompletionContextImpl.specialCompletion(CompletionContextImpl.java:624)
        at 
org.netbeans.modules.xml.schema.completion.util.CompletionContextImpl.initModels(CompletionContextImpl.java:594)
        at org.netbeans.modules.xml.schema.completion.CompletionQuery.getCompletionItems(CompletionQuery.java:103)
        at org.netbeans.modules.xml.schema.completion.CompletionQuery.query(CompletionQuery.java:87)
        at org.netbeans.spi.editor.completion.support.AsyncCompletionTask.run(AsyncCompletionTask.java:218)
        at org.openide.util.RequestProcessor$Task.run(RequestProcessor.java:572)
        at org.openide.util.RequestProcessor$Processor.run(RequestProcessor.java:997)
ADD DocumentListener to 0 present: org.netbeans.modules.xml.xam.dom.AbstractDocumentModel$WeakDocumentListener@12efc43
FINE [org.netbeans.editor.BaseDocument]
java.lang.Throwable: Using deprecated document construction for org.netbeans.editor.BaseDocument, see 
http://www.netbeans.org/nonav/issues/show_bug.cgi?id=114747. Use -J-Dorg.netbeans.editor.BaseDocument.level=500 to see 
the stacktrace.
        at org.netbeans.editor.BaseDocument.<init>(BaseDocument.java:468)
        at org.netbeans.modules.xml.xdm.xam.XDMAccessProvider.loadSwingDocument(XDMAccessProvider.java:72)
        at 
org.netbeans.modules.xml.schema.completion.RuntimeCatalogModel.createModelSource(RuntimeCatalogModel.java:108)
        at org.netbeans.modules.xml.schema.completion.RuntimeCatalogModel.getModelSource(RuntimeCatalogModel.java:98)
        at 
org.netbeans.modules.xml.xam.dom.AbstractDocumentComponent.resolveModelSource(AbstractDocumentComponent.java:747)
        at 
org.netbeans.modules.xml.xam.dom.AbstractDocumentComponent._resolveModel(AbstractDocumentComponent.java:774)
        at org.netbeans.modules.xml.xam.dom.AbstractDocumentComponent.resolveModel(AbstractDocumentComponent.java:766)
        at org.netbeans.modules.xml.schema.model.impl.ImportImpl.resolveReferencedModel(ImportImpl.java:119)
        at org.netbeans.modules.xml.axi.impl.AXIModelImpl.buildReferenceableCache(AXIModelImpl.java:294)
        at org.netbeans.modules.xml.axi.impl.ModelAccessImpl.sync(ModelAccessImpl.java:85)
        at org.netbeans.modules.xml.xam.AbstractModel.sync(AbstractModel.java:259)
        at org.netbeans.modules.xml.axi.impl.AXIModelImpl.sync(AXIModelImpl.java:204)
        at org.netbeans.modules.xml.xam.AbstractModelFactory.getModel(AbstractModelFactory.java:137)
        at org.netbeans.modules.xml.axi.AXIModelFactory.getModel(AXIModelFactory.java:98)
        at org.netbeans.modules.xml.axi.AXIModelFactory.getModel(AXIModelFactory.java:88)
        at 
org.netbeans.modules.xml.schema.completion.util.CompletionUtil.findAXIElementAtContext(CompletionUtil.java:448)
        at org.netbeans.modules.xml.schema.completion.util.CompletionUtil.getElements(CompletionUtil.java:242)
        at org.netbeans.modules.xml.schema.completion.CompletionQuery.getCompletionItems(CompletionQuery.java:110)
        at org.netbeans.modules.xml.schema.completion.CompletionQuery.query(CompletionQuery.java:87)
        at org.netbeans.spi.editor.completion.support.AsyncCompletionTask.run(AsyncCompletionTask.java:218)
        at org.openide.util.RequestProcessor$Task.run(RequestProcessor.java:572)
        at org.openide.util.RequestProcessor$Processor.run(RequestProcessor.java:997)
ADD DocumentListener to 0 present: org.netbeans.modules.xml.xam.dom.AbstractDocumentModel$WeakDocumentListener@b5e5d7
FINE [org.netbeans.editor.BaseDocument]
java.lang.Throwable: Using deprecated document construction for org.netbeans.editor.BaseDocument, see 
http://www.netbeans.org/nonav/issues/show_bug.cgi?id=114747. Use -J-Dorg.netbeans.editor.BaseDocument.level=500 to see 
the stacktrace.
        at org.netbeans.editor.BaseDocument.<init>(BaseDocument.java:468)
        at org.netbeans.modules.xml.xdm.xam.XDMAccessProvider.loadSwingDocument(XDMAccessProvider.java:72)
        at 
org.netbeans.modules.xml.schema.completion.RuntimeCatalogModel.createModelSource(RuntimeCatalogModel.java:108)
        at org.netbeans.modules.xml.schema.completion.RuntimeCatalogModel.getModelSource(RuntimeCatalogModel.java:98)
        at 
org.netbeans.modules.xml.xam.dom.AbstractDocumentComponent.resolveModelSource(AbstractDocumentComponent.java:747)
        at 
org.netbeans.modules.xml.xam.dom.AbstractDocumentComponent._resolveModel(AbstractDocumentComponent.java:774)
        at org.netbeans.modules.xml.xam.dom.AbstractDocumentComponent.resolveModel(AbstractDocumentComponent.java:766)
        at org.netbeans.modules.xml.schema.model.impl.ImportImpl.resolveReferencedModel(ImportImpl.java:119)
        at org.netbeans.modules.xml.axi.impl.AXIModelImpl.buildReferenceableCache(AXIModelImpl.java:294)
        at org.netbeans.modules.xml.axi.impl.ModelAccessImpl.sync(ModelAccessImpl.java:85)
        at org.netbeans.modules.xml.xam.AbstractModel.sync(AbstractModel.java:259)
        at org.netbeans.modules.xml.axi.impl.AXIModelImpl.sync(AXIModelImpl.java:204)
        at org.netbeans.modules.xml.xam.AbstractModelFactory.getModel(AbstractModelFactory.java:137)
        at org.netbeans.modules.xml.axi.AXIModelFactory.getModel(AXIModelFactory.java:98)
        at org.netbeans.modules.xml.axi.AXIModelFactory.getModel(AXIModelFactory.java:88)
        at 
org.netbeans.modules.xml.schema.completion.util.CompletionUtil.findAXIElementAtContext(CompletionUtil.java:448)
        at org.netbeans.modules.xml.schema.completion.util.CompletionUtil.getElements(CompletionUtil.java:242)
        at org.netbeans.modules.xml.schema.completion.CompletionQuery.getCompletionItems(CompletionQuery.java:110)
        at org.netbeans.modules.xml.schema.completion.CompletionQuery.query(CompletionQuery.java:87)
        at org.netbeans.spi.editor.completion.support.AsyncCompletionTask.run(AsyncCompletionTask.java:218)
        at org.openide.util.RequestProcessor$Task.run(RequestProcessor.java:572)
        at org.openide.util.RequestProcessor$Processor.run(RequestProcessor.java:997)
ADD DocumentListener to 0 present: org.netbeans.modules.xml.xam.dom.AbstractDocumentModel$WeakDocumentListener@e91662
Comment 8 Vitezslav Stejskal 2008-08-25 10:51:33 UTC
From the API standpoint the work that this issue requested is done - BaseDocument can be (should be and usually is)
created by using the constructor, which accepts mimetype. There are still places, that use the old constructor, hence
the warning in the log.

I'm passing this to the XML editor to fix. Thanks for the stactrace.
Comment 9 Samaresh Panda 2008-08-25 17:22:07 UTC
See issue 145026. I want to understand whether to pass true/false in here.
Comment 10 Quality Engineering 2008-08-26 06:07:35 UTC
Integrated into 'main-golden', available in build *200808260201* on http://bits.netbeans.org/dev/nightly/
Changeset: http://hg.netbeans.org/main/rev/f0e52fb36b64
User: samaresh@netbeans.org
Log: #114747 BaseDocument should be created for mimetype instead of kit.
Comment 11 Samaresh Panda 2008-08-26 16:34:28 UTC
Fixed: http://hg.netbeans.org/main?cmd=changeset;node=f0e52fb36b64.