From dbab21ad9dcf43e82da59d6d8943cbd4e8791abc Mon Sep 17 00:00:00 2001 From: Peter Kriens Date: Mon, 22 Jan 2024 14:32:21 +0100 Subject: [PATCH 1/5] Bug in GogoRefactorer, scrunch --- Signed-off-by: Peter Kriens Signed-off-by: Peter Kriens --- .../src/org/bndtools/facade/package-info.java | 2 +- .../refactor/types/GogoRefactorer.java | 36 +++++++++---------- .../refactor/types/GogoRefactorerTest.java | 8 +++++ .../refactor/types/TestRefactors.java | 31 ++++++++++++++++ .../bndtools/refactor/types/package-info.java | 6 ++++ 5 files changed, 64 insertions(+), 19 deletions(-) create mode 100644 bndtools.core/test/org/bndtools/refactor/types/TestRefactors.java create mode 100644 bndtools.core/test/org/bndtools/refactor/types/package-info.java diff --git a/bndtools.core/src/org/bndtools/facade/package-info.java b/bndtools.core/src/org/bndtools/facade/package-info.java index baeb6b5127..61afa9a236 100644 --- a/bndtools.core/src/org/bndtools/facade/package-info.java +++ b/bndtools.core/src/org/bndtools/facade/package-info.java @@ -1,3 +1,3 @@ @org.osgi.annotation.bundle.Export -@org.osgi.annotation.versioning.Version("1.0.0") +@org.osgi.annotation.versioning.Version("1.1.0") package org.bndtools.facade; diff --git a/bndtools.core/src/org/bndtools/refactor/types/GogoRefactorer.java b/bndtools.core/src/org/bndtools/refactor/types/GogoRefactorer.java index 5da4d66283..3c3724b410 100644 --- a/bndtools.core/src/org/bndtools/refactor/types/GogoRefactorer.java +++ b/bndtools.core/src/org/bndtools/refactor/types/GogoRefactorer.java @@ -188,24 +188,6 @@ public void addGogo() { }); } - private String scrunch(String string) { - String s = string.toLowerCase(); - if (s.length() < 8) - return s; - - StringBuilder result = new StringBuilder(s); - for (int i = result.length() - 1; i >= 0 && result.length() > 8; i--) { - char c = result.charAt(i); - if (!Character.isAlphabetic(c) || "aeiou".indexOf(c) >= 0) { - result.delete(i, 1); - } - } - if (result.length() > 8) { - result.delete(8, result.length()); - } - return result.toString(); - } - String[] calculateNames(String name) { if (name.length() < 1) return new String[0]; @@ -373,4 +355,22 @@ void doCommand(ProposalBuilder builder, Cursor methodDeclarat () -> state.add(new Command(methodDeclaration))); } + static public String scrunch(String string) { + String s = string.toLowerCase(); + if (s.length() < 8) + return s; + + StringBuilder result = new StringBuilder(s); + for (int i = result.length() - 1; i >= 0 && result.length() > 8; i--) { + char c = result.charAt(i); + if (!Character.isAlphabetic(c) || "aeiou".indexOf(c) >= 0) { + result.delete(i, i + 1); + } + } + if (result.length() > 8) { + result.delete(8, result.length()); + } + return result.toString(); + } + } diff --git a/bndtools.core/test/org/bndtools/refactor/types/GogoRefactorerTest.java b/bndtools.core/test/org/bndtools/refactor/types/GogoRefactorerTest.java index 4cc1138e1e..5381f43d42 100644 --- a/bndtools.core/test/org/bndtools/refactor/types/GogoRefactorerTest.java +++ b/bndtools.core/test/org/bndtools/refactor/types/GogoRefactorerTest.java @@ -10,6 +10,7 @@ import org.bndtools.refactor.util.RefactorAssistant; import org.eclipse.jface.text.Document; import org.eclipse.jface.text.IDocument; +import org.junit.jupiter.api.Test; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.MethodSource; @@ -164,4 +165,11 @@ static List scenarios() { //@formatter:on ); } + + @Test + public void testScrunch() { + assertThat(GogoRefactorer.scrunch("TestRefactors")).isEqualTo("tstrfctr"); + assertThat(GogoRefactorer.scrunch("foobarffoo")).isEqualTo("foobarff"); + + } } diff --git a/bndtools.core/test/org/bndtools/refactor/types/TestRefactors.java b/bndtools.core/test/org/bndtools/refactor/types/TestRefactors.java new file mode 100644 index 0000000000..0a8b13698c --- /dev/null +++ b/bndtools.core/test/org/bndtools/refactor/types/TestRefactors.java @@ -0,0 +1,31 @@ +package org.bndtools.refactor.types; + +import java.util.Date; + +import org.osgi.framework.BundleContext; +import org.osgi.service.component.annotations.Activate; +import org.osgi.service.component.annotations.Component; +import org.osgi.service.component.annotations.Deactivate; +import org.osgi.service.component.annotations.Reference; + +@Component +public class TestRefactors { + + interface Bar {} + + @Activate + public TestRefactors(BundleContext context, @Reference + Bar serice) {} + + @Reference + void setBar(Bar bar) {} + + void unsetBar(Bar bar) {} + + Date getDate() { + return new Date(); + } + + @Deactivate + void close() {} +} diff --git a/bndtools.core/test/org/bndtools/refactor/types/package-info.java b/bndtools.core/test/org/bndtools/refactor/types/package-info.java new file mode 100644 index 0000000000..454c7f69d2 --- /dev/null +++ b/bndtools.core/test/org/bndtools/refactor/types/package-info.java @@ -0,0 +1,6 @@ +@Version("1.0.0") +@Export +package org.bndtools.refactor.types; + +import org.osgi.annotation.versioning.Version; +import org.osgi.annotation.bundle.Export; From 196a3c9f871d1b2b33bfd7b99182eb0172e5c743 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 22 Jan 2024 22:04:30 +0000 Subject: [PATCH 2/5] build(deps): Bump ruby/setup-ruby from 1.168.0 to 1.169.0 Bumps [ruby/setup-ruby](https://github.com/ruby/setup-ruby) from 1.168.0 to 1.169.0. - [Release notes](https://github.com/ruby/setup-ruby/releases) - [Commits](https://github.com/ruby/setup-ruby/compare/432702e864cadc1b56247e31aa341be5be3e129a...5daca165445f0ae10478593083f72ca2625e241d) --- updated-dependencies: - dependency-name: ruby/setup-ruby dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- .github/workflows/docs.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index b4baf5c8bc..f81de55e10 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -38,7 +38,7 @@ jobs: - name: Git Checkout uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 - name: Set up Ruby - uses: ruby/setup-ruby@432702e864cadc1b56247e31aa341be5be3e129a + uses: ruby/setup-ruby@5daca165445f0ae10478593083f72ca2625e241d with: ruby-version: 2.7 bundler-cache: true From cac01f0eb397c3ef8d4e578901040c540a109245 Mon Sep 17 00:00:00 2001 From: Peter Kriens Date: Tue, 23 Jan 2024 18:07:32 +0100 Subject: [PATCH 3/5] NPE on File System Compare --- Signed-off-by: Peter Kriens Signed-off-by: Peter Kriens --- .../src/bndtools/jareditor/internal/JarFileSystem.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/bndtools.jareditor/src/bndtools/jareditor/internal/JarFileSystem.java b/bndtools.jareditor/src/bndtools/jareditor/internal/JarFileSystem.java index f38144e8eb..0bed075df6 100644 --- a/bndtools.jareditor/src/bndtools/jareditor/internal/JarFileSystem.java +++ b/bndtools.jareditor/src/bndtools/jareditor/internal/JarFileSystem.java @@ -27,6 +27,7 @@ import org.eclipse.core.filesystem.provider.FileStore; import org.eclipse.core.filesystem.provider.FileSystem; import org.eclipse.core.internal.filesystem.NullFileStore; +import org.eclipse.core.internal.filesystem.NullFileSystem; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.IProgressMonitor; @@ -54,7 +55,8 @@ */ public class JarFileSystem extends FileSystem { private static final ILogger logger = Logger.getLogger(JarFileSystem.class); - + @SuppressWarnings("unused") + private static final NullFileSystem INIT = new NullFileSystem(); private static final String SCHEME_JARF = "jarf"; private final ConcurrentMap> roots = new ConcurrentHashMap<>(); @@ -98,6 +100,7 @@ public String[] childNames(int options, IProgressMonitor monitor) throws CoreExc @Override public IFileStore getChild(String name) { + new NullFileSystem(); return new NullFileStore(new Path(getPath()).append(name)); } From 98e3200b69f748040537ce4a1352f324d232b304 Mon Sep 17 00:00:00 2001 From: Peter Kriens Date: Wed, 24 Jan 2024 08:57:16 +0100 Subject: [PATCH 4/5] Dependency bot does not get the action/upload version bumped --- Signed-off-by: Peter Kriens Signed-off-by: Peter Kriens --- .github/workflows/cibuild.yml | 2 +- .github/workflows/rebuild.yml | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/cibuild.yml b/.github/workflows/cibuild.yml index 045e4d0b83..716602127c 100644 --- a/.github/workflows/cibuild.yml +++ b/.github/workflows/cibuild.yml @@ -102,7 +102,7 @@ jobs: JFROG_PASSWORD: ${{ secrets.JFROG_PASSWORD }} - name: Upload Test Reports if: ${{ always() && ((steps.build.outcome == 'success') || (steps.build.outcome == 'failure')) }} - uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 + uses: actions/upload-artifact@v4 with: name: Build_JDK${{ matrix.java }}_${{ matrix.os }}-test-reports path: | diff --git a/.github/workflows/rebuild.yml b/.github/workflows/rebuild.yml index 71431b8805..b3118654b9 100644 --- a/.github/workflows/rebuild.yml +++ b/.github/workflows/rebuild.yml @@ -72,7 +72,7 @@ jobs: run: | ./.github/scripts/rebuild-build.sh - name: Upload dist/bundles - uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 + uses: actions/upload-artifact@v4 with: name: Dist_Bundles_JDK${{ matrix.java }}_${{ matrix.os }} if-no-files-found: error @@ -110,7 +110,7 @@ jobs: - name: Set up Gradle uses: gradle/gradle-build-action@982da8e78c05368c70dac0351bb82647a9e9a5d2 - name: Download dist/bundles - uses: actions/download-artifact@9bc31d5ccc31df68ecc42ccf4149144866c47d8a + uses: actions/download-artifact@v4 with: name: ${{ needs.build.outputs.dist-bundles }} path: dist/bundles @@ -120,7 +120,7 @@ jobs: ${{ format(matrix.runner, './.github/scripts/rebuild-test.sh') }} - name: Upload Test Reports if: ${{ always() && ((steps.build.outcome == 'success') || (steps.build.outcome == 'failure')) }} - uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 + uses: actions/upload-artifact@v4 with: name: Rebuild_JDK${{ matrix.java }}_${{ matrix.os }}-test-reports path: | From 25d3f0f055009147f39a615538bd4fafed7ab757 Mon Sep 17 00:00:00 2001 From: Peter Kriens Date: Wed, 24 Jan 2024 16:42:38 +0100 Subject: [PATCH 5/5] Use EFS.getNullFileSystem() instead of new NullFileSystem() --- Signed-off-by: Peter Kriens Signed-off-by: Peter Kriens --- .../jareditor/internal/JarFileSystem.java | 21 ++++++++++--------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/bndtools.jareditor/src/bndtools/jareditor/internal/JarFileSystem.java b/bndtools.jareditor/src/bndtools/jareditor/internal/JarFileSystem.java index 0bed075df6..11abe69d0d 100644 --- a/bndtools.jareditor/src/bndtools/jareditor/internal/JarFileSystem.java +++ b/bndtools.jareditor/src/bndtools/jareditor/internal/JarFileSystem.java @@ -26,8 +26,6 @@ import org.eclipse.core.filesystem.provider.FileInfo; import org.eclipse.core.filesystem.provider.FileStore; import org.eclipse.core.filesystem.provider.FileSystem; -import org.eclipse.core.internal.filesystem.NullFileStore; -import org.eclipse.core.internal.filesystem.NullFileSystem; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.IProgressMonitor; @@ -51,12 +49,10 @@ * jarfileuri ::= * * - * @author aqute */ public class JarFileSystem extends FileSystem { private static final ILogger logger = Logger.getLogger(JarFileSystem.class); @SuppressWarnings("unused") - private static final NullFileSystem INIT = new NullFileSystem(); private static final String SCHEME_JARF = "jarf"; private final ConcurrentMap> roots = new ConcurrentHashMap<>(); @@ -100,10 +96,10 @@ public String[] childNames(int options, IProgressMonitor monitor) throws CoreExc @Override public IFileStore getChild(String name) { - new NullFileSystem(); - return new NullFileStore(new Path(getPath()).append(name)); + return nullFileStore(new Path(getPath()).append(name)); } + @Override public InputStream openInputStream(int options, IProgressMonitor monitor) throws CoreException { return new ByteArrayInputStream(new byte[0]); @@ -215,7 +211,7 @@ public InputStream openInputStream(int options, IProgressMonitor monitor) throws public IFileStore getStore(URI uri) { if (!SCHEME_JARF.equals(uri.getScheme())) { logger.logError("No file system for : " + uri, null); - return new NullFileStore(Path.EMPTY); + return nullFileStore(new Path(uri.getPath())); } return jarf(uri).map(pair -> { URI fileuri = pair.getFirst(); @@ -224,14 +220,14 @@ public IFileStore getStore(URI uri) { store = EFS.getStore(fileuri); } catch (CoreException e) { logger.logError("Cannot locate filestore for the JAR file: " + fileuri, e); - return new NullFileStore(Path.EMPTY); + return nullFileStore(Path.EMPTY); } JarRootNode root = roots.compute(store, this::computeRootNode) .get(); if (root == null) { logger.logError("Failed to load jar for: " + fileuri, null); - return new NullFileStore(Path.EMPTY); + return nullFileStore(Path.EMPTY); } IPath path = pair.getSecond(); @@ -243,7 +239,7 @@ public IFileStore getStore(URI uri) { }) .recover(err -> { logger.logError(err, null); - return new NullFileStore(Path.EMPTY); + return nullFileStore(Path.EMPTY); }) .unwrap(); } @@ -333,4 +329,9 @@ static Result openInputStream(URI uri, String path, IProgressMonito return Result.err("Failed to open resource %s from %s : %s", path, uri, e); } } + + static IFileStore nullFileStore(IPath path) { + return EFS.getNullFileSystem() + .getStore(path); + } }