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

The following examples show how to use org.eclipse.xtext.xbase.compiler.ISourceAppender. 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: SarlConstructorBuilder.java    From sarl with Apache License 2.0 6 votes vote down vote up
@Override
public ISourceAppender build(ISourceAppender appendable) {
	final ISourceAppender mAppender;
	if (appendable instanceof SourceAppenderWithTypeMapping) {
		mAppender = appendable;
	} else {
		mAppender = new SourceAppenderWithTypeMapping(appendable, this.keywords);
	}
	final JvmVisibility defaultVisibility = this.visiblityProvider.getDefaultJvmVisibility(getOwner(),
			XtendPackage.eINSTANCE.getXtendConstructor());
	appendVisibility(mAppender, getVisibility(), defaultVisibility);
	mAppender.append(this.keywords.getNewKeyword());
	appendParameters(mAppender);
	appendThrowsClause(mAppender);
	appendBody(mAppender, ""); //$NON-NLS-1$
	return mAppender;
}
 
Example #2
Source File: MemberFromSuperImplementor.java    From xtext-xtend with Eclipse Public License 2.0 6 votes vote down vote up
public void appendConstructorFromSuper(final XtendClass overrider, final IResolvedConstructor superConstructor, final ISourceAppender appendable) {
  final JvmGenericType inferredType = this.associations.getInferredType(overrider);
  final AbstractConstructorBuilder constructorBuilder = this.codeBuilderFactory.createConstructorBuilder(inferredType);
  this.initializeExecutableBuilder(constructorBuilder, inferredType, superConstructor);
  final Procedure1<ISourceAppender> _function = (ISourceAppender it) -> {
    boolean _isEmpty = superConstructor.getResolvedParameterTypes().isEmpty();
    boolean _not = (!_isEmpty);
    if (_not) {
      StringConcatenation _builder = new StringConcatenation();
      _builder.append("super(");
      final Function1<JvmFormalParameter, String> _function_1 = (JvmFormalParameter it_1) -> {
        return it_1.getSimpleName();
      };
      String _join = IterableExtensions.join(ListExtensions.<JvmFormalParameter, String>map(superConstructor.getDeclaration().getParameters(), _function_1), ", ");
      _builder.append(_join);
      _builder.append(")");
      it.append(_builder);
    }
  };
  constructorBuilder.setBodyGenerator(_function);
  boolean _isValid = constructorBuilder.isValid();
  if (_isValid) {
    constructorBuilder.build(appendable);
  }
}
 
Example #3
Source File: SarlFieldBuilder.java    From sarl with Apache License 2.0 6 votes vote down vote up
@Override
public ISourceAppender build(ISourceAppender appendable) {
	final ISourceAppender mAppender;
	if (appendable instanceof SourceAppenderWithTypeMapping) {
		mAppender = appendable;
	} else {
		mAppender = new SourceAppenderWithTypeMapping(appendable, this.keywords);
	}
	final JvmVisibility defaultVisibility = this.visiblityProvider.getDefaultJvmVisibility(getOwner(),
			XtendPackage.eINSTANCE.getXtendField());
	appendVisibility(mAppender, getVisibility(), defaultVisibility);
	if (isStaticFlag()) {
		mAppender.append(this.keywords.getStaticStaticKeyword()).append(" "); //$NON-NLS-1$
	}
	mAppender.append(this.keywords.protectKeyword(getFieldName()));
	mAppender.append(" ").append(this.keywords.getColonKeyword()).append(" "); //$NON-NLS-1$ //$NON-NLS-2$
	appendType(mAppender, getFieldType(), Object.class.getName());
	return mAppender;
}
 
Example #4
Source File: ConstructorBuilderTest.java    From xtext-xtend with Eclipse Public License 2.0 6 votes vote down vote up
@Test
public void testXtendCustomBody() {
  AbstractConstructorBuilder _createConstructorBuilder = this._codeBuilderFactory.createConstructorBuilder(this.getXtendClass());
  final Procedure1<AbstractConstructorBuilder> _function = (AbstractConstructorBuilder it) -> {
    it.setContext(this.getXtendClass());
    final Procedure1<ISourceAppender> _function_1 = (ISourceAppender it_1) -> {
      it_1.append("return");
    };
    it.setBodyGenerator(_function_1);
  };
  AbstractConstructorBuilder _doubleArrow = ObjectExtensions.<AbstractConstructorBuilder>operator_doubleArrow(_createConstructorBuilder, _function);
  StringConcatenation _builder = new StringConcatenation();
  _builder.append("new() {");
  _builder.newLine();
  _builder.append("  ");
  _builder.append("return");
  _builder.newLine();
  _builder.append("}");
  this.assertBuilds(_doubleArrow, _builder.toString());
}
 
Example #5
Source File: SourceAppenderWithTypeMapping.java    From sarl with Apache License 2.0 6 votes vote down vote up
@Override
public ISourceAppender append(LightweightTypeReference typeRef) {
	if (typeRef.isFunctionType()) {
		final FunctionTypeReference functionReference = typeRef.getAsFunctionTypeReference();
		this.source.append(this.keywords.getLeftParenthesisKeyword());
		boolean first = true;
		for (final LightweightTypeReference parameter : functionReference.getParameterTypes()) {
			if (first) {
				first = false;
			} else {
				this.source.append(","); //$NON-NLS-1$
			}
			append(parameter);
		}
		this.source.append(this.keywords.getRightParenthesisKeyword());
		this.source.append(this.keywords.getEqualsSignGreaterThanSignKeyword());
		append(functionReference.getReturnType());
		return this;
	}
	this.source.append(typeRef);
	return this;
}
 
Example #6
Source File: MethodBuilderTest.java    From xtext-xtend with Eclipse Public License 2.0 6 votes vote down vote up
@Test
public void testXtendCustomBody() {
  AbstractMethodBuilder _createMethodBuilder = this._codeBuilderFactory.createMethodBuilder(this.getXtendClass());
  final Procedure1<AbstractMethodBuilder> _function = (AbstractMethodBuilder it) -> {
    it.setContext(this.getXtendClass());
    it.setMethodName("foo");
    final Procedure1<ISourceAppender> _function_1 = (ISourceAppender it_1) -> {
      it_1.append("return");
    };
    it.setBodyGenerator(_function_1);
  };
  AbstractMethodBuilder _doubleArrow = ObjectExtensions.<AbstractMethodBuilder>operator_doubleArrow(_createMethodBuilder, _function);
  StringConcatenation _builder = new StringConcatenation();
  _builder.append("def foo() {");
  _builder.newLine();
  _builder.append("  ");
  _builder.append("return");
  _builder.newLine();
  _builder.append("}");
  this.assertBuilds(_doubleArrow, _builder.toString());
}
 
Example #7
Source File: AbstractSourceAppender.java    From sarl with Apache License 2.0 5 votes vote down vote up
public void serialize(EObject object, ISourceAppender appender, boolean isFormatting) throws IOException {
	final AppenderBasedTokenStream stream = new AppenderBasedTokenStream(appender);
	final SaveOptions options;
	if (isFormatting) {
		options = SaveOptions.newBuilder().format().getOptions();
	} else {
		options = SaveOptions.defaultOptions();
	}
	serialize(object, stream, options);
	stream.flush();
}
 
Example #8
Source File: SarlConstructorBuilder.java    From sarl with Apache License 2.0 5 votes vote down vote up
@Override
protected ISourceAppender appendParameters(ISourceAppender appendable) {
	if (getParameterBuilders().isEmpty()) {
		return appendable;
	}
	return super.appendParameters(appendable);
}
 
Example #9
Source File: AbstractCodeBuilder.java    From xtext-xtend with Eclipse Public License 2.0 5 votes vote down vote up
protected ISourceAppender appendVisibility(final ISourceAppender appendable, final JvmVisibility visibility, final JvmVisibility skippableDefault) {
  String _switchResult = null;
  boolean _matched = false;
  if (Objects.equal(visibility, skippableDefault)) {
    _matched=true;
    _switchResult = "";
  }
  if (!_matched) {
    if (Objects.equal(visibility, JvmVisibility.PRIVATE)) {
      _matched=true;
      _switchResult = "private ";
    }
  }
  if (!_matched) {
    if (Objects.equal(visibility, JvmVisibility.PROTECTED)) {
      _matched=true;
      _switchResult = "protected ";
    }
  }
  if (!_matched) {
    if (Objects.equal(visibility, JvmVisibility.PUBLIC)) {
      _matched=true;
      _switchResult = "public ";
    }
  }
  if (!_matched) {
    _switchResult = "";
  }
  return appendable.append(_switchResult);
}
 
Example #10
Source File: AbstractSubCodeBuilderFragment.java    From sarl with Apache License 2.0 5 votes vote down vote up
/** Generate the members related to appenders.
 *
 * @param appenderSimpleName the simple name of the appender.
 * @param builderInterface the interface of the code builder to wrap.
 * @param elementAccessor the code for accessing to the generated element.
 * @return the code.
 */
@SuppressWarnings("static-method")
protected StringConcatenationClient generateAppenderMembers(String appenderSimpleName,
		TypeReference builderInterface, String elementAccessor) {
	return new StringConcatenationClient() {
		@Override
		protected void appendTo(TargetStringConcatenation it) {
			it.append("\tprivate final "); //$NON-NLS-1$
			it.append(builderInterface);
			it.append(" builder;"); //$NON-NLS-1$
			it.newLineIfNotEmpty();
			it.newLine();
			it.append("\tpublic "); //$NON-NLS-1$
			it.append(appenderSimpleName);
			it.append("("); //$NON-NLS-1$
			it.append(builderInterface);
			it.append(" builder) {"); //$NON-NLS-1$
			it.newLine();
			it.append("\t\tthis.builder = builder;"); //$NON-NLS-1$
			it.newLine();
			it.append("\t}"); //$NON-NLS-1$
			it.newLineIfNotEmpty();
			it.newLine();
			it.append("\tpublic void build("); //$NON-NLS-1$
			it.append(ISourceAppender.class);
			it.append(" appender) throws "); //$NON-NLS-1$
			it.append(IOException.class);
			it.append(" {"); //$NON-NLS-1$
			it.newLine();
			it.append("\t\tbuild(this.builder."); //$NON-NLS-1$
			it.append(elementAccessor);
			it.append(", appender);"); //$NON-NLS-1$
			it.newLine();
			it.append("\t}"); //$NON-NLS-1$
			it.newLineIfNotEmpty();
			it.newLine();
		}
	};
}
 
Example #11
Source File: NewSarlBehaviorWizardPage.java    From sarl with Apache License 2.0 5 votes vote down vote up
@Override
protected void generateTypeContent(ISourceAppender appender, IJvmTypeProvider typeProvider,
		String comment, IProgressMonitor monitor) throws Exception {
	final SubMonitor mon = SubMonitor.convert(monitor, 4);
	final ScriptSourceAppender scriptBuilder = this.codeBuilderFactory.buildScript(
			getPackageFragment().getElementName(), typeProvider);
	final ISarlBehaviorBuilder behavior = scriptBuilder.addSarlBehavior(getTypeName());
	behavior.setExtends(getSuperClass());
	behavior.setDocumentation(comment);
	mon.worked(1);
	createStandardSARLEventTemplates(Messages.NewSarlBehaviorWizardPage_4,
		name -> behavior.addSarlBehaviorUnit(name),
		name -> behavior.addSarlCapacityUses(name));
	mon.worked(2);
	if (behavior.getSarlBehavior().getExtends() != null) {
		createInheritedMembers(
			Behavior.class.getCanonicalName(),
			behavior.getSarlBehavior(),
			true,
			() -> behavior.addSarlConstructor(),
			name -> behavior.addOverrideSarlAction(name),
			getSuperClass());
	}
	mon.worked(3);
	scriptBuilder.build(appender);
	mon.done();
}
 
Example #12
Source File: DocumentSourceAppender.java    From xtext-eclipse with Eclipse Public License 2.0 5 votes vote down vote up
@Override
public ISourceAppender decreaseIndentation() {
	if (currentIndentLevel == 0)
		throw new IllegalStateException("Can't reduce indentation level. It's already zero.");
	currentIndentLevel--;
	return this;
}
 
Example #13
Source File: XtendMethodBuilder.java    From xtext-xtend with Eclipse Public License 2.0 5 votes vote down vote up
@Override
public ISourceAppender build(final ISourceAppender appendable) {
  ISourceAppender _xblockexpression = null;
  {
    String _xifexpression = null;
    boolean _isOverrideFlag = this.isOverrideFlag();
    if (_isOverrideFlag) {
      _xifexpression = "override ";
    } else {
      _xifexpression = "def ";
    }
    this.appendVisibility(appendable.append(_xifexpression), this.getVisibility(), JvmVisibility.PUBLIC);
    boolean _isStaticFlag = this.isStaticFlag();
    if (_isStaticFlag) {
      appendable.append("static ");
    }
    boolean _isSynchronizedFlag = this.isSynchronizedFlag();
    if (_isSynchronizedFlag) {
      appendable.append("synchronized ");
    }
    this.appendTypeParameters(appendable, this.getTypeParameters());
    boolean _isAbstractFlag = this.isAbstractFlag();
    if (_isAbstractFlag) {
      this.appendType(appendable, this.getReturnType(), "void").append(" ");
    }
    this.appendThrowsClause(this.appendParameters(appendable.append(this.getMethodName())));
    boolean _isAbstractFlag_1 = this.isAbstractFlag();
    boolean _not = (!_isAbstractFlag_1);
    if (_not) {
      this.appendBody(appendable, "");
    }
    _xblockexpression = appendable;
  }
  return _xblockexpression;
}
 
Example #14
Source File: NewSarlAgentWizardPage.java    From sarl with Apache License 2.0 5 votes vote down vote up
@Override
protected void generateTypeContent(ISourceAppender appender, IJvmTypeProvider typeProvider,
		String comment, IProgressMonitor monitor) throws Exception {
	final SubMonitor mon = SubMonitor.convert(monitor, 4);
	final ScriptSourceAppender scriptBuilder = this.codeBuilderFactory.buildScript(
			getPackageFragment().getElementName(), typeProvider);
	final ISarlAgentBuilder agent = scriptBuilder.addSarlAgent(getTypeName());
	agent.setExtends(getSuperClass());
	agent.setDocumentation(comment);
	mon.worked(1);
	createStandardSARLEventTemplates(Messages.NewSarlAgentWizardPage_3,
		name -> agent.addSarlBehaviorUnit(name),
		name -> agent.addSarlCapacityUses(name));
	mon.worked(2);
	if (agent.getSarlAgent().getExtends() != null) {
		createInheritedMembers(
			Agent.class.getCanonicalName(),
			agent.getSarlAgent(),
			true,
			() -> agent.addSarlConstructor(),
			name -> agent.addOverrideSarlAction(name),
			getSuperClass());
	}
	mon.worked(3);
	scriptBuilder.build(appender);
	mon.done();
}
 
Example #15
Source File: NewSarlClassWizardPage.java    From sarl with Apache License 2.0 5 votes vote down vote up
@Override
protected void generateTypeContent(ISourceAppender appender, IJvmTypeProvider typeProvider,
		String comment, IProgressMonitor monitor) throws Exception {
	final SubMonitor mon = SubMonitor.convert(monitor, 3);
	final ScriptSourceAppender scriptBuilder = this.codeBuilderFactory.buildScript(
			getPackageFragment().getElementName(), typeProvider);
	final ISarlClassBuilder clazz = scriptBuilder.addSarlClass(getTypeName());
	final String superType = getSuperClass();
	// Do not add the "Object" type because it is the default.
	if (Strings.isNullOrEmpty(superType) || Object.class.getName().equals(superType)) {
		clazz.setExtends(null);
	} else {
		clazz.setExtends(superType);
	}
	for (final String type : getSuperInterfaces()) {
		clazz.addImplements(type);
	}
	clazz.setDocumentation(comment);
	mon.worked(1);
	createInheritedMembers(
		Object.class.getCanonicalName(),
		clazz.getSarlClass(),
		true,
		() -> clazz.addSarlConstructor(),
		name -> clazz.addOverrideSarlAction(name),
		superType,
		getSuperInterfaces());
	mon.worked(2);
	scriptBuilder.build(appender);
	mon.done();
}
 
Example #16
Source File: AbstractExecutableBuilder.java    From xtext-xtend with Eclipse Public License 2.0 5 votes vote down vote up
protected ISourceAppender appendParameters(final ISourceAppender appendable) {
  ISourceAppender _xblockexpression = null;
  {
    appendable.append("(");
    final HashSet<String> notAllowed = CollectionLiterals.<String>newHashSet();
    boolean _isEmpty = this.parameterBuilders.isEmpty();
    boolean _not = (!_isEmpty);
    if (_not) {
      AbstractParameterBuilder _last = IterableExtensions.<AbstractParameterBuilder>last(this.parameterBuilders);
      _last.setVarArgsFlag(this.varArgsFlag);
    }
    int _size = this.parameterBuilders.size();
    ExclusiveRange _doubleDotLessThan = new ExclusiveRange(0, _size, true);
    for (final Integer i : _doubleDotLessThan) {
      {
        final AbstractParameterBuilder parameterBuilder = this.parameterBuilders.get((i).intValue());
        final VariableNameAcceptor acceptor = new VariableNameAcceptor(notAllowed);
        String _name = parameterBuilder.getName();
        boolean _tripleEquals = (_name == null);
        if (_tripleEquals) {
          this._jdtVariableCompletions.getVariableProposals(parameterBuilder.getType().getIdentifier(), this.getContext(), 
            JdtVariableCompletions.VariableType.PARAMETER, notAllowed, acceptor);
          parameterBuilder.setName(acceptor.getVariableName());
        }
        parameterBuilder.build(appendable);
        int _size_1 = this.parameterBuilders.size();
        int _minus = (_size_1 - 1);
        boolean _notEquals = ((i).intValue() != _minus);
        if (_notEquals) {
          appendable.append(", ");
        }
      }
    }
    _xblockexpression = appendable.append(")");
  }
  return _xblockexpression;
}
 
Example #17
Source File: AbstractExecutableBuilder.java    From xtext-xtend with Eclipse Public License 2.0 5 votes vote down vote up
public ISourceAppender appendBody(final ISourceAppender appendable, final String statementSeparator) {
  ISourceAppender _xblockexpression = null;
  {
    appendable.append(" {").increaseIndentation().newLine();
    if ((this.bodyGenerator != null)) {
      this.bodyGenerator.apply(appendable);
    } else {
      appendable.append(this.defaultBody());
    }
    _xblockexpression = appendable.append(statementSeparator).decreaseIndentation().newLine().append("}");
  }
  return _xblockexpression;
}
 
Example #18
Source File: SarlMethodBuilder.java    From sarl with Apache License 2.0 5 votes vote down vote up
@Override
protected ISourceAppender appendTypeParameters(ISourceAppender appendable, List<JvmTypeParameter> typeParameters) {
	final Iterator<JvmTypeParameter> iterator = typeParameters.iterator();
	if (iterator.hasNext()) {
		appendable.append(" ").append(this.keywords.getWithKeyword()).append(" "); //$NON-NLS-1$//$NON-NLS-2$
		final String objectId = Object.class.getName();
		do {
			final JvmTypeParameter typeParameter = iterator.next();
			appendable.append(this.keywords.protectKeyword(typeParameter.getName()));
			final Iterable<JvmUpperBound> upperBounds =
				Iterables.filter(Iterables.filter(typeParameter.getConstraints(), JvmUpperBound.class),
					it -> !it.getTypeReference().getIdentifier().equals(objectId));
			final Iterator<JvmUpperBound> iterator2 = upperBounds.iterator();
			if (iterator2.hasNext()) {
				appendable.append(" ").append(this.keywords.getExtendsKeyword()).append(" "); //$NON-NLS-1$ //$NON-NLS-2$
				boolean isFirst = true;
				final StandardTypeReferenceOwner owner = new StandardTypeReferenceOwner(this.services, getContext());
				for (final JvmUpperBound upperBound: upperBounds) {
					if (!isFirst) {
						appendable.append(" ").append(this.keywords.getAmpersandKeyword()).append(" "); //$NON-NLS-1$ //$NON-NLS-2$
					}
					isFirst = false;
					appendType(appendable,
							owner.toLightweightTypeReference(upperBound.getTypeReference()),
							Object.class.getSimpleName());
				}
			}
			if (iterator.hasNext()) {
				appendable.append(this.keywords.getCommaKeyword()).append(" "); //$NON-NLS-1$
			}
		} while (iterator.hasNext());
	}
	return appendable;
}
 
Example #19
Source File: NewSarlSkillWizardPage.java    From sarl with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings("all")
@Override
protected void generateTypeContent(ISourceAppender appender, IJvmTypeProvider typeProvider,
		String comment, IProgressMonitor monitor) throws Exception {
	final SubMonitor mon = SubMonitor.convert(monitor, 4);
	final ScriptSourceAppender scriptBuilder = this.codeBuilderFactory.buildScript(
			getPackageFragment().getElementName(), typeProvider);
	final ISarlSkillBuilder skill = scriptBuilder.addSarlSkill(getTypeName());
	skill.setExtends(getSuperClass());
	for (final String type : getSuperInterfaces()) {
		skill.addImplements(type);
	}
	skill.setDocumentation(comment);
	mon.worked(1);
	createStandardSARLLifecycleFunctionTemplates(
			"skill",
			(it) -> skill.addSarlAction(it),
			(it) -> skill.addSarlCapacityUses(it));
	mon.worked(2);
	createInheritedMembers(
			Skill.class.getCanonicalName(),
			skill.getSarlSkill(),
			true,
			() -> skill.addSarlConstructor(),
			(name) -> skill.addOverrideSarlAction(name),
			getSuperClass(),
			getSuperInterfaces());
	mon.worked(3);
	scriptBuilder.build(appender);
	mon.done();
}
 
Example #20
Source File: JavaFieldBuilder.java    From xtext-xtend with Eclipse Public License 2.0 5 votes vote down vote up
@Override
public ISourceAppender build(final ISourceAppender appendable) {
  ISourceAppender _xblockexpression = null;
  {
    this.appendVisibility(appendable, this.getVisibility(), JvmVisibility.DEFAULT);
    boolean _isStaticFlag = this.isStaticFlag();
    if (_isStaticFlag) {
      appendable.append("static ");
    }
    _xblockexpression = this.appendType(appendable, this.getFieldType(), "Object").append(" ").append(this.getFieldName()).append(";");
  }
  return _xblockexpression;
}
 
Example #21
Source File: NewSarlAnnotationWizardPage.java    From sarl with Apache License 2.0 5 votes vote down vote up
@Override
protected void generateTypeContent(ISourceAppender appender, IJvmTypeProvider typeProvider,
		String comment, IProgressMonitor monitor) throws Exception {
	final SubMonitor mon = SubMonitor.convert(monitor, 2);
	final ScriptSourceAppender scriptBuilder = this.codeBuilderFactory.buildScript(
			getPackageFragment().getElementName(), typeProvider);
	final ISarlAnnotationTypeBuilder annotation = scriptBuilder.addSarlAnnotationType(getTypeName());
	annotation.setDocumentation(comment);
	mon.worked(1);
	scriptBuilder.build(appender);
	mon.done();
}
 
Example #22
Source File: AbstractParameterBuilder.java    From xtext-xtend with Eclipse Public License 2.0 5 votes vote down vote up
@Override
public ISourceAppender build(final ISourceAppender appendable) {
  ISourceAppender _xblockexpression = null;
  {
    this.appendModifiers(appendable);
    if (this.varArgsFlag) {
      this.appendType(appendable, ((ArrayTypeReference) this.type).getComponentType(), "Object").append("...");
    } else {
      this.appendType(appendable, this.type, "Object");
    }
    _xblockexpression = appendable.append(" ").append(this.name);
  }
  return _xblockexpression;
}
 
Example #23
Source File: XtendParameterBuilder.java    From xtext-xtend with Eclipse Public License 2.0 5 votes vote down vote up
@Override
protected ISourceAppender appendModifiers(final ISourceAppender appendable) {
  ISourceAppender _xblockexpression = null;
  {
    boolean _isExtensionFlag = this.isExtensionFlag();
    if (_isExtensionFlag) {
      appendable.append("extension ");
    }
    _xblockexpression = appendable;
  }
  return _xblockexpression;
}
 
Example #24
Source File: JavaParameterBuilder.java    From xtext-xtend with Eclipse Public License 2.0 5 votes vote down vote up
@Override
protected ISourceAppender appendModifiers(final ISourceAppender appendable) {
  ISourceAppender _xblockexpression = null;
  {
    boolean _isFinalFlag = this.isFinalFlag();
    if (_isFinalFlag) {
      appendable.append("final ");
    }
    _xblockexpression = appendable;
  }
  return _xblockexpression;
}
 
Example #25
Source File: XtendFieldBuilder.java    From xtext-xtend with Eclipse Public License 2.0 5 votes vote down vote up
@Override
public ISourceAppender build(final ISourceAppender appendable) {
  ISourceAppender _xblockexpression = null;
  {
    this.appendVisibility(appendable, this.getVisibility(), JvmVisibility.PRIVATE);
    boolean _isStaticFlag = this.isStaticFlag();
    if (_isStaticFlag) {
      appendable.append("static ");
    }
    _xblockexpression = this.appendType(appendable, this.getFieldType(), "Object").append(" ").append(this.getFieldName());
  }
  return _xblockexpression;
}
 
Example #26
Source File: NewSarlInterfaceWizardPage.java    From sarl with Apache License 2.0 5 votes vote down vote up
@Override
protected void generateTypeContent(ISourceAppender appender, IJvmTypeProvider typeProvider,
		String comment, IProgressMonitor monitor) throws Exception {
	final SubMonitor mon = SubMonitor.convert(monitor, 2);
	final ScriptSourceAppender scriptBuilder = this.codeBuilderFactory.buildScript(
			getPackageFragment().getElementName(), typeProvider);
	final ISarlInterfaceBuilder inter = scriptBuilder.addSarlInterface(getTypeName());
	for (final String type : getSuperInterfaces()) {
		inter.addExtends(type);
	}
	inter.setDocumentation(comment);
	mon.worked(1);
	scriptBuilder.build(appender);
	mon.done();
}
 
Example #27
Source File: JavaMethodBuilder.java    From xtext-xtend with Eclipse Public License 2.0 5 votes vote down vote up
@Override
public ISourceAppender build(final ISourceAppender appendable) {
  ISourceAppender _xblockexpression = null;
  {
    boolean _isOverrideFlag = this.isOverrideFlag();
    if (_isOverrideFlag) {
      appendable.append("@Override").newLine();
    }
    this.appendVisibility(appendable, this.getVisibility(), JvmVisibility.DEFAULT);
    boolean _isAbstractFlag = this.isAbstractFlag();
    if (_isAbstractFlag) {
      appendable.append("abstract ");
    }
    boolean _isStaticFlag = this.isStaticFlag();
    if (_isStaticFlag) {
      appendable.append("static ");
    }
    boolean _isSynchronizedFlag = this.isSynchronizedFlag();
    if (_isSynchronizedFlag) {
      appendable.append("synchronized ");
    }
    this.appendThrowsClause(this.appendParameters(this.appendType(this.appendTypeParameters(appendable, this.getTypeParameters()), this.getReturnType(), "void").append(" ").append(this.getMethodName())));
    boolean _isAbstractFlag_1 = this.isAbstractFlag();
    if (_isAbstractFlag_1) {
      appendable.append(";");
    } else {
      this.appendBody(appendable, ";");
    }
    _xblockexpression = appendable;
  }
  return _xblockexpression;
}
 
Example #28
Source File: NewSarlEnumerationWizardPage.java    From sarl with Apache License 2.0 5 votes vote down vote up
@Override
protected void generateTypeContent(ISourceAppender appender, IJvmTypeProvider typeProvider,
		String comment, IProgressMonitor monitor) throws Exception {
	final SubMonitor mon = SubMonitor.convert(monitor, 2);
	final ScriptSourceAppender scriptBuilder = this.codeBuilderFactory.buildScript(
			getPackageFragment().getElementName(), typeProvider);
	final ISarlEnumerationBuilder annotation = scriptBuilder.addSarlEnumeration(getTypeName());
	annotation.setDocumentation(comment);
	mon.worked(1);
	scriptBuilder.build(appender);
	mon.done();
}
 
Example #29
Source File: SourceAppenderWithTypeMapping.java    From sarl with Apache License 2.0 5 votes vote down vote up
/** Constructor.
 *
 * @param source the source appender.
 * @param keywords the keyword accessor.
 */
SourceAppenderWithTypeMapping(ISourceAppender source, SARLGrammarKeywordAccess keywords) {
	assert source != null;
	assert keywords != null;
	this.source = source;
	this.keywords = keywords;
}
 
Example #30
Source File: AbstractXmlHighlightingFragment2.java    From sarl with Apache License 2.0 4 votes vote down vote up
@Override
public ISourceAppender append(JvmType type) {
	appendNewLines();
	this.parent.append(type);
	return this;
}