From 591b8d42541d29f4d8ee97002905bc9cd96ac9a8 Mon Sep 17 00:00:00 2001 From: Christian Schima Date: Sun, 3 Nov 2024 22:45:15 +0100 Subject: [PATCH 1/2] Bugfix for #2453: NPE in BarContentAssistProcessor. --- .../contributions/BarContentAssistProcessor.java | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/tests/org.eclipse.ui.genericeditor.tests/src/org/eclipse/ui/genericeditor/tests/contributions/BarContentAssistProcessor.java b/tests/org.eclipse.ui.genericeditor.tests/src/org/eclipse/ui/genericeditor/tests/contributions/BarContentAssistProcessor.java index 58975100dc5..eceb8673361 100644 --- a/tests/org.eclipse.ui.genericeditor.tests/src/org/eclipse/ui/genericeditor/tests/contributions/BarContentAssistProcessor.java +++ b/tests/org.eclipse.ui.genericeditor.tests/src/org/eclipse/ui/genericeditor/tests/contributions/BarContentAssistProcessor.java @@ -42,11 +42,15 @@ public BarContentAssistProcessor(String completeString) { @Override public ICompletionProposal[] computeCompletionProposals(ITextViewer viewer, int offset) { - for (int offsetInProposal = Math.min(this.completeString.length(), viewer.getDocument().getLength()); offsetInProposal > 0; offsetInProposal--) { + final IDocument doc= viewer.getDocument(); + if (doc == null) { + return new ICompletionProposal[0]; + } + for (int offsetInProposal = Math.min(this.completeString.length(), doc.getLength()); offsetInProposal > 0; offsetInProposal--) { String maybeMatchingString = this.completeString.substring(0, offsetInProposal); try { int lastIndex = offset - offsetInProposal + this.completeString.length(); - if (offset >= offsetInProposal && viewer.getDocument().get(offset - offsetInProposal, maybeMatchingString.length()).equals(maybeMatchingString)) { + if (offset >= offsetInProposal && doc.get(offset - offsetInProposal, maybeMatchingString.length()).equals(maybeMatchingString)) { CompletionProposal proposal = new CompletionProposal(this.completeString.substring(offsetInProposal), offset, 0, lastIndex); return new ICompletionProposal[] { proposal }; } @@ -98,13 +102,13 @@ public IContextInformationValidator getContextInformationValidator() { return new IContextInformationValidator() { private ITextViewer viewer; private int offset; - + @Override public void install(IContextInformation info, ITextViewer infoViewer, int documentOffset) { this.viewer= infoViewer; this.offset= documentOffset; } - + @Override public boolean isContextInformationValid(int offsetToTest) { try { @@ -123,5 +127,4 @@ public boolean isContextInformationValid(int offsetToTest) { public String getErrorMessage() { return null; } - } From 113a6456eac86dd2bd2ced8ec0a24fc23b9533ea Mon Sep 17 00:00:00 2001 From: Eclipse Platform Bot Date: Sun, 3 Nov 2024 21:58:54 +0000 Subject: [PATCH 2/2] Version bump(s) for 4.34 stream --- tests/org.eclipse.ui.genericeditor.tests/META-INF/MANIFEST.MF | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/org.eclipse.ui.genericeditor.tests/META-INF/MANIFEST.MF b/tests/org.eclipse.ui.genericeditor.tests/META-INF/MANIFEST.MF index f95c0ce33f8..a3dd34a3a53 100644 --- a/tests/org.eclipse.ui.genericeditor.tests/META-INF/MANIFEST.MF +++ b/tests/org.eclipse.ui.genericeditor.tests/META-INF/MANIFEST.MF @@ -2,7 +2,7 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: %Plugin.name Bundle-SymbolicName: org.eclipse.ui.genericeditor.tests;singleton:=true -Bundle-Version: 1.3.500.qualifier +Bundle-Version: 1.3.600.qualifier Bundle-Vendor: %Plugin.providerName Bundle-Localization: plugin Export-Package: org.eclipse.ui.genericeditor.tests,