org.eclipse.xtext.xbase.compiler.StringBuilderBasedAppendable Java Examples
The following examples show how to use
org.eclipse.xtext.xbase.compiler.StringBuilderBasedAppendable.
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: SuperMemberImplementorTest.java From xtext-xtend with Eclipse Public License 2.0 | 6 votes |
protected void checkImplementConstructor(final String firstParamType, String implementCode) { StringBuilderBasedAppendable appendable = new StringBuilderBasedAppendable(); JvmConstructor constructor = Iterables.find(superClass.getDeclaredConstructors(), new Predicate<JvmConstructor>() { @Override public boolean apply(JvmConstructor c) { if (firstParamType == null) return c.getParameters().isEmpty(); if (c.getParameters().size() >= 1) { return firstParamType.equals(c.getParameters().get(0).getParameterType().getSimpleName()); } return false; } }); LightweightTypeReference contextType = getContextType(); ResolvedConstructor resolvedConstructor = new ResolvedConstructor(constructor, contextType); implementor.appendConstructorFromSuper(xtendClass, resolvedConstructor, appendable); String code = appendable.toString(); if (!equalsIgnoreWhitespace(implementCode, code)) assertEquals(implementCode, code); }
Example #2
Source File: SuperMemberImplementorTest.java From xtext-xtend with Eclipse Public License 2.0 | 5 votes |
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); }
Example #3
Source File: CreateMemberQuickfixes.java From xtext-xtend with Eclipse Public License 2.0 | 5 votes |
protected void newLocalVariableQuickfix(final String variableName, XAbstractFeatureCall call, Issue issue, IssueResolutionAcceptor issueResolutionAcceptor) { LightweightTypeReference variableType = getNewMemberType(call); final StringBuilderBasedAppendable localVarDescriptionBuilder = new StringBuilderBasedAppendable(); localVarDescriptionBuilder.append("...").newLine(); final String defaultValueLiteral = getDefaultValueLiteral(variableType); localVarDescriptionBuilder.append("val ").append(variableName).append(" = ").append(defaultValueLiteral); localVarDescriptionBuilder.newLine().append("..."); issueResolutionAcceptor.accept(issue, "Create local variable '" + variableName + "'", localVarDescriptionBuilder.toString(), "fix_local_var.png", new SemanticModificationWrapper(issue.getUriToProblem(), new ISemanticModification() { @Override public void apply(/* @Nullable */ final EObject element, /* @Nullable */ final IModificationContext context) throws Exception { if (element != null) { XtendMember xtendMember = EcoreUtil2.getContainerOfType(element, XtendMember.class); if (xtendMember != null) { int offset = getFirstOffsetOfKeyword(xtendMember, "{"); IXtextDocument xtextDocument = context.getXtextDocument(); if (offset != -1 && xtextDocument != null) { final ReplacingAppendable appendable = appendableFactory.create(xtextDocument, (XtextResource) element.eResource(), offset, 0, new OptionalParameters() {{ baseIndentationLevel = 1; }}); appendable.increaseIndentation().newLine().append("val ").append(variableName).append(" = ") .append(defaultValueLiteral); appendable.commitChanges(); } } } } })); }
Example #4
Source File: AbstractCodeBuilder.java From xtext-xtend with Eclipse Public License 2.0 | 5 votes |
@Override public String getPreview() { String _xblockexpression = null; { final StringBuilderBasedAppendable appendable = new StringBuilderBasedAppendable(); this.build(appendable.append("...").newLine()).newLine().append("..."); _xblockexpression = appendable.toString(); } return _xblockexpression; }
Example #5
Source File: ImportingStringConcatenation.java From xtext-extras with Eclipse Public License 2.0 | 4 votes |
protected String _getStringRepresentation(LightweightTypeReference object) { StringBuilderBasedAppendable appender = new StringBuilderBasedAppendable(importManager); LightweightTypeReferenceSerializer serializer = new LightweightTypeReferenceSerializer(appender); object.accept(serializer); return appender.toString(); }
Example #6
Source File: AbstractBuilderTest.java From xtext-xtend with Eclipse Public License 2.0 | 4 votes |
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()); }
Example #7
Source File: ExtractMethodRefactoring.java From xtext-xtend with Eclipse Public License 2.0 | 4 votes |
public String getMethodSignature() { StringBuilderBasedAppendable appendable = new StringBuilderBasedAppendable(); appendMethodSignature(appendable); return appendable.toString(); }
Example #8
Source File: DocumentationFormatter.java From sarl with Apache License 2.0 | 4 votes |
@Pure public String formatMultilineComment(String doc, String indentation) { IAppendable appendable = new StringBuilderBasedAppendable(); formatMultilineComment(doc, indentation, appendable); return appendable.getContent(); }
Example #9
Source File: DocumentationFormatter.java From sarl with Apache License 2.0 | 4 votes |
@Pure public String formatSinglelineComment(String doc, String indentation) { StringBuilderBasedAppendable appendable = new StringBuilderBasedAppendable(); formatSinglelineComment(doc, indentation, appendable); return appendable.getContent(); }