org.eclipse.xtext.util.Strings Java Examples

The following examples show how to use org.eclipse.xtext.util.Strings. 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: OctalIntValueConverter.java    From n4js with Eclipse Public License 1.0 6 votes vote down vote up
@Override
public BigDecimal toValue(String string, INode node) {
	if (Strings.isEmpty(string))
		throw new N4JSValueConverterException(IssueCodes.getMessageForVCO_OCTALINT_CONVERT_EMPTY_STR(),
				IssueCodes.VCO_OCTALINT_CONVERT_EMPTY_STR, node, null);
	if (string.length() <= 2) {
		throw new N4JSValueConverterWithValueException(
				IssueCodes.getMessageForVCO_OCTALINT_CONVERT_TOO_SHORT(string),
				IssueCodes.VCO_OCTALINT_CONVERT_TOO_SHORT, node,
				BigDecimal.ZERO, null);
	}
	try {
		return new BigDecimal(new BigInteger(string.substring(2), 8));
	} catch (NumberFormatException e) {
		throw new N4JSValueConverterException(IssueCodes.getMessageForVCO_OCTALINT_CONVERT_STR(string),
				IssueCodes.VCO_OCTALINT_CONVERT_STR, node, null);
	}
}
 
Example #2
Source File: WorkingCopyOwnerProviderTest.java    From xtext-xtend with Eclipse Public License 2.0 6 votes vote down vote up
@Test
public void testWorkingCopyOwner_02() {
  try {
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("package foo");
    _builder.newLine();
    _builder.append("class MyClass {");
    _builder.newLine();
    _builder.append("\t");
    _builder.newLine();
    _builder.append("}");
    _builder.newLine();
    this.workbenchTestHelper.createFile("foo/MyClass.xtend", _builder.toString());
    IResourcesSetupUtil.waitForBuild();
    StringConcatenation _builder_1 = new StringConcatenation();
    _builder_1.append("package foo;");
    _builder_1.newLine();
    _builder_1.append("public class MyClass{");
    _builder_1.newLine();
    _builder_1.append("}");
    Assert.assertEquals(Strings.toUnixLineSeparator(_builder_1).toString(), this.newWorkingCopyOwner().findSource("MyClass", "foo"));
  } catch (Throwable _e) {
    throw Exceptions.sneakyThrow(_e);
  }
}
 
Example #3
Source File: IssueInformationPage.java    From sarl with Apache License 2.0 6 votes vote down vote up
/** Update the page status and change the "finish" state button.
 */
protected void updatePageStatus() {
	final boolean ok;
	if (Strings.isEmpty(this.titleField.getText())) {
		ok = false;
		setMessage(Messages.IssueInformationPage_5, IMessageProvider.ERROR);
	} else if (Strings.isEmpty(this.trackerLogin.getText())) {
		ok = false;
		setMessage(Messages.IssueInformationPage_6, IMessageProvider.ERROR);
	} else if (Strings.isEmpty(this.trackerPassword.getText())) {
		ok = false;
		setMessage(Messages.IssueInformationPage_7, IMessageProvider.ERROR);
	} else {
		ok = true;
		if (Strings.isEmpty(this.descriptionField.getText())) {
			setMessage(Messages.IssueInformationPage_8, IMessageProvider.WARNING);
		} else {
			setMessage(null, IMessageProvider.NONE);
		}
	}
	setPageComplete(ok);
}
 
Example #4
Source File: SARLJvmGenerator.java    From sarl with Apache License 2.0 6 votes vote down vote up
@Override
protected void _internalDoGenerate(JvmDeclaredType type, IFileSystemAccess fsa) {
	if (DisableCodeGenerationAdapter.isDisabled(type)) {
		return;
	}
	final String qn = type.getQualifiedName();
	if (!Strings.isEmpty(qn)) {
		final String fn = qn.replace('.', '/') + ".java"; //$NON-NLS-1$
		final CharSequence content = generateType(type, this.generatorConfigProvider.get(type));
		final String outputConfigurationName;
		final Boolean isTest = this.resourceTypeDetector.isTestResource(type.eResource());
		if (isTest != null && isTest.booleanValue()) {
			outputConfigurationName = SARLConfig.TEST_OUTPUT_CONFIGURATION;
		} else {
			outputConfigurationName = IFileSystemAccess.DEFAULT_OUTPUT;
		}
		fsa.generateFile(fn, outputConfigurationName, content);
	}
}
 
Example #5
Source File: JavaInlineExpressionCompiler.java    From sarl with Apache License 2.0 6 votes vote down vote up
@Override
public void appendInlineAnnotation(JvmAnnotationTarget target, XtendExecutable source) {
	final ImportManager imports = new ImportManager();
	final InlineAnnotationTreeAppendable result = newAppendable(imports);
	generate(source.getExpression(), null, source, result);

	final String content = result.getContent();
	if (!Strings.isEmpty(content)) {
		final List<String> importedTypes = imports.getImports();
		final JvmTypeReference[] importArray = new JvmTypeReference[importedTypes.size()];
		for (int i = 0; i < importArray.length; ++i) {
			importArray[i] = this.typeReferences.getTypeForName(importedTypes.get(i), source);
		}
		appendInlineAnnotation(target, source.eResource().getResourceSet(), content,
				result.isConstant(), result.isStatement(), importArray);
	}
}
 
Example #6
Source File: Bug440858Test.java    From xtext-xtend with Eclipse Public License 2.0 6 votes vote down vote up
@Test
public void test_02() throws Exception {
  ContentAssistProcessorTestBuilder _newBuilder = this.newBuilder();
  StringConcatenation _builder = new StringConcatenation();
  _builder.append("annotation MyTest {");
  _builder.newLine();
  _builder.append("\t");
  _builder.append("static class MyInner {");
  _builder.newLine();
  _builder.append("\t\t");
  _builder.append("<|>");
  _builder.newLine();
  _builder.append("\t");
  _builder.append("}");
  _builder.newLine();
  _builder.append("}");
  _builder.newLine();
  _newBuilder.append(_builder.toString()).assertProposalAtCursor(Strings.toPlatformLineSeparator("\n\t\toverride toString() {\n\t\t\tsuper.toString()\n\t\t}\n\t\t"));
}
 
Example #7
Source File: XbaseImportedNamespaceScopeProvider.java    From xtext-extras with Eclipse Public License 2.0 6 votes vote down vote up
/**
 * Create a new {@link ImportNormalizer} for the given namespace.
 * @param namespace the namespace.
 * @param ignoreCase <code>true</code> if the resolver should be case insensitive.
 * @return a new {@link ImportNormalizer} or <code>null</code> if the namespace cannot be converted to a valid
 * qualified name.
 */
protected ImportNormalizer createImportedNamespaceResolver(final String namespace, boolean ignoreCase) {
	if (Strings.isEmpty(namespace))
		return null;
	QualifiedName importedNamespace = qualifiedNameConverter.toQualifiedName(namespace);
	if (importedNamespace == null || importedNamespace.isEmpty()) {
		return null;
	}
	boolean hasWildCard = ignoreCase ? 
			importedNamespace.getLastSegment().equalsIgnoreCase(getWildCard()) :
			importedNamespace.getLastSegment().equals(getWildCard());
	if (hasWildCard) {
		if (importedNamespace.getSegmentCount() <= 1)
			return null;
		return doCreateImportNormalizer(importedNamespace.skipLast(1), true, ignoreCase);
	} else {
		return doCreateImportNormalizer(importedNamespace, false, ignoreCase);
	}
}
 
Example #8
Source File: SarlSpecificTypeSelectionExtension.java    From sarl with Apache License 2.0 6 votes vote down vote up
@Override
public ImageDescriptor getImageDescriptor(ITypeInfoRequestor typeInfoRequestor) {
	QualifiedName qualifiedName;
	final String enclosing = typeInfoRequestor.getEnclosingName();
	if (Strings.isEmpty(enclosing)) {
		final String packageName = typeInfoRequestor.getPackageName();
		if (Strings.isEmpty(packageName)) {
			qualifiedName = null;
		} else {
			qualifiedName = this.converter.toQualifiedName(packageName);
		}
	} else {
		qualifiedName = this.converter.toQualifiedName(enclosing);
	}
	final QualifiedName qn = this.converter.toQualifiedName(typeInfoRequestor.getTypeName());
	if (qualifiedName == null) {
		qualifiedName = qn;
	} else {
		qualifiedName = qualifiedName.append(qn);
	}
	return this.imageProvider.getImageDescriptorForQualifiedName(qualifiedName, this.typeProvider.getResourceSet(),
			this.typeProvider);
}
 
Example #9
Source File: BinaryIntValueConverter.java    From n4js with Eclipse Public License 1.0 6 votes vote down vote up
@Override
public BigDecimal toValue(String string, INode node) {
	if (Strings.isEmpty(string))
		throw new N4JSValueConverterException(IssueCodes.getMessageForVCO_BINARYINT_CONVERT_EMPTY_STR(),
				IssueCodes.VCO_BINARYINT_CONVERT_EMPTY_STR, node, null);
	if (string.length() <= 2) {
		throw new N4JSValueConverterWithValueException(
				IssueCodes.getMessageForVCO_BINARYINT_CONVERT_TOO_SHORT(string),
				IssueCodes.VCO_BINARYINT_CONVERT_TOO_SHORT, node,
				BigDecimal.ZERO, null);
	}
	try {
		return new BigDecimal(new BigInteger(string.substring(2), 2));
	} catch (NumberFormatException e) {
		throw new N4JSValueConverterException(IssueCodes.getMessageForVCO_HEXINT_CONVERT_STR(string),
				IssueCodes.VCO_HEXINT_CONVERT_STR, node, null);
	}
}
 
Example #10
Source File: SarlSkillImplCustom.java    From sarl with Apache License 2.0 5 votes vote down vote up
@Override
public boolean isAbstract() {
	for (final String modifier: getModifiers()) {
		if (Strings.equal(modifier, "abstract")) {  //$NON-NLS-1$
			return true;
		}
		if (Strings.equal(modifier, "final")) {  //$NON-NLS-1$
			return false;
		}
	}
	return false;
}
 
Example #11
Source File: TerminalRuleToLexerBody.java    From xtext-extras with Eclipse Public License 2.0 5 votes vote down vote up
@Override
public String caseCharacterRange(CharacterRange object) {
	if (!Strings.isEmpty(object.getCardinality()))
		result.append('(');
	doSwitch(object.getLeft());
	result.append("..");
	doSwitch(object.getRight());
	if (!Strings.isEmpty(object.getCardinality())) {
		result.append(')');
		result.append(Strings.emptyIfNull(object.getCardinality()));
	}
	return "";
}
 
Example #12
Source File: AbstractConversionTable.java    From sarl with Apache License 2.0 5 votes vote down vote up
@Override
public Object getValue(Object element, String property) {
	final ConversionMapping pair = (ConversionMapping) element;
	if (Strings.equal(this.targetColumnPropertyName, property)) {
		return pair.getTarget();
	}
	if (Strings.equal(this.sourceColumnPropertyName, property)) {
		return pair.getSource();
	}
	return createDefaultValue();
}
 
Example #13
Source File: XbaseValueConverterService.java    From xtext-extras with Eclipse Public License 2.0 5 votes vote down vote up
@Override
public Integer toValue(String string, INode node) {
	if (Strings.isEmpty(string))
		throw new ValueConverterException("Couldn't convert empty string to an int value.", node, null);
	String withoutUnderscore = string.replace("_", "");
	if (Strings.isEmpty(withoutUnderscore))
		throw new ValueConverterException("Couldn't convert input '" + string + "' to an int value.", node, null);
	return super.toValue(withoutUnderscore, node);
}
 
Example #14
Source File: NestedTypesScope.java    From xtext-extras with Eclipse Public License 2.0 5 votes vote down vote up
protected void addDescriptions(JvmDeclaredType type, JvmType declarator, List<IEObjectDescription> result) {
	String typeName = type.getQualifiedName('.');
	String declaratorName = declarator.getQualifiedName('.');
	int declaratorLength = declaratorName.length();
	String subName = typeName.substring(declaratorLength + 1);
	List<String> segments = Strings.split(subName, '.');
	result.add(EObjectDescription.create(QualifiedName.create(segments), type));
	result.add(EObjectDescription.create(subName.replace('.', '$'), type));
	for(JvmDeclaredType nestedType: type.getAllNestedTypes()) {
		addDescriptions(nestedType, declarator, result);
	}
}
 
Example #15
Source File: ExternalHighlightingConfig.java    From sarl with Apache License 2.0 5 votes vote down vote up
/** Replies the color of the identifiers.
 *
 * @return the name of the color to use.
 */
public String getIdentifierColor() {
	if (Strings.isEmpty(this.identifierColor)) {
		return DEFAULT_COLOR;
	}
	return this.identifierColor;
}
 
Example #16
Source File: AbstractDocumentationMojo.java    From sarl with Apache License 2.0 5 votes vote down vote up
private Properties createProjectProperties() {
	final Properties props = new Properties();
	final MavenProject prj = this.session.getCurrentProject();
	props.put("project.groupId", Strings.emptyIfNull(prj.getGroupId())); //$NON-NLS-1$
	props.put("project.artifactId", Strings.emptyIfNull(prj.getArtifactId())); //$NON-NLS-1$
	props.put("project.basedir", prj.getBasedir() != null ? prj.getBasedir().getAbsolutePath() : ""); //$NON-NLS-1$ //$NON-NLS-2$
	props.put("project.description", Strings.emptyIfNull(prj.getDescription())); //$NON-NLS-1$
	props.put("project.id", Strings.emptyIfNull(prj.getId())); //$NON-NLS-1$
	props.put("project.inceptionYear", Strings.emptyIfNull(prj.getInceptionYear())); //$NON-NLS-1$
	props.put("project.name", Strings.emptyIfNull(prj.getName())); //$NON-NLS-1$
	props.put("project.version", Strings.emptyIfNull(prj.getVersion())); //$NON-NLS-1$
	props.put("project.url", Strings.emptyIfNull(prj.getUrl())); //$NON-NLS-1$
	props.put("project.encoding", Strings.emptyIfNull(this.encoding)); //$NON-NLS-1$
	return props;
}
 
Example #17
Source File: SarlBehaviorImplCustom.java    From sarl with Apache License 2.0 5 votes vote down vote up
@Override
public boolean isAbstract() {
	for (final String modifier: getModifiers()) {
		if (Strings.equal(modifier, "abstract")) {  //$NON-NLS-1$
			return true;
		}
		if (Strings.equal(modifier, "final")) {  //$NON-NLS-1$
			return false;
		}
	}
	return false;
}
 
Example #18
Source File: QualifiedNameValueConverter.java    From xtext-core with Eclipse Public License 2.0 5 votes vote down vote up
@Override
public String toValue(String string, INode node) throws ValueConverterException {
	StringBuilder buffer = new StringBuilder();
	boolean isFirst = true;
	if (node != null) {
		for(ILeafNode leafNode: node.getLeafNodes()) {
			EObject grammarElement = leafNode.getGrammarElement();
			if (isDelegateRuleCall(grammarElement) || isWildcardLiteral(grammarElement)) {
				if (!isFirst)
					buffer.append(getValueNamespaceDelimiter());
				isFirst = false;
				if (isDelegateRuleCall(grammarElement))
					buffer.append(delegateToValue(leafNode));
				else 
					buffer.append(getWildcardLiteral());
			}
		}
	} else {
		for (String segment : Strings.split(string, getStringNamespaceDelimiter())) {
			if (!isFirst)
				buffer.append(getValueNamespaceDelimiter());
			isFirst = false;
			if(getWildcardLiteral().equals(segment)) {
				buffer.append(getWildcardLiteral());
			} else {
				buffer.append((String) valueConverterService.toValue(segment, getDelegateRuleName(), null));
			}
		}
	}
	return buffer.toString();
}
 
Example #19
Source File: RenameRefactoringController.java    From xtext-eclipse with Eclipse Public License 2.0 5 votes vote down vote up
protected void startDirectRefactoring() throws InterruptedException {
	if (Strings.isEmpty(newName)) {
		restoreOriginalSelection();
	} else {
		String originalName = getOriginalName(getXtextEditor());
		if(!equal(originalName, newName)) {
			IRenameSupport renameSupport = createRenameSupport(renameElementContext, newName);
			if(renameSupport != null) 
				renameSupport.startDirectRefactoring();
		}
	}
}
 
Example #20
Source File: XtendJvmModelInferrer.java    From xtext-xtend with Eclipse Public License 2.0 5 votes vote down vote up
protected void copyTypeParameters(List<JvmTypeParameter> typeParameters, JvmTypeParameterDeclarator target) {
	for (JvmTypeParameter typeParameter : typeParameters) {
		if (!Strings.isEmpty(typeParameter.getName())) {
			final JvmTypeParameter clonedTypeParameter = jvmTypesBuilder.cloneWithProxies(typeParameter);
			if (clonedTypeParameter != null) {
				target.getTypeParameters().add(clonedTypeParameter);
				associator.associate(typeParameter, clonedTypeParameter);
			}
		}
	}
}
 
Example #21
Source File: JdtToBeBuiltComputer.java    From xtext-eclipse with Eclipse Public License 2.0 5 votes vote down vote up
protected void queueJavaChange(String typeName) {
	URI typeURI = URIHelperConstants.OBJECTS_URI.appendSegment(typeName);
	QualifiedName qualifiedName = QualifiedName.create(Strings.split(typeName, '.'));
	NameBasedEObjectDescription nameBasedEObjectDescription = new NameBasedEObjectDescription(qualifiedName);
	TypeResourceDescription oldDescription = new TypeResourceDescription(typeURI, Collections.<IEObjectDescription>singletonList(nameBasedEObjectDescription));
	Delta delta = new ChangedResourceDescriptionDelta(oldDescription, null);
	queuedBuildData.queueChange(delta);
}
 
Example #22
Source File: Xtext2EcoreTransformer.java    From xtext-core with Eclipse Public License 2.0 5 votes vote down vote up
private void addGeneratedEPackage(GeneratedMetamodel generatedMetamodel) throws TransformationException {
	// we do not allow the same alias twice for generated metamodels
	String alias = Strings.emptyIfNull(generatedMetamodel.getAlias());
	if (generatedEPackages.containsKey(alias))
		throw new TransformationException(TransformationErrorCode.AliasForMetamodelAlreadyExists, "alias '" + alias
				+ "' already exists", generatedMetamodel);

	if (generatedMetamodel.getEPackage() == null)
		throw new TransformationException(TransformationErrorCode.UnknownMetaModelAlias, "Cannot create EPackage without NsURI.", generatedMetamodel);

	// instantiate EPackages for generated metamodel
	EPackage generatedEPackage = generatedMetamodel.getEPackage();
	generatedEPackages.put(alias, generatedEPackage);
	collectClassInfosOf(generatedEPackage, generatedMetamodel);
}
 
Example #23
Source File: PasteJavaCodeHandler.java    From xtext-xtend with Eclipse Public License 2.0 5 votes vote down vote up
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
	final XtextEditor activeXtextEditor = EditorUtils.getActiveXtextEditor(event);
	if (activeXtextEditor == null || !activeXtextEditor.isEditable()) {
		return null;
	}

	String clipboardText = ClipboardUtil.getTextFromClipboard();
	if (!Strings.isEmpty(clipboardText)) {
		JavaImportData javaImports = ClipboardUtil.getJavaImportsContent();
		doPasteJavaCode(activeXtextEditor, clipboardText, javaImports);
	}
	return null;
}
 
Example #24
Source File: IssueDatabaseExtensions.java    From sarl with Apache License 2.0 5 votes vote down vote up
private static void extractIssueCodes(Class<?> definitions, Set<String> codes) {
	for (final Field field : definitions.getDeclaredFields()) {
		if (String.class.equals(field.getType()) && Modifier.isStatic(field.getModifiers())
				&& Modifier.isPublic(field.getModifiers())) {
			try {
				final String value = (String) field.get(null);
				if (!Strings.isEmpty(value) && !value.endsWith(".")) {
					codes.add(value);
				}
			} catch (Exception e) {
				throw new RuntimeException(e);
			}
		}
	}
}
 
Example #25
Source File: SARLValidator.java    From sarl with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings("checkstyle:nestedifdepth")
@Override
@Check
public void checkCasts(XCastedExpression cast) {
	// Validation of the casting according to the SARL specification of this operator.
	if (cast instanceof SarlCastedExpression) {
		final SarlCastedExpression sarlCast = (SarlCastedExpression) cast;
		final JvmOperation operation = sarlCast.getFeature();
		if (operation != null) {
			// We have to test the unnecessary cast because because it is tested into the standard process
			final JvmTypeReference concreteSyntax = sarlCast.getType();
			if (concreteSyntax != null) {
				final LightweightTypeReference toType = toLightweightTypeReference(cast.getType());
				reportCastWarnings(
						concreteSyntax,
						toType,
						getActualType(cast.getTarget()));

				if (!isIgnored(POTENTIAL_INEFFICIENT_VALUE_CONVERSION)) {
					final LightweightTypeReference fromType = toLightweightTypeReference(operation.getReturnType());
					final String message;
					if (Strings.equal(concreteSyntax.getIdentifier(), fromType.getIdentifier())) {
						message = MessageFormat.format(Messages.SARLValidator_97, operation.getSimpleName());
					} else {
						message = MessageFormat.format(Messages.SARLValidator_98, operation.getSimpleName(),
								toType.getHumanReadableName(), fromType.getHumanReadableName());
					}
					addIssue(message, concreteSyntax, POTENTIAL_INEFFICIENT_VALUE_CONVERSION);
				}
			}

			// Break to avoid the standard validation for casted expressions
			return;
		}
	}
	// Standard check of the types.
	super.checkCasts(cast);
}
 
Example #26
Source File: DynamicValidationContext.java    From sarl with Apache License 2.0 5 votes vote down vote up
private static void appendSafeTitleAnchorExistenceTest(ITreeAppendable receiver, File fileInResource, String anchor) {
	receiver.newLine();
	receiver.append("{").increaseIndentation().newLine(); //$NON-NLS-1$
	receiver.append("// ").append(FileSystem.extension(fileInResource)).append(": "); //$NON-NLS-1$ //$NON-NLS-2$
	receiver.append(fileInResource.getName()).newLine();
	receiver.append(File.class).append(" theFile = new ").append(File.class).append("(\""); //$NON-NLS-1$ //$NON-NLS-2$
	receiver.append(Strings.convertToJavaString(fileInResource.toString())).append("\");"); //$NON-NLS-1$
	receiver.newLine().append("if (theFile.exists()) {"); //$NON-NLS-1$
	receiver.increaseIndentation().newLine();
	receiver.append("String content = ").append(Strings.class); //$NON-NLS-1$
	receiver.append(".concat(\"\\n\", ").append(Files.class); //$NON-NLS-1$
	receiver.append(".readLines(theFile, "); //$NON-NLS-1$
	receiver.append(Charset.class).append(".defaultCharset()));").newLine(); //$NON-NLS-1$
	receiver.append(Matcher.class).append(" matcher = sectionPattern.matcher(content);").newLine(); //$NON-NLS-1$
	receiver.append("while (matcher.find()) {").increaseIndentation().newLine(); //$NON-NLS-1$
	receiver.append("String title = matcher.group(1);").newLine(); //$NON-NLS-1$
	receiver.append("String key1 = computeHeaderIdWithSectionNumber(title);").newLine(); //$NON-NLS-1$
	receiver.append("String key2 = computeHeaderIdWithoutSectionNumber(title);").newLine(); //$NON-NLS-1$
	receiver.append("if (\"").append(Strings.convertToJavaString(anchor)).append("\".equals(key1) || \""); //$NON-NLS-1$ //$NON-NLS-2$
	receiver.append(Strings.convertToJavaString(anchor)).append("\".equals(key2)) {"); //$NON-NLS-1$
	receiver.increaseIndentation().newLine().append("return;").decreaseIndentation().newLine(); //$NON-NLS-1$
	receiver.append("}").decreaseIndentation().newLine(); //$NON-NLS-1$
	receiver.append("}").newLine().append(Assertions.class).append(".fail(\""); //$NON-NLS-1$ //$NON-NLS-2$
	receiver.append(Strings.convertToJavaString(MessageFormat.format(Messages.DynamicValidationContext_0,
			anchor, fileInResource.getName())));
	receiver.append("\");").newLine(); //$NON-NLS-1$
	receiver.append("return;"); //$NON-NLS-1$
	receiver.decreaseIndentation().newLine();
	receiver.append("}").decreaseIndentation().newLine().append("}"); //$NON-NLS-1$ //$NON-NLS-2$
}
 
Example #27
Source File: N4JSProjectSourceContainer.java    From n4js with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public SafeURI<?> getLocation() {
	String location = getRelativeLocation();
	if (!Strings.isEmpty(location)) {
		String linuxPath = OSInfo.isWindows() ? location.replace(File.separatorChar, '/') : location;
		return project.getLocation().appendPath(linuxPath);
	}
	return project.getLocation();
}
 
Example #28
Source File: XClosureImplCustom.java    From xtext-extras with Eclipse Public License 2.0 5 votes vote down vote up
@Override
public String toString() {
	String expressionAsString = Strings.emptyIfNull(expression == null ? null : expression.toString());
	if (isExplicitSyntax()) {
		return String.format("[%s | %s ]", Joiner.on(", ").join(getFormalParameters()), expressionAsString);
	} else {
		return String.format("[ %s ]", expressionAsString);
	}
}
 
Example #29
Source File: SarlBatchCompiler.java    From sarl with Apache License 2.0 5 votes vote down vote up
/** Change the classpath.
 *
 * <p>The classpath is a list the names of folders or jar files that are separated by {@link File#pathSeparator}.
 *
 * @param classpath the new classpath.
 */
public void setClassPath(String classpath) {
	this.classpath = new ArrayList<>();
	for (final String path : Strings.split(classpath, File.pathSeparator)) {
		this.classpath.add(normalizeFile(path));
	}
}
 
Example #30
Source File: SarlBatchCompiler.java    From sarl with Apache License 2.0 5 votes vote down vote up
/** Change the source path.
 *
 * <p>The source path is a list the names of folders that are separated by {@link File#pathSeparator}.
 *
 * @param sourcePath the new source path.
 */
public void setSourcePath(String sourcePath) {
	this.sourcePath = new ArrayList<>();
	for (final String path : Strings.split(sourcePath, File.pathSeparator)) {
		this.sourcePath.add(normalizeFile(path));
	}
}