Skip to content

Commit

Permalink
Merge branch 'master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
nedtwigg authored Mar 28, 2020
2 parents 588aa43 + 64849c8 commit 528e708
Show file tree
Hide file tree
Showing 18 changed files with 134 additions and 35 deletions.
3 changes: 3 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ We adhere to the [keepachangelog](https://keepachangelog.com/en/1.0.0/) format (
## [Unreleased]
### Added
* Tsfmt Maven Plugin ([#548](https://github.com/diffplug/spotless/pull/548))
### Fixed
* Javadoc for the `ext/eclipse-*` projects.
* Replace the deprecated `compile` with `implementation` for the `ext/eclipse-*` projects.

## [1.28.0] - 2020-03-20
### Added
Expand Down
4 changes: 2 additions & 2 deletions _ext/eclipse-base/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ ext {
}

dependencies {
compile("org.eclipse.platform:org.eclipse.core.resources:${VER_ECLIPSE_CORE_RESOURCES}") {
implementation("org.eclipse.platform:org.eclipse.core.resources:${VER_ECLIPSE_CORE_RESOURCES}") {
exclude group: 'org.eclipse.platform', module: 'org.eclipse.ant.core'
exclude group: 'org.eclipse.platform', module: 'org.eclipse.core.expressions'
exclude group: 'org.eclipse.platform', module: 'org.eclipse.core.filesystem'
}
compile("org.slf4j:slf4j-api:${VER_SLF4J}")
implementation("org.slf4j:slf4j-api:${VER_SLF4J}")

testImplementation("org.slf4j:slf4j-simple:${VER_SLF4J}")
}
Expand Down
8 changes: 4 additions & 4 deletions _ext/eclipse-cdt/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,15 @@ apply from: rootProject.file('gradle/java-publish.gradle')


dependencies {
compile "com.diffplug.spotless:spotless-eclipse-base:${VER_SPOTLESS_ECLISPE_BASE}"
implementation "com.diffplug.spotless:spotless-eclipse-base:${VER_SPOTLESS_ECLISPE_BASE}"
// Provides text partitioners for formatters
compile ("org.eclipse.platform:org.eclipse.jface.text:${VER_ECLISPE_JFACE}") {
implementation ("org.eclipse.platform:org.eclipse.jface.text:${VER_ECLISPE_JFACE}") {
exclude group: 'org.eclipse.platform', module: 'org.eclipse.swt'
}
// Required to by CCorePlugin calling CDTLogWriter
compile "com.ibm.icu:icu4j:${VER_IBM_ICU}"
implementation "com.ibm.icu:icu4j:${VER_IBM_ICU}"
// Required to by CCorePlugin calling PositionTrackerManager
compile "org.eclipse.platform:org.eclipse.core.filebuffers:${VER_ECLISPE_PLATFORM}"
implementation "org.eclipse.platform:org.eclipse.core.filebuffers:${VER_ECLISPE_PLATFORM}"

testImplementation("org.slf4j:slf4j-simple:${VER_SLF4J}")
}
Expand Down
6 changes: 3 additions & 3 deletions _ext/eclipse-groovy/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ ext {
]

p2Repository = "https://dist.springsource.org/release/GRECLIPSE/${VER_GRECLIPSE}/e${VER_ECLIPSE}"

p2Dependencies = [
'org.codehaus.groovy.eclipse.refactoring':'+', // GroovyFormatter and related

Expand Down Expand Up @@ -38,9 +38,9 @@ apply from: rootProject.file('_ext/gradle/p2-fat-jar-setup.gradle')
apply from: rootProject.file('gradle/java-publish.gradle')

dependencies {
compile "com.diffplug.spotless:spotless-eclipse-base:${VER_SPOTLESS_ECLISPE_BASE}"
implementation "com.diffplug.spotless:spotless-eclipse-base:${VER_SPOTLESS_ECLISPE_BASE}"
// Provides text partitioners for formatters
compile ("org.eclipse.platform:org.eclipse.jface.text:${VER_ECLISPE_JFACE}") {
implementation ("org.eclipse.platform:org.eclipse.jface.text:${VER_ECLISPE_JFACE}") {
exclude group: 'org.eclipse.platform', module: 'org.eclipse.swt'
}
testImplementation("org.slf4j:slf4j-simple:${VER_SLF4J}")
Expand Down
4 changes: 2 additions & 2 deletions _ext/eclipse-jdt/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ ext {
}

dependencies {
compile "com.diffplug.spotless:spotless-eclipse-base:${VER_SPOTLESS_ECLISPE_BASE}"
compile("org.eclipse.jdt:org.eclipse.jdt.core:${VER_ECLIPSE_JDT_CORE}") {
implementation "com.diffplug.spotless:spotless-eclipse-base:${VER_SPOTLESS_ECLISPE_BASE}"
implementation("org.eclipse.jdt:org.eclipse.jdt.core:${VER_ECLIPSE_JDT_CORE}") {
exclude group: 'org.eclipse.platform', module: 'org.eclipse.ant.core'
exclude group: 'org.eclipse.platform', module: 'org.eclipse.core.expressions'
exclude group: 'org.eclipse.platform', module: 'org.eclipse.core.filesystem'
Expand Down
4 changes: 4 additions & 0 deletions _ext/eclipse-wtp/CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ We adhere to the [keepachangelog](https://keepachangelog.com/en/1.0.0/) format (

## [Unreleased]

## [3.15.3] - 2020-03-26
### Fixed
* Handling of character encodings on OS with non-unicode default file encoding format. CSS, HTML and JSON formatter steps encoded intermediately the input using the default file encoding, which was not lossless if the default file encoding did not support the full unicode character set. ([#545](https://github.com/diffplug/spotless/issues/545)).

## [3.15.2] - 2020-03-04
### Fixed
* Racing conditions in WTP formatter configurations. Multiple configurations within the same project are no longer supported. ([#492](https://github.com/diffplug/spotless/pull/492)).
Expand Down
20 changes: 10 additions & 10 deletions _ext/eclipse-wtp/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ ext {
]

p2Repository = "https://download.eclipse.org/webtools/repository/${VER_ECLIPSE_WTP}"

p2Dependencies = [
// XML/HTML Formatter - Dependencies
'org.eclipse.wst.xml.core':'+', // DefaultXMLPartitionFormatter and XMLAssociationProvider
Expand Down Expand Up @@ -60,24 +60,24 @@ apply from: rootProject.file('_ext/gradle/p2-fat-jar-setup.gradle')
apply from: rootProject.file('gradle/java-publish.gradle')

dependencies {
compile "com.diffplug.spotless:spotless-eclipse-base:${VER_SPOTLESS_ECLISPE_BASE}"
implementation "com.diffplug.spotless:spotless-eclipse-base:${VER_SPOTLESS_ECLISPE_BASE}"
// Required by most WPT formatters
compile "com.ibm.icu:icu4j:${VER_IBM_ICU}"
implementation "com.ibm.icu:icu4j:${VER_IBM_ICU}"
// The XSD/DTD and other models are defined with EMF.
compile "org.eclipse.emf:org.eclipse.emf.common:${VER_ECLISPE_EMF}"
compile "org.eclipse.emf:org.eclipse.emf.ecore:${VER_ECLISPE_EMF}"
implementation "org.eclipse.emf:org.eclipse.emf.common:${VER_ECLISPE_EMF}"
implementation "org.eclipse.emf:org.eclipse.emf.ecore:${VER_ECLISPE_EMF}"
// Some WPT plugins requires OSGI bundle interfaces (but not effectively used)
compile "org.eclipse.platform:org.eclipse.osgi.services:${VER_ECLIPSE_OSGI_SERVICES}"
implementation "org.eclipse.platform:org.eclipse.osgi.services:${VER_ECLIPSE_OSGI_SERVICES}"
// Provides document data structure and file buffers for formatters
compile "org.eclipse.platform:org.eclipse.core.filebuffers:${VER_ECLIPSE_FILE_BUFFERS}"
implementation "org.eclipse.platform:org.eclipse.core.filebuffers:${VER_ECLIPSE_FILE_BUFFERS}"
// Provides text partitioners for formatters
compile ("org.eclipse.platform:org.eclipse.jface.text:${VER_ECLISPE_JFACE}") {
implementation ("org.eclipse.platform:org.eclipse.jface.text:${VER_ECLISPE_JFACE}") {
exclude group: 'org.eclipse.platform', module: 'org.eclipse.swt'
}
// Some WPT plugins use the EFS for storing temporary worspace data
compile "org.eclipse.platform:org.eclipse.core.filesystem:${VER_ECLISPE_EFS}"
implementation "org.eclipse.platform:org.eclipse.core.filesystem:${VER_ECLISPE_EFS}"
// Required by org.eclipse.wst.xsd.core
compile "org.eclipse.xsd:org.eclipse.xsd:${VER_ECLISPE_XSD}"
implementation "org.eclipse.xsd:org.eclipse.xsd:${VER_ECLISPE_XSD}"

testImplementation("org.slf4j:slf4j-simple:${VER_SLF4J}")
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,19 +36,34 @@
import com.diffplug.spotless.extra.eclipse.base.service.NoContentTypeSpecificHandling;

/**
* For some embedded formatters, the WTP uses the content type ID for
* preferences lookup.
* WTP ModelHandlerRegistry uses the content type mamanger clean-up formatters
* to provide association of content to content type related functionality.
* <p>
* The preference lookup is accomplished via the Eclipse preference service,
* which must be provided in combination with this service.
* For cleanup tasks, the ID mapping is also used by the model handler
* to determine the model which a string stream requires.
* Preference lookup per content type is accomplished via the
* Eclipse PreferencesService, which must be provided in combination with
* this service.
* </p>
* The input byte steam encoding detection is accomplished by the
* content type manager. Normally the encoding is bount do a document/file.
* Spotless applies the formatting on strings already decoded.
* The WTP AbstractStructuredCleanupProcessor provides for non-documents
* a clean-up function converting the decoded string into an UTF-8 encoded byte stream.
* WTP AbstractDocumentLoader uses content type mamanger to determine the encoding
* of the input stream.
* Only the steps are affected that are using the
* AbstractStructuredCleanupProcessor. All other steps creating an empty document
* (e.g. via WTP AbstractDocumentLoader) and setting the textual content of the new document.
*
* @see org.eclipse.core.internal.preferences.PreferencesService
* @see org.eclipse.wst.sse.core.internal.cleanup.AbstractStructuredCleanupProcessor
* @see org.eclipse.wst.sse.core.internal.document.AbstractDocumentLoader
* @see org.eclipse.wst.sse.core.internal.modelhandler.ModelHandlerRegistry
*/
class ContentTypeManager extends NoContentTypeSpecificHandling {
private final Map<String, IContentType> id2Object;
private final IContentType processorStepType;
private final IContentDescription processorStepDescription;

/**
* Content type manager as required for cleanup steps.
Expand All @@ -66,6 +81,7 @@ class ContentTypeManager extends NoContentTypeSpecificHandling {
if (null == processorStepType) {
throw new IllegalArgumentException("The manager does not support content type " + formatterContentTypeID);
}
processorStepDescription = new StringDescription(processorStepType);
}

@Override
Expand All @@ -83,8 +99,48 @@ public IContentType findContentTypeFor(InputStream contents, String fileName) th
return processorStepType;
}

@Override
public IContentDescription getDescriptionFor(InputStream contents, String fileName, QualifiedName[] options) throws IOException {
return processorStepDescription;
}

private static class StringDescription implements IContentDescription {

private final IContentType type;

public StringDescription(IContentType type) {
this.type = type;
}

@Override
public boolean isRequested(QualifiedName key) {
return false; //Don't use set Property
}

@Override
public String getCharset() {
//Called by AbstractDocumentLoader.readInputStream
return "UTF-8"; //UTF-8 encoded by AbstractStructuredCleanupProcessor.cleanupContent
}

@Override
public IContentType getContentType() {
return type;
}

@Override
public Object getProperty(QualifiedName key) {
return null; //Assume that the property map is empty
}

@Override
public void setProperty(QualifiedName key, Object value) {
throw new IllegalArgumentException("Content description key cannot be set: " + key);
}
}

/**
* The WTP uses the manager only for ID mapping, so most of the methods are not used.
* The WTP uses the manager mainly for ID mapping, so most of the methods are not used.
* Actually it has a hand stitched way for transforming the content type ID
* {@code org.eclipse.wst...source} to the plugin ID {@code org.eclipse.wst...core}.
* @see org.eclipse.wst.sse.core.internal.encoding.ContentBasedPreferenceGateway
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,26 @@ public void formatCSS() throws Exception {
testData.expected("css.html"), output);
}

@Test
public void checkCleanupForNonUtf8() throws Exception {
String osEncoding = System.getProperty("file.encoding");
System.setProperty("file.encoding", "ISO-8859-1"); //Simulate a non UTF-8 OS
String[] input = testData.input("utf-8.html");
String output = formatter.format(input[0]);
System.setProperty("file.encoding", osEncoding);
assertEquals("Unexpected formatting of UTF-8", testData.expected("utf-8.html"), output);
}

@Test
public void checkBOMisStripped() throws Exception {
String[] input = testData.input("bom.html");
String[] inputWithoutBom = testData.input("utf-8.html");
//The UTF-8 BOM is interpreted as on UTF-16 character.
assertEquals("BOM input invalid", input[0].length() - 1, inputWithoutBom[0].length());
String output = formatter.format(input[0]);
assertEquals("BOM is not stripped", testData.expected("utf-8.html"), output);
}

@Test(expected = IllegalArgumentException.class)
public void configurationChange() throws Exception {
new EclipseHtmlFormatterStepImpl(new Properties());
Expand Down
7 changes: 7 additions & 0 deletions _ext/eclipse-wtp/src/test/resources/html/expected/utf-8.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<!DOCTYPE html>
<HTML>
<HEAD>
<META charset="UTF-8">
<TITLE>ÄÜ€</TITLE>
</HEAD>
</HTML>
2 changes: 2 additions & 0 deletions _ext/eclipse-wtp/src/test/resources/html/input/bom.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<!DOCTYPE html>
<html><head><meta charset="UTF-8"><title>ÄÜ€</title></head></html>
2 changes: 2 additions & 0 deletions _ext/eclipse-wtp/src/test/resources/html/input/utf-8.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<!DOCTYPE html>
<html><head><meta charset="UTF-8"><title>ÄÜ€</title></head></html>
2 changes: 1 addition & 1 deletion _ext/gradle/p2-fat-jar-setup.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ dependencies {
embeddedJars "p2:${groupArtifact}:${version}"
}
// Includes the classes from P2 JARs during compilation
compile files(embeddedClassesDir)
implementation files(embeddedClassesDir)
}

jar {
Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ plugins {
// https://github.com/diffplug/goomph/blob/master/CHANGES.md
id 'com.diffplug.eclipse.resourcefilters' version '3.21.0'
// https://plugins.gradle.org/plugin/com.gradle.plugin-publish
id 'com.gradle.plugin-publish' version '0.10.1' apply false
id 'com.gradle.plugin-publish' version '0.11.0' apply false
// https://github.com/bintray/gradle-bintray-plugin/releases
id 'com.jfrog.bintray' version '1.8.4' apply false
// https://github.com/mnlipp/jdrupes-mdoclet/releases
Expand Down
9 changes: 5 additions & 4 deletions gradle/java-publish.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ def makeLink = { url, text -> "<a href=\"${url}\" style=\"text-transform: none;\
def javadocInfo = '<h2>' + makeLink("https://github.com/${org}/${name}", "${group}:${project.ext.artifactId}:${version}") +
' by ' + makeLink('https://www.diffplug.com', 'DiffPlug') + '</h2>'

String dotdotGradle = project.name.startsWith('eclipse-') ? '../../gradle' : '../gradle'
apply plugin: 'org.jdrupes.mdoclet'
javadoc {
// Where it's possible to name parameters and methods clearly enough
Expand All @@ -33,12 +34,12 @@ javadoc {
options.header javadocInfo
options.footer javadocInfo
// setup links
options.linksOffline('https://docs.oracle.com/javase/8/docs/api/', '../gradle/javadoc/java8')
options.linksOffline('https://docs.gradle.org/2.14/javadoc/', '../gradle/javadoc/gradle')
options.linksOffline('https://docs.oracle.com/javase/8/docs/api/', "${dotdotGradle}/javadoc/java8")
options.linksOffline('https://docs.gradle.org/2.14/javadoc/', "${dotdotGradle}/javadoc/gradle")

// links to javadoc from the other versions
options.linksOffline("https://javadoc.io/static/com.diffplug.spotless/spotless-lib/${rootProject.spotlessChangelog.versionLast}", "../gradle/javadoc/spotless-lib")
options.linksOffline("https://javadoc.io/static/com.diffplug.spotless/spotless-lib-extra/${rootProject.spotlessChangelog.versionLast}", "../gradle/javadoc/spotless-lib-extra")
options.linksOffline("https://javadoc.io/static/com.diffplug.spotless/spotless-lib/${rootProject.spotlessChangelog.versionLast}", "${dotdotGradle}/javadoc/spotless-lib")
options.linksOffline("https://javadoc.io/static/com.diffplug.spotless/spotless-lib-extra/${rootProject.spotlessChangelog.versionLast}", "${dotdotGradle}/javadoc/spotless-lib-extra")
}

task javadocJar(type: Jar, dependsOn: javadoc) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Spotless formatter based on Eclipse-WTP version 3.15 (see https://www.eclipse.org/webtools/)
com.diffplug.spotless:spotless-eclipse-wtp:3.15.2
com.diffplug.spotless:spotless-eclipse-wtp:3.15.3
com.diffplug.spotless:spotless-eclipse-base:3.3.0
com.google.code.findbugs:annotations:3.0.0
com.google.code.findbugs:jsr305:3.0.0
Expand Down
2 changes: 2 additions & 0 deletions plugin-gradle/CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
We adhere to the [keepachangelog](https://keepachangelog.com/en/1.0.0/) format (starting after version `3.27.0`).

## [Unreleased]
### Fixed
* Eclipse-WTP formatter (web tools platform, not java) handles some character encodings incorrectly on OS with non-unicode default file encoding [#545](https://github.com/diffplug/spotless/issues/545). Fixed for Eclipse-WTP formatter Eclipse version 4.13.0 (default version).

## [3.28.0] - 2020-03-20
### Added
Expand Down
2 changes: 2 additions & 0 deletions plugin-maven/CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ We adhere to the [keepachangelog](https://keepachangelog.com/en/1.0.0/) format (
## [Unreleased]
### Added
* Tsfmt Maven Plugin ([#548](https://github.com/diffplug/spotless/pull/548))
### Fixed
* Eclipse-WTP formatter (web tools platform, not java) handles some character encodings incorrectly on OS with non-unicode default file encoding [#545](https://github.com/diffplug/spotless/issues/545). Fixed for Eclipse-WTP formatter Eclipse version 4.13.0 (default version).

## [1.28.0] - 2020-03-20
### Added
Expand Down

0 comments on commit 528e708

Please sign in to comment.