Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
186 additions
and
101 deletions.
There are no files selected for viewing
20 changes: 0 additions & 20 deletions
20
org.erlide.runtime.tests/src/org/erlide/runtime/RuntimeInfoTest.java
This file was deleted.
Oops, something went wrong.
27 changes: 27 additions & 0 deletions
27
org.erlide.runtime.tests/src/org/erlide/runtime/RuntimeInfoTest.xtend
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package org.erlide.runtime | ||
|
||
import java.util.Collection | ||
import org.erlide.runtime.runtimeinfo.RuntimeInfo | ||
import org.junit.Test | ||
|
||
import static org.hamcrest.MatcherAssert.assertThat | ||
import static org.hamcrest.Matchers.is | ||
|
||
class RuntimeInfoTest { | ||
|
||
@Test | ||
def void codePath_Runtime_1() { | ||
val RuntimeInfo info = new RuntimeInfo("dummy") | ||
val Collection<String> pa = info.getCodePath() | ||
assertThat(pa.size(), is(0)) | ||
assertThat(info.isValid(), is(false)) | ||
} | ||
|
||
// @Test | ||
// def void versionLocator() { | ||
// val RuntimeInfo info1 = new RuntimeInfo("dummy", "", "", #[]) | ||
// TODO create dir that looks like an otp home | ||
// val RuntimeInfo info2 = new RuntimeInfo("dummy", "", "", #[]) | ||
// assertThat(VersionLocator.locateVersion(new RuntimeVersion(18), #[info1, info2], false), is(#[info1])) | ||
// } | ||
} |
23 changes: 23 additions & 0 deletions
23
org.erlide.runtime.tests/xtend-gen/org/erlide/runtime/RuntimeInfoTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package org.erlide.runtime; | ||
|
||
import java.util.Collection; | ||
import org.erlide.runtime.runtimeinfo.RuntimeInfo; | ||
import org.hamcrest.Matcher; | ||
import org.hamcrest.MatcherAssert; | ||
import org.hamcrest.Matchers; | ||
import org.junit.Test; | ||
|
||
@SuppressWarnings("all") | ||
public class RuntimeInfoTest { | ||
@Test | ||
public void codePath_Runtime_1() { | ||
final RuntimeInfo info = new RuntimeInfo("dummy"); | ||
final Collection<String> pa = info.getCodePath(); | ||
int _size = pa.size(); | ||
Matcher<Integer> _is = Matchers.<Integer>is(Integer.valueOf(0)); | ||
MatcherAssert.<Integer>assertThat(Integer.valueOf(_size), _is); | ||
boolean _isValid = info.isValid(); | ||
Matcher<Boolean> _is_1 = Matchers.<Boolean>is(Boolean.valueOf(false)); | ||
MatcherAssert.<Boolean>assertThat(Boolean.valueOf(_isValid), _is_1); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 0 additions & 43 deletions
43
org.erlide.runtime/src/org/erlide/runtime/runtimeinfo/VersionLocator.java
This file was deleted.
Oops, something went wrong.
38 changes: 38 additions & 0 deletions
38
org.erlide.runtime/src/org/erlide/runtime/runtimeinfo/VersionLocator.xtend
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package org.erlide.runtime.runtimeinfo | ||
|
||
import java.util.Collection | ||
import java.util.Collections | ||
import java.util.List | ||
|
||
class VersionLocator { | ||
/** | ||
* Locate runtimes with this version. If exact matches exist, they are first in the | ||
* result list. If strict, only this version or newer are returned, otherwise all. A | ||
* null or empty version returns all runtimes. | ||
*/ | ||
def static Collection<RuntimeInfo> locateVersion(RuntimeVersion vsn, Collection<RuntimeInfo> runtimes, | ||
boolean strict) { | ||
val List<RuntimeInfo> result = newArrayList() | ||
for (info : runtimes) { | ||
val v = info.getVersion() | ||
if (v.isReleaseCompatible(vsn)) { | ||
result.add(info) | ||
} | ||
} | ||
Collections.reverse(result) | ||
// at the end, first newer versions | ||
for (info : runtimes) { | ||
val v = info.getVersion() | ||
if (v.compareTo(vsn) > 0) { | ||
result.add(info) | ||
} | ||
} | ||
// and if necessary, older versions | ||
if (!strict) { | ||
for (info : runtimes) { | ||
result.add(info) | ||
} | ||
} | ||
result.filter[isValid()].toSet | ||
} | ||
} |
60 changes: 60 additions & 0 deletions
60
org.erlide.runtime/xtend-gen/org/erlide/runtime/runtimeinfo/VersionLocator.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
package org.erlide.runtime.runtimeinfo; | ||
|
||
import java.util.Collection; | ||
import java.util.Collections; | ||
import java.util.List; | ||
import java.util.Set; | ||
import org.eclipse.xtext.xbase.lib.CollectionLiterals; | ||
import org.eclipse.xtext.xbase.lib.Functions.Function1; | ||
import org.eclipse.xtext.xbase.lib.IterableExtensions; | ||
import org.erlide.runtime.runtimeinfo.RuntimeInfo; | ||
import org.erlide.runtime.runtimeinfo.RuntimeVersion; | ||
|
||
@SuppressWarnings("all") | ||
public class VersionLocator { | ||
/** | ||
* Locate runtimes with this version. If exact matches exist, they are first in the | ||
* result list. If strict, only this version or newer are returned, otherwise all. A | ||
* null or empty version returns all runtimes. | ||
*/ | ||
public static Collection<RuntimeInfo> locateVersion(final RuntimeVersion vsn, final Collection<RuntimeInfo> runtimes, final boolean strict) { | ||
Set<RuntimeInfo> _xblockexpression = null; | ||
{ | ||
final List<RuntimeInfo> result = CollectionLiterals.<RuntimeInfo>newArrayList(); | ||
for (final RuntimeInfo info : runtimes) { | ||
{ | ||
final RuntimeVersion v = info.getVersion(); | ||
boolean _isReleaseCompatible = v.isReleaseCompatible(vsn); | ||
if (_isReleaseCompatible) { | ||
result.add(info); | ||
} | ||
} | ||
} | ||
Collections.reverse(result); | ||
for (final RuntimeInfo info_1 : runtimes) { | ||
{ | ||
final RuntimeVersion v = info_1.getVersion(); | ||
int _compareTo = v.compareTo(vsn); | ||
boolean _greaterThan = (_compareTo > 0); | ||
if (_greaterThan) { | ||
result.add(info_1); | ||
} | ||
} | ||
} | ||
if ((!strict)) { | ||
for (final RuntimeInfo info_2 : runtimes) { | ||
result.add(info_2); | ||
} | ||
} | ||
final Function1<RuntimeInfo, Boolean> _function = new Function1<RuntimeInfo, Boolean>() { | ||
@Override | ||
public Boolean apply(final RuntimeInfo it) { | ||
return Boolean.valueOf(it.isValid()); | ||
} | ||
}; | ||
Iterable<RuntimeInfo> _filter = IterableExtensions.<RuntimeInfo>filter(result, _function); | ||
_xblockexpression = IterableExtensions.<RuntimeInfo>toSet(_filter); | ||
} | ||
return _xblockexpression; | ||
} | ||
} |
Oops, something went wrong.