Java Code Examples for org.eclipse.xtext.ui.testing.ContentAssistProcessorTestBuilder#expectContent()

The following examples show how to use org.eclipse.xtext.ui.testing.ContentAssistProcessorTestBuilder#expectContent() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ContentAssistTest.java    From xtext-eclipse with Eclipse Public License 2.0 5 votes vote down vote up
@Test
public void testEntityTemplateProposal() {
  try {
    ContentAssistProcessorTestBuilder _applyProposal = this.newBuilder().applyProposal("Entity - template for an Entity");
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("entity name {");
    _builder.newLine();
    _builder.append("\t");
    _builder.newLine();
    _builder.append("}");
    _applyProposal.expectContent(_builder.toString());
  } catch (Throwable _e) {
    throw Exceptions.sneakyThrow(_e);
  }
}
 
Example 2
Source File: ContentAssistTest.java    From xtext-eclipse with Eclipse Public License 2.0 5 votes vote down vote up
@Test
public void testPackageTemplateProposal() {
  try {
    ContentAssistProcessorTestBuilder _applyProposal = this.newBuilder().applyProposal("Package - template for a Package");
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("package name {");
    _builder.newLine();
    _builder.append("\t");
    _builder.newLine();
    _builder.append("}");
    _applyProposal.expectContent(_builder.toString());
  } catch (Throwable _e) {
    throw Exceptions.sneakyThrow(_e);
  }
}
 
Example 3
Source File: XImportSectionContentAssistTest.java    From xtext-xtend with Eclipse Public License 2.0 5 votes vote down vote up
@Test
public void testStaticFavoriteImports_operation() {
  try {
    final String defaultprefs = PreferenceConstants.getPreference(PreferenceConstants.CODEASSIST_FAVORITE_STATIC_MEMBERS, null);
    final IEclipsePreferences jdtPreference = InstanceScope.INSTANCE.getNode(JavaUI.ID_PLUGIN);
    try {
      String _name = StaticClassExample.class.getName();
      String _plus = (_name + ".*");
      jdtPreference.put(PreferenceConstants.CODEASSIST_FAVORITE_STATIC_MEMBERS, _plus);
      ContentAssistProcessorTestBuilder _newBuilder = this.newBuilder();
      StringConcatenation _builder = new StringConcatenation();
      _builder.append("package mypack");
      _builder.newLine();
      _builder.append("class Bar{");
      _builder.newLine();
      _builder.append("\t");
      _builder.append("def void foo(){");
      _builder.newLine();
      ContentAssistProcessorTestBuilder _applyProposal = _newBuilder.append(_builder.toString()).applyProposal("staticMethod()");
      StringConcatenation _builder_1 = new StringConcatenation();
      _builder_1.append("package mypack");
      _builder_1.newLine();
      _builder_1.newLine();
      _builder_1.append("import static org.eclipse.xtend.ide.tests.data.contentassist.StaticClassExample.staticMethod");
      _builder_1.newLine();
      _builder_1.newLine();
      _builder_1.append("class Bar{");
      _builder_1.newLine();
      _builder_1.append("\t");
      _builder_1.append("def void foo(){");
      _builder_1.newLine();
      _builder_1.append("staticMethod()");
      _applyProposal.expectContent(_builder_1.toString());
    } finally {
      jdtPreference.put(PreferenceConstants.CODEASSIST_FAVORITE_STATIC_MEMBERS, defaultprefs);
    }
  } catch (Throwable _e) {
    throw Exceptions.sneakyThrow(_e);
  }
}
 
Example 4
Source File: XImportSectionContentAssistTest.java    From xtext-xtend with Eclipse Public License 2.0 5 votes vote down vote up
@Test
public void testStaticFavoriteImports_operation_direct() {
  try {
    final String defaultprefs = PreferenceConstants.getPreference(PreferenceConstants.CODEASSIST_FAVORITE_STATIC_MEMBERS, null);
    final IEclipsePreferences jdtPreference = InstanceScope.INSTANCE.getNode(JavaUI.ID_PLUGIN);
    try {
      String _name = StaticClassExample.class.getName();
      String _plus = (_name + ".staticMethod");
      jdtPreference.put(PreferenceConstants.CODEASSIST_FAVORITE_STATIC_MEMBERS, _plus);
      ContentAssistProcessorTestBuilder _newBuilder = this.newBuilder();
      StringConcatenation _builder = new StringConcatenation();
      _builder.append("package mypack");
      _builder.newLine();
      _builder.append("class Bar{");
      _builder.newLine();
      _builder.append("\t");
      _builder.append("def void foo(){");
      _builder.newLine();
      ContentAssistProcessorTestBuilder _applyProposal = _newBuilder.append(_builder.toString()).applyProposal("staticMethod()");
      StringConcatenation _builder_1 = new StringConcatenation();
      _builder_1.append("package mypack");
      _builder_1.newLine();
      _builder_1.newLine();
      _builder_1.append("import static org.eclipse.xtend.ide.tests.data.contentassist.StaticClassExample.staticMethod");
      _builder_1.newLine();
      _builder_1.newLine();
      _builder_1.append("class Bar{");
      _builder_1.newLine();
      _builder_1.append("\t");
      _builder_1.append("def void foo(){");
      _builder_1.newLine();
      _builder_1.append("staticMethod()");
      _applyProposal.expectContent(_builder_1.toString());
    } finally {
      jdtPreference.put(PreferenceConstants.CODEASSIST_FAVORITE_STATIC_MEMBERS, defaultprefs);
    }
  } catch (Throwable _e) {
    throw Exceptions.sneakyThrow(_e);
  }
}
 
Example 5
Source File: XImportSectionContentAssistTest.java    From xtext-xtend with Eclipse Public License 2.0 5 votes vote down vote up
@Test
public void testStaticFavoriteImports_field() {
  try {
    final String defaultprefs = PreferenceConstants.getPreference(PreferenceConstants.CODEASSIST_FAVORITE_STATIC_MEMBERS, null);
    final IEclipsePreferences jdtPreference = InstanceScope.INSTANCE.getNode(JavaUI.ID_PLUGIN);
    try {
      String _name = StaticClassExample.class.getName();
      String _plus = (_name + ".*");
      jdtPreference.put(PreferenceConstants.CODEASSIST_FAVORITE_STATIC_MEMBERS, _plus);
      ContentAssistProcessorTestBuilder _newBuilder = this.newBuilder();
      StringConcatenation _builder = new StringConcatenation();
      _builder.append("package mypack");
      _builder.newLine();
      _builder.append("class Bar{");
      _builder.newLine();
      _builder.append("\t");
      _builder.append("def void foo(){");
      _builder.newLine();
      ContentAssistProcessorTestBuilder _applyProposal = _newBuilder.append(_builder.toString()).applyProposal("STATICFIELD");
      StringConcatenation _builder_1 = new StringConcatenation();
      _builder_1.append("package mypack");
      _builder_1.newLine();
      _builder_1.newLine();
      _builder_1.append("import static org.eclipse.xtend.ide.tests.data.contentassist.StaticClassExample.STATICFIELD");
      _builder_1.newLine();
      _builder_1.newLine();
      _builder_1.append("class Bar{");
      _builder_1.newLine();
      _builder_1.append("\t");
      _builder_1.append("def void foo(){");
      _builder_1.newLine();
      _builder_1.append("STATICFIELD");
      _applyProposal.expectContent(_builder_1.toString());
    } finally {
      jdtPreference.put(PreferenceConstants.CODEASSIST_FAVORITE_STATIC_MEMBERS, defaultprefs);
    }
  } catch (Throwable _e) {
    throw Exceptions.sneakyThrow(_e);
  }
}
 
Example 6
Source File: Issue242Test.java    From xtext-xtend with Eclipse Public License 2.0 5 votes vote down vote up
@Test
public void test_01() throws Exception {
  ContentAssistProcessorTestBuilder _newBuilder = this.newBuilder();
  StringConcatenation _builder = new StringConcatenation();
  _builder.append("class Test {");
  _builder.newLine();
  _builder.append("\t");
  _builder.append("def void m() {");
  _builder.newLine();
  _builder.append("\t\t");
  _builder.append("val ^default = 1");
  _builder.newLine();
  _builder.append("\t\t");
  _builder.append("println(^de<|>");
  ContentAssistProcessorTestBuilder _apply = _newBuilder.append(_builder.toString()).assertProposalAtCursor("^default").apply();
  StringConcatenation _builder_1 = new StringConcatenation();
  _builder_1.append("class Test {");
  _builder_1.newLine();
  _builder_1.append("\t");
  _builder_1.append("def void m() {");
  _builder_1.newLine();
  _builder_1.append("\t\t");
  _builder_1.append("val ^default = 1");
  _builder_1.newLine();
  _builder_1.append("\t\t");
  _builder_1.append("println(^default");
  _apply.expectContent(_builder_1.toString());
}
 
Example 7
Source File: Bug460093Test.java    From xtext-xtend with Eclipse Public License 2.0 5 votes vote down vote up
@Test
public void testMethodOverrides1() {
  try {
    ContentAssistProcessorTestBuilder _newBuilder = this.newBuilder();
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("import java.util.List");
    _builder.newLine();
    _builder.newLine();
    _builder.append("interface I extends List<String> {");
    _builder.newLine();
    _builder.newLine();
    _builder.append("\t");
    _builder.append("str");
    ContentAssistProcessorTestBuilder _applyProposal = _newBuilder.append(_builder.toString()).assertText("\n\toverride stream() {\n\t\tList.super.stream()\n\t}").applyProposal();
    StringConcatenation _builder_1 = new StringConcatenation();
    _builder_1.append("import java.util.List");
    _builder_1.newLine();
    _builder_1.newLine();
    _builder_1.append("interface I extends List<String> {");
    _builder_1.newLine();
    _builder_1.newLine();
    _builder_1.append("\t");
    _builder_1.append("override stream() {");
    _builder_1.newLine();
    _builder_1.append("\t\t");
    _builder_1.append("List.super.stream()");
    _builder_1.newLine();
    _builder_1.append("\t");
    _builder_1.append("}");
    _applyProposal.expectContent(_builder_1.toString());
  } catch (Throwable _e) {
    throw Exceptions.sneakyThrow(_e);
  }
}
 
Example 8
Source File: Bug460093Test.java    From xtext-xtend with Eclipse Public License 2.0 5 votes vote down vote up
@Test
public void testMethodOverrides2() {
  try {
    ContentAssistProcessorTestBuilder _newBuilder = this.newBuilder();
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("import java.util.Comparator");
    _builder.newLine();
    _builder.newLine();
    _builder.append("interface I extends Comparator<String> {");
    _builder.newLine();
    _builder.newLine();
    _builder.append("\t");
    _builder.append("r");
    ContentAssistProcessorTestBuilder _applyProposal = _newBuilder.append(_builder.toString()).assertText("\n\toverride reversed() {\n\t\tComparator.super.reversed()\n\t}").applyProposal();
    StringConcatenation _builder_1 = new StringConcatenation();
    _builder_1.append("import java.util.Comparator");
    _builder_1.newLine();
    _builder_1.newLine();
    _builder_1.append("interface I extends Comparator<String> {");
    _builder_1.newLine();
    _builder_1.newLine();
    _builder_1.append("\t");
    _builder_1.append("override reversed() {");
    _builder_1.newLine();
    _builder_1.append("\t\t");
    _builder_1.append("Comparator.super.reversed()");
    _builder_1.newLine();
    _builder_1.append("\t");
    _builder_1.append("}");
    _applyProposal.expectContent(_builder_1.toString());
  } catch (Throwable _e) {
    throw Exceptions.sneakyThrow(_e);
  }
}
 
Example 9
Source File: Bug415030Test.java    From xtext-xtend with Eclipse Public License 2.0 5 votes vote down vote up
@Test
public void testMethodOverrides() {
  try {
    ContentAssistProcessorTestBuilder _newBuilder = this.newBuilder();
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("class A {");
    _builder.newLine();
    _builder.newLine();
    _builder.append("\t");
    _builder.append("to");
    ContentAssistProcessorTestBuilder _applyProposal = _newBuilder.append(_builder.toString()).assertText("\n\toverride toString() {\n\t\tsuper.toString()\n\t}").applyProposal();
    StringConcatenation _builder_1 = new StringConcatenation();
    _builder_1.append("class A {");
    _builder_1.newLine();
    _builder_1.newLine();
    _builder_1.append("\t");
    _builder_1.append("override toString() {");
    _builder_1.newLine();
    _builder_1.append("\t\t");
    _builder_1.append("super.toString()");
    _builder_1.newLine();
    _builder_1.append("\t");
    _builder_1.append("}");
    _applyProposal.expectContent(_builder_1.toString());
  } catch (Throwable _e) {
    throw Exceptions.sneakyThrow(_e);
  }
}
 
Example 10
Source File: Bug415030Test.java    From xtext-xtend with Eclipse Public License 2.0 5 votes vote down vote up
@Test
public void testMethodOverrides_2() {
  try {
    ContentAssistProcessorTestBuilder _newBuilder = this.newBuilder();
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("class A {");
    _builder.newLine();
    _builder.newLine();
    _builder.append("\t");
    _builder.append("to");
    ContentAssistProcessorTestBuilder _appendAndApplyProposal = _newBuilder.append(_builder.toString()).assertText("\n\toverride toString() {\n\t\tsuper.toString()\n\t}").appendAndApplyProposal("Str");
    StringConcatenation _builder_1 = new StringConcatenation();
    _builder_1.append("class A {");
    _builder_1.newLine();
    _builder_1.newLine();
    _builder_1.append("\t");
    _builder_1.append("override toString() {");
    _builder_1.newLine();
    _builder_1.append("\t\t");
    _builder_1.append("super.toString()");
    _builder_1.newLine();
    _builder_1.append("\t");
    _builder_1.append("}");
    _appendAndApplyProposal.expectContent(_builder_1.toString());
  } catch (Throwable _e) {
    throw Exceptions.sneakyThrow(_e);
  }
}
 
Example 11
Source File: EclipseIssue219Test.java    From xtext-xtend with Eclipse Public License 2.0 5 votes vote down vote up
@Test
public void testIssue219() {
  try {
    ContentAssistProcessorTestBuilder _newBuilder = this.newBuilder();
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("package test");
    _builder.newLine();
    _builder.append("class Test {");
    _builder.newLine();
    _builder.append("\t");
    _builder.newLine();
    ContentAssistProcessorTestBuilder _applyProposal = _newBuilder.append(_builder.toString()).applyProposal("def - public method");
    StringConcatenation _builder_1 = new StringConcatenation();
    _builder_1.append("package test");
    _builder_1.newLine();
    _builder_1.append("class Test {");
    _builder_1.newLine();
    _builder_1.append("\t");
    _builder_1.newLine();
    _builder_1.append("def name(params) {");
    _builder_1.newLine();
    _builder_1.append("\t");
    _builder_1.newLine();
    _builder_1.append("}");
    _applyProposal.expectContent(_builder_1.toString());
  } catch (Throwable _e) {
    throw Exceptions.sneakyThrow(_e);
  }
}
 
Example 12
Source File: XImportSectionContentAssistTest.java    From xtext-xtend with Eclipse Public License 2.0 4 votes vote down vote up
@Test
public void testMemberName_3() {
  try {
    ContentAssistProcessorTestBuilder _newBuilder = this.newBuilder();
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("package org.eclipse.xtend.ide.tests.data.contentassist");
    _builder.newLine();
    _builder.newLine();
    _builder.append("import static org.eclipse.xtend.ide.tests.data.contentassist.Foo.");
    final ContentAssistProcessorTestBuilder builder = _newBuilder.append(_builder.toString()).assertText("publicStaticMethod", "defaultStaticMethod", "protectedStaticMethod", 
      "publicStaticField", "defaultStaticField", "protectedStaticField");
    ContentAssistProcessorTestBuilder _applyProposal = builder.applyProposal("publicStaticMethod");
    StringConcatenation _builder_1 = new StringConcatenation();
    _builder_1.append("package org.eclipse.xtend.ide.tests.data.contentassist");
    _builder_1.newLine();
    _builder_1.newLine();
    _builder_1.append("import static org.eclipse.xtend.ide.tests.data.contentassist.Foo.publicStaticMethod");
    _applyProposal.expectContent(_builder_1.toString());
    ContentAssistProcessorTestBuilder _applyProposal_1 = builder.applyProposal("defaultStaticMethod");
    StringConcatenation _builder_2 = new StringConcatenation();
    _builder_2.append("package org.eclipse.xtend.ide.tests.data.contentassist");
    _builder_2.newLine();
    _builder_2.newLine();
    _builder_2.append("import static org.eclipse.xtend.ide.tests.data.contentassist.Foo.defaultStaticMethod");
    _applyProposal_1.expectContent(_builder_2.toString());
    ContentAssistProcessorTestBuilder _applyProposal_2 = builder.applyProposal("protectedStaticMethod");
    StringConcatenation _builder_3 = new StringConcatenation();
    _builder_3.append("package org.eclipse.xtend.ide.tests.data.contentassist");
    _builder_3.newLine();
    _builder_3.newLine();
    _builder_3.append("import static org.eclipse.xtend.ide.tests.data.contentassist.Foo.protectedStaticMethod");
    _applyProposal_2.expectContent(_builder_3.toString());
    ContentAssistProcessorTestBuilder _applyProposal_3 = builder.applyProposal("publicStaticField");
    StringConcatenation _builder_4 = new StringConcatenation();
    _builder_4.append("package org.eclipse.xtend.ide.tests.data.contentassist");
    _builder_4.newLine();
    _builder_4.newLine();
    _builder_4.append("import static org.eclipse.xtend.ide.tests.data.contentassist.Foo.publicStaticField");
    _applyProposal_3.expectContent(_builder_4.toString());
    ContentAssistProcessorTestBuilder _applyProposal_4 = builder.applyProposal("defaultStaticField");
    StringConcatenation _builder_5 = new StringConcatenation();
    _builder_5.append("package org.eclipse.xtend.ide.tests.data.contentassist");
    _builder_5.newLine();
    _builder_5.newLine();
    _builder_5.append("import static org.eclipse.xtend.ide.tests.data.contentassist.Foo.defaultStaticField");
    _applyProposal_4.expectContent(_builder_5.toString());
    ContentAssistProcessorTestBuilder _applyProposal_5 = builder.applyProposal("protectedStaticField");
    StringConcatenation _builder_6 = new StringConcatenation();
    _builder_6.append("package org.eclipse.xtend.ide.tests.data.contentassist");
    _builder_6.newLine();
    _builder_6.newLine();
    _builder_6.append("import static org.eclipse.xtend.ide.tests.data.contentassist.Foo.protectedStaticField");
    _applyProposal_5.expectContent(_builder_6.toString());
  } catch (Throwable _e) {
    throw Exceptions.sneakyThrow(_e);
  }
}
 
Example 13
Source File: XImportSectionContentAssistTest.java    From xtext-xtend with Eclipse Public License 2.0 4 votes vote down vote up
@Test
public void testStaticFavoriteImports_operation_direct_extension() {
  try {
    final String defaultprefs = PreferenceConstants.getPreference(PreferenceConstants.CODEASSIST_FAVORITE_STATIC_MEMBERS, null);
    final IEclipsePreferences jdtPreference = InstanceScope.INSTANCE.getNode(JavaUI.ID_PLUGIN);
    try {
      String _name = StaticClassExample.class.getName();
      String _plus = (_name + ".staticMethod");
      jdtPreference.put(PreferenceConstants.CODEASSIST_FAVORITE_STATIC_MEMBERS, _plus);
      ContentAssistProcessorTestBuilder _newBuilder = this.newBuilder();
      StringConcatenation _builder = new StringConcatenation();
      _builder.append("package mypack");
      _builder.newLine();
      _builder.append("class Bar{");
      _builder.newLine();
      _builder.append("\t");
      _builder.append("def void foo(){");
      _builder.newLine();
      _builder.append("\t\t");
      _builder.append("\"foo\".");
      ContentAssistProcessorTestBuilder _applyProposal = _newBuilder.append(_builder.toString()).applyProposal("staticMethod");
      StringConcatenation _builder_1 = new StringConcatenation();
      _builder_1.append("package mypack");
      _builder_1.newLine();
      _builder_1.newLine();
      _builder_1.append("import static extension org.eclipse.xtend.ide.tests.data.contentassist.StaticClassExample.staticMethod");
      _builder_1.newLine();
      _builder_1.newLine();
      _builder_1.append("class Bar{");
      _builder_1.newLine();
      _builder_1.append("\t");
      _builder_1.append("def void foo(){");
      _builder_1.newLine();
      _builder_1.append("\t\t");
      _builder_1.append("\"foo\".staticMethod");
      _applyProposal.expectContent(_builder_1.toString());
    } finally {
      jdtPreference.put(PreferenceConstants.CODEASSIST_FAVORITE_STATIC_MEMBERS, defaultprefs);
    }
  } catch (Throwable _e) {
    throw Exceptions.sneakyThrow(_e);
  }
}
 
Example 14
Source File: XImportSectionContentAssistTest.java    From xtext-xtend with Eclipse Public License 2.0 4 votes vote down vote up
@Test
public void testStaticFavoriteImports_operation_extension() {
  try {
    final String defaultprefs = PreferenceConstants.getPreference(PreferenceConstants.CODEASSIST_FAVORITE_STATIC_MEMBERS, null);
    final IEclipsePreferences jdtPreference = InstanceScope.INSTANCE.getNode(JavaUI.ID_PLUGIN);
    try {
      String _name = StaticClassExample.class.getName();
      String _plus = (_name + ".*");
      jdtPreference.put(PreferenceConstants.CODEASSIST_FAVORITE_STATIC_MEMBERS, _plus);
      ContentAssistProcessorTestBuilder _newBuilder = this.newBuilder();
      StringConcatenation _builder = new StringConcatenation();
      _builder.append("package mypack");
      _builder.newLine();
      _builder.append("class Bar{");
      _builder.newLine();
      _builder.append("\t");
      _builder.append("def void foo(){");
      _builder.newLine();
      _builder.append("\t\t");
      _builder.append("\"foo\".");
      ContentAssistProcessorTestBuilder _applyProposal = _newBuilder.append(_builder.toString()).applyProposal("staticMethod");
      StringConcatenation _builder_1 = new StringConcatenation();
      _builder_1.append("package mypack");
      _builder_1.newLine();
      _builder_1.newLine();
      _builder_1.append("import static extension org.eclipse.xtend.ide.tests.data.contentassist.StaticClassExample.staticMethod");
      _builder_1.newLine();
      _builder_1.newLine();
      _builder_1.append("class Bar{");
      _builder_1.newLine();
      _builder_1.append("\t");
      _builder_1.append("def void foo(){");
      _builder_1.newLine();
      _builder_1.append("\t\t");
      _builder_1.append("\"foo\".staticMethod");
      _applyProposal.expectContent(_builder_1.toString());
    } finally {
      jdtPreference.put(PreferenceConstants.CODEASSIST_FAVORITE_STATIC_MEMBERS, defaultprefs);
    }
  } catch (Throwable _e) {
    throw Exceptions.sneakyThrow(_e);
  }
}
 
Example 15
Source File: XImportSectionContentAssistTest.java    From xtext-xtend with Eclipse Public License 2.0 4 votes vote down vote up
@Test
public void testStaticFavoriteImports_field_No_additional_import() {
  try {
    final String defaultprefs = PreferenceConstants.getPreference(PreferenceConstants.CODEASSIST_FAVORITE_STATIC_MEMBERS, null);
    final IEclipsePreferences jdtPreference = InstanceScope.INSTANCE.getNode(JavaUI.ID_PLUGIN);
    try {
      String _name = StaticClassExample.class.getName();
      String _plus = (_name + ".*");
      jdtPreference.put(PreferenceConstants.CODEASSIST_FAVORITE_STATIC_MEMBERS, _plus);
      ContentAssistProcessorTestBuilder _newBuilder = this.newBuilder();
      StringConcatenation _builder = new StringConcatenation();
      _builder.append("package mypack");
      _builder.newLine();
      _builder.append("class Bar{");
      _builder.newLine();
      _builder.append("\t");
      _builder.append("def void foo(){");
      _builder.newLine();
      _builder.append("\t\t");
      _builder.append("STATICFIELD");
      _builder.newLine();
      ContentAssistProcessorTestBuilder _applyProposal = _newBuilder.append(_builder.toString()).applyProposal("STATICFIELD");
      StringConcatenation _builder_1 = new StringConcatenation();
      _builder_1.append("package mypack");
      _builder_1.newLine();
      _builder_1.newLine();
      _builder_1.append("import static org.eclipse.xtend.ide.tests.data.contentassist.StaticClassExample.STATICFIELD");
      _builder_1.newLine();
      _builder_1.newLine();
      _builder_1.append("class Bar{");
      _builder_1.newLine();
      _builder_1.append("\t");
      _builder_1.append("def void foo(){");
      _builder_1.newLine();
      _builder_1.append("\t\t");
      _builder_1.append("STATICFIELD");
      _builder_1.newLine();
      _builder_1.append("STATICFIELD");
      _applyProposal.expectContent(_builder_1.toString());
    } finally {
      jdtPreference.put(PreferenceConstants.CODEASSIST_FAVORITE_STATIC_MEMBERS, defaultprefs);
    }
  } catch (Throwable _e) {
    throw Exceptions.sneakyThrow(_e);
  }
}
 
Example 16
Source File: XImportSectionContentAssistTest.java    From xtext-xtend with Eclipse Public License 2.0 4 votes vote down vote up
@Test
public void testStaticFavoriteImports_No_additional_import() {
  try {
    final String defaultprefs = PreferenceConstants.getPreference(PreferenceConstants.CODEASSIST_FAVORITE_STATIC_MEMBERS, null);
    final IEclipsePreferences jdtPreference = InstanceScope.INSTANCE.getNode(JavaUI.ID_PLUGIN);
    try {
      String _name = StaticClassExample.class.getName();
      String _plus = (_name + ".*");
      jdtPreference.put(PreferenceConstants.CODEASSIST_FAVORITE_STATIC_MEMBERS, _plus);
      ContentAssistProcessorTestBuilder _newBuilder = this.newBuilder();
      StringConcatenation _builder = new StringConcatenation();
      _builder.append("package mypack");
      _builder.newLine();
      _builder.append("class Bar{");
      _builder.newLine();
      _builder.append("\t");
      _builder.append("def void foo(){");
      _builder.newLine();
      _builder.append("\t\t");
      _builder.append("staticMethod()");
      _builder.newLine();
      ContentAssistProcessorTestBuilder _applyProposal = _newBuilder.append(_builder.toString()).applyProposal("staticMethod()");
      StringConcatenation _builder_1 = new StringConcatenation();
      _builder_1.append("package mypack");
      _builder_1.newLine();
      _builder_1.newLine();
      _builder_1.append("import static org.eclipse.xtend.ide.tests.data.contentassist.StaticClassExample.staticMethod");
      _builder_1.newLine();
      _builder_1.newLine();
      _builder_1.append("class Bar{");
      _builder_1.newLine();
      _builder_1.append("\t");
      _builder_1.append("def void foo(){");
      _builder_1.newLine();
      _builder_1.append("\t\t");
      _builder_1.append("staticMethod()");
      _builder_1.newLine();
      _builder_1.append("staticMethod()");
      _applyProposal.expectContent(_builder_1.toString());
    } finally {
      jdtPreference.put(PreferenceConstants.CODEASSIST_FAVORITE_STATIC_MEMBERS, defaultprefs);
    }
  } catch (Throwable _e) {
    throw Exceptions.sneakyThrow(_e);
  }
}