org.eclipse.xtext.xbase.compiler.IAppendable Java Examples

The following examples show how to use org.eclipse.xtext.xbase.compiler.IAppendable. 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: PyExpressionGenerator.java    From sarl with Apache License 2.0 6 votes vote down vote up
/** Generate the given object.
 *
 * @param varDeclaration the variable declaration.
 * @param it the target for the generated content.
 * @param context the context.
 * @return the statement.
 */
protected XExpression _generate(XVariableDeclaration varDeclaration, IAppendable it, IExtraLanguageGeneratorContext context) {
	final String name = it.declareUniqueNameVariable(varDeclaration, varDeclaration.getName());
	it.append(name);
	it.append(" = "); //$NON-NLS-1$
	if (varDeclaration.getRight() != null) {
		generate(varDeclaration.getRight(), it, context);
	} else if (varDeclaration.getType() != null) {
		it.append(toDefaultValue(varDeclaration.getType()));
	} else {
		it.append("None"); //$NON-NLS-1$
	}
	if (context.getExpectedExpressionType() != null) {
		it.newLine();
		it.append("return ").append(name); //$NON-NLS-1$
	}
	return varDeclaration;
}
 
Example #2
Source File: PyExpressionGenerator.java    From sarl with Apache License 2.0 6 votes vote down vote up
/** Generate the given object.
 *
 * @param operation the postfix operator.
 * @param it the target for the generated content.
 * @param context the context.
 * @return the operation.
 */
protected XExpression _generate(XPostfixOperation operation, IAppendable it, IExtraLanguageGeneratorContext context) {
	appendReturnIfExpectedReturnedExpression(it, context);
	final String operator = getOperatorSymbol(operation);
	if (operator != null) {
		it.append("("); //$NON-NLS-1$
		switch (operator) {
		case "++": //$NON-NLS-1$
			generate(operation.getOperand(), it, context);
			it.append(" += 1"); //$NON-NLS-1$
			break;
		case "--": //$NON-NLS-1$
			generate(operation.getOperand(), it, context);
			it.append(" -= 1"); //$NON-NLS-1$
			break;
		default:
			throw new IllegalArgumentException(MessageFormat.format(Messages.PyExpressionGenerator_0, operator));
		}
		it.append(")"); //$NON-NLS-1$
	}
	return operation;
}
 
Example #3
Source File: PyExpressionGenerator.java    From sarl with Apache License 2.0 6 votes vote down vote up
/** Generate the given object.
 *
 * @param operation the unary operation.
 * @param it the target for the generated content.
 * @param context the context.
 * @return the operation.
 */
protected XExpression _generate(XUnaryOperation operation, IAppendable it, IExtraLanguageGeneratorContext context) {
	appendReturnIfExpectedReturnedExpression(it, context);
	final String operator = getOperatorSymbol(operation);
	if (operator != null) {
		it.append("("); //$NON-NLS-1$
		switch (operator) {
		case "+": //$NON-NLS-1$
			generate(operation.getOperand(), it, context);
			break;
		case "-": //$NON-NLS-1$
			it.append("-"); //$NON-NLS-1$
			generate(operation.getOperand(), it, context);
			break;
		default:
			throw new IllegalArgumentException(MessageFormat.format(Messages.PyExpressionGenerator_0, operator));
		}
		it.append(")"); //$NON-NLS-1$
	}
	return operation;
}
 
Example #4
Source File: PyExpressionGenerator.java    From sarl with Apache License 2.0 6 votes vote down vote up
/** Generate the given object.
 *
 * @param assertStatement the assert statement.
 * @param it the target for the generated content.
 * @param context the context.
 * @return the statement.
 */
protected XExpression _generate(SarlAssertExpression assertStatement, IAppendable it, IExtraLanguageGeneratorContext context) {
	final boolean haveAssert = !assertStatement.isIsStatic() && assertStatement.getCondition() != null;
	if (haveAssert) {
		it.append("assert (lambda:"); //$NON-NLS-1$
		it.increaseIndentation().newLine();
		generate(assertStatement.getCondition(), it, context);
		it.decreaseIndentation().newLine();
		it.append(")()"); //$NON-NLS-1$
	}
	if (context.getExpectedExpressionType() != null) {
		if (haveAssert) {
			it.newLine();
		}
		it.append("return ").append(toDefaultValue(context.getExpectedExpressionType().toJavaCompliantTypeReference())); //$NON-NLS-1$
	}
	return assertStatement;
}
 
Example #5
Source File: PyExpressionGenerator.java    From sarl with Apache License 2.0 6 votes vote down vote up
/** Generate the given object.
 *
 * @param anonClass the anonymous class.
 * @param it the target for the generated content.
 * @param context the context.
 * @return the class definition.
 */
protected XExpression _generate(AnonymousClass anonClass, IAppendable it, IExtraLanguageGeneratorContext context) {
	if (it.hasName(anonClass)) {
		appendReturnIfExpectedReturnedExpression(it, context);
		it.append(it.getName(anonClass)).append("("); //$NON-NLS-1$
		boolean firstArg = true;
		for (final XExpression arg : anonClass.getConstructorCall().getArguments()) {
			if (firstArg) {
				firstArg = false;
			} else {
				it.append(", "); //$NON-NLS-1$
			}
			generate(arg, it, context);
		}
		it.append(")"); //$NON-NLS-1$
	}
	return anonClass;
}
 
Example #6
Source File: PyExpressionGenerator.java    From sarl with Apache License 2.0 6 votes vote down vote up
/** Generate the given object.
 *
 * @param literal the list literal.
 * @param it the target for the generated content.
 * @param context the context.
 * @return the literal.
 */
protected XExpression _generate(XListLiteral literal, IAppendable it, IExtraLanguageGeneratorContext context) {
	appendReturnIfExpectedReturnedExpression(it, context);
	it.append("["); //$NON-NLS-1$
	boolean first = true;
	for (final XExpression value : literal.getElements()) {
		if (first) {
			first = false;
		} else {
			it.append(", "); //$NON-NLS-1$
		}
		generate(value, it, context);
	}
	it.append("]"); //$NON-NLS-1$
	return literal;
}
 
Example #7
Source File: PyExpressionGenerator.java    From sarl with Apache License 2.0 6 votes vote down vote up
/** Generate the given object.
 *
 * @param literal the set literal.
 * @param it the target for the generated content.
 * @param context the context.
 * @return the literal.
 */
protected XExpression _generate(XSetLiteral literal, IAppendable it, IExtraLanguageGeneratorContext context) {
	appendReturnIfExpectedReturnedExpression(it, context);
	it.append("{"); //$NON-NLS-1$
	boolean first = true;
	for (final XExpression value : literal.getElements()) {
		if (first) {
			first = false;
		} else {
			it.append(", "); //$NON-NLS-1$
		}
		generate(value, it, context);
	}
	it.append("}"); //$NON-NLS-1$
	return literal;
}
 
Example #8
Source File: DocumentationFormatter.java    From sarl with Apache License 2.0 6 votes vote down vote up
protected static void applyReplacements(IAppendable appendable, String text, Map<Integer, Replacement> replacements) {
	int offset = 0;
	for (final Replacement replacement : replacements.values()) {
		if (replacement.getOffset() < offset) {
			appendable.append("<<<Conflicting replacements>>>");
		} else {
			assert offset >= 0;
			assert replacement.getOffset() <= text.length();
			String notReplacedString = text.substring(offset, replacement.getOffset());
			appendable.append(notReplacedString);
			offset += notReplacedString.length();
			appendable.append(replacement.getText());
			offset += replacement.getLength();
		}
	}
	if (offset < text.length()) {
		String notReplacedString = text.substring(offset);
		appendable.append(notReplacedString);
	}
}
 
Example #9
Source File: DocumentationFormatter.java    From sarl with Apache License 2.0 6 votes vote down vote up
@Pure
public void formatSinglelineComment(String doc, String indentation, IAppendable appendable) {
	if (!Strings.isEmpty(doc)) {
		final SortedMap<Integer, Replacement> replacements = new TreeMap<>();
		int offset = doc.indexOf(getSinglelineCommentPrefix());
		if (offset < 0) {
			offset = 0;
		}
		int endOffset = doc.indexOf(NL_CHAR, offset);
		if (endOffset < 0) {
			endOffset = doc.length();
		}
		formatSinglelineComment(
			indentation,
			new AppendableAccessor(appendable, doc, replacements, offset, endOffset));
	}
}
 
Example #10
Source File: PyExpressionGenerator.java    From sarl with Apache License 2.0 6 votes vote down vote up
/** Generate the given object.
 *
 * @param tryStatement the try-catch-finally statement.
 * @param it the target for the generated content.
 * @param context the context.
 * @return the statement.
 */
protected XExpression _generate(XTryCatchFinallyExpression tryStatement, IAppendable it, IExtraLanguageGeneratorContext context) {
	it.append("try:"); //$NON-NLS-1$
	it.increaseIndentation().newLine();
	generate(tryStatement.getExpression(), context.getExpectedExpressionType(), it, context);
	it.decreaseIndentation().newLine();
	for (final XCatchClause clause : tryStatement.getCatchClauses()) {
		it.append("except "); //$NON-NLS-1$
		it.append(clause.getDeclaredParam().getParameterType().getType());
		it.append(", "); //$NON-NLS-1$
		it.append(it.declareUniqueNameVariable(clause.getDeclaredParam(), clause.getDeclaredParam().getSimpleName()));
		it.append(":"); //$NON-NLS-1$
		it.increaseIndentation().newLine();
		generate(clause.getExpression(), context.getExpectedExpressionType(), it, context);
		it.decreaseIndentation().newLine();
	}
	if (tryStatement.getFinallyExpression() != null) {
		it.append("finally:"); //$NON-NLS-1$
		it.increaseIndentation().newLine();
		generate(tryStatement.getFinallyExpression(), it, context);
		it.decreaseIndentation();
	}
	return tryStatement;
}
 
Example #11
Source File: PyExpressionGenerator.java    From sarl with Apache License 2.0 5 votes vote down vote up
/** Generate the given object.
 *
 * @param closure the closure.
 * @param it the target for the generated content.
 * @param context the context.
 * @return the closure.
 */
@SuppressWarnings("static-method")
protected XExpression _generate(XClosure closure, IAppendable it, IExtraLanguageGeneratorContext context) {
	if (it.hasName(closure)) {
		appendReturnIfExpectedReturnedExpression(it, context);
		it.append(it.getName(closure)).append("()"); //$NON-NLS-1$
	}
	return closure;
}
 
Example #12
Source File: PyExpressionGenerator.java    From sarl with Apache License 2.0 5 votes vote down vote up
/** Generate the given object.
 *
 * @param block the block expression.
 * @param it the target for the generated content.
 * @param context the context.
 * @return the last expression in the block or {@code null}.
 */
protected XExpression _generate(XBlockExpression block, IAppendable it, IExtraLanguageGeneratorContext context) {
	XExpression last = block;
	if (block.getExpressions().isEmpty()) {
		it.append("pass"); //$NON-NLS-1$
	} else {
		it.openScope();
		if (context.getExpectedExpressionType() == null) {
			boolean first = true;
			for (final XExpression expression : block.getExpressions()) {
				if (first) {
					first = false;
				} else {
					it.newLine();
				}
				last = generate(expression, it, context);
			}
		} else {
			final List<XExpression> exprs = block.getExpressions();
			if (!exprs.isEmpty()) {
				for (int i = 0; i < exprs.size() - 1; ++i) {
					if (i > 0) {
						it.newLine();
					}
					last = generate(exprs.get(i), it, context);
				}
				last = generate(exprs.get(exprs.size() - 1), context.getExpectedExpressionType(), it, context);
			}
		}
		it.closeScope();
	}
	return last;
}
 
Example #13
Source File: PyExpressionGenerator.java    From sarl with Apache License 2.0 5 votes vote down vote up
/** Generate the anonymous class definition.
 *
 * @param anonClass the anonymous class.
 * @param it the target for the generated content.
 * @param context the context.
 */
protected void generateAnonymousClassDefinition(AnonymousClass anonClass, IAppendable it, IExtraLanguageGeneratorContext context) {
	if (!it.hasName(anonClass) && it instanceof PyAppendable) {
		final LightweightTypeReference jvmAnonType = getExpectedType(anonClass);
		final String anonName = it.declareSyntheticVariable(anonClass, jvmAnonType.getSimpleName());
		QualifiedName anonQualifiedName = QualifiedName.create(
				jvmAnonType.getType().getQualifiedName().split(Pattern.quote("."))); //$NON-NLS-1$
		anonQualifiedName = anonQualifiedName.skipLast(1);
		if (anonQualifiedName.isEmpty()) {
			// The type resolver does not include the enclosing class.
			assert anonClass.getDeclaringType() == null : "The Xtend API has changed the AnonymousClass definition!"; //$NON-NLS-1$
			final XtendTypeDeclaration container = EcoreUtil2.getContainerOfType(anonClass.eContainer(), XtendTypeDeclaration.class);
			anonQualifiedName = anonQualifiedName.append(this.qualifiedNameProvider.getFullyQualifiedName(container));
		}
		anonQualifiedName = anonQualifiedName.append(anonName);
		it.openPseudoScope();
		final IRootGenerator rootGenerator = context.getRootGenerator();
		assert rootGenerator instanceof PyGenerator;
		final List<JvmTypeReference> types = new ArrayList<>();
		for (final JvmTypeReference superType : anonClass.getConstructorCall().getConstructor().getDeclaringType().getSuperTypes()) {
			if (!Object.class.getCanonicalName().equals(superType.getIdentifier())) {
				types.add(superType);
			}
		}
		((PyGenerator) rootGenerator).generateTypeDeclaration(
				anonQualifiedName.toString(),
				anonName,
				false,
				types,
				getTypeBuilder().getDocumentation(anonClass),
				false,
				anonClass.getMembers(),
				(PyAppendable) it,
				context,
				null);
		it.closeScope();
	}
}
 
Example #14
Source File: PyExpressionGenerator.java    From sarl with Apache License 2.0 5 votes vote down vote up
@Override
protected void before(XExpression expression, IAppendable output, IExtraLanguageGeneratorContext context) {
	if (!(expression instanceof XClosure) && !(expression instanceof AnonymousClass)) {
		// Generate the closure definitions before their usage in the expressions
		for (final XClosure closure : EcoreUtil2.getAllContentsOfType(expression, XClosure.class)) {
			generateClosureDefinition(closure, output, context);
		}
		// Generate the closure definitions before their usage in the expressions
		for (final AnonymousClass anonClass : EcoreUtil2.getAllContentsOfType(expression, AnonymousClass.class)) {
			generateAnonymousClassDefinition(anonClass, output, context);
		}
	}
}
 
Example #15
Source File: PyExpressionGenerator.java    From sarl with Apache License 2.0 5 votes vote down vote up
/** Generate the given object.
 *
 * @param continueStatement the continue statement.
 * @param it the target for the generated content.
 * @param context the context.
 * @return the statement.
 */
@SuppressWarnings("static-method")
protected XExpression _generate(SarlContinueExpression continueStatement, IAppendable it, IExtraLanguageGeneratorContext context) {
	if (context.getExpectedExpressionType() == null) {
		it.append("continue"); //$NON-NLS-1$
	} else {
		it.append("return ").append(toDefaultValue(context.getExpectedExpressionType().toJavaCompliantTypeReference())); //$NON-NLS-1$
	}
	return continueStatement;
}
 
Example #16
Source File: PyExpressionGenerator.java    From sarl with Apache License 2.0 5 votes vote down vote up
/** Generate the given object.
 *
 * @param breakStatement the break statement.
 * @param it the target for the generated content.
 * @param context the context.
 * @return the statement.
 */
@SuppressWarnings("static-method")
protected XExpression _generate(SarlBreakExpression breakStatement, IAppendable it, IExtraLanguageGeneratorContext context) {
	if (context.getExpectedExpressionType() == null) {
		it.append("break"); //$NON-NLS-1$
	} else {
		it.append("return ").append(toDefaultValue(context.getExpectedExpressionType().toJavaCompliantTypeReference())); //$NON-NLS-1$
	}
	return breakStatement;
}
 
Example #17
Source File: PyExpressionGenerator.java    From sarl with Apache License 2.0 5 votes vote down vote up
/** Generate the given object.
 *
 * @param assignment the assignment operator.
 * @param it the target for the generated content.
 * @param context the context.
 * @return the assignment.
 */
protected XExpression _generate(XAssignment assignment, IAppendable it, IExtraLanguageGeneratorContext context) {
	appendReturnIfExpectedReturnedExpression(it, context);
	it.append("("); //$NON-NLS-1$
	newFeatureCallGenerator(context, it).generate(assignment);
	it.append(" = "); //$NON-NLS-1$
	generate(assignment.getValue(), it, context);
	it.append(")"); //$NON-NLS-1$
	return assignment;
}
 
Example #18
Source File: AbstractExpressionGenerator.java    From sarl with Apache License 2.0 5 votes vote down vote up
@Override
public XExpression generate(XExpression expression, LightweightTypeReference expectedType, IAppendable output,
		IExtraLanguageGeneratorContext context) {
	final LightweightTypeReference old = context.setExpectedExpressionType(expectedType);
	try {
		before(expression, output, context);
		return this.generateDispatcher.invoke(expression, output, context);
	} finally {
		after(expression, output, context);
		context.setExpectedExpressionType(old);
	}
}
 
Example #19
Source File: PyExpressionGenerator.java    From sarl with Apache License 2.0 5 votes vote down vote up
/** Generate the given object.
 *
 * @param whileLoop the while-loop.
 * @param it the target for the generated content.
 * @param context the context.
 * @return the last statement in the loop or {@code null}.
 */
protected XExpression _generate(XWhileExpression whileLoop, IAppendable it, IExtraLanguageGeneratorContext context) {
	it.append("while "); //$NON-NLS-1$
	generate(whileLoop.getPredicate(), it, context);
	it.append(":"); //$NON-NLS-1$
	it.increaseIndentation().newLine();
	final XExpression last = generate(whileLoop.getBody(), it, context);
	it.decreaseIndentation();
	return last;
}
 
Example #20
Source File: PyExpressionGenerator.java    From sarl with Apache License 2.0 5 votes vote down vote up
/** Generate the given object.
 *
 * @param whileLoop the while-loop.
 * @param it the target for the generated content.
 * @param context the context.
 * @return the last statement in the loop or {@code null}.
 */
protected XExpression _generate(XDoWhileExpression whileLoop, IAppendable it, IExtraLanguageGeneratorContext context) {
	generate(whileLoop.getBody(), it, context);
	it.newLine();
	it.append("while "); //$NON-NLS-1$
	generate(whileLoop.getPredicate(), it, context);
	it.append(":"); //$NON-NLS-1$
	it.increaseIndentation().newLine();
	final XExpression last = generate(whileLoop.getBody(), it, context);
	it.decreaseIndentation();
	return last;
}
 
Example #21
Source File: PyExpressionGenerator.java    From sarl with Apache License 2.0 5 votes vote down vote up
/** Generate the given object.
 *
 * @param forLoop the for-loop.
 * @param it the target for the generated content.
 * @param context the context.
 * @return the statement.
 */
protected XExpression _generate(XForLoopExpression forLoop, IAppendable it, IExtraLanguageGeneratorContext context) {
	it.append("for "); //$NON-NLS-1$
	final String varName = it.declareUniqueNameVariable(forLoop.getDeclaredParam(), forLoop.getDeclaredParam().getSimpleName());
	it.append(varName);
	it.append(" in "); //$NON-NLS-1$
	generate(forLoop.getForExpression(), it, context);
	it.append(":"); //$NON-NLS-1$
	it.increaseIndentation().newLine();
	final XExpression last = generate(forLoop.getEachExpression(), it, context);
	it.decreaseIndentation();
	return last;
}
 
Example #22
Source File: PyExpressionGenerator.java    From sarl with Apache License 2.0 5 votes vote down vote up
/** Generate the given object.
 *
 * @param ifStatement the if-then-else statement.
 * @param it the target for the generated content.
 * @param context the context.
 * @return the statement.
 */
protected XExpression _generate(XIfExpression ifStatement, IAppendable it, IExtraLanguageGeneratorContext context) {
	it.append("if "); //$NON-NLS-1$
	generate(ifStatement.getIf(), it, context);
	it.append(":"); //$NON-NLS-1$
	it.increaseIndentation().newLine();
	if (ifStatement.getThen() != null) {
		generate(ifStatement.getThen(), context.getExpectedExpressionType(), it, context);
	} else if (context.getExpectedExpressionType() == null) {
		it.append("pass"); //$NON-NLS-1$
	} else {
		it.append("return ").append(toDefaultValue(context.getExpectedExpressionType().toJavaCompliantTypeReference())); //$NON-NLS-1$
	}
	it.decreaseIndentation();
	if (ifStatement.getElse() != null) {
		it.newLine().append("else:"); //$NON-NLS-1$
		it.increaseIndentation().newLine();
		generate(ifStatement.getElse(), context.getExpectedExpressionType(), it, context);
		it.decreaseIndentation();
	} else if (context.getExpectedExpressionType() != null) {
		it.newLine().append("else:"); //$NON-NLS-1$
		it.increaseIndentation().newLine();
		it.append("return ").append(toDefaultValue(context.getExpectedExpressionType().toJavaCompliantTypeReference())); //$NON-NLS-1$
		it.decreaseIndentation();
	}
	return ifStatement;
}
 
Example #23
Source File: PyExpressionGenerator.java    From sarl with Apache License 2.0 5 votes vote down vote up
/** Generate the given object.
 *
 * @param operator the instance-of operator.
 * @param it the target for the generated content.
 * @param context the context.
 * @return the expression.
 */
protected XExpression _generate(XInstanceOfExpression operator, IAppendable it, IExtraLanguageGeneratorContext context) {
	appendReturnIfExpectedReturnedExpression(it, context);
	it.append("isinstance("); //$NON-NLS-1$
	generate(operator.getExpression(), it, context);
	it.append(", "); //$NON-NLS-1$
	it.append(operator.getType().getType());
	it.append(")"); //$NON-NLS-1$
	return operator;
}
 
Example #24
Source File: DocumentationFormatter.java    From sarl with Apache License 2.0 5 votes vote down vote up
@Pure
public void formatMultilineComment(String doc, String indentation, IAppendable appendable) {
	if (!Strings.isEmpty(doc)) {
		final SortedMap<Integer, Replacement> replacements = new TreeMap();
		formatMultlineComment(indentation, Strings.newLine(), new AppendableAccessor(appendable, doc, replacements, 0, doc.length()));
	}
}
 
Example #25
Source File: PyExpressionGenerator.java    From sarl with Apache License 2.0 4 votes vote down vote up
/** Generate the given object.
 *
 * @param operation the binary operation.
 * @param it the target for the generated content.
 * @param context the context.
 * @return the operation.
 */
@SuppressWarnings("checkstyle:cyclomaticcomplexity")
protected XExpression _generate(XBinaryOperation operation, IAppendable it, IExtraLanguageGeneratorContext context) {
	appendReturnIfExpectedReturnedExpression(it, context);
	final String operator = getOperatorSymbol(operation);
	if (operator != null) {
		it.append("("); //$NON-NLS-1$
		generate(operation.getLeftOperand(), it, context);
		switch (operator) {
		case "-": //$NON-NLS-1$
		case "+": //$NON-NLS-1$
		case "*": //$NON-NLS-1$
		case "/": //$NON-NLS-1$
		case "%": //$NON-NLS-1$
		case "-=": //$NON-NLS-1$
		case "+=": //$NON-NLS-1$
		case "*=": //$NON-NLS-1$
		case "/=": //$NON-NLS-1$
		case "%=": //$NON-NLS-1$
		case "<": //$NON-NLS-1$
		case ">": //$NON-NLS-1$
		case "<=": //$NON-NLS-1$
		case ">=": //$NON-NLS-1$
		case "==": //$NON-NLS-1$
		case "!=": //$NON-NLS-1$
		case "<<": //$NON-NLS-1$
		case ">>": //$NON-NLS-1$
			it.append(" ").append(operator).append(" "); //$NON-NLS-1$ //$NON-NLS-2$
			break;
		case "&&": //$NON-NLS-1$
			it.append(" and "); //$NON-NLS-1$
			break;
		case "||": //$NON-NLS-1$
			it.append(" or "); //$NON-NLS-1$
			break;
		case "===": //$NON-NLS-1$
			it.append(" is "); //$NON-NLS-1$
			break;
		case "!==": //$NON-NLS-1$
			it.append(" is not "); //$NON-NLS-1$
			break;
		default:
			throw new IllegalArgumentException(MessageFormat.format(Messages.PyExpressionGenerator_0, operator));
		}
		generate(operation.getRightOperand(), it, context);
		it.append(")"); //$NON-NLS-1$
	}
	return operation;
}
 
Example #26
Source File: DocumentationFormatter.java    From sarl with Apache License 2.0 4 votes vote down vote up
@Pure
public String formatMultilineComment(String doc, String indentation) {
	IAppendable appendable = new StringBuilderBasedAppendable();
	formatMultilineComment(doc, indentation, appendable);
	return appendable.getContent();
}
 
Example #27
Source File: DispatchMethodCompileStrategy.java    From xtext-xtend with Eclipse Public License 2.0 4 votes vote down vote up
protected String getVarName(JvmIdentifiableElement ex, IAppendable appendable) {
	return appendable.getName(ex);
}
 
Example #28
Source File: PyExpressionGenerator.java    From sarl with Apache License 2.0 4 votes vote down vote up
private static void appendReturnIfExpectedReturnedExpression(IAppendable it, IExtraLanguageGeneratorContext context) {
	if (context.getExpectedExpressionType() != null) {
		it.append("return "); //$NON-NLS-1$
	}
}
 
Example #29
Source File: DocumentationFormatter.java    From sarl with Apache License 2.0 4 votes vote down vote up
@Pure
public void formatMultilineComment(String doc, IAppendable appendable) {
	formatMultilineComment(doc, null, appendable);
}
 
Example #30
Source File: DocumentationFormatter.java    From sarl with Apache License 2.0 4 votes vote down vote up
@Pure
public void formatSinglelineComment(String doc, IAppendable appendable) {
	formatSinglelineComment(doc, null, appendable);
}