use of org.eclipse.xtext.xbase.lib.Pair in project xtext-core by eclipse.
the class FormattingTest method testFormattingClosedFile.
@Test
public void testFormattingClosedFile() {
final Procedure1<FormattingConfiguration> _function = (FormattingConfiguration it) -> {
StringConcatenation _builder = new StringConcatenation();
_builder.append("type Foo{int bar} type Bar{Foo foo}");
Pair<String, String> _mappedTo = Pair.<String, String>of("foo.testlang", _builder.toString());
it.setFilesInScope(Collections.<String, CharSequence>unmodifiableMap(CollectionLiterals.<String, CharSequence>newHashMap(_mappedTo)));
StringConcatenation _builder_1 = new StringConcatenation();
_builder_1.append("type Foo{");
_builder_1.newLine();
_builder_1.append("\t");
_builder_1.append("int bar");
_builder_1.newLine();
_builder_1.append("}");
_builder_1.newLine();
_builder_1.append("type Bar{");
_builder_1.newLine();
_builder_1.append("\t");
_builder_1.append("Foo foo");
_builder_1.newLine();
_builder_1.append("}");
_builder_1.newLine();
it.setExpectedText(_builder_1.toString());
};
this.testFormatting(_function);
}
use of org.eclipse.xtext.xbase.lib.Pair in project xtext-core by eclipse.
the class ReferenceTest method testReferences_03_acrossFiles.
@Test
public void testReferences_03_acrossFiles() {
final Procedure1<ReferenceTestConfiguration> _function = (ReferenceTestConfiguration it) -> {
StringConcatenation _builder = new StringConcatenation();
_builder.append("type Foo {}");
_builder.newLine();
Pair<String, String> _mappedTo = Pair.<String, String>of("foo.testlang", _builder.toString());
it.setFilesInScope(Collections.<String, CharSequence>unmodifiableMap(CollectionLiterals.<String, CharSequence>newHashMap(_mappedTo)));
StringConcatenation _builder_1 = new StringConcatenation();
_builder_1.append("type Bar {");
_builder_1.newLine();
_builder_1.append(" ");
_builder_1.append("Foo foo");
_builder_1.newLine();
_builder_1.append("}");
_builder_1.newLine();
it.setModel(_builder_1.toString());
it.setLine(1);
it.setColumn(6);
it.setIncludeDeclaration(true);
StringConcatenation _builder_2 = new StringConcatenation();
_builder_2.append("foo.testlang [[0, 5] .. [0, 8]]");
_builder_2.newLine();
_builder_2.append("MyModel.testlang [[1, 4] .. [1, 7]]");
_builder_2.newLine();
it.setExpectedReferences(_builder_2.toString());
};
this.testReferences(_function);
}
use of org.eclipse.xtext.xbase.lib.Pair in project erlide_eclipse by erlang.
the class CompilerOptionTest method testToTerm_5a.
@Test
public void testToTerm_5a() throws OtpParserException {
final DefineOption option = CompilerOptions.DEFINE;
@SuppressWarnings("unchecked") final List<Pair<String, String>> values = Lists.newArrayList(new Pair<>("Macro", ""));
final OtpErlangObject actual = option.toTerm(values);
final String expected = "[{d,'Macro'}]";
Assert.assertEquals(expected, actual.toString());
}
use of org.eclipse.xtext.xbase.lib.Pair in project erlide_eclipse by erlang.
the class MarkerUtils method getScanMarkersFor.
public static void getScanMarkersFor(final IResource resource) {
try (final BufferedReader reader = new BufferedReader(new FileReader(resource.getLocation().toPortableString()))) {
String line = reader.readLine();
final List<Pair<String, Integer>> cl = new ArrayList<>();
int numline = 0;
while (line != null) {
if (line.matches(MarkerUtils.TODO_XXX_FIXME_PATTERN)) {
cl.add(new Pair<>(line, numline));
}
numline++;
line = reader.readLine();
}
for (final Pair<String, Integer> c : cl) {
MarkerUtils.createTaskMarkerAtText(resource, c.getValue(), c.getKey(), MarkerUtils.TODO_TAG, IMarker.PRIORITY_NORMAL);
MarkerUtils.createTaskMarkerAtText(resource, c.getValue(), c.getKey(), MarkerUtils.XXX_TAG, IMarker.PRIORITY_NORMAL);
MarkerUtils.createTaskMarkerAtText(resource, c.getValue(), c.getKey(), MarkerUtils.FIXME_TAG, IMarker.PRIORITY_HIGH);
}
} catch (final IOException e) {
}
}
use of org.eclipse.xtext.xbase.lib.Pair in project erlide_eclipse by erlang.
the class ErlidePreferencePage method addTextField.
protected Pair<Text, String> addTextField(final Composite composite, final String label, final String key, final int textLimit, final int indentation, final boolean isNumber) {
final Label labelControl = new Label(composite, SWT.NONE);
labelControl.setText(label);
GridData gd = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
gd.horizontalIndent = indentation;
labelControl.setLayoutData(gd);
final Text textControl = new Text(composite, SWT.BORDER | SWT.SINGLE);
gd = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
gd.widthHint = convertWidthInCharsToPixels(textLimit + 1);
textControl.setLayoutData(gd);
textControl.setTextLimit(textLimit);
if (isNumber) {
textControl.addModifyListener(getNumberFieldListener());
fNumberFields.add(textControl);
}
return new Pair<>(textControl, getDialogPreferenceKey() + "/" + key);
}
Aggregations