use of org.eclipse.xtext.xbase.compiler.StringBuilderBasedAppendable in project xtext-xtend by eclipse.
the class SuperMemberImplementorTest method checkOverrideMethodCode.
protected void checkOverrideMethodCode(String operationName, String overrideCode) {
StringBuilderBasedAppendable appendable = new StringBuilderBasedAppendable();
LightweightTypeReference contextType = getContextType();
IResolvedOperation resolvedOperation = new BottomResolvedOperation((JvmOperation) findExecutable(implementedInterface, operationName), contextType, new OverrideTester());
implementor.appendOverrideFunction(xtendClass, resolvedOperation, appendable);
String code = appendable.toString();
if (!equalsIgnoreWhitespace(overrideCode, code))
assertEquals(overrideCode, code);
}
use of org.eclipse.xtext.xbase.compiler.StringBuilderBasedAppendable in project xtext-xtend by eclipse.
the class AbstractBuilderTest method assertBuilds.
protected void assertBuilds(final ICodeBuilder builder, final String expectedCode) {
Assert.assertTrue(builder.isValid());
final StringBuilderBasedAppendable appendable = new StringBuilderBasedAppendable();
builder.build(appendable);
Assert.assertEquals(Strings.toUnixLineSeparator(expectedCode), appendable.toString());
}
use of org.eclipse.xtext.xbase.compiler.StringBuilderBasedAppendable in project xtext-xtend by eclipse.
the class CodeBuilderQuickfix method getJavaModification.
protected IModification getJavaModification(final ICodeBuilder.Java builder) {
final IModification _function = (IModificationContext it) -> {
final IType type = builder.getIType();
char _charAt = ".".charAt(0);
final ImportManager importManager = new ImportManager(true, _charAt);
final StringBuilderBasedAppendable content = new StringBuilderBasedAppendable(importManager);
builder.build(content);
final Consumer<String> _function_1 = (String it_1) -> {
try {
ICompilationUnit _compilationUnit = type.getCompilationUnit();
NullProgressMonitor _nullProgressMonitor = new NullProgressMonitor();
_compilationUnit.createImport(it_1, null, _nullProgressMonitor);
} catch (Throwable _e) {
throw Exceptions.sneakyThrow(_e);
}
};
importManager.getImports().forEach(_function_1);
Object _switchResult = null;
boolean _matched = false;
if (builder instanceof JavaFieldBuilder) {
_matched = true;
String _string = content.toString();
NullProgressMonitor _nullProgressMonitor = new NullProgressMonitor();
_switchResult = type.createField(_string, null, true, _nullProgressMonitor);
}
if (!_matched) {
if (builder instanceof JavaConstructorBuilder) {
_matched = true;
String _string = content.toString();
NullProgressMonitor _nullProgressMonitor = new NullProgressMonitor();
_switchResult = type.createMethod(_string, null, true, _nullProgressMonitor);
}
}
if (!_matched) {
if (builder instanceof JavaMethodBuilder) {
_matched = true;
String _string = content.toString();
NullProgressMonitor _nullProgressMonitor = new NullProgressMonitor();
_switchResult = type.createMethod(_string, null, true, _nullProgressMonitor);
}
}
if (!_matched) {
_switchResult = null;
}
final Object element = ((Object) _switchResult);
if ((element != null)) {
JdtHyperlink _jdtHyperlink = new JdtHyperlink();
final Procedure1<JdtHyperlink> _function_2 = (JdtHyperlink it_1) -> {
it_1.setJavaElement(((IMember) element));
it_1.open();
};
ObjectExtensions.<JdtHyperlink>operator_doubleArrow(_jdtHyperlink, _function_2);
}
};
return _function;
}
Aggregations