<commit_before>/*******************************************************************************
 * Copyright (c) 2016 TypeFox GmbH (http://www.typefox.io) and others.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *******************************************************************************/
package org.eclipse.xtext.ide.server

import com.google.inject.Singleton
import java.nio.file.Paths
import org.eclipse.emf.common.util.URI

/**
 * @author kosyakov - Initial contribution and API
 * @since 2.11
 */
@Singleton
class UriExtensions {

	def URI toUri(String pathWithScheme) {
		return URI.createURI(java.net.URI.create(pathWithScheme).toPath)
	}

	def String toPath(URI uri) {
		return java.net.URI.create(uri.toString).toPath
	}

	def String toPath(java.net.URI uri) {
		val path = Paths.get(uri)
		return path.toUri.toString
	}

}<commit_msg>[lsp] allow scheme’s for unregistered filesystems<commit_after>/*******************************************************************************
 * Copyright (c) 2016 TypeFox GmbH (http://www.typefox.io) and others.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *******************************************************************************/
package org.eclipse.xtext.ide.server

import com.google.inject.Singleton
import java.nio.file.FileSystemNotFoundException
import java.nio.file.Paths
import org.eclipse.emf.common.util.URI

/**
 * @author kosyakov - Initial contribution and API
 * @since 2.11
 */
@Singleton
class UriExtensions {

	def URI toUri(String pathWithScheme) {
		val javaNetUri = java.net.URI.create(pathWithScheme);
		val path = javaNetUri.toPath
        return URI.createURI(path)
	}

	def String toPath(URI uri) {
		return java.net.URI.create(uri.toString).toPath
	}

	def String toPath(java.net.URI uri) {
	    try {
    		val path = Paths.get(uri)
    		return path.toUri.toString
	    } catch (FileSystemNotFoundException e) {
	        return uri.toString
	    }
	}
}
{'fraction_non_alphanumeric': 0.22449850618864703, 'fraction_numerical': 0.009389671361502348, 'mean_word_length': 4.489461358313817, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 4, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5938288', 'n_tokens_mistral': 707, 'n_tokens_neox': 643, 'n_words': 177}