Search in sources :

Example 6 with Pair

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);
}
Also used : StringConcatenation(org.eclipse.xtend2.lib.StringConcatenation) FormattingConfiguration(org.eclipse.xtext.testing.FormattingConfiguration) RangeFormattingConfiguration(org.eclipse.xtext.testing.RangeFormattingConfiguration) Pair(org.eclipse.xtext.xbase.lib.Pair) AbstractTestLangLanguageServerTest(org.eclipse.xtext.ide.tests.server.AbstractTestLangLanguageServerTest) Test(org.junit.Test)

Example 7 with Pair

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);
}
Also used : ReferenceTestConfiguration(org.eclipse.xtext.testing.ReferenceTestConfiguration) StringConcatenation(org.eclipse.xtend2.lib.StringConcatenation) Pair(org.eclipse.xtext.xbase.lib.Pair) Test(org.junit.Test) AbstractTestLangLanguageServerTest(org.eclipse.xtext.ide.tests.server.AbstractTestLangLanguageServerTest)

Example 8 with Pair

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());
}
Also used : DefineOption(org.erlide.core.builder.CompilerOption.DefineOption) OtpErlangObject(com.ericsson.otp.erlang.OtpErlangObject) Pair(org.eclipse.xtext.xbase.lib.Pair) Test(org.junit.Test)

Example 9 with Pair

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) {
    }
}
Also used : BufferedReader(java.io.BufferedReader) ArrayList(java.util.ArrayList) FileReader(java.io.FileReader) IOException(java.io.IOException) Pair(org.eclipse.xtext.xbase.lib.Pair)

Example 10 with Pair

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);
}
Also used : Label(org.eclipse.swt.widgets.Label) GridData(org.eclipse.swt.layout.GridData) Text(org.eclipse.swt.widgets.Text) Pair(org.eclipse.xtext.xbase.lib.Pair)

Aggregations

Pair (org.eclipse.xtext.xbase.lib.Pair)67 StringConcatenation (org.eclipse.xtend2.lib.StringConcatenation)22 Test (org.junit.Test)15 Collection (java.util.Collection)11 List (java.util.List)11 ArrayList (java.util.ArrayList)9 AbstractHierarchyBuilderTest (org.eclipse.xtext.junit4.ide.AbstractHierarchyBuilderTest)9 Function1 (org.eclipse.xtext.xbase.lib.Functions.Function1)9 Map (java.util.Map)6 EObject (org.eclipse.emf.ecore.EObject)6 Resource (org.eclipse.emf.ecore.resource.Resource)6 AbstractElement (org.eclipse.xtext.AbstractElement)6 HashMap (java.util.HashMap)5 ParameterizedTypeRef (org.eclipse.n4js.ts.typeRefs.ParameterizedTypeRef)5 Type (org.eclipse.n4js.ts.types.Type)5 EList (org.eclipse.emf.common.util.EList)4 StringConcatenationClient (org.eclipse.xtend2.lib.StringConcatenationClient)4 UnorderedGroup (org.eclipse.xtext.UnorderedGroup)4 LinkedHashMap (java.util.LinkedHashMap)3 LinkedList (java.util.LinkedList)3