Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
View | Details | Raw Unified | Return to bug 128866 | Differences between
and this patch

Collapse All | Expand All

(-)src/org/eclipse/core/internal/registry/ExtensionsParser.java (-10 / +72 lines)
Lines 23-28 Link Here
23
public class ExtensionsParser extends DefaultHandler {
23
public class ExtensionsParser extends DefaultHandler {
24
	// Introduced for backward compatibility
24
	// Introduced for backward compatibility
25
	private final static String NO_EXTENSION_MUNGING = "eclipse.noExtensionMunging"; //$NON-NLS-1$ //System property
25
	private final static String NO_EXTENSION_MUNGING = "eclipse.noExtensionMunging"; //$NON-NLS-1$ //System property
26
	private static final String VERSION_3_0 = "3.0"; //$NON-NLS-1$
27
	private static final String VERSION_3_2 = "3.2"; //$NON-NLS-1$
26
	private static Map extensionPointMap;
28
	private static Map extensionPointMap;
27
29
28
	static {
30
	static {
Lines 134-152 Link Here
134
136
135
	private Locator locator = null;
137
	private Locator locator = null;
136
138
139
	// Cache the behavior toggle (true: attempt to extract namespace from qualified IDs)
140
	private boolean extractNamespaces = false;
141
137
	public ExtensionsParser(MultiStatus status, ExtensionRegistry registry) {
142
	public ExtensionsParser(MultiStatus status, ExtensionRegistry registry) {
138
		super();
143
		super();
139
		this.status = status;
144
		this.status = status;
140
		this.registry = registry;
145
		this.registry = registry;
141
	}
146
	}
142
147
143
	/**
148
	/* (non-Javadoc)
144
	 * @see ContentHandler#setDocumentLocator
149
	 * @see org.xml.sax.helpers.DefaultHandler#setDocumentLocator(org.xml.sax.Locator)
145
	 */
150
	 */
146
	public void setDocumentLocator(Locator locator) {
151
	public void setDocumentLocator(Locator locator) {
147
		this.locator = locator;
152
		this.locator = locator;
148
	}
153
	}
149
154
155
	/* (non-Javadoc)
156
	 * @see org.xml.sax.helpers.DefaultHandler#characters(char[], int, int)
157
	 */
150
	public void characters(char[] ch, int start, int length) {
158
	public void characters(char[] ch, int start, int length) {
151
		int state = ((Integer) stateStack.peek()).intValue();
159
		int state = ((Integer) stateStack.peek()).intValue();
152
		if (state != CONFIGURATION_ELEMENT_STATE)
160
		if (state != CONFIGURATION_ELEMENT_STATE)
Lines 168-177 Link Here
168
		}
176
		}
169
	}
177
	}
170
178
179
	/* (non-Javadoc)
180
	 * @see org.xml.sax.helpers.DefaultHandler#endDocument()
181
	 */
171
	public void endDocument() {
182
	public void endDocument() {
172
		// do nothing
183
		// do nothing
173
	}
184
	}
174
185
186
	/* (non-Javadoc)
187
	 * @see org.xml.sax.helpers.DefaultHandler#endElement(java.lang.String, java.lang.String, java.lang.String)
188
	 */
175
	public void endElement(String uri, String elementName, String qName) {
189
	public void endElement(String uri, String elementName, String qName) {
176
		switch (((Integer) stateStack.peek()).intValue()) {
190
		switch (((Integer) stateStack.peek()).intValue()) {
177
			case IGNORED_ELEMENT_STATE :
191
			case IGNORED_ELEMENT_STATE :
Lines 252-261 Link Here
252
		}
266
		}
253
	}
267
	}
254
268
269
	/* (non-Javadoc)
270
	 * @see org.xml.sax.helpers.DefaultHandler#error(org.xml.sax.SAXParseException)
271
	 */
255
	public void error(SAXParseException ex) {
272
	public void error(SAXParseException ex) {
256
		logStatus(ex);
273
		logStatus(ex);
257
	}
274
	}
258
275
276
	/* (non-Javadoc)
277
	 * @see org.xml.sax.helpers.DefaultHandler#fatalError(org.xml.sax.SAXParseException)
278
	 */
259
	public void fatalError(SAXParseException ex) throws SAXException {
279
	public void fatalError(SAXParseException ex) throws SAXException {
260
		logStatus(ex);
280
		logStatus(ex);
261
		throw ex;
281
		throw ex;
Lines 404-410 Link Here
404
				String simpleId;
424
				String simpleId;
405
				String namespaceName;
425
				String namespaceName;
406
				int simpleIdStart = attrValue.lastIndexOf('.');
426
				int simpleIdStart = attrValue.lastIndexOf('.');
407
				if (simpleIdStart != -1) {
427
				if ((simpleIdStart != -1) && extractNamespaces) {
408
					simpleId = attrValue.substring(simpleIdStart + 1);
428
					simpleId = attrValue.substring(simpleIdStart + 1);
409
					namespaceName = attrValue.substring(0, simpleIdStart);
429
					namespaceName = attrValue.substring(0, simpleIdStart);
410
				} else {
430
				} else {
Lines 473-484 Link Here
473
				String uniqueId;
493
				String uniqueId;
474
				String namespaceName;
494
				String namespaceName;
475
				int simpleIdStart = attrValue.lastIndexOf('.');
495
				int simpleIdStart = attrValue.lastIndexOf('.');
476
				if (simpleIdStart == -1) {
496
				if (simpleIdStart != -1 && extractNamespaces) {
477
					namespaceName = contribution.getDefaultNamespace();
478
					uniqueId = namespaceName + '.' + attrValue;
479
				} else {
480
					namespaceName = attrValue.substring(0, simpleIdStart);
497
					namespaceName = attrValue.substring(0, simpleIdStart);
481
					uniqueId = attrValue;
498
					uniqueId = attrValue;
499
				} else {
500
					namespaceName = contribution.getDefaultNamespace();
501
					uniqueId = namespaceName + '.' + attrValue;
482
				}
502
				}
483
				currentExtPoint.setUniqueIdentifier(uniqueId);
503
				currentExtPoint.setUniqueIdentifier(uniqueId);
484
				currentExtPoint.setNamespace(namespaceName);
504
				currentExtPoint.setNamespace(namespaceName);
Lines 505-510 Link Here
505
		scratchVectors[EXTENSION_POINT_INDEX].add(currentExtPoint);
525
		scratchVectors[EXTENSION_POINT_INDEX].add(currentExtPoint);
506
	}
526
	}
507
527
528
	/* (non-Javadoc)
529
	 * @see org.xml.sax.helpers.DefaultHandler#startDocument()
530
	 */
508
	public void startDocument() {
531
	public void startDocument() {
509
		stateStack.push(new Integer(INITIAL_STATE));
532
		stateStack.push(new Integer(INITIAL_STATE));
510
		for (int i = 0; i <= LAST_INDEX; i++) {
533
		for (int i = 0; i <= LAST_INDEX; i++) {
Lines 512-517 Link Here
512
		}
535
		}
513
	}
536
	}
514
537
538
	/* (non-Javadoc)
539
	 * @see org.xml.sax.helpers.DefaultHandler#startElement(java.lang.String, java.lang.String, java.lang.String, org.xml.sax.Attributes)
540
	 */
515
	public void startElement(String uri, String elementName, String qName, Attributes attributes) {
541
	public void startElement(String uri, String elementName, String qName, Attributes attributes) {
516
		switch (((Integer) stateStack.peek()).intValue()) {
542
		switch (((Integer) stateStack.peek()).intValue()) {
517
			case INITIAL_STATE :
543
			case INITIAL_STATE :
Lines 534-539 Link Here
534
		}
560
		}
535
	}
561
	}
536
562
563
	/* (non-Javadoc)
564
	 * @see org.xml.sax.helpers.DefaultHandler#warning(org.xml.sax.SAXParseException)
565
	 */
537
	public void warning(SAXParseException ex) {
566
	public void warning(SAXParseException ex) {
538
		logStatus(ex);
567
		logStatus(ex);
539
	}
568
	}
Lines 551-561 Link Here
551
		// the start of the manifest file is used to indicate the plug-in manifest
580
		// the start of the manifest file is used to indicate the plug-in manifest
552
		// schema version in effect. Pre-3.0 (i.e., 2.1) plug-in manifest files do not
581
		// schema version in effect. Pre-3.0 (i.e., 2.1) plug-in manifest files do not
553
		// have one of these, and this is how we can distinguish the manifest of a
582
		// have one of these, and this is how we can distinguish the manifest of a
554
		// pre-3.0 plug-in from a post-3.0 one (for compatibility tranformations).
583
		// pre-3.0 plug-in from a post-3.0 one (for compatibility transformations).
555
		if (target.equalsIgnoreCase("eclipse")) { //$NON-NLS-1$
584
		if (target.equalsIgnoreCase("eclipse")) { //$NON-NLS-1$
556
			// just the presence of this processing instruction indicates that this
585
			// just the presence of this processing instruction indicates that this
557
			// plug-in is at least 3.0
586
			// plug-in is at least 3.0
558
			schemaVersion = "3.0"; //$NON-NLS-1$
587
			schemaVersion = VERSION_3_0;
559
			StringTokenizer tokenizer = new StringTokenizer(data, "=\""); //$NON-NLS-1$
588
			StringTokenizer tokenizer = new StringTokenizer(data, "=\""); //$NON-NLS-1$
560
			while (tokenizer.hasMoreTokens()) {
589
			while (tokenizer.hasMoreTokens()) {
561
				String token = tokenizer.nextToken();
590
				String token = tokenizer.nextToken();
Lines 567-572 Link Here
567
					break;
596
					break;
568
				}
597
				}
569
			}
598
			}
599
			initializeExtractNamespace();
570
		}
600
		}
571
	}
601
	}
572
602
Lines 589-595 Link Here
589
	 * for extension points that were renamed between release 2.1 and 3.0.
619
	 * for extension points that were renamed between release 2.1 and 3.0.
590
	 */
620
	 */
591
	private Extension[] fixRenamedExtensionPoints(Extension[] extensions) {
621
	private Extension[] fixRenamedExtensionPoints(Extension[] extensions) {
592
		if (extensions == null || (schemaVersion != null && schemaVersion.equals("3.0")) || RegistryProperties.getProperty(NO_EXTENSION_MUNGING) != null) //$NON-NLS-1$
622
		if (extensions == null || versionAtLeast(VERSION_3_0) || RegistryProperties.getProperty(NO_EXTENSION_MUNGING) != null)
593
			return extensions;
623
			return extensions;
594
		for (int i = 0; i < extensions.length; i++) {
624
		for (int i = 0; i < extensions.length; i++) {
595
			Extension extension = extensions[i];
625
			Extension extension = extensions[i];
Lines 601-604 Link Here
601
		}
631
		}
602
		return extensions;
632
		return extensions;
603
	}
633
	}
634
635
	/**
636
	 * To preserve backward compatibility, we will only attempt to extract namespace form the name 
637
	 * if Eclipse version specified in the plugin.xml (<?eclipse version="3.2"?>) is at least 3.2.
638
	 */
639
	private void initializeExtractNamespace() {
640
		extractNamespaces = new Boolean(versionAtLeast(VERSION_3_2)).booleanValue();
641
	}
642
643
	/**
644
	 * Makes sense only for plugin.xml versions >= 3.0 (Eclipse version was introduced in 3.0).
645
	 * Assumes that version is stored as "X1.X2.....XN" where X1 is a major version; X2 is a minor version
646
	 * and so on.
647
	 */
648
	private boolean versionAtLeast(String testVersion) {
649
		if (schemaVersion == null)
650
			return false;
651
652
		String[] testVersions = testVersion.split("\\."); // '.' is a special character in the regular expressions //$NON-NLS-1$
653
		String[] schemaVersions = schemaVersion.split("\\."); //$NON-NLS-1$
654
		int maxCount = Math.min(testVersions.length, schemaVersions.length);
655
656
		for (int i = 0; i < maxCount; i++) {
657
			try {
658
				if (Integer.parseInt(schemaVersions[i]) < Integer.parseInt(testVersions[i]))
659
					return false;
660
			} catch (NumberFormatException e) {
661
				return false;
662
			}
663
		}
664
		return true;
665
	}
604
}
666
}
(-)Plugin_Testing/registry/testNamespace/1/plugin.xml (-1 / +1 lines)
Lines 1-5 Link Here
1
<?xml version="1.0" encoding="UTF-8"?>
1
<?xml version="1.0" encoding="UTF-8"?>
2
<?eclipse version="3.0"?>
2
<?eclipse version="3.2"?>
3
<plugin id="testNamespace1" name="TestNamespace Plug-in1" version="1.0.0" provider-name="">
3
<plugin id="testNamespace1" name="TestNamespace Plug-in1" version="1.0.0" provider-name="">
4
  
4
  
5
    <extension-point id="org.abc.xptNS1" name="Label xptNS1" schema="schema/xptNS1.exsd"/>
5
    <extension-point id="org.abc.xptNS1" name="Label xptNS1" schema="schema/xptNS1.exsd"/>
(-)Plugin_Testing/registry/testNamespace/2/plugin.xml (-1 / +1 lines)
Lines 1-5 Link Here
1
<?xml version="1.0" encoding="UTF-8"?>
1
<?xml version="1.0" encoding="UTF-8"?>
2
<?eclipse version="3.0"?>
2
<?eclipse version="3.2"?>
3
<plugin id="testNamespace2" name="TestNamespace Plug-in2" version="1.0.0" provider-name="">
3
<plugin id="testNamespace2" name="TestNamespace Plug-in2" version="1.0.0" provider-name="">
4
  
4
  
5
    <extension-point id="org.abc.xptNS2" name="Label xptNS2" schema="schema/xptNS2.exsd"/>
5
    <extension-point id="org.abc.xptNS2" name="Label xptNS2" schema="schema/xptNS2.exsd"/>

Return to bug 128866