Skip to content

Commit

Permalink
fix some warnings
Browse files Browse the repository at this point in the history
Signed-off-by: Christian Dietrich <[email protected]>
  • Loading branch information
cdietrich committed Dec 25, 2024
1 parent 05ae681 commit 059d582
Show file tree
Hide file tree
Showing 17 changed files with 41 additions and 48 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2013, 2016 itemis AG (http://www.itemis.eu) and others.
* Copyright (c) 2013, 2024 itemis AG (http://www.itemis.eu) and others.
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0.
Expand All @@ -8,6 +8,7 @@
*******************************************************************************/
package org.eclipse.xtend.core.tests.compiler;

import java.nio.charset.StandardCharsets;
import java.util.Collections;
import java.util.Set;

Expand All @@ -28,7 +29,6 @@
import org.junit.Test;
import org.junit.runner.RunWith;

import com.google.common.base.Charsets;
import com.google.inject.Inject;

/**
Expand All @@ -43,27 +43,27 @@ public class UnicodeAwarePostProcessorTest extends Assert implements IJvmModelAs

@Test
public void testUTF8_plain() {
CharSequence result = postProcessor.postProcess(URI.createFileURI("com/acme/MyFile.java"), "\u03b1\u03c1\u03b5\u03c4\u03b7", Charsets.UTF_8);
CharSequence result = postProcessor.postProcess(URI.createFileURI("com/acme/MyFile.java"), "\u03b1\u03c1\u03b5\u03c4\u03b7", StandardCharsets.UTF_8);
assertEquals("\u03b1\u03c1\u03b5\u03c4\u03b7", result.toString());
}

@Test
public void testISO_8859_1_plain() {
CharSequence result = postProcessor.postProcess(URI.createFileURI("com/acme/MyFile.java"), "\u03b1\u03c1\u03b5\u03c4\u03b7", Charsets.ISO_8859_1);
CharSequence result = postProcessor.postProcess(URI.createFileURI("com/acme/MyFile.java"), "\u03b1\u03c1\u03b5\u03c4\u03b7", StandardCharsets.ISO_8859_1);
assertEquals("\\u03b1\\u03c1\\u03b5\\u03c4\\u03b7", result.toString());
}

@Test
public void testOnlyJavaEscaped() {
CharSequence result = postProcessor.postProcess(URI.createFileURI("com/acme/MyFile.notJava"), "\u03b1\u03c1\u03b5\u03c4\u03b7", Charsets.ISO_8859_1);
CharSequence result = postProcessor.postProcess(URI.createFileURI("com/acme/MyFile.notJava"), "\u03b1\u03c1\u03b5\u03c4\u03b7", StandardCharsets.ISO_8859_1);
assertEquals("\u03b1\u03c1\u03b5\u03c4\u03b7", result.toString());
}

@Test
public void testUTF8_tree() {
TreeAppendable treeAppendable = new TreeAppendable(null, null, this, this, EcoreFactory.eINSTANCE.createEObject(), " ", "\n");
treeAppendable.append("\u03b1\u03c1\u03b5\u03c4\u03b7");
CharSequence result = postProcessor.postProcess(URI.createFileURI("com/acme/MyFile.java"), treeAppendable, Charsets.UTF_8);
CharSequence result = postProcessor.postProcess(URI.createFileURI("com/acme/MyFile.java"), treeAppendable, StandardCharsets.UTF_8);
assertSame(treeAppendable, result);
assertEquals("\u03b1\u03c1\u03b5\u03c4\u03b7", result.toString());
}
Expand All @@ -72,7 +72,7 @@ public void testUTF8_tree() {
public void testISO_8859_1_tree() {
TreeAppendable treeAppendable = new TreeAppendable(null, null, this, this, EcoreFactory.eINSTANCE.createEObject(), " ", "\n");
treeAppendable.append("\u03b1\u03c1\u03b5\u03c4\u03b7");
CharSequence result = postProcessor.postProcess(URI.createFileURI("com/acme/MyFile.java"), treeAppendable, Charsets.ISO_8859_1);
CharSequence result = postProcessor.postProcess(URI.createFileURI("com/acme/MyFile.java"), treeAppendable, StandardCharsets.ISO_8859_1);
assertSame(treeAppendable, result);
assertEquals("\\u03b1\\u03c1\\u03b5\\u03c4\\u03b7", result.toString());
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2012, 2022 itemis AG (http://www.itemis.eu) and others.
* Copyright (c) 2012, 2024 itemis AG (http://www.itemis.eu) and others.
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0.
Expand All @@ -8,7 +8,6 @@
*******************************************************************************/
package org.eclipse.xtend.core.tests.compiler.batch

import com.google.common.base.Charsets
import com.google.common.io.Files
import com.google.inject.Inject
import java.io.File
Expand All @@ -29,6 +28,7 @@ import org.junit.runner.RunWith

import static org.eclipse.xtext.util.Files.*
import static org.junit.Assert.*
import java.nio.charset.StandardCharsets

/**
* Batch compiler tests.
Expand Down Expand Up @@ -466,7 +466,8 @@ class BatchCompilerTest {
}

def private String getContents(String fileName) {
Files.asCharSource(new File(fileName), Charsets.UTF_8).read()
Files.asCharSource(new File(fileName), StandardCharsets.UTF_8
).read()
}

@Test
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright (c) 2012, 2022 itemis AG (http://www.itemis.eu) and others.
* Copyright (c) 2012, 2024 itemis AG (http://www.itemis.eu) and others.
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0.
Expand All @@ -8,11 +8,11 @@
*/
package org.eclipse.xtend.core.tests.compiler.batch;

import com.google.common.base.Charsets;
import com.google.inject.Inject;
import java.io.File;
import java.io.FilenameFilter;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.util.List;
import java.util.Set;
import java.util.function.Consumer;
Expand Down Expand Up @@ -696,7 +696,7 @@ private boolean isSymlink(final File file) {
private String getContents(final String fileName) {
try {
File _file = new File(fileName);
return com.google.common.io.Files.asCharSource(_file, Charsets.UTF_8).read();
return com.google.common.io.Files.asCharSource(_file, StandardCharsets.UTF_8).read();
} catch (Throwable _e) {
throw Exceptions.sneakyThrow(_e);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@
*******************************************************************************/
package org.eclipse.xtend.ide.tests.compiler

import com.google.common.base.Charsets
import com.google.common.io.CharStreams
import com.google.inject.Inject
import java.io.InputStreamReader
import java.nio.charset.StandardCharsets
import org.eclipse.core.resources.IFile
import org.eclipse.core.resources.IMarker
import org.eclipse.core.resources.IProject
Expand All @@ -20,6 +20,7 @@ import org.eclipse.ui.texteditor.MarkerUtilities
import org.eclipse.xtend.ide.internal.XtendActivator
import org.eclipse.xtend.ide.tests.WorkbenchTestHelper
import org.eclipse.xtext.ui.testing.util.IResourcesSetupUtil
import org.eclipse.xtext.ui.testing.util.TargetPlatformUtil
import org.eclipse.xtext.util.JavaVersion
import org.junit.After
import org.junit.AfterClass
Expand All @@ -29,7 +30,6 @@ import org.junit.BeforeClass
import org.junit.Test

import static org.eclipse.xtext.ui.testing.util.IResourcesSetupUtil.*
import org.eclipse.xtext.ui.testing.util.TargetPlatformUtil

/**
* @author Miro Spoenemann - Initial contribution and API
Expand Down Expand Up @@ -84,7 +84,7 @@ class JavaVersionSettingTest extends Assert {
assertTrue("Generated Java file does not exist.", javaFile.exists)
assertNoErrors(javaFile)
val javaFileStream = javaFile.contents
val content = CharStreams.toString(new InputStreamReader(javaFileStream, Charsets.UTF_8))
val content = CharStreams.toString(new InputStreamReader(javaFileStream, StandardCharsets.UTF_8))
javaFileStream.close
return content
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@
*/
package org.eclipse.xtend.ide.tests.compiler;

import com.google.common.base.Charsets;
import com.google.common.io.CharStreams;
import com.google.inject.Inject;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.nio.charset.StandardCharsets;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IMarker;
import org.eclipse.core.resources.IProject;
Expand Down Expand Up @@ -106,7 +106,7 @@ private String getJavaFileContent(final String fileName, final IProject project)
Assert.assertTrue("Generated Java file does not exist.", javaFile.exists());
this.assertNoErrors(javaFile);
final InputStream javaFileStream = javaFile.getContents();
InputStreamReader _inputStreamReader = new InputStreamReader(javaFileStream, Charsets.UTF_8);
InputStreamReader _inputStreamReader = new InputStreamReader(javaFileStream, StandardCharsets.UTF_8);
final String content = CharStreams.toString(_inputStreamReader);
javaFileStream.close();
return content;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2012, 2017 itemis AG (http://www.itemis.eu) and others.
* Copyright (c) 2012, 2024 itemis AG (http://www.itemis.eu) and others.
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0.
Expand All @@ -11,6 +11,7 @@
import java.io.IOException;
import java.io.InputStream;
import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;

import org.apache.log4j.Logger;
import org.eclipse.core.resources.IProject;
Expand Down Expand Up @@ -43,7 +44,6 @@
import org.eclipse.xtext.util.Pair;
import org.eclipse.xtext.util.Tuples;

import com.google.common.base.Charsets;
import com.google.inject.Inject;
import com.google.inject.Provider;
import com.google.inject.Singleton;
Expand Down Expand Up @@ -155,7 +155,7 @@ protected Charset getSourceEncoding(final ITypeRoot derivedJavaType) {
return Charset.forName(ResourcesPlugin.getWorkspace().getRoot().getDefaultCharset());
} catch (CoreException e) {
log.error("Error determining encoding for source file for " + derivedJavaType.getElementName(), e);
return Charsets.UTF_8;
return StandardCharsets.UTF_8;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
import org.eclipse.lsp4j.DidChangeWorkspaceFoldersParams;
import org.eclipse.lsp4j.InitializeParams;
import org.eclipse.lsp4j.InitializeResult;
import org.eclipse.lsp4j.NotebookDocumentChangeEvent;
import org.eclipse.lsp4j.WorkspaceClientCapabilities;
import org.eclipse.lsp4j.WorkspaceFolder;
import org.eclipse.lsp4j.WorkspaceFoldersChangeEvent;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright (c) 2015, 2020 itemis AG (http://www.itemis.eu) and others.
* Copyright (c) 2015, 2024 itemis AG (http://www.itemis.eu) and others.
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0.
Expand All @@ -11,6 +11,7 @@
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
Expand Down Expand Up @@ -43,7 +44,6 @@
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;

import com.google.common.base.Charsets;
import com.google.common.collect.Lists;
import com.google.common.collect.Sets;

Expand Down Expand Up @@ -288,7 +288,7 @@ public String toString() {
}
};
result.setXtextVersion(new XtextVersion("unspecified"));
result.setEncoding(Charsets.UTF_8);
result.setEncoding(StandardCharsets.UTF_8);
result.setLineDelimiter(LineDelimiter.UNIX.getValue());
result.getLanguage().setName("mydsl.MyDsl");
result.getLanguage().setFileExtensions(LanguageDescriptor.FileExtensions.fromString("mydsl"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,6 @@
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.editors.text.TextEditor;
import org.eclipse.ui.texteditor.DefaultMarkerAnnotationAccess;
import org.eclipse.ui.texteditor.IDocumentProvider;
import org.eclipse.ui.texteditor.IDocumentProviderExtension3;
import org.eclipse.ui.texteditor.ITextEditor;
import org.eclipse.ui.texteditor.ITextEditorActionConstants;
import org.eclipse.ui.texteditor.ITextEditorActionDefinitionIds;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright (c) 2015, 2020 itemis AG (http://www.itemis.eu) and others.
* Copyright (c) 2015, 2024 itemis AG (http://www.itemis.eu) and others.
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0.
Expand All @@ -9,13 +9,13 @@
package org.eclipse.xtext.web.server.test;

import java.io.File;
import java.nio.charset.StandardCharsets;

import org.eclipse.xtext.web.server.XtextServiceDispatcher;
import org.eclipse.xtext.web.server.persistence.ResourceContentResult;
import org.junit.Assert;
import org.junit.Test;

import com.google.common.base.Charsets;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableMap.Builder;
import com.google.common.io.Files;
Expand Down Expand Up @@ -88,7 +88,7 @@ public void testSaveFile() throws Exception {
nb().put("serviceType", "save").put("resource", file.getName()).build(), session);
Assert.assertTrue(save.isHasSideEffects());
save.getService().apply();
String resourceContent = Files.asCharSource(file, Charsets.UTF_8).read();
String resourceContent = Files.asCharSource(file, StandardCharsets.UTF_8).read();
assertEquals("state bar end", resourceContent);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2010 itemis AG (http://www.itemis.eu) and others.
* Copyright (c) 2010, 2024 itemis AG (http://www.itemis.eu) and others.
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0.
Expand All @@ -10,6 +10,7 @@

import java.io.File;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
Expand All @@ -30,7 +31,6 @@
import org.eclipse.xtext.xtext.ui.wizard.project.XtextProjectInfo;
import org.eclipse.xtext.xtext.wizard.EPackageInfo;

import com.google.common.base.Charsets;
import com.google.common.io.Files;

/**
Expand Down Expand Up @@ -82,7 +82,7 @@ protected void invokeInternal(final WorkflowContext ctx, ProgressMonitor monitor
createXtextProjectInfo(issues);
CharSequence grammar = xtextProjectInfo.getRuntimeProject().grammar();
try {
Files.asCharSink(new File(genPath, xtextProjectInfo.getRuntimeProject().getGrammarFilePath()), Charsets.ISO_8859_1).write(grammar);
Files.asCharSink(new File(genPath, xtextProjectInfo.getRuntimeProject().getGrammarFilePath()), StandardCharsets.ISO_8859_1).write(grammar);
} catch (IOException e) {
String message = "Can't create grammar file";
log.error(message, e);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@
*******************************************************************************/
package org.eclipse.xtext.xtext.ui;

import static org.junit.Assert.*;

import org.eclipse.xtext.AbstractElement;
import org.eclipse.xtext.AbstractMetamodelDeclaration;
import org.eclipse.xtext.Grammar;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
*******************************************************************************/
package org.eclipse.xtext.xtext.wizard

import com.google.common.base.Charsets
import com.google.common.io.Resources
import java.nio.charset.StandardCharsets
import org.eclipse.xtend.lib.annotations.FinalFieldsConstructor

@FinalFieldsConstructor
Expand Down Expand Up @@ -73,7 +73,7 @@ class ParentProjectDescriptor extends ProjectDescriptor {
}

def private CharSequence loadResource(String resourcePath) {
Resources.toString(class.classLoader.getResource(resourcePath), Charsets.ISO_8859_1)
Resources.toString(class.classLoader.getResource(resourcePath), StandardCharsets.ISO_8859_1)
}

override buildGradle() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2018, 2022 itemis AG (http://www.itemis.eu) and others.
* Copyright (c) 2018, 2024 itemis AG (http://www.itemis.eu) and others.
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0.
Expand All @@ -10,6 +10,7 @@

import java.io.File;
import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
import java.util.List;

import org.apache.log4j.Logger;
Expand All @@ -28,8 +29,6 @@
import org.kohsuke.args4j.CmdLineParser;
import org.kohsuke.args4j.Option;

import com.google.common.base.Charsets;

/**
*
* @author Karsten Thoms ([email protected])
Expand Down Expand Up @@ -60,7 +59,7 @@ public enum ProjectType {
private String fileExtension;

@Option(name = "-encoding", usage = "File encoding")
private String encoding = Charsets.UTF_8.name();
private String encoding = StandardCharsets.UTF_8.name();

@Option(name = "-xtextVersion", usage = "Xtext Version (for code header comments)")
private String xtextVersion = "unspecified";
Expand Down
Loading

0 comments on commit 059d582

Please sign in to comment.