Bug 462110 - [bower] Install/Update commands don't follow the NPM Node SemVer rules

Fix an issue with ranges

Author: Stéphane Bégaudeau <stephane.begaudeau@obeo.fr>
Signed-off-by: Stéphane Bégaudeau <stephane.begaudeau@obeo.fr>
Signed-off-by: vrubezhny <vrubezhny@exadel.com>
diff --git a/bundles/org.eclipse.wst.jsdt.nodejs.core/src/main/java/org/eclipse/wst/jsdt/nodejs/core/api/semver/Range.java b/bundles/org.eclipse.wst.jsdt.nodejs.core/src/main/java/org/eclipse/wst/jsdt/nodejs/core/api/semver/Range.java
index ee21abf..274c5a9 100755
--- a/bundles/org.eclipse.wst.jsdt.nodejs.core/src/main/java/org/eclipse/wst/jsdt/nodejs/core/api/semver/Range.java
+++ b/bundles/org.eclipse.wst.jsdt.nodejs.core/src/main/java/org/eclipse/wst/jsdt/nodejs/core/api/semver/Range.java
@@ -29,8 +29,8 @@
 	 * values in this array matters!!! /!\.
 	 */
 	private static final ConstraintKind[] constraintKinds = new ConstraintKind[] {
-			ConstraintKind.GREATER_THAN_OR_EQUALS_TO, ConstraintKind.GREATER_THAN, ConstraintKind.EQUALS_TO,
-			ConstraintKind.LOWER_THAN_OR_EQUALS_TO, ConstraintKind.LOWER_THAN };
+		ConstraintKind.GREATER_THAN_OR_EQUALS_TO, ConstraintKind.GREATER_THAN, ConstraintKind.EQUALS_TO,
+		ConstraintKind.LOWER_THAN_OR_EQUALS_TO, ConstraintKind.LOWER_THAN };
 
 	/**
 	 * The list of constraints of the range.
@@ -70,14 +70,31 @@
 			String nextToken = tokenizer.nextToken();
 			nextToken = nextToken.trim();
 
+			ConstraintKind constraint = null;
+
 			for (ConstraintKind constraintKind : Range.constraintKinds) {
 				if (nextToken.startsWith(constraintKind.getLabel())) {
-					Version version = Version.fromString(nextToken.substring(constraintKind.getLabel()
-							.length()));
-					range.addVersionedConstraint(new VersionedConstraint(version, constraintKind));
+					constraint = constraintKind;
 					break;
 				}
 			}
+
+			if (constraint != null) {
+				Version version = Version.fromString(nextToken.substring(constraint.getLabel().length()));
+				range.addVersionedConstraint(new VersionedConstraint(version, constraint));
+			} else {
+				// Test to see if we have an exact version only
+				Version version = null;
+				try {
+					version = Version.fromString(nextToken);
+				} catch (IllegalArgumentException e) {
+					// do nothing
+				}
+
+				if (version != null) {
+					range.addVersionedConstraint(new VersionedConstraint(version, ConstraintKind.EQUALS_TO));
+				}
+			}
 		}
 
 		return range;
diff --git a/tests/org.eclipse.wst.jsdt.nodejs.core.tests/src/main/java/org/eclipse/wst/jsdt/nodejs/core/tests/internal/semver/RangeTests.java b/tests/org.eclipse.wst.jsdt.nodejs.core.tests/src/main/java/org/eclipse/wst/jsdt/nodejs/core/tests/internal/semver/RangeTests.java
index 266cda9..d247077 100644
--- a/tests/org.eclipse.wst.jsdt.nodejs.core.tests/src/main/java/org/eclipse/wst/jsdt/nodejs/core/tests/internal/semver/RangeTests.java
+++ b/tests/org.eclipse.wst.jsdt.nodejs.core.tests/src/main/java/org/eclipse/wst/jsdt/nodejs/core/tests/internal/semver/RangeTests.java
@@ -49,6 +49,9 @@
 		assertTrue(Version.fromString("1.0.0").isIn(Range.fromString("=v1"))); //$NON-NLS-1$ //$NON-NLS-2$
 
 		// invalid
+		assertFalse(Version.fromString("1.0.1").isIn(Range.fromString("1.0.0"))); //$NON-NLS-1$ //$NON-NLS-2$
+		assertFalse(Version.fromString("1.1.0").isIn(Range.fromString("1.0.0"))); //$NON-NLS-1$ //$NON-NLS-2$
+		assertFalse(Version.fromString("2.0.0").isIn(Range.fromString("1.0.0"))); //$NON-NLS-1$ //$NON-NLS-2$
 		assertFalse(Version.fromString("1.0.1").isIn(Range.fromString("=1.0.0"))); //$NON-NLS-1$ //$NON-NLS-2$
 		assertFalse(Version.fromString("0.9.9").isIn(Range.fromString("=1.0.0"))); //$NON-NLS-1$ //$NON-NLS-2$
 		assertFalse(Version.fromString("1.0.0-beta").isIn(Range.fromString("=1.0.0"))); //$NON-NLS-1$ //$NON-NLS-2$