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 271381

Summary: Schema-aware code completion does not work when a reference is referring to element from the same schema/namespace (patch provided)
Product: xml Reporter: kostas_papadopoulos
Component: Text-EditAssignee: Svata Dedic <sdedic>
Status: RESOLVED FIXED    
Severity: normal    
Priority: P1    
Version: 8.2   
Hardware: PC   
OS: Linux   
Issue Type: DEFECT Exception Reporter:
Attachments: patch for issue, against main-silver
xsd to show the problem, modified from tests
xsd to show the problem, modified from tests
xml to show the problem, modified from tests
xsd with test cases

Description kostas_papadopoulos 2017-08-28 04:22:04 UTC
Created attachment 165025 [details]
patch for issue, against main-silver

When a schema has a reference pointing to an element from within the same schema, code completion fails to find element attributes or children elements of complex types. Additionally, if the referred element is used in a substitution group then it fails to find the substituted elements and their attributes.

The attached patch resolve the issue for me.

Product Version: NetBeans IDE 8.2 (Build 201705191307)
Updates: NetBeans IDE is updated to version NetBeans 8.2 Patch 2
Java: 1.8.0_92; Java HotSpot(TM) 64-Bit Server VM 25.92-b14
Comment 1 kostas_papadopoulos 2017-08-28 04:24:27 UTC
Created attachment 165026 [details]
xsd to show the problem, modified from tests
Comment 2 kostas_papadopoulos 2017-08-28 04:25:01 UTC
Created attachment 165027 [details]
xsd to show the problem, modified from tests
Comment 3 kostas_papadopoulos 2017-08-28 04:25:27 UTC
Created attachment 165028 [details]
xml to show the problem, modified from tests
Comment 4 Svata Dedic 2017-08-28 12:40:12 UTC
I wasn't able to simulate the 1st case: CC does not complete complex type attributes. Specifically the code execution did not hit the added
if(qname.getLocalPart().equals(ref.getName())){
                    return ref;
                }
check on the referrent.

IMHO, in that case, the execution would already returned earlier, since qname.getLocalPart().equals(e.getName()) == true (the proxy local name part should equal to the referrent's local name).

Otherwise OK (and I'll commit some additional fixes implemented during testing).
Comment 5 kostas_papadopoulos 2017-08-29 04:54:24 UTC
Created attachment 165040 [details]
xsd with test cases

You are right, of course, regarding the test:
if(qname.getLocalPart().equals(ref.getName())){
                    return ref;

I added the case that I thought I was addressing in the uploaded schema (non-abstract-child).
Comment 6 Svata Dedic 2017-09-01 09:25:20 UTC
Will be pushed as jet-main#8c6815fd6bb3
Comment 7 Quality Engineering 2017-09-03 02:50:45 UTC
Integrated into 'main-silver', will be available in build *201709030001* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)

Changeset: http://hg.netbeans.org/main-silver/rev/8c6815fd6bb3
User: Svata Dedic <sdedic@netbeans.org>
Log: #271381: Fixed completion of referenced elements; by kostas_papadopoulos