use of kotlin.Pair in project kotlin by JetBrains.
the class AbstractLineNumberTest method createPsiFile.
@NotNull
private Pair<KtFile, KotlinCoreEnvironment> createPsiFile(@NotNull String filename) {
File file = new File(filename);
KotlinCoreEnvironment environment = createEnvironment();
String text;
try {
text = FileUtil.loadFile(file, true);
} catch (IOException e) {
throw ExceptionUtilsKt.rethrow(e);
}
return new Pair<KtFile, KotlinCoreEnvironment>(KotlinTestUtils.createFile(file.getName(), text, environment.getProject()), environment);
}
use of kotlin.Pair in project kotlin by JetBrains.
the class AbstractCliTest method executeCompilerGrabOutput.
@NotNull
public static Pair<String, ExitCode> executeCompilerGrabOutput(@NotNull CLICompiler<?> compiler, @NotNull List<String> args) {
ByteArrayOutputStream bytes = new ByteArrayOutputStream();
PrintStream origErr = System.err;
try {
System.setErr(new PrintStream(bytes));
ExitCode exitCode = CLICompiler.doMainNoExit(compiler, ArrayUtil.toStringArray(args));
return new Pair<String, ExitCode>(bytes.toString("utf-8"), exitCode);
} catch (Exception e) {
throw ExceptionUtilsKt.rethrow(e);
} finally {
System.setErr(origErr);
}
}
use of kotlin.Pair in project Ardent by adamint.
the class Command method dispatchInteractiveEvent.
private static boolean dispatchInteractiveEvent(OffsetDateTime creationTime, TextChannel channel, Message message, User user, Consumer<Message> function, int time, boolean sendMessage) {
final boolean[] success = { false };
Pair<String, Triplet<String, String, Consumer<Message>>> p = new Pair<>(channel.getId(), new Triplet<>(user.getId(), message.getId(), function));
InteractiveEvent e = GuildUtils.getShard(channel.getJDA()).interactiveEvent;
e.getMessageInteractivesQueue().add(p);
ex.schedule(() -> {
if (e.getMessageInteractivesQueue().contains(p)) {
e.getMessageInteractivesQueue().remove(p);
if (sendMessage) {
if (time >= 15) {
channel.sendMessage("Cancelled your interactive operation because you didn't respond within " + time + " seconds!").queue();
} else {
channel.sendMessage("Cancelled your reaction event because you didn't respond within **" + String.valueOf(time / 1000) + "** seconds").queue();
}
}
}
return success[0];
}, time, TimeUnit.SECONDS);
return success[0];
}
use of kotlin.Pair in project kotlin by JetBrains.
the class CheckerTestUtil method getDiagnosticsIncludingSyntaxErrors.
@NotNull
public static List<ActualDiagnostic> getDiagnosticsIncludingSyntaxErrors(@NotNull BindingContext bindingContext, @NotNull List<Pair<MultiTargetPlatform, BindingContext>> implementingModulesBindings, @NotNull PsiElement root, boolean markDynamicCalls, @Nullable List<DeclarationDescriptor> dynamicCallDescriptors) {
List<ActualDiagnostic> result = getDiagnosticsIncludingSyntaxErrors(bindingContext, root, markDynamicCalls, dynamicCallDescriptors, null);
List<Pair<MultiTargetPlatform, BindingContext>> sortedBindings = CollectionsKt.sortedWith(implementingModulesBindings, new Comparator<Pair<MultiTargetPlatform, BindingContext>>() {
@Override
public int compare(Pair<MultiTargetPlatform, BindingContext> o1, Pair<MultiTargetPlatform, BindingContext> o2) {
return o1.getFirst().compareTo(o2.getFirst());
}
});
for (Pair<MultiTargetPlatform, BindingContext> binding : sortedBindings) {
MultiTargetPlatform platform = binding.getFirst();
assert platform instanceof MultiTargetPlatform.Specific : "Implementing module must have a specific platform: " + platform;
result.addAll(getDiagnosticsIncludingSyntaxErrors(binding.getSecond(), root, markDynamicCalls, dynamicCallDescriptors, ((MultiTargetPlatform.Specific) platform).getPlatform()));
}
return result;
}
use of kotlin.Pair in project kotlin by JetBrains.
the class AbstractCompileKotlinAgainstKotlinTest method doTwoFileTest.
@NotNull
protected Pair<ClassFileFactory, ClassFileFactory> doTwoFileTest(@NotNull List<TestFile> files) throws Exception {
// Note that it may be beneficial to improve this test to handle many files, compiling them successively against all previous
assert files.size() == 2 : "There should be exactly two files in this test";
TestFile fileA = files.get(0);
TestFile fileB = files.get(1);
ClassFileFactory factoryA = compileA(fileA, files);
ClassFileFactory factoryB = null;
try {
factoryB = compileB(fileB, files);
invokeBox(PackagePartClassUtils.getFilePartShortName(new File(fileB.name).getName()));
} catch (Throwable e) {
String result = "FIRST: \n\n" + factoryA.createText();
if (factoryB != null) {
result += "\n\nSECOND: \n\n" + factoryB.createText();
}
System.out.println(result);
throw ExceptionUtilsKt.rethrow(e);
}
return new Pair<ClassFileFactory, ClassFileFactory>(factoryA, factoryB);
}
Aggregations