From 9a5d486356362f452d72e1450283a31f7f3cf49b Mon Sep 17 00:00:00 2001 From: CentOS Sources Date: May 31 2016 08:11:12 +0000 Subject: import devtoolset-4-eclipse-4.5.2-5.4.el7 --- diff --git a/.devtoolset-4-eclipse.metadata b/.devtoolset-4-eclipse.metadata index 1ecd76c..ca5f390 100644 --- a/.devtoolset-4-eclipse.metadata +++ b/.devtoolset-4-eclipse.metadata @@ -1,2 +1,2 @@ -7726c8ddfd10217c8a4ec0eea6ff7ae318f06927 SOURCES/R4_platform-aggregator-R4_5.tar.xz -ba938b1f051b35b6c563d1dbf880eb6bec3d7a9b SOURCES/org.eclipse.linuxtools.eclipse-build-27693f414e65ae520724dca2fa5c682fa3256d29.tar.xz +a2c2cc8c3b739770b608c663d4b600475e168b9b SOURCES/R4_platform-aggregator-S4_5_2_RC4.tar.xz +5d5b5c701184fcf169b0f5d124968688b1e9e769 SOURCES/org.eclipse.linuxtools.eclipse-build-d40359cd541c521122c962a23be90d8490deea83.tar.xz diff --git a/.gitignore b/.gitignore index 0ea9d12..d488ae8 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,2 @@ -SOURCES/R4_platform-aggregator-R4_5.tar.xz -SOURCES/org.eclipse.linuxtools.eclipse-build-27693f414e65ae520724dca2fa5c682fa3256d29.tar.xz +SOURCES/R4_platform-aggregator-S4_5_2_RC4.tar.xz +SOURCES/org.eclipse.linuxtools.eclipse-build-d40359cd541c521122c962a23be90d8490deea83.tar.xz diff --git a/SOURCES/eclipse-adjust-droplets.patch b/SOURCES/eclipse-adjust-droplets.patch new file mode 100644 index 0000000..e22e4a5 --- /dev/null +++ b/SOURCES/eclipse-adjust-droplets.patch @@ -0,0 +1,26 @@ +diff --git rt.equinox.p2/bundles/org.eclipse.equinox.simpleconfigurator/src/org/eclipse/equinox/internal/simpleconfigurator/utils/SimpleConfiguratorUtils.java rt.equinox.p2/bundles/org.eclipse.equinox.simpleconfigurator/src/org/eclipse/equinox/internal/simpleconfigurator/utils/SimpleConfiguratorUtils.java +index 12e4d89..77945ef 100644 +--- rt.equinox.p2/bundles/org.eclipse.equinox.simpleconfigurator/src/org/eclipse/equinox/internal/simpleconfigurator/utils/SimpleConfiguratorUtils.java ++++ rt.equinox.p2/bundles/org.eclipse.equinox.simpleconfigurator/src/org/eclipse/equinox/internal/simpleconfigurator/utils/SimpleConfiguratorUtils.java +@@ -156,7 +156,20 @@ public class SimpleConfiguratorUtils { + } + continue; + } +- File[] listFiles = extension.listFiles(); ++ ++ // Support the additional 'eclipse' directory if it exists. ++ File[] extensionFiles = extension.listFiles(new FilenameFilter() { ++ public boolean accept(File dir, String name) { ++ return name.equals("eclipse"); ++ } ++ }); ++ ++ File[] listFiles; ++ if (extensionFiles.length == 1) { ++ listFiles = extensionFiles[0].listFiles(); ++ } else { ++ listFiles = extension.listFiles(); ++ } + // new magic - multiple info files, f.e. + // egit.info (git feature) + // cdt.link (properties file containing link=path) to other info file diff --git a/SOURCES/eclipse-bug-466314.patch b/SOURCES/eclipse-bug-466314.patch new file mode 100644 index 0000000..29faa6d --- /dev/null +++ b/SOURCES/eclipse-bug-466314.patch @@ -0,0 +1,165 @@ +From eec69d54257dd905a06e43fb705f40df9326414e Mon Sep 17 00:00:00 2001 +From: Alexander Kurtakov +Date: Fri, 20 Nov 2015 13:24:54 +0200 +Subject: Bug 466314 - [GTK3] Text in Forms abbreviated + +Switching from gtk_text_view_scroll_mark_onscreen to +gtk_text_view_scroll_to_mark gives us total control over the alignment +allowing us to alway position to the 0 0. + +Change-Id: I4fc141980e96c81cf65ef076a0224f0e4eee47ba +Signed-off-by: Alexander Kurtakov +--- + .../org.eclipse.swt/Eclipse SWT PI/gtk/library/os.c | 20 ++++++++++---------- + .../Eclipse SWT PI/gtk/library/os_stats.c | 2 +- + .../Eclipse SWT PI/gtk/library/os_stats.h | 2 +- + .../gtk/org/eclipse/swt/internal/gtk/OS.java | 10 +++++++--- + .../gtk/org/eclipse/swt/widgets/Text.java | 12 ++++++------ + 5 files changed, 25 insertions(+), 21 deletions(-) + +diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os.c b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os.c +index 7e937f0..c0dff7f 100644 +--- a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os.c ++++ b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os.c +@@ -16167,16 +16167,6 @@ JNIEXPORT jintLong JNICALL OS_NATIVE(_1gtk_1text_1view_1new) + } + #endif + +-#ifndef NO__1gtk_1text_1view_1scroll_1mark_1onscreen +-JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1text_1view_1scroll_1mark_1onscreen) +- (JNIEnv *env, jclass that, jintLong arg0, jintLong arg1) +-{ +- OS_NATIVE_ENTER(env, that, _1gtk_1text_1view_1scroll_1mark_1onscreen_FUNC); +- gtk_text_view_scroll_mark_onscreen((GtkTextView *)arg0, (GtkTextMark *)arg1); +- OS_NATIVE_EXIT(env, that, _1gtk_1text_1view_1scroll_1mark_1onscreen_FUNC); +-} +-#endif +- + #ifndef NO__1gtk_1text_1view_1scroll_1to_1iter + JNIEXPORT jboolean JNICALL OS_NATIVE(_1gtk_1text_1view_1scroll_1to_1iter) + (JNIEnv *env, jclass that, jintLong arg0, jbyteArray arg1, jdouble arg2, jboolean arg3, jdouble arg4, jdouble arg5) +@@ -16193,6 +16183,16 @@ fail: + } + #endif + ++#ifndef NO__1gtk_1text_1view_1scroll_1to_1mark ++JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1text_1view_1scroll_1to_1mark) ++ (JNIEnv *env, jclass that, jintLong arg0, jintLong arg1, jdouble arg2, jboolean arg3, jdouble arg4, jdouble arg5) ++{ ++ OS_NATIVE_ENTER(env, that, _1gtk_1text_1view_1scroll_1to_1mark_FUNC); ++ gtk_text_view_scroll_to_mark((GtkTextView *)arg0, (GtkTextMark *)arg1, (gdouble)arg2, (gboolean)arg3, (gdouble)arg4, (gdouble)arg5); ++ OS_NATIVE_EXIT(env, that, _1gtk_1text_1view_1scroll_1to_1mark_FUNC); ++} ++#endif ++ + #ifndef NO__1gtk_1text_1view_1set_1editable + JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1text_1view_1set_1editable) + (JNIEnv *env, jclass that, jintLong arg0, jboolean arg1) +diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_stats.c b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_stats.c +index 82775bd..bd9d7b5 100644 +--- a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_stats.c ++++ b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_stats.c +@@ -1183,8 +1183,8 @@ char * OS_nativeFunctionNames[] = { + "_1gtk_1text_1view_1get_1visible_1rect", + "_1gtk_1text_1view_1get_1window", + "_1gtk_1text_1view_1new", +- "_1gtk_1text_1view_1scroll_1mark_1onscreen", + "_1gtk_1text_1view_1scroll_1to_1iter", ++ "_1gtk_1text_1view_1scroll_1to_1mark", + "_1gtk_1text_1view_1set_1editable", + "_1gtk_1text_1view_1set_1justification", + "_1gtk_1text_1view_1set_1tabs", +diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_stats.h b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_stats.h +index a1d68ed..016b472 100644 +--- a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_stats.h ++++ b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_stats.h +@@ -1193,8 +1193,8 @@ typedef enum { + _1gtk_1text_1view_1get_1visible_1rect_FUNC, + _1gtk_1text_1view_1get_1window_FUNC, + _1gtk_1text_1view_1new_FUNC, +- _1gtk_1text_1view_1scroll_1mark_1onscreen_FUNC, + _1gtk_1text_1view_1scroll_1to_1iter_FUNC, ++ _1gtk_1text_1view_1scroll_1to_1mark_FUNC, + _1gtk_1text_1view_1set_1editable_FUNC, + _1gtk_1text_1view_1set_1justification_FUNC, + _1gtk_1text_1view_1set_1tabs_FUNC, +diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk/OS.java b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk/OS.java +index cf8cda6..0ee6dda 100644 +--- a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk/OS.java ++++ b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk/OS.java +@@ -12528,12 +12528,16 @@ public static final long /*int*/ gtk_text_view_new() { + /** + * @param text_view cast=(GtkTextView *) + * @param mark cast=(GtkTextMark *) ++ * @param within_margin cast=(gdouble) ++ * @param use_align cast=(gboolean) ++ * @param xalign cast=(gdouble) ++ * @param yalign cast=(gdouble) + */ +-public static final native void _gtk_text_view_scroll_mark_onscreen(long /*int*/ text_view, long /*int*/ mark); +-public static final void gtk_text_view_scroll_mark_onscreen(long /*int*/ text_view, long /*int*/ mark) { ++public static final native void _gtk_text_view_scroll_to_mark(long /*int*/ text_view, long /*int*/ mark, double within_margin, boolean use_align, double xalign, double yalign); ++public static final void gtk_text_view_scroll_to_mark(long /*int*/ text_view, long /*int*/ mark, double within_margin, boolean use_align, double xalign, double yalign) { + lock.lock(); + try { +- _gtk_text_view_scroll_mark_onscreen(text_view, mark); ++ _gtk_text_view_scroll_to_mark(text_view, mark, within_margin, use_align, xalign, yalign); + } finally { + lock.unlock(); + } +diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Text.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Text.java +index 9aa3a52..2865cd5 100644 +--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Text.java ++++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Text.java +@@ -414,7 +414,7 @@ public void append (String string) { + OS.gtk_text_buffer_insert (bufferHandle, position, buffer, buffer.length); + OS.gtk_text_buffer_place_cursor (bufferHandle, position); + long /*int*/ mark = OS.gtk_text_buffer_get_insert (bufferHandle); +- OS.gtk_text_view_scroll_mark_onscreen (handle, mark); ++ OS.gtk_text_view_scroll_to_mark (handle, mark, 0, true, 0, 0); + } + applySegments (); + } +@@ -1947,7 +1947,7 @@ public void insert (String string) { + OS.gtk_text_buffer_insert (bufferHandle, start, buffer, buffer.length); + OS.gtk_text_buffer_place_cursor (bufferHandle, start); + long /*int*/ mark = OS.gtk_text_buffer_get_insert (bufferHandle); +- OS.gtk_text_view_scroll_mark_onscreen (handle, mark); ++ OS.gtk_text_view_scroll_to_mark (handle, mark, 0, true, 0, 0); + } + applySegments (); + } +@@ -2340,7 +2340,7 @@ public void setSelection (int start) { + OS.gtk_text_buffer_get_iter_at_offset (bufferHandle, startIter, start); + OS.gtk_text_buffer_place_cursor (bufferHandle, startIter); + long /*int*/ mark = OS.gtk_text_buffer_get_insert (bufferHandle); +- OS.gtk_text_view_scroll_mark_onscreen (handle, mark); ++ OS.gtk_text_view_scroll_to_mark (handle, mark, 0, true, 0, 0); + } + } + +@@ -2563,7 +2563,7 @@ void setText (char [] text) { + OS.gtk_text_buffer_get_iter_at_offset (bufferHandle, position, 0); + OS.gtk_text_buffer_place_cursor (bufferHandle, position); + long /*int*/ mark = OS.gtk_text_buffer_get_insert (bufferHandle); +- OS.gtk_text_view_scroll_mark_onscreen (handle, mark); ++ OS.gtk_text_view_scroll_to_mark (handle, mark, 0, true, 0, 0); + Arrays.fill (buffer, (byte) 0); + } + sendEvent (SWT.Modify); +@@ -2644,9 +2644,9 @@ public void showSelection () { + checkWidget (); + if ((style & SWT.SINGLE) != 0) return; + long /*int*/ mark = OS.gtk_text_buffer_get_selection_bound (bufferHandle); +- OS.gtk_text_view_scroll_mark_onscreen (handle, mark); ++ OS.gtk_text_view_scroll_to_mark (handle, mark, 0, true, 0, 0); + mark = OS.gtk_text_buffer_get_insert (bufferHandle); +- OS.gtk_text_view_scroll_mark_onscreen (handle, mark); ++ OS.gtk_text_view_scroll_to_mark (handle, mark, 0, true, 0, 0); + } + + int translateOffset (int offset) { +-- +cgit v0.11.2-4-g4a35 + + diff --git a/SOURCES/eclipse-bug-466500.patch b/SOURCES/eclipse-bug-466500.patch new file mode 100644 index 0000000..eb126a7 --- /dev/null +++ b/SOURCES/eclipse-bug-466500.patch @@ -0,0 +1,47 @@ +From ddcfd1f3efd70591480e6c053946618ef6696104 Mon Sep 17 00:00:00 2001 +From: Eric Williams +Date: Wed, 14 Oct 2015 13:41:06 -0400 +Subject: Bug 466500: [GTK3] Trying to resize quick outline or quick type + hierarchy closes the popup + +In PopupDialog, Shells with no children are closed on deactivation. On +Linux-Gtk, this causes popups like the "Quick Outline" or "Quick +Type Hierarchy" to close prematurely when opening the system menu, +re-sizing, or moving the window with the mouse. + +It is for this reason that we need to exclude the call to asyncClose() +from running on Gtk. This also fixes bug 113577. + +Tested on Gtk3.16.6, and Gtk2.24. + +Change-Id: I4111ad961e2b4e57c90939e7cb0e982b7bf3b894 +Signed-off-by: Eric Williams --- + .../src/org/eclipse/jface/dialogs/PopupDialog.java | 13 ++++++++----- + 1 file changed, 8 insertions(+), 5 deletions(-) + +diff --git a/eclipse.platform.ui/bundles/org.eclipse.jface/src/org/eclipse/jface/dialogs/PopupDialog.java b/eclipse.platform.ui/bundles/org.eclipse.jface/src/org/eclipse/jface/dialogs/PopupDialog.java +index 2068cc4..0d361af 100644 +--- a/eclipse.platform.ui/bundles/org.eclipse.jface/src/org/eclipse/jface/dialogs/PopupDialog.java ++++ b/eclipse.platform.ui/bundles/org.eclipse.jface/src/org/eclipse/jface/dialogs/PopupDialog.java +@@ -588,13 +588,17 @@ + /* + * Close if we are deactivating and have no child shells. If we + * have child shells, we are deactivating due to their opening. +- * On X, we receive this when a menu child (such as the system +- * menu) of the shell opens, but I have not found a way to +- * distinguish that case here. Hence bug #113577 still exists. ++ * ++ * Feature in GTK: this causes the Quick Outline/Type Hierarchy ++ * Shell to close on re-size/movement on Gtk3. For this reason, ++ * the asyncClose() call is disabled in GTK. See Eclipse Bugs ++ * 466500 and 113577 for more information. + */ + if (listenToDeactivate && event.widget == getShell() + && getShell().getShells().length == 0) { +- asyncClose(); ++ if (!Util.isGtk()) { ++ asyncClose(); ++ } + } else { + /* + * We typically ignore deactivates to work around diff --git a/SOURCES/eclipse-bug-477487.patch b/SOURCES/eclipse-bug-477487.patch new file mode 100644 index 0000000..ea64851 --- /dev/null +++ b/SOURCES/eclipse-bug-477487.patch @@ -0,0 +1,145 @@ +diff --git a/eclipse.platform.ui/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/themes/RGBVisibleContrastColorFactory.java b/eclipse.platform.ui/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/themes/RGBVisibleContrastColorFactory.java +new file mode 100644 +index 0000000..67b33c7 +--- /dev/null ++++ b/eclipse.platform.ui/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/themes/RGBVisibleContrastColorFactory.java +@@ -0,0 +1,106 @@ ++/******************************************************************************* ++ * Copyright (c) 2004, 2011 IBM Corporation 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 ++ * ++ * Contributors: ++ * IBM Corporation - initial API and implementation ++ *******************************************************************************/ ++package org.eclipse.ui.internal.themes; ++ ++import java.util.Hashtable; ++import org.eclipse.core.runtime.CoreException; ++import org.eclipse.core.runtime.IConfigurationElement; ++import org.eclipse.core.runtime.IExecutableExtension; ++import org.eclipse.swt.graphics.RGB; ++import org.eclipse.ui.themes.ColorUtil; ++import org.eclipse.ui.themes.IColorFactory; ++ ++/** ++ * A IColorFactory that may be used to select a color with a higher ++ * contrast. The input colors are specified as per method number two in ++ * {@link org.eclipse.core.runtime.IExecutableExtension}. ++ *

++ * Example usage: ++ * ++ *

++ * <colorDefinition
++ *     label="Declaration view background"
++ *     id="org.eclipse.jdt.ui.DeclarationView.backgroundColor">
++ *     <colorFactory
++ *             plugin="org.eclipse.ui"
++ *             class="org.eclipse.ui.internal.themes.RGBContrastFactory">
++ *         <parameter name="foreground" value="0,0,0" />
++ *         <parameter name="background" value="COLOR_INFO_BACKGROUND" />
++ *         <parameter name="alternativeBackground" value="COLOR_LIST_BACKGROUND" />
++ *     </colorFactory>
++ * </colorDefinition>
++ * 
++ * ++ *

++ * Returns background if foreground is visibly distinct from ++ * background. Otherwise, returns alternativeBackground if ++ * that color has more difference in brightness to the foreground. If both ++ * colors are bad, returns background. The color values may be ++ * specified as RGB triples or as SWT constants. ++ * ++ * @see org.eclipse.swt.SWT ++ * @since 3.107.100 ++ */ ++// This class is used by org.eclipse.jdt.ui/plugin.xml to fix ++// https://bugs.eclipse.org/477487 ++public class RGBVisibleContrastColorFactory implements IColorFactory, IExecutableExtension { ++ private String fg, bg, altBg; ++ ++ @Override ++ public RGB createColor() { ++ RGB cfg, cbg, cbgAlt; ++ ++ if (fg != null) { ++ cfg = ColorUtil.getColorValue(fg); ++ } else { ++ cfg = new RGB(0, 0, 0); ++ } ++ if (bg != null) { ++ cbg = ColorUtil.getColorValue(bg); ++ } else { ++ cbg = new RGB(255, 255, 255); ++ } ++ if (altBg != null) { ++ cbgAlt = ColorUtil.getColorValue(altBg); ++ } else { ++ cbgAlt = new RGB(255, 255, 255); ++ } ++ ++ float bfg = cfg.getHSB()[2]; ++ float bbg = cbg.getHSB()[2]; ++ float bbgAlt = cbgAlt.getHSB()[2]; ++ ++ if (Math.abs(bbg - bfg) < 0.5f && Math.abs(bbgAlt - bfg) > Math.abs(bbg - bfg)) { ++ return cbgAlt; ++ } ++ return cbg; ++ } ++ ++ /** ++ * This executable extension requires parameters to be explicitly declared ++ * via the second method described in the IExecutableExtension ++ * documentation. This class expects that there will be three parameters, ++ * foreground, background and ++ * alternativeBackground. These values may either be RGB ++ * triples or SWT constants. ++ */ ++ @Override ++ public void setInitializationData(IConfigurationElement config, String propertyName, Object data) ++ throws CoreException { ++ if (data instanceof Hashtable) { ++ @SuppressWarnings("unchecked") ++ Hashtable table = (Hashtable) data; ++ fg = table.get("foreground"); //$NON-NLS-1$ ++ bg = table.get("background"); //$NON-NLS-1$ ++ altBg = table.get("alternativeBackground"); //$NON-NLS-1$ ++ } ++ } ++} +diff --git a/eclipse.jdt.ui/org.eclipse.jdt.ui/plugin.xml b/org.eclipse.jdt.ui/plugin.xml +index e266d1a..f4b51ed 100644 +--- a/eclipse.jdt.ui/org.eclipse.jdt.ui/plugin.xml ++++ b/eclipse.jdt.ui/org.eclipse.jdt.ui/plugin.xml +@@ -1065,8 +1065,23 @@ + ++ ++ ++ ++ ++ ++ ++ ++ + + %DeclarationViewBackgroundColor.description + +-- +cgit v0.11.2-4-g4a35 + + diff --git a/SOURCES/eclipse-bug-478962.patch b/SOURCES/eclipse-bug-478962.patch new file mode 100644 index 0000000..6b4ce02 --- /dev/null +++ b/SOURCES/eclipse-bug-478962.patch @@ -0,0 +1,214 @@ +From 87d512619f0b0b05332e4c83f651f29bfa50c5e9 Mon Sep 17 00:00:00 2001 +From: Snjezana Peco +Date: Tue, 24 Nov 2015 13:46:51 +0100 +Subject: Bug 478962 - [GTK3] Eclipse Mars SR1 consumes 60% CPU while idling + +The +https://git.gnome.org/browse/gtk+/commit/?id=fe51ac273c8045279a222c22a52d297d5ede4169 +commit changes the state of a node instead of copying the style info. +When getting some properties (color, background color, border, padding), +SWT changes the state of the node 0 (OS.GTK_STATE_FLAG_NORMAL) which +sometimes causes a widget to continously repaint. +For example: +SWT uses the following method to get the background color: + +OS.gtk_style_context_get_background_color (context, +OS.GTK_STATE_FLAG_NORMAL, rgba); + +This method changes the state of a node to 0 (OS.GTK_STATE_FLAG_NORMAL). +CTabFolder calls the method from inside the paint listener which causes an +infinite painting loop. + +This commit fixes the issue by using the widget's current style state +instead of OS.GTK_STATE_FLAG_NORMAL. + +Change-Id: I4dd27e3f6c5895a115fd76788ca2b2322aad6c4d +Signed-off-by: Snjezana Peco +--- + bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os.c | 8 ++++---- + .../gtk/org/eclipse/swt/internal/gtk/OS.java | 4 ++-- + .../gtk/org/eclipse/swt/widgets/Control.java | 17 +++++++++++------ + .../gtk/org/eclipse/swt/widgets/DateTime.java | 8 +++++--- + .../gtk/org/eclipse/swt/widgets/Spinner.java | 5 +++-- + .../Eclipse SWT/gtk/org/eclipse/swt/widgets/Text.java | 3 ++- + 6 files changed, 27 insertions(+), 18 deletions(-) + +diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os.c b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os.c +index c0dff7f..52ade78 100644 +--- a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os.c ++++ b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os.c +@@ -18341,18 +18341,18 @@ fail: + #endif + + #ifndef NO__1gtk_1widget_1get_1state_1flags +-JNIEXPORT jintLong JNICALL OS_NATIVE(_1gtk_1widget_1get_1state_1flags) ++JNIEXPORT jint JNICALL OS_NATIVE(_1gtk_1widget_1get_1state_1flags) + (JNIEnv *env, jclass that, jintLong arg0) + { +- jintLong rc = 0; ++ jint rc = 0; + OS_NATIVE_ENTER(env, that, _1gtk_1widget_1get_1state_1flags_FUNC); + /* +- rc = (jintLong)gtk_widget_get_state_flags((GtkWidget *)arg0); ++ rc = (jint)gtk_widget_get_state_flags((GtkWidget *)arg0); + */ + { + OS_LOAD_FUNCTION(fp, gtk_widget_get_state_flags) + if (fp) { +- rc = (jintLong)((jintLong (CALLING_CONVENTION*)(GtkWidget *))fp)((GtkWidget *)arg0); ++ rc = (jint)((jintLong (CALLING_CONVENTION*)(GtkWidget *))fp)((GtkWidget *)arg0); + } + } + OS_NATIVE_EXIT(env, that, _1gtk_1widget_1get_1state_1flags_FUNC); +diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk/OS.java b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk/OS.java +index 0ee6dda..a7fb6fe 100644 +--- a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk/OS.java ++++ b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk/OS.java +@@ -11855,8 +11855,8 @@ public static final void gtk_style_context_restore(long /*int*/ context) { + /** @method flags=dynamic + * @param self cast=(GtkWidget *) + * */ +-public static final native long /*int*/ _gtk_widget_get_state_flags(long /*int*/ self); +-public static final long /*int*/ gtk_widget_get_state_flags(long /*int*/ self) { ++public static final native int _gtk_widget_get_state_flags(long /*int*/ self); ++public static final int gtk_widget_get_state_flags(long /*int*/ self) { + lock.lock(); + try { + return _gtk_widget_get_state_flags(self); +diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Control.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Control.java +index 7061084..ecf2da0 100644 +--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Control.java ++++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Control.java +@@ -2585,8 +2585,9 @@ + } + } else { + long /*int*/ context = OS.gtk_widget_get_style_context (fontHandle); ++ int styleState = OS.gtk_widget_get_state_flags(handle); + GdkRGBA rgba = new GdkRGBA (); +- OS.gtk_style_context_get_background_color (context, OS.GTK_STATE_FLAG_NORMAL, rgba); ++ OS.gtk_style_context_get_background_color (context, styleState, rgba); + if (rgba.alpha == 0) { + return display.COLOR_WIDGET_BACKGROUND; + } +@@ -2625,8 +2626,9 @@ GdkColor getContextBackground () { + GdkColor getContextColor () { + long /*int*/ fontHandle = fontHandle (); + long /*int*/ context = OS.gtk_widget_get_style_context (fontHandle); ++ int styleState = OS.gtk_widget_get_state_flags(handle); + GdkRGBA rgba = new GdkRGBA (); +- rgba = display.styleContextGetColor (context, OS.GTK_STATE_FLAG_NORMAL, rgba); ++ rgba = display.styleContextGetColor (context, styleState, rgba); + GdkColor color = new GdkColor (); + color.red = (short)(rgba.red * 0xFFFF); + color.green = (short)(rgba.green * 0xFFFF); +@@ -2761,7 +2763,8 @@ long /*int*/ getFontDescription () { + long /*int*/ fontHandle = fontHandle (); + if (OS.GTK3) { + long /*int*/ context = OS.gtk_widget_get_style_context (fontHandle); +- return OS.gtk_style_context_get_font(context, OS.GTK_STATE_FLAG_NORMAL); ++ int styleState = OS.gtk_widget_get_state_flags(fontHandle); ++ return OS.gtk_style_context_get_font(context, styleState); + } + OS.gtk_widget_realize (fontHandle); + return OS.gtk_style_get_font_desc (OS.gtk_widget_get_style (fontHandle)); +@@ -3021,12 +3024,13 @@ Point getThickness (long /*int*/ widget) { + int xthickness = 0, ythickness = 0; + GtkBorder tmp = new GtkBorder(); + long /*int*/ context = OS.gtk_widget_get_style_context (widget); ++ int styleState = OS.gtk_widget_get_state_flags(widget); + OS.gtk_style_context_save (context); + OS.gtk_style_context_add_class (context, OS.GTK_STYLE_CLASS_FRAME); +- OS.gtk_style_context_get_padding (context, OS.GTK_STATE_FLAG_NORMAL, tmp); ++ OS.gtk_style_context_get_padding (context, styleState, tmp); + xthickness += tmp.left; + ythickness += tmp.top; +- OS.gtk_style_context_get_border (context, OS.GTK_STATE_FLAG_NORMAL, tmp); ++ OS.gtk_style_context_get_border (context, styleState, tmp); + xthickness += tmp.left; + ythickness += tmp.top; + OS.gtk_style_context_restore (context); +@@ -5595,7 +5599,8 @@ long /*int*/ windowProc (long /*int*/ handle, long /*int*/ arg0, long /*int*/ us + if (OS.GTK3 && !draw && (state & CANVAS) != 0) { + GdkRGBA rgba = new GdkRGBA(); + long /*int*/ context = OS.gtk_widget_get_style_context (handle); +- OS.gtk_style_context_get_background_color (context, OS.GTK_STATE_FLAG_NORMAL, rgba); ++ int styleState = OS.gtk_widget_get_state_flags(handle); ++ OS.gtk_style_context_get_background_color (context, styleState, rgba); + draw = rgba.alpha == 0; + } + if (draw) { +diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/DateTime.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/DateTime.java +index 12bca54..81780bd 100644 +--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/DateTime.java ++++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/DateTime.java +@@ -296,13 +296,14 @@ public Rectangle computeTrim (int x, int y, int width, int height) { + if (OS.GTK3) { + GtkBorder tmp = new GtkBorder (); + long /*int*/ context = OS.gtk_widget_get_style_context (textEntryHandle); +- OS.gtk_style_context_get_padding (context, OS.GTK_STATE_FLAG_NORMAL, tmp); ++ int styleState = OS.gtk_widget_get_state_flags(textEntryHandle); ++ OS.gtk_style_context_get_padding (context, styleState, tmp); + trim.x -= tmp.left; + trim.y -= tmp.top; + trim.width += tmp.left + tmp.right; + trim.height += tmp.top + tmp.bottom; + if ((style & SWT.BORDER) != 0) { +- OS.gtk_style_context_get_border (context, OS.GTK_STATE_FLAG_NORMAL, tmp); ++ OS.gtk_style_context_get_border (context, styleState, tmp); + trim.x -= tmp.left; + trim.y -= tmp.top; + trim.width += tmp.left + tmp.right; +@@ -1738,7 +1739,8 @@ GtkBorder getGtkBorderPadding () { + //In Gtk3, acquire border. + GtkBorder gtkBorderPadding = new GtkBorder (); + long /*int*/ context = OS.gtk_widget_get_style_context (textEntryHandle); +- OS.gtk_style_context_get_padding (context, OS.GTK_STATE_FLAG_NORMAL, gtkBorderPadding); ++ int styleState = OS.gtk_widget_get_state_flags(textEntryHandle); ++ OS.gtk_style_context_get_padding (context, styleState, gtkBorderPadding); + return gtkBorderPadding; + } else { + //in GTK2 hard code the padding +diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Spinner.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Spinner.java +index 7550122..3bbb886 100644 +--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Spinner.java ++++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Spinner.java +@@ -255,9 +255,10 @@ public Rectangle computeTrim (int x, int y, int width, int height) { + if (OS.GTK3) { + GtkBorder tmp = new GtkBorder(); + long /*int*/ context = OS.gtk_widget_get_style_context (handle); +- OS.gtk_style_context_get_padding (context, OS.GTK_STATE_FLAG_NORMAL, tmp); ++ int styleState = OS.gtk_widget_get_state_flags(handle); ++ OS.gtk_style_context_get_padding (context, styleState, tmp); + if ((style & SWT.BORDER) != 0) { +- OS.gtk_style_context_get_border (context, OS.GTK_STATE_FLAG_NORMAL, tmp); ++ OS.gtk_style_context_get_border (context, styleState, tmp); + trim.x -= tmp.left; + trim.y -= tmp.top; + trim.width += tmp.left + tmp.right; +diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Text.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Text.java +index ee9172e..8d5d0ba 100644 +--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Text.java ++++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Text.java +@@ -591,7 +591,8 @@ public Rectangle computeTrim (int x, int y, int width, int height) { + if (OS.GTK3) { + GtkBorder tmp = new GtkBorder(); + long /*int*/ context = OS.gtk_widget_get_style_context (handle); +- OS.gtk_style_context_get_padding (context, OS.GTK_STATE_FLAG_NORMAL, tmp); ++ int styleState = OS.gtk_widget_get_state_flags(handle); ++ OS.gtk_style_context_get_padding (context, styleState, tmp); + trim.x -= tmp.left; + trim.y -= tmp.top; + trim.width += tmp.left + tmp.right; +@@ -598,7 +602,7 @@ public Rectangle computeTrim (int x, int y, int width, int height) { + trim.width += tmp.left + tmp.right; + trim.height += tmp.top + tmp.bottom; + if ((style & SWT.BORDER) != 0) { +- OS.gtk_style_context_get_border (context, OS.GTK_STATE_FLAG_NORMAL, tmp); ++ OS.gtk_style_context_get_border (context, styleState, tmp); + trim.x -= tmp.left; + trim.y -= tmp.top; + trim.width += tmp.left + tmp.right; +-- +cgit v0.11.2-4-g4a35 + + diff --git a/SOURCES/eclipse-bug-480986.patch b/SOURCES/eclipse-bug-480986.patch new file mode 100644 index 0000000..3010334 --- /dev/null +++ b/SOURCES/eclipse-bug-480986.patch @@ -0,0 +1,47 @@ +From 531d3f18481988494e77b5f1ded92a7f346ea14d Mon Sep 17 00:00:00 2001 +From: Eric Williams +Date: Wed, 28 Oct 2015 10:52:36 -0400 +Subject: Bug 480986: [Wayland] Workspace chooser won't launch + +gtk_size_allocate() in Shell is called more often on Wayland. These +additional and unexpected calls trigger an infinite recursive call to +resizeBounds(), which causes non-resizable Shells/Dialogs to crash. + +The fix is to only resize Shells that have the SWT.RESIZE attribute +enabled. + +Tested on Gtk3.16 on Wayland, Gtk3.16 on X, and Gtk2.24. AllNonBrowser +JUnit test cases pass on Gtk3 running X. There are some irregularities +with test cases on Wayland, as outlined in bug 480893. + +Change-Id: I55612d8486cdd512e275a8a7456e0197ed717c75 +Signed-off-by: Eric Williams +--- + .../Eclipse SWT/gtk/org/eclipse/swt/widgets/Shell.java | 9 +++++++-- + 1 file changed, 7 insertions(+), 2 deletions(-) + +diff --git eclipse.platform.swt/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Shell.java eclipse.platform.swt/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Shell.java +index d65af5c..49ae036 100644 +--- eclipse.platform.swt/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Shell.java ++++ eclipse.platform.swt/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Shell.java +@@ -1528,10 +1528,15 @@ long /*int*/ gtk_size_allocate (long /*int*/ widget, long /*int*/ allocation) { + OS.gtk_widget_get_allocation (shellHandle, widgetAllocation); + int width = widgetAllocation.width; + int height = widgetAllocation.height; +- if (!resized || oldWidth != width || oldHeight != height) { ++ ++ // Bug 474235: on Wayland gtk_size_allocate() is called more frequently, causing an ++ // infinitely recursive resize call. This causes non-resizable Shells/Dialogs to ++ // crash. Fix: only call resizeBounds() on resizable Shells. ++ if ((!resized || oldWidth != width || oldHeight != height) ++ && (OS.GTK3 && !OS.isX11() ? ((style & SWT.RESIZE) != 0) : true)) { //Wayland + oldWidth = width; + oldHeight = height; +- resizeBounds (width, height, true); ++ resizeBounds (width, height, true); //this is called to resize child widgets when the shell is resized. + } + return 0; + } +-- +cgit v0.11.2-4-g4a35 + diff --git a/SOURCES/eclipse-bug-481122.patch b/SOURCES/eclipse-bug-481122.patch new file mode 100644 index 0000000..28b7d50 --- /dev/null +++ b/SOURCES/eclipse-bug-481122.patch @@ -0,0 +1,136 @@ +From 3dc220718412431322c00e1f820c9ce0168892f5 Mon Sep 17 00:00:00 2001 +From: Eric Williams +Date: Mon, 23 Nov 2015 10:37:11 -0500 +Subject: Bug 481122: [GTK3.18+] some set/get Background/Foreground color + methods have no effect + +With changes in GTK3.18 and onward, gtk_style_context_get_color() +behaves differently. In order to correctly fetch the color we must first +save the GtkStyleContext, set its state, fetch the color, and then +restore the GtkStyleContext. Failure to do this on GTK3.18+ leads to +failures in the getForegroundColor() method. + +The convenience method styleContextGetColor() in Display takes care of +the process. + +Tested on GTK 3.18, 3.16, 3.14, 3.8, and 2.24. All foreground color +related tests on GTK3 now pass. GTK2 behaviour remains unchanged. + +Change-Id: I6423edab5038dc0ef54afc6dd826f19fc936f987 +Signed-off-by: Eric Williams +--- + .../gtk/org/eclipse/swt/widgets/Control.java | 2 +- + .../gtk/org/eclipse/swt/widgets/Display.java | 36 ++++++++++++++-------- + .../gtk/org/eclipse/swt/widgets/Text.java | 2 +- + 3 files changed, 26 insertions(+), 14 deletions(-) + +diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Control.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Control.java +index ffd9d11..7061084 100644 +--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Control.java ++++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Control.java +@@ -2626,7 +2626,7 @@ GdkColor getContextColor () { + long /*int*/ fontHandle = fontHandle (); + long /*int*/ context = OS.gtk_widget_get_style_context (fontHandle); + GdkRGBA rgba = new GdkRGBA (); +- OS.gtk_style_context_get_color (context, OS.GTK_STATE_FLAG_NORMAL, rgba); ++ rgba = display.styleContextGetColor (context, OS.GTK_STATE_FLAG_NORMAL, rgba); + GdkColor color = new GdkColor (); + color.red = (short)(rgba.red * 0xFFFF); + color.green = (short)(rgba.green * 0xFFFF); +diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Display.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Display.java +index 0119882..d7e670c 100644 +--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Display.java ++++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Display.java +@@ -2373,8 +2373,7 @@ void initializeSystemColors () { + OS.gtk_style_context_add_class (context, OS.GTK_STYLE_CLASS_TOOLTIP); + OS.gtk_style_context_invalidate(context); + GdkRGBA rgba = new GdkRGBA(); +- OS.gtk_style_context_get_color (context, OS.GTK_STATE_FLAG_NORMAL, rgba); +- COLOR_INFO_FOREGROUND = toGdkColor (rgba); ++ COLOR_INFO_FOREGROUND = toGdkColor (styleContextGetColor (context, OS.GTK_STATE_FLAG_NORMAL, rgba)); + getBackgroundColor (context, OS.GTK_STATE_FLAG_NORMAL, rgba); + COLOR_INFO_BACKGROUND = toGdkColor (rgba); + OS.gtk_widget_destroy (tooltipShellHandle); +@@ -2387,8 +2386,7 @@ void initializeSystemColors () { + COLOR_WIDGET_NORMAL_SHADOW = toGdkColor (rgba, 0.7); + COLOR_WIDGET_HIGHLIGHT_SHADOW = toGdkColor (rgba, 1.3); + +- OS.gtk_style_context_get_color (context, OS.GTK_STATE_FLAG_NORMAL, rgba); +- COLOR_WIDGET_FOREGROUND = toGdkColor (rgba); ++ COLOR_WIDGET_FOREGROUND = toGdkColor (styleContextGetColor (context, OS.GTK_STATE_FLAG_NORMAL, rgba)); + OS.gtk_style_context_get_background_color (context, OS.GTK_STATE_FLAG_NORMAL, rgba); + COLOR_WIDGET_BACKGROUND = toGdkColor (rgba); + +@@ -2396,17 +2394,14 @@ void initializeSystemColors () { + OS.gtk_style_context_add_class(context, OS.GTK_STYLE_CLASS_VIEW); + OS.gtk_style_context_add_class(context, OS.GTK_STYLE_CLASS_CELL); + OS.gtk_style_context_invalidate(context); +- OS.gtk_style_context_get_color (context, OS.GTK_STATE_FLAG_NORMAL, rgba); +- COLOR_LIST_FOREGROUND = toGdkColor (rgba); ++ COLOR_LIST_FOREGROUND = toGdkColor (styleContextGetColor (context, OS.GTK_STATE_FLAG_NORMAL, rgba)); + OS.gtk_style_context_get_background_color (context, OS.GTK_STATE_FLAG_NORMAL, rgba); + COLOR_LIST_BACKGROUND = toGdkColor (rgba); + OS.gtk_style_context_restore (context); +- OS.gtk_style_context_get_color (context, OS.GTK_STATE_FLAG_SELECTED, rgba); +- COLOR_LIST_SELECTION_TEXT = toGdkColor (rgba); ++ COLOR_LIST_SELECTION_TEXT = toGdkColor (styleContextGetColor (context, OS.GTK_STATE_FLAG_SELECTED, rgba)); + OS.gtk_style_context_get_background_color (context, OS.GTK_STATE_FLAG_SELECTED, rgba); + COLOR_LIST_SELECTION = toGdkColor (rgba); +- OS.gtk_style_context_get_color (context, OS.GTK_STATE_FLAG_ACTIVE, rgba); +- COLOR_LIST_SELECTION_TEXT_INACTIVE = toGdkColor (rgba); ++ COLOR_LIST_SELECTION_TEXT_INACTIVE = toGdkColor (styleContextGetColor (context, OS.GTK_STATE_FLAG_ACTIVE, rgba)); + OS.gtk_style_context_get_background_color (context, OS.GTK_STATE_FLAG_ACTIVE, rgba); + COLOR_LIST_SELECTION_INACTIVE = toGdkColor (rgba); + +@@ -2415,8 +2410,7 @@ void initializeSystemColors () { + OS.gtk_style_context_get_background_color (context, OS.GTK_STATE_FLAG_SELECTED, rgba); + COLOR_TITLE_BACKGROUND_GRADIENT = toGdkColor (rgba, 1.3); + +- OS.gtk_style_context_get_color (context, OS.GTK_STATE_FLAG_INSENSITIVE, rgba); +- COLOR_TITLE_INACTIVE_FOREGROUND = toGdkColor (rgba); ++ COLOR_TITLE_INACTIVE_FOREGROUND = toGdkColor (styleContextGetColor (context, OS.GTK_STATE_FLAG_INSENSITIVE, rgba)); + OS.gtk_style_context_get_background_color (context, OS.GTK_STATE_FLAG_INSENSITIVE, rgba); + COLOR_TITLE_INACTIVE_BACKGROUND = toGdkColor (rgba); + COLOR_TITLE_INACTIVE_BACKGROUND_GRADIENT = toGdkColor (rgba, 1.3); +@@ -2497,6 +2491,24 @@ void initializeSystemColors () { + COLOR_TITLE_INACTIVE_BACKGROUND_GRADIENT = gdkColor; + } + ++GdkRGBA styleContextGetColor(long /*int*/ context, int flag, GdkRGBA rgba) { ++ /* ++ * Feature in GTK: we need to handle calls to gtk_style_context_get_color() ++ * differently due to changes in GTK3.18+. This solves failing test cases ++ * which started failing after GTK3.16. See Bug 481122 for more info. ++ * Reference: https://blogs.gnome.org/mclasen/2015/11/20/a-gtk-update/ ++ */ ++ if (OS.GTK_VERSION >= OS.VERSION(3, 18, 0)) { ++ OS.gtk_style_context_save(context); ++ OS.gtk_style_context_set_state(context, flag); ++ OS.gtk_style_context_get_color (context, flag, rgba); ++ OS.gtk_style_context_restore(context); ++ } else { ++ OS.gtk_style_context_get_color (context, flag, rgba); ++ } ++ return rgba; ++} ++ + /** + * Returns the single instance of the system taskBar or null + * when there is no system taskBar available for the platform. +diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Text.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Text.java +index 2865cd5..6b68b6a 100644 +--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Text.java ++++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Text.java +@@ -1664,7 +1664,7 @@ void drawMessage (long /*int*/ cr) { + if (OS.GTK3) { + long /*int*/ styleContext = OS.gtk_widget_get_style_context (handle); + GdkRGBA rgba = new GdkRGBA (); +- OS.gtk_style_context_get_color (styleContext, OS.GTK_STATE_FLAG_INSENSITIVE, rgba); ++ rgba = display.styleContextGetColor (styleContext, OS.GTK_STATE_FLAG_INSENSITIVE, rgba); + textColor.red = (short)(rgba.red * 0xFFFF); + textColor.green = (short)(rgba.green * 0xFFFF); + textColor.blue = (short)(rgba.blue * 0xFFFF); +-- +cgit v0.11.2-4-g4a35 + + diff --git a/SOURCES/eclipse-bug-484696.patch b/SOURCES/eclipse-bug-484696.patch new file mode 100644 index 0000000..713a380 --- /dev/null +++ b/SOURCES/eclipse-bug-484696.patch @@ -0,0 +1,59 @@ +From 428cc3497ee844b9262d1bdc7cb09a8332eee87c Mon Sep 17 00:00:00 2001 +From: Eric Williams +Date: Wed, 23 Dec 2015 09:55:43 -0500 +Subject: [PATCH] Bug 484696: [GTK] Empty repositories view links have white + backgrounds + +After bug 479998, an empty EGit repositories view still has mismatched +label colors. It turns out in this case the background color of the +parent composite was incorrect -- it should have been white (like on +GTK3.14 and earlier) instead of gray. + +In this case the parent composite's background color is set to be that +of the TreeViewer which will display the future repository branches, +information, etc. The default color for Trees/Tables is white. The fixes +for bug 479998 and bug 479998 introduced a small regression which set +the default color of Table/Trees to be gray. The issue in this case does +not lie with the labels but with the color of the parent composite. With +Table/Trees returning their proper default background color (white, or +COLOR_LIST_BACKGROUND), the EGit label issue is fixed. + +Tested on GTK3.18.6, 3.16, 3.14, and 2.24. AllNonBrowser JUnit tests +pass on GTK3 and GTK2. + +Change-Id: I47fe95c1ad5fc87411c0f27ff344f6369c9aa0c6 +Signed-off-by: Eric Williams +--- + .../Eclipse SWT/gtk/org/eclipse/swt/widgets/Table.java | 16 +++++++++++++--- + .../Eclipse SWT/gtk/org/eclipse/swt/widgets/Tree.java | 16 +++++++++++++--- + 2 files changed, 26 insertions(+), 6 deletions(-) + +diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Table.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Table.java +index 89bd414..2510efa 100644 +--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Table.java ++++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Table.java +@@ -3138,7 +3148,7 @@ void setBackgroundColor (long /*int*/ context, long /*int*/ handle, GdkRGBA rgba + selectedBackground.green = (defaultColor.green & 0xFFFF) / (float)0xFFFF; + selectedBackground.blue = (defaultColor.blue & 0xFFFF) / (float)0xFFFF; + if (OS.GTK_VERSION >= OS.VERSION(3, 16, 0)) { +- String css = "GtkTreeView {background-color: " + gtk_rgba_to_css_string(rgba) + ";}\n" ++ String css = "GtkTreeView {background-color: " + gtk_rgba_to_css_string(background) + ";}\n" + + "GtkTreeView:selected {background-color: " + gtk_rgba_to_css_string(selectedBackground) + ";}"; + gtk_css_provider_load_from_css(context, css); + } else { +diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Tree.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Tree.java +index f8aaa6a..23cf3dc 100644 +--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Tree.java ++++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Tree.java +@@ -3123,7 +3133,7 @@ void setBackgroundColor (long /*int*/ context, long /*int*/ handle, GdkRGBA rgba + selectedBackground.green = (defaultColor.green & 0xFFFF) / (float)0xFFFF; + selectedBackground.blue = (defaultColor.blue & 0xFFFF) / (float)0xFFFF; + if (OS.GTK_VERSION >= OS.VERSION(3, 16, 0)) { +- String css = "GtkTreeView {background-color: " + gtk_rgba_to_css_string(rgba) + ";}\n" ++ String css = "GtkTreeView {background-color: " + gtk_rgba_to_css_string(background) + ";}\n" + + "GtkTreeView:selected {background-color: " + gtk_rgba_to_css_string(selectedBackground) + ";}"; + gtk_css_provider_load_from_css(context, css); + } else { +-- +2.5.0 + diff --git a/SOURCES/eclipse-bug-486368.patch b/SOURCES/eclipse-bug-486368.patch new file mode 100644 index 0000000..c02e24f --- /dev/null +++ b/SOURCES/eclipse-bug-486368.patch @@ -0,0 +1,36 @@ +From 3b20eb8505d7eba958b07ebdccab29881c7016b5 Mon Sep 17 00:00:00 2001 +From: Eric Williams +Date: Tue, 9 Feb 2016 13:46:03 -0500 +Subject: Bug 486368: [GTK3] Preferences dialog background color garbled + +Restore call to gtk_style_context_set_background() in order to prevent +dialog background color issues on earlier versions of GTK. + +Tested on GTK3.18, 3.16, 3.14, and 2.24. AllNonBrowser JUnit tests pass +on GTK2 and GTK3. + +Change-Id: I1885f7e0a3d9312c4f7fe033c9a80abf31f20182 +Signed-off-by: Eric Williams +--- + bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_custom.c | 3 +++ + 1 file changed, 3 insertions(+) + +diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_custom.c b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_custom.c +index 8f5d022..032ce43 100644 +--- a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_custom.c ++++ b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_custom.c +@@ -512,7 +512,9 @@ static void swt_fixed_realize (GtkWidget *widget) { + window = gdk_window_new (gtk_widget_get_parent_window (widget), &attributes, attributes_mask); + gtk_widget_set_window (widget, window); + gdk_window_set_user_data (window, widget); +- gtk_style_context_set_background (gtk_widget_get_style_context (widget), window); ++ if (NULL != gtk_check_version (3, 18, 0)) { ++ gtk_style_context_set_background (gtk_widget_get_style_context (widget), window); ++ } + } + + static void swt_fixed_map (GtkWidget *widget) { +-- +cgit v0.11.2-4-g4a35 + + diff --git a/SOURCES/eclipse-bug-487712.patch b/SOURCES/eclipse-bug-487712.patch new file mode 100644 index 0000000..871d7ab --- /dev/null +++ b/SOURCES/eclipse-bug-487712.patch @@ -0,0 +1,62 @@ +From d0a9c478604ba6a32016a631c6d0b05ac839dffe Mon Sep 17 00:00:00 2001 +From: Alexander Kurtakov +Date: Fri, 12 Feb 2016 11:57:13 +0200 +Subject: Bug 487712 - Snippet128 crashes on Fedora + +Bug in ProgressBar due to calling gdk_window_process_updates which sends +expose events for redrawing purposes. But this event is implementation +detail in GTK3 and shouldn't be used from outside and playing with it +leads to race conditions with webkitgtk. +Also GtkProgressBar redraws properly now so trying to force redraw is +useless on GTK 3. + +Change-Id: I22373b9e33c83759e0ff9dc2d0600fe39cacb91e +Signed-off-by: Alexander Kurtakov +--- + .../gtk/org/eclipse/swt/widgets/ProgressBar.java | 24 ++++++++++++---------- + 1 file changed, 13 insertions(+), 11 deletions(-) + +diff --git a/eclipse.platform.swt/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ProgressBar.java b/eclipse.platform.swt/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ProgressBar.java +index d6749ef..cbdd8c7 100644 +--- a/eclipse.platform.swt/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ProgressBar.java ++++ b/eclipse.platform.swt/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ProgressBar.java +@@ -1,5 +1,5 @@ + /******************************************************************************* +- * Copyright (c) 2000, 2013 IBM Corporation and others. ++ * Copyright (c) 2000, 2016 IBM Corporation 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 +@@ -301,16 +301,18 @@ void updateBar (int selection, int minimum, int maximum) { + + double fraction = minimum == maximum ? 1 : (double)(selection - minimum) / (maximum - minimum); + OS.gtk_progress_bar_set_fraction (handle, fraction); +- /* +- * Feature in GTK. The progress bar does +- * not redraw right away when a value is +- * changed. This is not strictly incorrect +- * but unexpected. The fix is to force all +- * outstanding redraws to be delivered. +- */ +- long /*int*/ window = paintWindow (); +- OS.gdk_window_process_updates (window, false); +- OS.gdk_flush (); ++ if (!OS.GTK3) { ++ /* ++ * Feature in GTK. The progress bar does ++ * not redraw right away when a value is ++ * changed. This is not strictly incorrect ++ * but unexpected. The fix is to force all ++ * outstanding redraws to be delivered. ++ */ ++ long /*int*/ window = paintWindow (); ++ OS.gdk_window_process_updates (window, false); ++ OS.gdk_flush (); ++ } + } + + void gtk_orientable_set_orientation (long /*int*/ pbar, int orientation) { +-- +cgit v0.11.2-4-g4a35 + + diff --git a/SOURCES/eclipse-bug-488226.patch b/SOURCES/eclipse-bug-488226.patch new file mode 100644 index 0000000..c047251 --- /dev/null +++ b/SOURCES/eclipse-bug-488226.patch @@ -0,0 +1,318 @@ +From 46e387352f469e26ecedddc10ffec2cd16f11d82 Mon Sep 17 00:00:00 2001 +From: Eric Williams +Date: Fri, 19 Feb 2016 15:59:12 -0500 +Subject: Bug 488226: [GTK3] Content Assist using Table/Tree has wrong + selection background colors + +On GTK3.14 and above, SWT.COLOR_LIST_SELECTION was returning gray +instead of the default (and correct) blue. This causes bugs in +Table/Tree, making highlighted TableItems/TreeItems difficult to read. +COLOR_LIST_BACKGROUND is unaffected. + +System background colors like SWT.COLOR_* are fetched using +gtk_style_context_get_background_color() when SWT loads. This approach +is no longer valid as 1) it is deprecated on the GTK side and 2) it is +unreliable/not guaranteed to work. This patch only changes this behavior +for SWT.COLOR_LIST_SELECTION, but in the future other system colors will +need to be changed as well. + +The fix in this case is to fetch the GTK theme colors of the currently +running system theme from GTK. This can be done using GtkCssProvider. +Once the currently running theme is fetched, the correct selection +background color can be extracted. If there is no selection background +color specified in the theme, then the fall-back is to load the color +via SWT's COLOR_LIST_SELECTION. This ensures that the correct color is +chosen according to GTK, should a theme specify one. + +Tested on GTK3.8, 3.14, 3.16, and 3.18. AllNonBrowser JUnit tests pass +on GTK3 and GTK2. + +Change-Id: Ic9aeb4d35efef961be1f724a2ad7dcc852c06453 +Signed-off-by: Eric Williams +--- + .../Eclipse SWT PI/gtk/library/os.c | 27 ++++++ + .../Eclipse SWT PI/gtk/library/os_custom.h | 1 + + .../Eclipse SWT PI/gtk/library/os_stats.c | 1 + + .../Eclipse SWT PI/gtk/library/os_stats.h | 1 + + .../gtk/org/eclipse/swt/internal/gtk/OS.java | 14 +++ + .../gtk/org/eclipse/swt/widgets/Control.java | 17 +--- + .../gtk/org/eclipse/swt/widgets/Display.java | 108 ++++++++++++++++++++- + 7 files changed, 153 insertions(+), 16 deletions(-) + +diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os.c b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os.c +index 64e39f3..02dbadd 100644 +--- a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os.c ++++ b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os.c +@@ -10056,6 +10056,33 @@ JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1container_1set_1border_1width) + } + #endif + ++#ifndef NO__1gtk_1css_1provider_1get_1named ++JNIEXPORT jintLong JNICALL OS_NATIVE(_1gtk_1css_1provider_1get_1named) ++ (JNIEnv *env, jclass that, jbyteArray arg0, jbyteArray arg1) ++{ ++ jbyte *lparg0=NULL; ++ jbyte *lparg1=NULL; ++ jintLong rc = 0; ++ OS_NATIVE_ENTER(env, that, _1gtk_1css_1provider_1get_1named_FUNC); ++ if (arg0) if ((lparg0 = (*env)->GetByteArrayElements(env, arg0, NULL)) == NULL) goto fail; ++ if (arg1) if ((lparg1 = (*env)->GetByteArrayElements(env, arg1, NULL)) == NULL) goto fail; ++/* ++ rc = (jintLong)gtk_css_provider_get_named((const gchar *)lparg0, (const gchar *)lparg1); ++*/ ++ { ++ OS_LOAD_FUNCTION(fp, gtk_css_provider_get_named) ++ if (fp) { ++ rc = (jintLong)((jintLong (CALLING_CONVENTION*)(const gchar *, const gchar *))fp)((const gchar *)lparg0, (const gchar *)lparg1); ++ } ++ } ++fail: ++ if (arg1 && lparg1) (*env)->ReleaseByteArrayElements(env, arg1, lparg1, 0); ++ if (arg0 && lparg0) (*env)->ReleaseByteArrayElements(env, arg0, lparg0, 0); ++ OS_NATIVE_EXIT(env, that, _1gtk_1css_1provider_1get_1named_FUNC); ++ return rc; ++} ++#endif ++ + #ifndef NO__1gtk_1css_1provider_1load_1from_1data + JNIEXPORT jboolean JNICALL OS_NATIVE(_1gtk_1css_1provider_1load_1from_1data) + (JNIEnv *env, jclass that, jintLong arg0, jbyteArray arg1, jintLong arg2, jintLongArray arg3) +diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_custom.h b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_custom.h +index 7a27475..8e5844b 100644 +--- a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_custom.h ++++ b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_custom.h +@@ -530,6 +530,7 @@ + #define gtk_css_provider_load_from_data_LIB LIB_GTK + #define gtk_css_provider_new_LIB LIB_GTK + #define gtk_css_provider_to_string_LIB LIB_GTK ++#define gtk_css_provider_get_named_LIB LIB_GTK + #define gtk_icon_set_render_icon_pixbuf_LIB LIB_GTK + #define gtk_drag_set_icon_surface_LIB LIB_GTK + #define gtk_accel_label_set_accel_LIB LIB_GTK +diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_stats.c b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_stats.c +index 5d77479..670adf8 100644 +--- a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_stats.c ++++ b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_stats.c +@@ -729,6 +729,7 @@ char * OS_nativeFunctionNames[] = { + "_1gtk_1container_1remove", + "_1gtk_1container_1resize_1children", + "_1gtk_1container_1set_1border_1width", ++ "_1gtk_1css_1provider_1get_1named", + "_1gtk_1css_1provider_1load_1from_1data", + "_1gtk_1css_1provider_1new", + "_1gtk_1css_1provider_1to_1string", +diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_stats.h b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_stats.h +index a0a30b7..11fdfe4 100644 +--- a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_stats.h ++++ b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_stats.h +@@ -739,6 +739,7 @@ typedef enum { + _1gtk_1container_1remove_FUNC, + _1gtk_1container_1resize_1children_FUNC, + _1gtk_1container_1set_1border_1width_FUNC, ++ _1gtk_1css_1provider_1get_1named_FUNC, + _1gtk_1css_1provider_1load_1from_1data_FUNC, + _1gtk_1css_1provider_1new_FUNC, + _1gtk_1css_1provider_1to_1string_FUNC, +diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk/OS.java b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk/OS.java +index d3e52c3..353d4b7 100644 +--- a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk/OS.java ++++ b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk/OS.java +@@ -650,6 +650,7 @@ public class OS extends C { + public static final byte[] gtk_show_input_method_menu = ascii("gtk-show-input-method-menu"); + public static final byte[] gtk_menu_bar_accel = ascii("gtk-menu-bar-accel"); + public static final byte[] gtk_menu_images = ascii("gtk-menu-images"); ++ public static final byte[] gtk_theme_name = ascii("gtk-theme-name"); + public static final byte[] inner_border = ascii("inner-border"); + public static final byte[] has_backward_stepper = ascii("has-backward-stepper"); + public static final byte[] has_secondary_backward_stepper = ascii("has-secondary-backward-stepper"); +@@ -9299,6 +9300,19 @@ public static final long /*int*/gtk_css_provider_to_string(long /*int*/ provider + lock.unlock(); + } + } ++/** @method flags=dynamic ++ * @param name cast=(const gchar *) ++ * @param variant cast=(const gchar *) ++ */ ++public static final native long /*int*/ _gtk_css_provider_get_named (byte[] name, byte[] variant); ++public static final long /*int*/gtk_css_provider_get_named(byte[] name, byte[] variant) { ++ lock.lock(); ++ try { ++ return _gtk_css_provider_get_named(name, variant); ++ } finally { ++ lock.unlock(); ++ } ++} + /** + * @method flags=dynamic + * @param screen cast=(GdkScreen *) +diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Control.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Control.java +index d296192..741a4e2 100644 +--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Control.java ++++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Control.java +@@ -4178,7 +4178,7 @@ GdkColor gtk_css_parse_background (long /*int*/ provider) { + shortOutput = cssOutput.substring (startIndex + 18); + // Double check to make sure with have a valid rgb/rgba property + if (shortOutput.contains ("rgba") || shortOutput.contains ("rgb")) { +- rgba = gtk_css_property_to_rgba (shortOutput); ++ rgba = display.gtk_css_property_to_rgba (shortOutput); + } else { + return display.COLOR_WIDGET_BACKGROUND; + } +@@ -4187,7 +4187,7 @@ GdkColor gtk_css_parse_background (long /*int*/ provider) { + shortOutput = cssOutput.substring (startIndex + 13); + // Double check to make sure with have a valid rgb/rgba property + if (shortOutput.contains ("rgba") || shortOutput.contains ("rgb")) { +- rgba = gtk_css_property_to_rgba (shortOutput); ++ rgba = display.gtk_css_property_to_rgba (shortOutput); + } else { + return display.COLOR_WIDGET_BACKGROUND; + } +@@ -4195,18 +4195,6 @@ GdkColor gtk_css_parse_background (long /*int*/ provider) { + return color; + } + +-GdkRGBA gtk_css_property_to_rgba(String property) { +- /* Here we convert rgb(...) or rgba(...) properties +- * into GdkRGBA objects using gdk_rgba_parse(). Note +- * that we still need to remove the ";" character from the +- * input string. +- */ +- GdkRGBA rgba = new GdkRGBA (); +- String [] propertyParsed = new String [1]; +- propertyParsed = property.split (";"); +- OS.gdk_rgba_parse (rgba, Converter.wcsToMbcs (null, propertyParsed[0], true)); +- return rgba; +-} + + void gtk_css_provider_load_from_css (long /*int*/ context, String css) { + /* Utility function. */ +diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Display.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Display.java +index 49c0e0d..7dee6d7 100644 +--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Display.java ++++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Display.java +@@ -1693,6 +1693,99 @@ long /*int*/ gtk_cell_renderer_toggle_get_type () { + return toggle_renderer_type; + } + ++String gtk_css_default_theme_values (int swt) { ++ /* ++ * This method fetches GTK theme values/properties. This is accomplished ++ * by determining the name of the current system theme loaded, giving that ++ * name to GTK, and then parsing values from the returned theme contents. ++ * ++ * The idea here is that SWT variables that have corresponding GTK theme ++ * elements can be fetched easily by supplying the SWT variable as an ++ * parameter to this method. ++ */ ++ ++ // Find CSS theme name ++ byte [] buffer; ++ int length; ++ long /*int*/ settings = OS.gtk_settings_get_default (); ++ long /*int*/ [] ptr = new long /*int*/ [1]; ++ long /*int*/ str; ++ OS.g_object_get (settings, OS.gtk_theme_name, ptr, 0); ++ if (ptr [0] == 0) { ++ return ""; ++ } ++ length = OS.strlen (ptr [0]); ++ if (length == 0) { ++ return ""; ++ } ++ buffer = new byte [length]; ++ OS.memmove (buffer, ptr [0], length); ++ OS.g_free (ptr [0]); ++ ++ // Fetch the actual theme in char/string format ++ long /*int*/ themeProvider = OS.gtk_css_provider_get_named(buffer, null); ++ str = OS.gtk_css_provider_to_string (themeProvider); ++ length = OS.strlen (str); ++ if (length == 0) { ++ return ""; ++ } ++ buffer = new byte [length]; ++ OS.memmove (buffer, str, length); ++ String cssOutput = new String (Converter.mbcsToWcs (null, buffer)); ++ ++ // Parse the theme values based on the corresponding SWT value ++ // i.e. theme_selected_bg_color in GTK is SWT.COLOR_LIST_SELECTION in SWT ++ String color; ++ switch (swt) { ++ case SWT.COLOR_LIST_SELECTION: ++ /* ++ * These strings are the GTK named colors we are looking for. ++ * ++ * NOTE: we need to be careful of cases where one is being assigned ++ * to the other. For example we do NOT want to parse: ++ * @define-color theme_selected_bg_color selected_bg_color ++ * Instead we want the actual value for selected_bg_color, i.e. ++ * @define-color selected_bg_color rgb(255, 255, 255) ++ * ++ * We also want to filter out any color formats other than #xxyyzz, ++ * rgb(xxx,yyy,zzz) and rgba(www,xxx,yyy,zzz) since gdk_rgba_parse() ++ * can only handle strings in this format. ++ */ ++ int tSelected = cssOutput.indexOf ("@define-color theme_selected_bg_color"); ++ int selected = cssOutput.indexOf ("@define-color selected_bg_color"); ++ if (tSelected != -1) { ++ color = cssOutput.substring(tSelected + 38); ++ if (color.startsWith("#") || color.startsWith("rgb")) { ++ return color; ++ } ++ } ++ if (selected != -1) { ++ color = cssOutput.substring(selected + 32); ++ if (color.startsWith("#") || color.startsWith("rgb")) { ++ return color; ++ } ++ } ++ else { ++ return ""; ++ } ++ default: ++ return ""; ++ } ++} ++ ++GdkRGBA gtk_css_property_to_rgba(String property) { ++ /* Here we convert rgb(...) or rgba(...) properties ++ * into GdkRGBA objects using gdk_rgba_parse(). Note ++ * that we still need to remove the ";" character from the ++ * input string. ++ */ ++ GdkRGBA rgba = new GdkRGBA (); ++ String [] propertyParsed = new String [1]; ++ propertyParsed = property.split (";"); ++ OS.gdk_rgba_parse (rgba, Converter.wcsToMbcs (null, propertyParsed[0], true)); ++ return rgba; ++} ++ + /** + * Returns the default display. One is created (making the + * thread that invokes this method its user-interface thread) +@@ -2409,7 +2502,20 @@ void initializeSystemColors () { + COLOR_LIST_BACKGROUND = toGdkColor (rgba); + OS.gtk_style_context_restore (context); + COLOR_LIST_SELECTION_TEXT = toGdkColor (styleContextGetColor (context, OS.GTK_STATE_FLAG_SELECTED, rgba)); +- OS.gtk_style_context_get_background_color (context, OS.GTK_STATE_FLAG_SELECTED, rgba); ++ ++ // SWT.COLOR_LIST_SELECTION will be fetched using GTK CSS for GTK3.14+. ++ // TODO: convert other system colors to this method and re-factor. ++ if (OS.GTK_VERSION >= OS.VERSION(3, 14, 0)) { ++ String colorListSelection = gtk_css_default_theme_values(SWT.COLOR_LIST_SELECTION); ++ if (!colorListSelection.isEmpty()) { ++ rgba = gtk_css_property_to_rgba (colorListSelection); ++ } else { ++ OS.gtk_style_context_get_background_color (context, OS.GTK_STATE_FLAG_SELECTED, rgba); ++ } ++ } else { ++ OS.gtk_style_context_get_background_color (context, OS.GTK_STATE_FLAG_SELECTED, rgba); ++ } ++ + COLOR_LIST_SELECTION = toGdkColor (rgba); + COLOR_LIST_SELECTION_TEXT_INACTIVE = toGdkColor (styleContextGetColor (context, OS.GTK_STATE_FLAG_ACTIVE, rgba)); + OS.gtk_style_context_get_background_color (context, OS.GTK_STATE_FLAG_ACTIVE, rgba); +-- +cgit v0.11.2-4-g4a35 + + diff --git a/SOURCES/eclipse-bug-489953.patch b/SOURCES/eclipse-bug-489953.patch new file mode 100644 index 0000000..b4c7514 --- /dev/null +++ b/SOURCES/eclipse-bug-489953.patch @@ -0,0 +1,63 @@ +From bd2e4b64ecd5e5b0d476810cc1d365ce8f3065c5 Mon Sep 17 00:00:00 2001 +From: Eric Williams +Date: Fri, 18 Mar 2016 11:45:13 -0400 +Subject: Bug 489953: [GTK3.14-] Button background tests fail + +GTK3.14 and below does not have access to CSS parsing methods. There are +however a handful of widgets that use CSS background colors on GTK3.14. +Button is one of these, as CSS theming was introduced to Button to fix +some bugs. + +This means that on GTK3.14 there is a test failure for +Button.getBackground() since SWT cannot parse GTK CSS on GTK3.14. The +solution to keep track of the background color and override +getContextBackground() in Button. This eliminates the last failing color +test case on GTK3.14 + +This modifies behavior for GTK3.14 and below. GTK3.16 behavior is +unaffected as CSS parsing machinery exists for 3.16 and up. + +Tested on GTK3.18, 3.16, 3.14, and 2.24. AllNonBrowserTests pass on GTK3 +and GTK2.--- + .../Eclipse SWT/gtk/org/eclipse/swt/widgets/Button.java | 10 ++++++++++ + 1 file changed, 10 insertions(+) + +diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Button.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Button.java +index 967550c..9aab8be 100644 +--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Button.java ++++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Button.java +@@ -50,6 +50,7 @@ public class Button extends Control { + ImageList imageList; + Image image; + String text; ++ GdkRGBA background; + + static final int INNER_BORDER = 1; + static final int DEFAULT_BORDER = 1; +@@ -127,6 +128,14 @@ static GtkBorder getBorder (byte[] border, long /*int*/ handle, int defaultBorde + return gtkBorder; + } + ++@Override ++GdkColor getContextBackground () { ++ if (background != null) { ++ return display.toGdkColor (background); ++ } ++ return display.COLOR_WIDGET_BACKGROUND; ++} ++ + /** + * Adds the listener to the collection of listeners who will + * be notified when the control is selected by the user, by sending +@@ -799,6 +808,7 @@ void _setAlignment (int alignment) { + void setBackgroundColor (long /*int*/ context, long /*int*/ handle, GdkRGBA rgba) { + /* Note: this function is called on Gtk3 only */ + ++ background = rgba; + //Pre Gtk 3.10 doesn't handle CSS background color very well for Gtk Check/Radio button. + // 3.10.3 as it was the latest to affect themeing in button. + if (OS.GTK_VERSION < OS.VERSION(3, 10, 3) && (style & (SWT.CHECK | SWT.RADIO)) != 0) { +-- +cgit v0.11.2-4-g4a35 + + diff --git a/SOURCES/eclipse-change-build-packagings.patch b/SOURCES/eclipse-change-build-packagings.patch index 7b7beb3..62f62eb 100644 --- a/SOURCES/eclipse-change-build-packagings.patch +++ b/SOURCES/eclipse-change-build-packagings.patch @@ -1,23 +1,23 @@ --- eclipse.platform.releng/features/org.eclipse.sdk/feature.xml.orig 2014-04-08 15:47:19.927087084 +0100 +++ eclipse.platform.releng/features/org.eclipse.sdk/feature.xml 2014-04-08 15:48:00.045367311 +0100 -@@ -19,7 +19,7 @@ - %license - +@@ -59,7 +59,7 @@ + id="org.eclipse.help.source" + version="0.0.0"/> - + - - + +--- + .../Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk/OS.java | 1 + + .../Eclipse SWT/gtk/org/eclipse/swt/widgets/Scrollable.java | 3 +++ + 2 files changed, 4 insertions(+) + +diff --git a/eclipse.platform.swt/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk/OS.java b/eclipse.platform.swt/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk/OS.java +index fe8283d..cf8cda6 100644 +--- a/eclipse.platform.swt/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk/OS.java ++++ b/eclipse.platform.swt/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk/OS.java +@@ -363,6 +363,7 @@ public class OS extends C { + public static final int GTK_POLICY_ALWAYS = 0x0; + public static final int GTK_POLICY_AUTOMATIC = 0x1; + public static final int GTK_POLICY_NEVER = 0x2; ++ public static final int GTK_POLICY_EXTERNAL = 0x3; + public static final int GTK_POS_TOP = 0x2; + public static final int GTK_POS_BOTTOM = 0x3; + public static final int GTK_PRINT_CAPABILITY_PAGE_SET = 1 << 0; +diff --git a/eclipse.platform.swt/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Scrollable.java b/eclipse.platform.swt/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Scrollable.java +index 2d38a95..7295a27 100644 +--- a/eclipse.platform.swt/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Scrollable.java ++++ b/eclipse.platform.swt/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Scrollable.java +@@ -389,6 +389,9 @@ boolean setScrollBarVisible (ScrollBar bar, boolean visible) { + int [] hsp = new int [1], vsp = new int [1]; + OS.gtk_scrolled_window_get_policy (scrolledHandle, hsp, vsp); + int policy = visible ? OS.GTK_POLICY_ALWAYS : OS.GTK_POLICY_NEVER; ++ if (OS.GTK_VERSION >= OS.VERSION(3, 16, 0) && !visible) { ++ policy = OS.GTK_POLICY_EXTERNAL; ++ } + if ((bar.style & SWT.HORIZONTAL) != 0) { + if (hsp [0] == policy) return false; + hsp [0] = policy; +-- +cgit v0.11.2-4-g4a35 + diff --git a/SOURCES/eclipse-feature-plugins-to-category-ius.patch b/SOURCES/eclipse-feature-plugins-to-category-ius.patch index 561ae3f..6753c67 100644 --- a/SOURCES/eclipse-feature-plugins-to-category-ius.patch +++ b/SOURCES/eclipse-feature-plugins-to-category-ius.patch @@ -199,7 +199,7 @@ index c6d5da0..e76f33f 100644 + + + -+ ++ + + + @@ -385,7 +385,7 @@ index 6f6526b..c05d703 100644 + + + -+ ++ + + + diff --git a/SOURCES/eclipse-fix-ant-version.patch b/SOURCES/eclipse-fix-ant-version.patch index 11a2be3..d3986da 100644 --- a/SOURCES/eclipse-fix-ant-version.patch +++ b/SOURCES/eclipse-fix-ant-version.patch @@ -1,22 +1,29 @@ ---- ./eclipse.platform/ant/org.eclipse.ant.tests.core/tests/org/eclipse/ant/tests/core/tests/OptionTests.java.fix 2015-07-17 11:39:32.329451983 -0400 -+++ ./eclipse.platform/ant/org.eclipse.ant.tests.core/tests/org/eclipse/ant/tests/core/tests/OptionTests.java 2015-07-17 11:39:49.917684403 -0400 -@@ -26,7 +26,7 @@ public class OptionTests extends Abstrac - - protected static final String UNKNOWN_ARG = "Unknown argument: "; //$NON-NLS-1$ - protected static final String START_OF_HELP = "ant [options] [target [target2 [target3] ...]]"; //$NON-NLS-1$ -- protected static final String VERSION = "Apache Ant(TM) version 1.9.4"; //$NON-NLS-1$ -+ protected static final String VERSION = "Apache Ant(TM) version 1.9.2"; //$NON-NLS-1$ - protected static final String PLUGIN_VERSION = "org.apache.ant_1.9.4"; //$NON-NLS-1$ - - public OptionTests(String name) { --- ./eclipse.platform/ant/org.eclipse.ant.tests.ui/Ant Debug Tests/org/eclipse/ant/tests/ui/debug/PropertyTests.java.orig 2015-07-28 10:54:11.378383606 +0100 +++ ./eclipse.platform/ant/org.eclipse.ant.tests.ui/Ant Debug Tests/org/eclipse/ant/tests/ui/debug/PropertyTests.java 2015-07-28 10:53:08.509290691 +0100 @@ -24,7 +24,7 @@ public class PropertyTests extends AbstractAntDebugTest { -- private static final String ANT_VERSION = "Apache Ant(TM) version 1.9.4"; //$NON-NLS-1$ +- private static final String ANT_VERSION = "Apache Ant(TM) version 1.9.6"; //$NON-NLS-1$ + private static final String ANT_VERSION = "Apache Ant(TM) version 1.9.2"; //$NON-NLS-1$ public PropertyTests(String name) { super(name); +--- ./eclipse.platform/ant/org.eclipse.ant.tests.core/tests/org/eclipse/ant/tests/core/tests/OptionTests.java.orig 2016-02-28 14:27:56.000000000 +0000 ++++ ./eclipse.platform/ant/org.eclipse.ant.tests.core/tests/org/eclipse/ant/tests/core/tests/OptionTests.java 2016-03-24 09:58:22.543830386 +0000 +@@ -26,7 +26,7 @@ + + protected static final String UNKNOWN_ARG = "Unknown argument: "; //$NON-NLS-1$ + protected static final String START_OF_HELP = "ant [options] [target [target2 [target3] ...]]"; //$NON-NLS-1$ +- protected static final String VERSION = "Apache Ant(TM) version 1.9.6"; //$NON-NLS-1$ ++ protected static final String VERSION = "Apache Ant(TM) version 1.9.2"; //$NON-NLS-1$ + protected static final String PLUGIN_VERSION = "org.apache.ant_1.9.6"; //$NON-NLS-1$ + + public OptionTests(String name) { +@@ -671,4 +671,4 @@ + + assertTrue("The build should have failed", false); //$NON-NLS-1$ + } +-} +\ No newline at end of file ++} diff --git a/SOURCES/eclipse-fix-tests.patch b/SOURCES/eclipse-fix-tests.patch index 4b24a01..2c9066e 100644 --- a/SOURCES/eclipse-fix-tests.patch +++ b/SOURCES/eclipse-fix-tests.patch @@ -113,3 +113,130 @@ index bc8963d..fbe4da3 100644 +jars.compile.order = lib/apttestprocessors.jar,\ + lib/apttestprocessors8.jar,\ + . +--- eclipse.platform/ant/org.eclipse.ant.tests.ui/build.properties.orig 2016-03-24 14:25:47.076289150 +0000 ++++ eclipse.platform/ant/org.eclipse.ant.tests.ui/build.properties 2016-03-24 14:26:39.528660802 +0000 +@@ -25,6 +25,8 @@ + Ant Tests/ + + source.lib/antUITestsSupport.jar = test support/ +-jars.compile.order=anttestsui.jar,lib/antUITestsSupport.jar ++source.testbuildfiles/antUITestsSupport.jar = test support/ ++jars.compile.order=anttestsui.jar,lib/antUITestsSupport.jar,testbuildfiles/antUITestsSupport.jar + output.lib/antUITestsSupport.jar = test_support_bin/ ++output.testbuildfiles/antUITestsSupport.jar = test_support_bin/ + output.anttestsui.jar = bin/ +--- eclipse.jdt.ui/org.eclipse.jdt.ui.tests/build.properties.orig 2016-03-25 15:09:40.557786910 +0000 ++++ eclipse.jdt.ui/org.eclipse.jdt.ui.tests/build.properties 2016-03-25 15:12:08.476059326 +0000 +@@ -22,3 +22,5 @@ + leaks/,\ + performance/ + javacWarnings..=-raw,-unchecked ++source.testresources/nls.jar = nls/ ++jars.compile.order = .,testresources/nls.jar +--- /dev/null 1970-01-01 01:00:00.000000000 +0100 ++++ eclipse.jdt.ui/org.eclipse.jdt.ui.tests/nls/pkg/Client.java 2004-11-12 14:37:36.000000000 +0000 +@@ -0,0 +1,25 @@ ++/******************************************************************************* ++ * Copyright (c) 2000, 2004 IBM Corporation and others. ++ * All rights reserved. This program and the accompanying materials ++ * are made available under the terms of the Common Public License v1.0 ++ * which accompanies this distribution, and is available at ++ * http://www.eclipse.org/legal/cpl-v10.html ++ * ++ * Contributors: ++ * IBM Corporation - initial API and implementation ++ *******************************************************************************/ ++package pkg; ++ ++public class Client { ++ ++ public String s; ++ ++ { ++ s= Messages.getString("test"); ++ s= Messages.getString("test_undefined"); ++ s= Messages.getString("duplicate"); ++ s= Messages.getString("test.long.key"); ++ s= Messages.getString("SearchResultView.removed_resource"); ++ } ++ ++} +--- /dev/null 1970-01-01 01:00:00.000000000 +0100 ++++ eclipse.jdt.ui/org.eclipse.jdt.ui.tests/nls/pkg/Messages.java 2004-11-12 14:37:28.000000000 +0000 +@@ -0,0 +1,58 @@ ++/******************************************************************************* ++ * Copyright (c) 2000, 2004 IBM Corporation and others. ++ * All rights reserved. This program and the accompanying materials ++ * are made available under the terms of the Common Public License v1.0 ++ * which accompanies this distribution, and is available at ++ * http://www.eclipse.org/legal/cpl-v10.html ++ * ++ * Contributors: ++ * IBM Corporation - initial API and implementation ++ *******************************************************************************/ ++package pkg; ++ ++import java.text.MessageFormat; ++import java.util.MissingResourceException; ++import java.util.ResourceBundle; ++ ++public class Messages extends Object { ++ private static final String RESOURCE_BUNDLE = Messages.class.getName(); ++ private static ResourceBundle fgResourceBundle = ResourceBundle.getBundle(RESOURCE_BUNDLE); ++ ++ private Messages() {} ++ ++ /** ++ * Gets a string from the resource bundle and formats it with the argument ++ * ++ * @param key the string used to get the bundle value, must not be null ++ */ ++ public static String getFormattedString(String key, Object arg) { ++ String format = null; ++ ++ try { ++ format = fgResourceBundle.getString(key); ++ } catch (MissingResourceException e) { ++ return "!" + key + "!"; //$NON-NLS-2$ //$NON-NLS-1$ ++ } ++ ++ if (arg == null) { ++ arg = ""; //$NON-NLS-1$ ++ } ++ ++ return MessageFormat.format(format, new Object[] { arg }); ++ } ++ ++ /** ++ * Gets a string from the resource bundle and formats it with arguments ++ */ ++ public static String getFormattedString(String key, String[] args) { ++ return MessageFormat.format(fgResourceBundle.getString(key), args); ++ } ++ ++ public static String getString(String key) { ++ try { ++ return fgResourceBundle.getString(key); ++ } catch (MissingResourceException e) { ++ return "!" + key + "!"; //$NON-NLS-2$ //$NON-NLS-1$ ++ } ++ } ++} +--- /dev/null 1970-01-01 01:00:00.000000000 +0100 ++++ eclipse.jdt.ui/org.eclipse.jdt.ui.tests/nls/pkg/Messages.properties 2004-11-12 14:38:06.000000000 +0000 +@@ -0,0 +1,15 @@ ++############################################################################### ++# Copyright (c) 2000, 2004 IBM Corporation and others. ++# All rights reserved. This program and the accompanying materials ++# are made available under the terms of the Common Public License v1.0 ++# which accompanies this distribution, and is available at ++# http://www.eclipse.org/legal/cpl-v10.html ++# ++# Contributors: ++# IBM Corporation - initial API and implementation ++############################################################################### ++test= Hello World ++duplicate= Duplicate 1 ++test.long.key= Hello World Long ++duplicate= Duplicate 2 ++SearchResultView.removed_resource= diff --git a/SOURCES/eclipse-lucene-4.patch b/SOURCES/eclipse-lucene-4.patch deleted file mode 100644 index e8de4ca..0000000 --- a/SOURCES/eclipse-lucene-4.patch +++ /dev/null @@ -1,502 +0,0 @@ -From f93bcfb45708895f90396552677f11881f342dc9 Mon Sep 17 00:00:00 2001 -From: Mat Booth -Date: Wed, 4 Mar 2015 15:10:27 +0000 -Subject: [PATCH] Port to Lucene 4. - ---- - org.eclipse.help.base/META-INF/MANIFEST.MF | 4 +- - .../eclipse/help/internal/search/Analyzer_en.java | 27 +++++--- - .../help/internal/search/DefaultAnalyzer.java | 13 ++-- - .../search/LowerCaseAndDigitsTokenizer.java | 7 +- - .../eclipse/help/internal/search/QueryBuilder.java | 15 +++- - .../eclipse/help/internal/search/SearchIndex.java | 81 ++++++++++------------ - .../help/internal/search/SmartAnalyzer.java | 14 ++-- - .../help/internal/search/WordTokenStream.java | 2 + - org.eclipse.ua.tests/META-INF/MANIFEST.MF | 7 +- - .../help/search/PrebuiltIndexCompatibility.java | 6 +- - 10 files changed, 94 insertions(+), 82 deletions(-) - -diff --git a/eclipse.platform.ua/org.eclipse.help.base/META-INF/MANIFEST.MF b/eclipse.platform.ua/org.eclipse.help.base/META-INF/MANIFEST.MF -index ee34c8e..fdef3e6 100644 ---- a/eclipse.platform.ua/org.eclipse.help.base/META-INF/MANIFEST.MF -+++ b/eclipse.platform.ua/org.eclipse.help.base/META-INF/MANIFEST.MF -@@ -43,8 +43,8 @@ Require-Bundle: org.eclipse.ant.core;bundle-version="3.2.200";resolution:=option - org.eclipse.core.runtime;bundle-version="[3.11.0,4.0.0)", - org.eclipse.help;bundle-version="[3.5.0,4.0.0)";visibility:=reexport, - org.eclipse.core.expressions;bundle-version="[3.4.200,4.0.0)", -- org.apache.lucene.analysis;bundle-version="[3.5.0,4.0.0)", -- org.apache.lucene.core;bundle-version="[3.5.0,4.0.0)", -+ org.apache.lucene.analysis;bundle-version="[4.7.0,5.0.0)", -+ org.apache.lucene.core;bundle-version="[4.7.0,5.0.0)", - org.eclipse.core.net;bundle-version="1.2.200" - Import-Package: com.ibm.icu.text, - org.eclipse.equinox.http.jetty;resolution:=optional -diff --git a/eclipse.platform.ua/org.eclipse.help.base/src/org/eclipse/help/internal/search/Analyzer_en.java b/eclipse.platform.ua/org.eclipse.help.base/src/org/eclipse/help/internal/search/Analyzer_en.java -index a066aa4..6c41103 100644 ---- a/eclipse.platform.ua/org.eclipse.help.base/src/org/eclipse/help/internal/search/Analyzer_en.java -+++ b/eclipse.platform.ua/org.eclipse.help.base/src/org/eclipse/help/internal/search/Analyzer_en.java -@@ -11,10 +11,15 @@ - *******************************************************************************/ - package org.eclipse.help.internal.search; - import java.io.*; --import java.util.HashSet; --import java.util.Set; -+import java.util.ArrayList; -+import java.util.List; - --import org.apache.lucene.analysis.*; -+import org.apache.lucene.analysis.Analyzer; -+import org.apache.lucene.analysis.TokenStream; -+import org.apache.lucene.analysis.Tokenizer; -+import org.apache.lucene.analysis.core.StopFilter; -+import org.apache.lucene.analysis.en.PorterStemFilter; -+import org.apache.lucene.analysis.util.CharArraySet; - import org.apache.lucene.util.Version; - /** - * Lucene Analyzer for English. LowerCaseTokenizer->StopFilter->PorterStemFilter -@@ -27,18 +32,22 @@ public final class Analyzer_en extends Analyzer { - super(); - } - /** -- * Creates a TokenStream which tokenizes all the text in the provided -+ * Creates a TokenStreamComponents which tokenizes all the text in the provided - * Reader. - */ -- public final TokenStream tokenStream(String fieldName, Reader reader) { -- return new PorterStemFilter(new StopFilter(Version.LUCENE_30, new LowerCaseAndDigitsTokenizer(reader), getStopWords(), false)); -+ @Override -+ public final TokenStreamComponents createComponents(String fieldName, Reader reader) { -+ CharArraySet stopWordsSet = StopFilter.makeStopSet(Version.LUCENE_47, getStopWords(), true); -+ Tokenizer source = new LowerCaseAndDigitsTokenizer(reader); -+ TokenStream filter = new PorterStemFilter(new StopFilter(Version.LUCENE_47, source, stopWordsSet)); -+ return new TokenStreamComponents(source, filter); - } - -- private Set stopWords; -+ private List stopWords; - -- private Set getStopWords() { -+ private List getStopWords() { - if ( stopWords == null ) { -- stopWords = new HashSet(); -+ stopWords = new ArrayList(); - for (int i = 0; i < STOP_WORDS.length; i++) { - stopWords.add(STOP_WORDS[i]); - } -diff --git a/eclipse.platform.ua/org.eclipse.help.base/src/org/eclipse/help/internal/search/DefaultAnalyzer.java b/eclipse.platform.ua/org.eclipse.help.base/src/org/eclipse/help/internal/search/DefaultAnalyzer.java -index 4109474..2718307 100644 ---- a/eclipse.platform.ua/org.eclipse.help.base/src/org/eclipse/help/internal/search/DefaultAnalyzer.java -+++ b/eclipse.platform.ua/org.eclipse.help.base/src/org/eclipse/help/internal/search/DefaultAnalyzer.java -@@ -17,8 +17,8 @@ import java.util.StringTokenizer; - import com.ibm.icu.text.BreakIterator; - - import org.apache.lucene.analysis.Analyzer; --import org.apache.lucene.analysis.LowerCaseFilter; --import org.apache.lucene.analysis.TokenStream; -+import org.apache.lucene.analysis.Tokenizer; -+import org.apache.lucene.analysis.core.LowerCaseFilter; - import org.apache.lucene.util.Version; - import org.eclipse.help.internal.base.HelpBasePlugin; - -@@ -84,11 +84,14 @@ public final class DefaultAnalyzer extends Analyzer { - } - - /** -- * Creates a TokenStream which tokenizes all the text in the provided -+ * Creates a TokenStreamComponents which tokenizes all the text in the provided - * Reader. - */ -- public final TokenStream tokenStream(String fieldName, Reader reader) { -- return new LowerCaseFilter(Version.LUCENE_30, new WordTokenStream(fieldName, reader, locale)); -+ @Override -+ public final TokenStreamComponents createComponents(String fieldName, Reader reader) { -+ Tokenizer source = new WordTokenStream(fieldName, reader, locale); -+ LowerCaseFilter filter = new LowerCaseFilter(Version.LUCENE_47, source); -+ return new TokenStreamComponents(source, filter); - } - - /** -diff --git a/eclipse.platform.ua/org.eclipse.help.base/src/org/eclipse/help/internal/search/LowerCaseAndDigitsTokenizer.java b/eclipse.platform.ua/org.eclipse.help.base/src/org/eclipse/help/internal/search/LowerCaseAndDigitsTokenizer.java -index a475688..91e3cb4 100644 ---- a/eclipse.platform.ua/org.eclipse.help.base/src/org/eclipse/help/internal/search/LowerCaseAndDigitsTokenizer.java -+++ b/eclipse.platform.ua/org.eclipse.help.base/src/org/eclipse/help/internal/search/LowerCaseAndDigitsTokenizer.java -@@ -13,7 +13,7 @@ package org.eclipse.help.internal.search; - - import java.io.*; - --import org.apache.lucene.analysis.*; -+import org.apache.lucene.analysis.util.CharTokenizer; - import org.apache.lucene.util.Version; - - /** -@@ -22,13 +22,14 @@ import org.apache.lucene.util.Version; - public class LowerCaseAndDigitsTokenizer extends CharTokenizer { - - public LowerCaseAndDigitsTokenizer(Reader input) { -- super(Version.LUCENE_30, input); -+ super(Version.LUCENE_47, input); - } - protected char normalize(char c) { - return Character.toLowerCase(c); - } - -- protected boolean isTokenChar(char c) { -+ @Override -+ public boolean isTokenChar(int c) { - return Character.isLetterOrDigit(c); - } - -diff --git a/eclipse.platform.ua/org.eclipse.help.base/src/org/eclipse/help/internal/search/QueryBuilder.java b/eclipse.platform.ua/org.eclipse.help.base/src/org/eclipse/help/internal/search/QueryBuilder.java -index 9cc690e..6449adb 100644 ---- a/eclipse.platform.ua/org.eclipse.help.base/src/org/eclipse/help/internal/search/QueryBuilder.java -+++ b/eclipse.platform.ua/org.eclipse.help.base/src/org/eclipse/help/internal/search/QueryBuilder.java -@@ -243,16 +243,25 @@ public class QueryBuilder { - private List analyzeText(Analyzer analyzer, String fieldName, String text) { - List words = new ArrayList(1); - Reader reader = new StringReader(text); -- TokenStream tStream = analyzer.tokenStream(fieldName, reader); - -- CharTermAttribute termAttribute = tStream.getAttribute(CharTermAttribute.class); -+ TokenStream tStream = null; - try { -+ tStream = analyzer.tokenStream(fieldName, reader); -+ tStream.reset(); -+ CharTermAttribute termAttribute = (CharTermAttribute) tStream -+ .getAttribute(CharTermAttribute.class); - while (tStream.incrementToken()) { - String term = termAttribute.toString(); - words.add(term); - } -- reader.close(); - } catch (IOException ioe) { -+ } finally { -+ if (tStream != null) { -+ try { -+ tStream.close(); -+ } catch (IOException e) { -+ } -+ } - } - - return words; -diff --git a/eclipse.platform.ua/org.eclipse.help.base/src/org/eclipse/help/internal/search/SearchIndex.java b/eclipse.platform.ua/org.eclipse.help.base/src/org/eclipse/help/internal/search/SearchIndex.java -index 33c9476..5a46fe5 100644 ---- a/eclipse.platform.ua/org.eclipse.help.base/src/org/eclipse/help/internal/search/SearchIndex.java -+++ b/eclipse.platform.ua/org.eclipse.help.base/src/org/eclipse/help/internal/search/SearchIndex.java -@@ -33,17 +33,20 @@ import java.util.Set; - import java.util.zip.ZipEntry; - import java.util.zip.ZipInputStream; - --import org.apache.lucene.analysis.LimitTokenCountAnalyzer; -+import org.apache.lucene.analysis.miscellaneous.LimitTokenCountAnalyzer; - import org.apache.lucene.document.Document; - import org.apache.lucene.document.Field; -+import org.apache.lucene.index.AtomicReader; -+import org.apache.lucene.index.DirectoryReader; -+import org.apache.lucene.index.DocsEnum; - import org.apache.lucene.index.IndexReader; - import org.apache.lucene.index.IndexWriter; --import org.apache.lucene.index.Term; --import org.apache.lucene.index.TermDocs; - import org.apache.lucene.index.IndexWriterConfig.OpenMode; - import org.apache.lucene.index.IndexWriterConfig; - import org.apache.lucene.index.LogByteSizeMergePolicy; - import org.apache.lucene.index.LogMergePolicy; -+import org.apache.lucene.index.SlowCompositeReaderWrapper; -+import org.apache.lucene.index.Term; - import org.apache.lucene.search.BooleanQuery; - import org.apache.lucene.search.IndexSearcher; - import org.apache.lucene.search.Query; -@@ -283,7 +286,7 @@ public class SearchIndex implements IHelpSearchIndex { - indexedDocs.restore(); - setInconsistent(true); - LimitTokenCountAnalyzer analyzer = new LimitTokenCountAnalyzer(analyzerDescriptor.getAnalyzer(), 1000000); -- IndexWriterConfig writerConfig = new IndexWriterConfig(org.apache.lucene.util.Version.LUCENE_31, analyzer); -+ IndexWriterConfig writerConfig = new IndexWriterConfig(org.apache.lucene.util.Version.LUCENE_47, analyzer); - writerConfig.setOpenMode(create ? OpenMode.CREATE : OpenMode.APPEND); - LogMergePolicy mergePolicy = new LogByteSizeMergePolicy(); - mergePolicy.setMergeFactor(20); -@@ -307,7 +310,7 @@ public class SearchIndex implements IHelpSearchIndex { - indexedDocs = new HelpProperties(INDEXED_DOCS_FILE, indexDir); - indexedDocs.restore(); - setInconsistent(true); -- ir = IndexReader.open(luceneDirectory, false); -+ ir = DirectoryReader.open(luceneDirectory); - return true; - } catch (IOException e) { - HelpBasePlugin.logError("Exception occurred in search indexing at beginDeleteBatch.", e); //$NON-NLS-1$ -@@ -323,7 +326,7 @@ public class SearchIndex implements IHelpSearchIndex { - if (ir != null) { - ir.close(); - } -- ir = IndexReader.open(luceneDirectory, false); -+ ir = DirectoryReader.open(luceneDirectory); - return true; - } catch (IOException e) { - HelpBasePlugin.logError("Exception occurred in search indexing at beginDeleteBatch.", e); //$NON-NLS-1$ -@@ -341,7 +344,7 @@ public class SearchIndex implements IHelpSearchIndex { - public IStatus removeDocument(String name) { - Term term = new Term(FIELD_NAME, name); - try { -- ir.deleteDocuments(term); -+ iw.deleteDocuments(term); - indexedDocs.remove(name); - } catch (IOException e) { - return new Status(IStatus.ERROR, HelpBasePlugin.PLUGIN_ID, IStatus.ERROR, -@@ -379,7 +382,7 @@ public class SearchIndex implements IHelpSearchIndex { - * know about this change. Close it so that it gets reloaded next search. - */ - if (searcher != null) { -- searcher.close(); -+ searcher.getIndexReader().close(); - searcher = null; - } - return true; -@@ -411,7 +414,7 @@ public class SearchIndex implements IHelpSearchIndex { - * know about this change. Close it so that it gets reloaded next search. - */ - if (searcher != null) { -- searcher.close(); -+ searcher.getIndexReader().close(); - searcher = null; - } - return true; -@@ -525,18 +528,19 @@ public class SearchIndex implements IHelpSearchIndex { - } - - public IStatus removeDuplicates(String name, String[] index_paths) { -- TermDocs hrefDocs = null; -- TermDocs indexDocs = null; -- Term hrefTerm = new Term(FIELD_NAME, name); - try { -+ AtomicReader ar = SlowCompositeReaderWrapper.wrap(ir); -+ DocsEnum hrefDocs = null; -+ DocsEnum indexDocs = null; -+ Term hrefTerm = new Term(FIELD_NAME, name); - for (int i = 0; i < index_paths.length; i++) { - Term indexTerm = new Term(FIELD_INDEX_ID, index_paths[i]); - if (i == 0) { -- hrefDocs = ir.termDocs(hrefTerm); -- indexDocs = ir.termDocs(indexTerm); -+ hrefDocs = ar.termDocsEnum(hrefTerm); -+ indexDocs = ar.termDocsEnum(indexTerm); - } else { -- hrefDocs.seek(hrefTerm); -- indexDocs.seek(indexTerm); -+ hrefDocs = ar.termDocsEnum(hrefTerm); -+ indexDocs = ar.termDocsEnum(indexTerm); - } - removeDocuments(hrefDocs, indexDocs); - } -@@ -545,19 +549,6 @@ public class SearchIndex implements IHelpSearchIndex { - "IO exception occurred while removing duplicates of document " + name //$NON-NLS-1$ - + " from index " + indexDir.getAbsolutePath() + ".", //$NON-NLS-1$ //$NON-NLS-2$ - ioe); -- } finally { -- if (hrefDocs != null) { -- try { -- hrefDocs.close(); -- } catch (IOException e) { -- } -- } -- if (indexDocs != null) { -- try { -- indexDocs.close(); -- } catch (IOException e) { -- } -- } - } - return Status.OK_STATUS; - } -@@ -569,33 +560,33 @@ public class SearchIndex implements IHelpSearchIndex { - * @param docs2 - * @throws IOException - */ -- private void removeDocuments(TermDocs doc1, TermDocs docs2) throws IOException { -- if (!doc1.next()) { -+ private void removeDocuments(DocsEnum doc1, DocsEnum docs2) throws IOException { -+ if (doc1.nextDoc() == DocsEnum.NO_MORE_DOCS) { - return; - } -- if (!docs2.next()) { -+ if (docs2.nextDoc() == DocsEnum.NO_MORE_DOCS) { - return; - } - while (true) { -- if (doc1.doc() < docs2.doc()) { -- if (!doc1.skipTo(docs2.doc())) { -- if (!doc1.next()) { -+ if (doc1.docID() < docs2.docID()) { -+ if (doc1.advance(docs2.docID()) == DocsEnum.NO_MORE_DOCS) { -+ if (doc1.nextDoc() == DocsEnum.NO_MORE_DOCS) { - return; - } - } -- } else if (doc1.doc() > docs2.doc()) { -- if (!docs2.skipTo(doc1.doc())) { -- if (!doc1.next()) { -+ } else if (doc1.docID() > docs2.docID()) { -+ if (docs2.advance(doc1.docID()) == DocsEnum.NO_MORE_DOCS) { -+ if (doc1.nextDoc() == DocsEnum.NO_MORE_DOCS) { - return; - } - } - } -- if (doc1.doc() == docs2.doc()) { -- ir.deleteDocument(doc1.doc()); -- if (!doc1.next()) { -+ if (doc1.docID() == docs2.docID()) { -+ iw.tryDeleteDocument(ir, doc1.docID()); -+ if (doc1.nextDoc() == DocsEnum.NO_MORE_DOCS) { - return; - } -- if (!docs2.next()) { -+ if (docs2.nextDoc() == DocsEnum.NO_MORE_DOCS) { - return; - } - } -@@ -802,7 +793,7 @@ public class SearchIndex implements IHelpSearchIndex { - public void openSearcher() throws IOException { - synchronized (searcherCreateLock) { - if (searcher == null) { -- searcher = new IndexSearcher(IndexReader.open(luceneDirectory, false)); -+ searcher = new IndexSearcher(DirectoryReader.open(luceneDirectory)); - } - } - } -@@ -820,7 +811,7 @@ public class SearchIndex implements IHelpSearchIndex { - if (searches.isEmpty()) { - if (searcher != null) { - try { -- searcher.close(); -+ searcher.getIndexReader().close(); - } catch (IOException ioe) { - } - } -@@ -903,7 +894,7 @@ public class SearchIndex implements IHelpSearchIndex { - IndexWriter cleaner = null; - LimitTokenCountAnalyzer analyzer = new LimitTokenCountAnalyzer(analyzerDescriptor.getAnalyzer(), 10000); - try { -- cleaner = new IndexWriter(luceneDirectory, new IndexWriterConfig(org.apache.lucene.util.Version.LUCENE_31, analyzer).setOpenMode( -+ cleaner = new IndexWriter(luceneDirectory, new IndexWriterConfig(org.apache.lucene.util.Version.LUCENE_47, analyzer).setOpenMode( - OpenMode.CREATE)); - } catch (IOException ioe) { - } finally { -diff --git a/eclipse.platform.ua/org.eclipse.help.base/src/org/eclipse/help/internal/search/SmartAnalyzer.java b/eclipse.platform.ua/org.eclipse.help.base/src/org/eclipse/help/internal/search/SmartAnalyzer.java -index d0a7bb7..1b20d3b 100644 ---- a/eclipse.platform.ua/org.eclipse.help.base/src/org/eclipse/help/internal/search/SmartAnalyzer.java -+++ b/eclipse.platform.ua/org.eclipse.help.base/src/org/eclipse/help/internal/search/SmartAnalyzer.java -@@ -10,15 +10,13 @@ - *******************************************************************************/ - package org.eclipse.help.internal.search; - --import java.io.*; -- - import org.apache.lucene.analysis.*; - - /** - * Smart Analyzer. Chooses underlying implementation based on the field which - * text is analyzed. - */ --public final class SmartAnalyzer extends Analyzer { -+public final class SmartAnalyzer extends AnalyzerWrapper { - Analyzer pluggedInAnalyzer; - Analyzer exactAnalyzer; - -@@ -31,14 +29,14 @@ public final class SmartAnalyzer extends Analyzer { - this.exactAnalyzer = new DefaultAnalyzer(locale); - } - /** -- * Creates a TokenStream which tokenizes all the text in the provided -- * Reader. Delegates to DefaultAnalyzer when field used to search for exact -+ * Delegates to DefaultAnalyzer when field used to search for exact - * match, and to plugged-in analyzer for other fields. - */ -- public final TokenStream tokenStream(String fieldName, Reader reader) { -+ @Override -+ public final Analyzer getWrappedAnalyzer(String fieldName) { - if (fieldName != null && fieldName.startsWith("exact_")) { //$NON-NLS-1$ -- return exactAnalyzer.tokenStream(fieldName, reader); -+ return exactAnalyzer; - } -- return pluggedInAnalyzer.tokenStream(fieldName, reader); -+ return pluggedInAnalyzer; - } - } -diff --git a/eclipse.platform.ua/org.eclipse.help.base/src/org/eclipse/help/internal/search/WordTokenStream.java b/eclipse.platform.ua/org.eclipse.help.base/src/org/eclipse/help/internal/search/WordTokenStream.java -index 0b70cf7..106775a 100644 ---- a/eclipse.platform.ua/org.eclipse.help.base/src/org/eclipse/help/internal/search/WordTokenStream.java -+++ b/eclipse.platform.ua/org.eclipse.help.base/src/org/eclipse/help/internal/search/WordTokenStream.java -@@ -35,6 +35,7 @@ public final class WordTokenStream extends Tokenizer { - * Constructor - */ - public WordTokenStream(String fieldName, Reader reader, Locale locale) { -+ super(reader); - this.reader = reader; - boundary = BreakIterator.getWordInstance(locale); - -@@ -105,6 +106,7 @@ public final class WordTokenStream extends Tokenizer { - } - - public void close() throws IOException { -+ super.close(); - /// Unlikely to be called as this is a reused - if (this.reader != null) { - this.reader.close(); -diff --git a/eclipse.platform.ua/org.eclipse.ua.tests/META-INF/MANIFEST.MF b/eclipse.platform.ua/org.eclipse.ua.tests/META-INF/MANIFEST.MF -index a8177c3..cd99e8a 100644 ---- a/eclipse.platform.ua/org.eclipse.ua.tests/META-INF/MANIFEST.MF -+++ b/eclipse.platform.ua/org.eclipse.ua.tests/META-INF/MANIFEST.MF -@@ -18,15 +18,14 @@ - org.eclipse.ui.intro.universal, - org.eclipse.ui.forms, - org.eclipse.ui.browser;bundle-version="3.2.300", -+ org.apache.lucene.analysis;bundle-version="[4.7.0,5.0.0)", -+ org.apache.lucene.core;bundle-version="[4.7.0,5.0.0)", - org.eclipse.equinox.jsp.jasper;bundle-version="1.0.200", - org.eclipse.equinox.jsp.jasper.registry;bundle-version="1.0.100" - Bundle-ActivationPolicy: lazy - Bundle-Vendor: Eclipse.org - Import-Package: javax.servlet;version="3.1.0", -- javax.servlet.http;version="3.1.0", -- org.apache.lucene.index;core=split;version="[3.5.0,4.0.0)", -- org.apache.lucene.search;core=split;version="[3.5.0,4.0.0)", -- org.apache.lucene.store;core=split;version="[3.5.0,4.0.0)" -+ javax.servlet.http;version="3.1.0" - Bundle-RequiredExecutionEnvironment: JavaSE-1.6 - Export-Package: org.eclipse.ua.tests, - org.eclipse.ua.tests.browser, -diff --git a/eclipse.platform.ua/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/search/PrebuiltIndexCompatibility.java b/eclipse.platform.ua/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/search/PrebuiltIndexCompatibility.java -index 640d4c9..8924fa7 100644 ---- a/eclipse.platform.ua/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/search/PrebuiltIndexCompatibility.java -+++ b/eclipse.platform.ua/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/search/PrebuiltIndexCompatibility.java -@@ -24,7 +24,7 @@ import junit.framework.TestSuite; - import org.osgi.framework.Bundle; - - import org.apache.lucene.index.CorruptIndexException; --import org.apache.lucene.index.IndexReader; -+import org.apache.lucene.index.DirectoryReader; - import org.apache.lucene.search.IndexSearcher; - import org.apache.lucene.search.Query; - import org.apache.lucene.search.TopDocs; -@@ -157,7 +157,7 @@ public class PrebuiltIndexCompatibility extends TestCase { - IndexSearcher searcher = null; - try { - luceneDirectory = new NIOFSDirectory(new File(filePath)); -- searcher = new IndexSearcher(IndexReader.open(luceneDirectory, true)); -+ searcher = new IndexSearcher(DirectoryReader.open(luceneDirectory)); - TopDocs hits = searcher.search(luceneQuery, 500); - assertEquals(hits.totalHits, 1); - } finally { -@@ -167,7 +167,7 @@ public class PrebuiltIndexCompatibility extends TestCase { - } catch (IOException x) { - } - if (searcher != null) -- searcher.close(); -+ searcher.getIndexReader().close(); - } - } else { - fail("Cannot resolve to file protocol"); --- -2.1.0 - diff --git a/SOURCES/eclipse-lucene-5.patch b/SOURCES/eclipse-lucene-5.patch new file mode 100644 index 0000000..1a5d281 --- /dev/null +++ b/SOURCES/eclipse-lucene-5.patch @@ -0,0 +1,2263 @@ +From e9b5adb1d0477a50111afe5cf7736c542b7e4998 Mon Sep 17 00:00:00 2001 +From: Sopot Cela +Date: Thu, 21 May 2015 13:48:41 +0200 +Subject: [PATCH] Bug 466829 - Upgrade platform.ua to Lucene 5.1.0 + +Change-Id: I882188205c2c1e2cc1106108680dd4e94570a975 +Signed-off-by: Sopot Cela +--- + +diff --git a/eclipse.platform.ua/org.eclipse.help.base/.settings/org.eclipse.jdt.core.prefs b/org.eclipse.help.base/.settings/org.eclipse.jdt.core.prefs +index 34d2b77..07713d8 100644 +--- a/eclipse.platform.ua/org.eclipse.help.base/.settings/org.eclipse.jdt.core.prefs ++++ b/eclipse.platform.ua/org.eclipse.help.base/.settings/org.eclipse.jdt.core.prefs +@@ -7,9 +7,9 @@ + org.eclipse.jdt.core.compiler.annotation.nullanalysis=disabled + org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled + org.eclipse.jdt.core.compiler.codegen.methodParameters=do not generate +-org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5 ++org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7 + org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +-org.eclipse.jdt.core.compiler.compliance=1.5 ++org.eclipse.jdt.core.compiler.compliance=1.7 + org.eclipse.jdt.core.compiler.debug.lineNumber=generate + org.eclipse.jdt.core.compiler.debug.localVariable=generate + org.eclipse.jdt.core.compiler.debug.sourceFile=generate +@@ -98,7 +98,7 @@ + org.eclipse.jdt.core.compiler.problem.unusedTypeParameter=ignore + org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning + org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning +-org.eclipse.jdt.core.compiler.source=1.5 ++org.eclipse.jdt.core.compiler.source=1.7 + org.eclipse.jdt.core.formatter.align_type_members_on_columns=false + org.eclipse.jdt.core.formatter.alignment_for_arguments_in_allocation_expression=16 + org.eclipse.jdt.core.formatter.alignment_for_arguments_in_enum_constant=16 +diff --git a/eclipse.platform.ua/org.eclipse.help.base/META-INF/MANIFEST.MF b/org.eclipse.help.base/META-INF/MANIFEST.MF +index ee34c8e..e4bd703 100644 +--- a/eclipse.platform.ua/org.eclipse.help.base/META-INF/MANIFEST.MF ++++ b/eclipse.platform.ua/org.eclipse.help.base/META-INF/MANIFEST.MF +@@ -43,9 +43,11 @@ + org.eclipse.core.runtime;bundle-version="[3.11.0,4.0.0)", + org.eclipse.help;bundle-version="[3.5.0,4.0.0)";visibility:=reexport, + org.eclipse.core.expressions;bundle-version="[3.4.200,4.0.0)", +- org.apache.lucene.analysis;bundle-version="[3.5.0,4.0.0)", +- org.apache.lucene.core;bundle-version="[3.5.0,4.0.0)", +- org.eclipse.core.net;bundle-version="1.2.200" ++ org.eclipse.core.net;bundle-version="1.2.200", ++ org.apache.lucene.analyzers-common;bundle-version="5.1.0", ++ org.apache.lucene.core;bundle-version="5.1.0", ++ org.apache.lucene.queryparser;bundle-version="5.1.0", ++ org.apache.lucene.analyzers-smartcn;bundle-version="5.1.0" + Import-Package: com.ibm.icu.text, + org.eclipse.equinox.http.jetty;resolution:=optional + Bundle-RequiredExecutionEnvironment: J2SE-1.5 +diff --git a/eclipse.platform.ua/org.eclipse.help.base/plugin.xml b/org.eclipse.help.base/plugin.xml +index 07a5a22..4daf3f0 100644 +--- a/eclipse.platform.ua/org.eclipse.help.base/plugin.xml ++++ b/eclipse.platform.ua/org.eclipse.help.base/plugin.xml +@@ -83,7 +83,7 @@ + + ++ class="org.apache.lucene.analysis.cn.smart.SmartChineseAnalyzer"> + + StopFilter->PorterStemFilter + */ + public final class Analyzer_en extends Analyzer { ++ + /** + * Constructor for Analyzer_en. + */ +@@ -27,18 +34,25 @@ + super(); + } + /** +- * Creates a TokenStream which tokenizes all the text in the provided ++ * Creates a TokenStreamComponents which tokenizes all the text in the provided + * Reader. + */ +- public final TokenStream tokenStream(String fieldName, Reader reader) { +- return new PorterStemFilter(new StopFilter(Version.LUCENE_30, new LowerCaseAndDigitsTokenizer(reader), getStopWords(), false)); ++ @Override ++ public final TokenStreamComponents createComponents(String fieldName) { ++ final Tokenizer source; ++ source = new LowerCaseAndDigitsTokenizer(); ++ TokenStream result = new EnglishPossessiveFilter(source); ++ result = new StopFilter(result, new CharArraySet(getStopWords(), false)); ++ result = new KeywordRepeatFilter(result); ++ result = new PorterStemFilter(result); ++ return new TokenStreamComponents(source, result); + } + +- private Set stopWords; ++ private List stopWords; + +- private Set getStopWords() { ++ private List getStopWords() { + if ( stopWords == null ) { +- stopWords = new HashSet(); ++ stopWords = new ArrayList(); + for (int i = 0; i < STOP_WORDS.length; i++) { + stopWords.add(STOP_WORDS[i]); + } +diff --git a/eclipse.platform.ua/org.eclipse.help.base/src/org/eclipse/help/internal/search/DefaultAnalyzer.java b/org.eclipse.help.base/src/org/eclipse/help/internal/search/DefaultAnalyzer.java +index 4109474..e3c8722 100644 +--- a/eclipse.platform.ua/org.eclipse.help.base/src/org/eclipse/help/internal/search/DefaultAnalyzer.java ++++ b/eclipse.platform.ua/org.eclipse.help.base/src/org/eclipse/help/internal/search/DefaultAnalyzer.java +@@ -7,22 +7,20 @@ + * Contributors: + * IBM Corporation - initial API and implementation + * Alexander Kurtakov - Bug 460787 ++ * Sopot Cela - Bug 466829 - Migration to Lucene 5 + *******************************************************************************/ + package org.eclipse.help.internal.search; + +-import java.io.Reader; + import java.util.Locale; + import java.util.StringTokenizer; + +-import com.ibm.icu.text.BreakIterator; +- + import org.apache.lucene.analysis.Analyzer; +-import org.apache.lucene.analysis.LowerCaseFilter; +-import org.apache.lucene.analysis.TokenStream; +-import org.apache.lucene.util.Version; ++import org.apache.lucene.analysis.Tokenizer; ++import org.apache.lucene.analysis.core.LowerCaseFilter; ++import org.eclipse.core.runtime.Platform; + import org.eclipse.help.internal.base.HelpBasePlugin; + +-import org.eclipse.core.runtime.Platform; ++import com.ibm.icu.text.BreakIterator; + + + /** +@@ -84,11 +82,14 @@ + } + + /** +- * Creates a TokenStream which tokenizes all the text in the provided ++ * Creates a TokenStreamComponents which tokenizes all the text in the provided + * Reader. + */ +- public final TokenStream tokenStream(String fieldName, Reader reader) { +- return new LowerCaseFilter(Version.LUCENE_30, new WordTokenStream(fieldName, reader, locale)); ++ @Override ++ public final TokenStreamComponents createComponents(String fieldName) { ++ Tokenizer source = new WordTokenStream(locale); ++ LowerCaseFilter filter = new LowerCaseFilter(source); ++ return new TokenStreamComponents(source, filter); + } + + /** +diff --git a/eclipse.platform.ua/org.eclipse.help.base/src/org/eclipse/help/internal/search/LowerCaseAndDigitsTokenizer.java b/org.eclipse.help.base/src/org/eclipse/help/internal/search/LowerCaseAndDigitsTokenizer.java +index a475688..cbb2472 100644 +--- a/eclipse.platform.ua/org.eclipse.help.base/src/org/eclipse/help/internal/search/LowerCaseAndDigitsTokenizer.java ++++ b/eclipse.platform.ua/org.eclipse.help.base/src/org/eclipse/help/internal/search/LowerCaseAndDigitsTokenizer.java +@@ -8,27 +8,26 @@ + * Contributors: + * IBM Corporation - initial API and implementation + * Alexander Kurtakov - Bug 460787 ++ * Sopot Cela - Bug 466829 - Migration to Lucene 5 + *******************************************************************************/ + package org.eclipse.help.internal.search; + +-import java.io.*; +- +-import org.apache.lucene.analysis.*; +-import org.apache.lucene.util.Version; ++import org.apache.lucene.analysis.util.CharTokenizer; + + /** + * Tokenizer breaking words around letters or digits. + */ + public class LowerCaseAndDigitsTokenizer extends CharTokenizer { + +- public LowerCaseAndDigitsTokenizer(Reader input) { +- super(Version.LUCENE_30, input); ++ public LowerCaseAndDigitsTokenizer() { ++ super(); + } + protected char normalize(char c) { + return Character.toLowerCase(c); + } + +- protected boolean isTokenChar(char c) { ++ @Override ++ public boolean isTokenChar(int c) { + return Character.isLetterOrDigit(c); + } + +diff --git a/eclipse.platform.ua/org.eclipse.help.base/src/org/eclipse/help/internal/search/LuceneSearchDocument.java b/org.eclipse.help.base/src/org/eclipse/help/internal/search/LuceneSearchDocument.java +index 60a545d..804bf5e 100644 +--- a/eclipse.platform.ua/org.eclipse.help.base/src/org/eclipse/help/internal/search/LuceneSearchDocument.java ++++ b/eclipse.platform.ua/org.eclipse.help.base/src/org/eclipse/help/internal/search/LuceneSearchDocument.java +@@ -1,5 +1,5 @@ + /******************************************************************************* +- * Copyright (c) 2010, 2011 IBM Corporation and others. ++ * Copyright (c) 2010, 2015 IBM Corporation 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 +@@ -7,6 +7,7 @@ + * + * Contributors: + * IBM Corporation - initial API and implementation ++ * Sopot Cela - Bug 466829 - Migration to Lucene 5 + *******************************************************************************/ + + package org.eclipse.help.internal.search; +@@ -16,6 +17,8 @@ + + import org.apache.lucene.document.Document; + import org.apache.lucene.document.Field; ++import org.apache.lucene.document.StoredField; ++import org.apache.lucene.document.TextField; + import org.eclipse.help.search.ISearchDocument; + + /** +@@ -31,22 +34,22 @@ + } + + public void setTitle(String title) { +- doc.add(new Field("title", title, Field.Store.NO, Field.Index.ANALYZED)); //$NON-NLS-1$ +- doc.add(new Field("exact_title", title, Field.Store.NO, Field.Index.ANALYZED)); //$NON-NLS-1$ +- doc.add(new Field("raw_title", title, Field.Store.YES, Field.Index.NO)); //$NON-NLS-1$ ++ doc.add(new TextField("title", title, Field.Store.NO)); //$NON-NLS-1$ ++ doc.add(new TextField("exact_title", title, Field.Store.NO)); //$NON-NLS-1$ ++ doc.add(new StoredField("raw_title", title)); //$NON-NLS-1$ + } + + public void setSummary(String summary) { +- doc.add(new Field("summary", summary, Field.Store.YES, Field.Index.NO)); //$NON-NLS-1$ ++ doc.add(new StoredField("summary", summary)); //$NON-NLS-1$ + } + + public void addContents(String contents) { +- doc.add(new Field("contents", new StringReader(contents))); //$NON-NLS-1$ +- doc.add(new Field("exact_contents", new StringReader(contents))); //$NON-NLS-1$ ++ doc.add(new TextField("contents", new StringReader(contents))); //$NON-NLS-1$ ++ doc.add(new TextField("exact_contents", new StringReader(contents))); //$NON-NLS-1$ + } + + public void setHasFilters(boolean hasFilters) { +- doc.add(new Field("filters", Boolean.toString(hasFilters), Field.Store.YES, Field.Index.NO)); //$NON-NLS-1$ ++ doc.add(new StoredField("filters", Boolean.toString(hasFilters))); //$NON-NLS-1$ + } + + public Document getDocument() { +@@ -54,8 +57,8 @@ + } + + public void addContents(Reader contents, Reader exactContents) { +- doc.add(new Field("contents", contents)); //$NON-NLS-1$ +- doc.add(new Field("exact_contents", exactContents)); //$NON-NLS-1$ ++ doc.add(new TextField("contents", contents)); //$NON-NLS-1$ ++ doc.add(new TextField("exact_contents", exactContents)); //$NON-NLS-1$ + } + + } +diff --git a/eclipse.platform.ua/org.eclipse.help.base/src/org/eclipse/help/internal/search/PluginIndex.java b/org.eclipse.help.base/src/org/eclipse/help/internal/search/PluginIndex.java +index ca9cd67..7952c8d 100644 +--- a/eclipse.platform.ua/org.eclipse.help.base/src/org/eclipse/help/internal/search/PluginIndex.java ++++ b/eclipse.platform.ua/org.eclipse.help.base/src/org/eclipse/help/internal/search/PluginIndex.java +@@ -1,5 +1,5 @@ + /******************************************************************************* +- * Copyright (c) 2005, 2014 IBM Corporation and others. ++ * Copyright (c) 2005, 2015 IBM Corporation 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 +@@ -7,6 +7,7 @@ + * + * Contributors: + * IBM Corporation - initial API and implementation ++ * Sopot Cela - Bug 466829 - Migration to Lucene 5 + *******************************************************************************/ + package org.eclipse.help.internal.search; + +@@ -152,6 +153,7 @@ + .getProperty(SearchIndex.DEPENDENCIES_KEY_ANALYZER); + if (!targetIndex.isLuceneCompatible(lucene) + || !targetIndex.isAnalyzerCompatible(analyzer)) { ++ HelpBasePlugin.logError("Error trying to consume Lucene index from bundle "+bundle.toString()+". Please use an index built with Lucene 5 or higher.", null); //$NON-NLS-1$ //$NON-NLS-2$ + return false; + } + } catch (MalformedURLException mue) { +diff --git a/eclipse.platform.ua/org.eclipse.help.base/src/org/eclipse/help/internal/search/QueryBuilder.java b/org.eclipse.help.base/src/org/eclipse/help/internal/search/QueryBuilder.java +deleted file mode 100644 +index 08cf58a..0000000 +--- a/eclipse.platform.ua/org.eclipse.help.base/src/org/eclipse/help/internal/search/QueryBuilder.java ++++ /dev/null +@@ -1,459 +0,0 @@ +-/******************************************************************************* +- * Copyright (c) 2000, 2012 IBM Corporation 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 +- * +- * Contributors: +- * IBM Corporation - initial API and implementation +- * Chris Torrence - patch for bug Bug 107648 +- *******************************************************************************/ +-package org.eclipse.help.internal.search; +-import java.io.*; +-import java.util.ArrayList; +-import java.util.Collection; +-import java.util.Iterator; +-import java.util.List; +-import java.util.Locale; +-import java.util.StringTokenizer; +- +-import org.apache.lucene.analysis.*; +-import org.apache.lucene.analysis.tokenattributes.CharTermAttribute; +-import org.apache.lucene.index.*; +-import org.apache.lucene.search.*; +-import org.eclipse.help.internal.base.*; +-/** +- * Build query acceptable by the search engine. +- */ +-public class QueryBuilder { +- // Maximum allowed number of terms +- private static final int MAX_TERMS = 10; +- // Maximum allowed number of ORs +- private static final int MAX_UNIONS = 4; +- // Maximum allowed number terms with wild cards +- private static final int MAX_WILD_TERMS = 2; +- // Query from user +- private String searchWords; +- // Descriptor of Analyzer to process the query words +- private AnalyzerDescriptor analyzerDesc; +- // Analyzer to process the query words +- private Analyzer analyzer; +- // List of QueryWordsToken +- private List analyzedTokens; +- // List of words to highlight +- private List highlightWords = new ArrayList(); +- private Locale locale; +- /** +- * Creates a query builder for the search word. The search word is processed +- * by a lexical analyzer. +- */ +- public QueryBuilder(String searchWords, AnalyzerDescriptor analyzerDesc) { +- this.searchWords = searchWords; +- String language = analyzerDesc.getLang(); +- if (language.length() >= 5) { +- this.locale = new Locale(language.substring(0, 2), language +- .substring(3, 5)); +- } else { +- this.locale = new Locale(language.substring(0, 2), ""); //$NON-NLS-1$ +- } +- this.analyzerDesc = analyzerDesc; +- this.analyzer = analyzerDesc.getAnalyzer(); +- } +- /** +- * Splits user query into tokens and returns a list of QueryWordsToken's. +- */ +- private List tokenizeUserQuery(String searchWords) { +- List tokenList = new ArrayList(); +- //Divide along quotation marks +- //StringTokenizer qTokenizer = new StringTokenizer(searchWords.trim(), +- // "\"", true); //$NON-NLS-1$ +- boolean withinQuotation = false; +- String quotedString = ""; //$NON-NLS-1$ +- int termCount = 0;// keep track of number of terms to disallow too many +- +- int fromIndex = -1; +- searchWords = searchWords.trim(); +- while((fromIndex = searchWords.indexOf("\"", fromIndex+1))!= -1){ //$NON-NLS-1$ +- withinQuotation = !withinQuotation; +- } +- if( withinQuotation ) { +- searchWords = searchWords + "\""; //$NON-NLS-1$ +- withinQuotation = !withinQuotation; +- } +- +- StringTokenizer qTokenizer = new StringTokenizer(searchWords,"\"",true); //$NON-NLS-1$ +- int orCount = 0; // keep track of number of ORs to disallow too many +- while (qTokenizer.hasMoreTokens()) { +- String curToken = qTokenizer.nextToken(); +- if (curToken.equals("\"")) { //$NON-NLS-1$ +- if (withinQuotation) { +- // check for too many terms +- if (BaseHelpSystem.getMode() == BaseHelpSystem.MODE_INFOCENTER +- && ++termCount > MAX_TERMS) { +- throw new QueryTooComplexException(); +- } +- tokenList.add(QueryWordsToken.exactPhrase(quotedString)); +- } else { +- quotedString = ""; //$NON-NLS-1$ +- } +- withinQuotation = !withinQuotation; +- continue; +- } else if (withinQuotation) { +- quotedString = curToken; +- continue; +- } else { +- //divide unquoted strings along white space +- StringTokenizer parser = new StringTokenizer(curToken.trim()); +- while (parser.hasMoreTokens()) { +- String token = parser.nextToken(); +- if (token.equalsIgnoreCase(QueryWordsToken.AND().value)) { +- tokenList.add(QueryWordsToken.AND()); +- } else if (token +- .equalsIgnoreCase(QueryWordsToken.OR().value)) { +- // Check for too many OR terms +- if (BaseHelpSystem.getMode() == BaseHelpSystem.MODE_INFOCENTER +- && ++orCount > MAX_UNIONS) { +- throw new QueryTooComplexException(); +- } +- tokenList.add(QueryWordsToken.OR()); +- } else if (token +- .equalsIgnoreCase(QueryWordsToken.NOT().value)) { +- tokenList.add(QueryWordsToken.NOT()); +- } else { +- // check for too many terms +- if (BaseHelpSystem.getMode() == BaseHelpSystem.MODE_INFOCENTER +- && ++termCount > MAX_TERMS) { +- throw new QueryTooComplexException(); +- } +- tokenList.add(QueryWordsToken.word(token)); +- } +- } +- } +- } +- return tokenList; +- } +- /** +- * Apply the Analyzer to the search tokens and return the list of processed +- * QueryWordsToken's. +- */ +- private List analyzeTokens(List tokens) { +- boolean isTokenAfterNot = false; +- List newTokens = new ArrayList(); +- int wildCardTermCount = 0; +- for (int i = 0; i < tokens.size(); i++) { +- QueryWordsToken token = tokens.get(i); +- if (token.type == QueryWordsToken.WORD) { +- int questionMIndex = token.value.indexOf('?'); +- int starIndex = token.value.indexOf('*'); +- if (starIndex >= 0 || questionMIndex >= 0) { +- if (BaseHelpSystem.getMode() == BaseHelpSystem.MODE_INFOCENTER +- && ++wildCardTermCount > MAX_WILD_TERMS) { +- throw new QueryTooComplexException(); +- } +- newTokens.add(QueryWordsToken.word(token.value +- .toLowerCase(locale))); +- // add word to the list of words to highlight +- if (!isTokenAfterNot && !highlightWords.contains(token.value)) { +- highlightWords.add(token.value); +- } +- } else { +- List wordList = analyzeText(analyzer, "contents", //$NON-NLS-1$ +- token.value); +- if (wordList.size() > 0) { +- if (!isTokenAfterNot && !highlightWords.contains(token.value)) { +- // add original word to the list of words to +- // highlight +- highlightWords.add(token.value); +- } +- if (wordList.size() == 1) { +- String word = wordList.get(0); +- newTokens.add(QueryWordsToken.word(word)); +- // add analyzed word to the list of words to +- // highlight +- // this is required to highlight stemmed words +- if (!isTokenAfterNot && !highlightWords.contains(word)) { +- highlightWords.add(word); +- } +- } else { +- QueryWordsPhrase phrase = QueryWordsToken.phrase(); +- for (Iterator it = wordList.iterator(); it +- .hasNext();) { +- String word = it.next(); +- phrase.addWord(word); +- // add each analyzed word to the list of words +- // to highlight +- // this is only required to highlight stemmed +- // words. +- // Adding words should not be done when +- // DefaultAnalyzer is used, +- // because it does not perform stemming and +- // common words removal +- // which would result in common characters +- // highlighted all over (bug 30263) +- if (!analyzerDesc.getId().startsWith( +- HelpBasePlugin.PLUGIN_ID + "#")) { //$NON-NLS-1$ +- if (!isTokenAfterNot && !highlightWords.contains(word)) { +- highlightWords.add(word); +- } +- } +- } +- newTokens.add(phrase); +- } +- } +- } +- } else if (// forget ANDs +- /* +- * token.type == SearchQueryToken.AND || +- */ +- token.type == QueryWordsToken.OR +- || token.type == QueryWordsToken.NOT) +- newTokens.add(token); +- else if (token.type == QueryWordsToken.EXACT_PHRASE) { +- List wordList = analyzeText(analyzer, "exact_contents", //$NON-NLS-1$ +- token.value); +- if (wordList.size() > 0) { +- if (!isTokenAfterNot && !highlightWords.contains(token.value)) { +- // add original word to the list of words to highlight +- highlightWords.add(token.value); +- } +- } +- QueryWordsExactPhrase phrase = QueryWordsToken.exactPhrase(); +- for (Iterator it = wordList.iterator(); it.hasNext();) { +- String word = it.next(); +- phrase.addWord(word); +- // add analyzed word to the list of words to highlight +- // if (!highlightWords.contains(word)) +- // highlightWords.add(word); +- } +- // add phrase only if not empty +- if (phrase.getWords().size() > 0) { +- newTokens.add(phrase); +- } +- } +- isTokenAfterNot = (token.type == QueryWordsToken.NOT); +- } +- return newTokens; +- } +- /** +- * Get a list of tokens corresponding to a search word or phrase +- * +- * @return List of String +- */ +- private List analyzeText(Analyzer analyzer, String fieldName, String text) { +- List words = new ArrayList(1); +- Reader reader = new StringReader(text); +- TokenStream tStream = analyzer.tokenStream(fieldName, reader); +- +- CharTermAttribute termAttribute = tStream.getAttribute(CharTermAttribute.class); +- try { +- while (tStream.incrementToken()) { +- String term = termAttribute.toString(); +- words.add(term); +- } +- reader.close(); +- } catch (IOException ioe) { +- } +- +- return words; +- } +- /** +- * Obtains Lucene Query from tokens +- * +- * @return Query or null if no query could be created +- */ +- private Query createLuceneQuery(List searchTokens, String[] fieldNames, +- float[] boosts) { +- // Get queries for parts separated by OR +- List requiredQueries = getRequiredQueries(searchTokens, fieldNames, +- boosts); +- if (requiredQueries.size() == 0) +- return null; +- else if (requiredQueries.size() <= 1) +- return requiredQueries.get(0); +- else +- /* if (requiredQueries.size() > 1) */ +- // OR queries +- return (orQueries(requiredQueries)); +- } +- /** +- * Obtains Lucene queries for token sequences separated at OR. +- * +- * @return List of Query (could be empty) +- */ +- private List getRequiredQueries(List tokens, String[] fieldNames, +- float[] boosts) { +- List oredQueries = new ArrayList(); +- ArrayList requiredQueryTokens = new ArrayList(); +- for (int i = 0; i < tokens.size(); i++) { +- QueryWordsToken token = tokens.get(i); +- if (token.type != QueryWordsToken.OR) { +- requiredQueryTokens.add(token); +- } else { +- Query reqQuery = getRequiredQuery(requiredQueryTokens, +- fieldNames, boosts); +- if (reqQuery != null) +- oredQueries.add(reqQuery); +- requiredQueryTokens = new ArrayList(); +- } +- } +- Query reqQuery = getRequiredQuery(requiredQueryTokens, fieldNames, +- boosts); +- if (reqQuery != null) +- oredQueries.add(reqQuery); +- return oredQueries; +- } +- private Query orQueries(Collection queries) { +- BooleanQuery bq = new BooleanQuery(); +- for (Iterator it = queries.iterator(); it.hasNext();) { +- Query q = it.next(); +- bq.add(q, BooleanClause.Occur.SHOULD); +- } +- return bq; +- } +- /** +- * Obtains Lucene Query for tokens containing only AND and NOT operators. +- * +- * @return BooleanQuery or null if no query could be created from the tokens +- */ +- private Query getRequiredQuery(List requiredTokens, String[] fieldNames, +- float[] boosts) { +- BooleanQuery retQuery = new BooleanQuery(); +- boolean requiredTermExist = false; +- // Parse tokens left to right +- QueryWordsToken operator = null; +- for (int i = 0; i < requiredTokens.size(); i++) { +- QueryWordsToken token = requiredTokens.get(i); +- if (token.type == QueryWordsToken.AND +- || token.type == QueryWordsToken.NOT) { +- operator = token; +- continue; +- } +- // Creates queries for all fields +- Query qs[] = new Query[fieldNames.length]; +- for (int f = 0; f < fieldNames.length; f++) { +- qs[f] = token.createLuceneQuery(fieldNames[f], boosts[f]); +- } +- // creates the boolean query of all fields +- Query q = qs[0]; +- if (fieldNames.length > 1) { +- BooleanQuery allFieldsQuery = new BooleanQuery(); +- for (int f = 0; f < fieldNames.length; f++) +- allFieldsQuery.add(qs[f], BooleanClause.Occur.SHOULD); +- q = allFieldsQuery; +- } +- if (operator != null && operator.type == QueryWordsToken.NOT) { +- retQuery.add(q, BooleanClause.Occur.MUST_NOT); // add as prohibited +- } else { +- retQuery.add(q, BooleanClause.Occur.MUST); // add as required +- requiredTermExist = true; +- } +- } +- if (!requiredTermExist) { +- return null; // cannot search for prohibited only +- } +- return retQuery; +- } +- private Query getLuceneQuery(String[] fieldNames, float[] boosts) { +- Query luceneQuery = createLuceneQuery(analyzedTokens, fieldNames, +- boosts); +- return luceneQuery; +- } +- /** +- * @param fieldNames - +- * Collection of field names of type String (e.g. "h1"); the +- * search will be performed on the given fields +- * @param fieldSearchOnly - +- * boolean indicating if field only search should be performed; +- * if set to false, default field "contents" and all other fields +- * will be searched +- */ +- public Query getLuceneQuery(Collection fieldNames, boolean fieldSearchOnly) +- throws QueryTooComplexException { +- // split search query into tokens +- List userTokens = tokenizeUserQuery(searchWords); +- analyzedTokens = analyzeTokens(userTokens); +- return buildLuceneQuery(fieldNames, fieldSearchOnly); +- } +- /** +- * @param fieldNames - +- * Collection of field names of type String (e.g. "h1"); the +- * search will be performed on the given fields +- * @param fieldSearchOnly - +- * boolean indicating if field only search should be performed; +- * if set to false, default field "contents" and all other fields +- * will be searched +- */ +- private Query buildLuceneQuery(Collection fieldNames, +- boolean fieldSearchOnly) { +- String[] fields; +- float[] boosts; +- if (fieldSearchOnly) { +- fields = new String[fieldNames.size()]; +- boosts = new float[fieldNames.size()]; +- Iterator fieldNamesIt = fieldNames.iterator(); +- for (int i = 0; i < fieldNames.size(); i++) { +- fields[i] = fieldNamesIt.next(); +- boosts[i] = 5.0f; +- } +- } else { +- fields = new String[fieldNames.size() + 2]; +- boosts = new float[fieldNames.size() + 2]; +- Iterator fieldNamesIt = fieldNames.iterator(); +- for (int i = 0; i < fieldNames.size(); i++) { +- fields[i] = fieldNamesIt.next(); +- boosts[i] = 5.0f; +- } +- fields[fieldNames.size()] = "contents"; //$NON-NLS-1$ +- boosts[fieldNames.size()] = 1.0f; +- fields[fieldNames.size()+1] = "title"; //$NON-NLS-1$ +- boosts[fieldNames.size()+1] = 1.0f; +- } +- Query query = getLuceneQuery(fields, boosts); +- query = improveRankingForUnqotedPhrase(query, fields, boosts); +- return query; +- } +- /** +- * If user query contained only words (no quotaions nor operators) extends +- * query with term phrase representing entire user query i.e for user string +- * a b, the query a AND b will be extended to "a b" OR a AND b +- */ +- private Query improveRankingForUnqotedPhrase(Query query, String[] fields, +- float[] boosts) { +- if (query == null) +- return query; +- // check if all tokens are words +- for (int i = 0; i < analyzedTokens.size(); i++) +- if (analyzedTokens.get(i).type != QueryWordsToken.WORD) +- return query; +- // Create phrase query for all tokens and OR with original query +- BooleanQuery booleanQuery = new BooleanQuery(); +- booleanQuery.add(query, BooleanClause.Occur.SHOULD); +- PhraseQuery[] phraseQueries = new PhraseQuery[fields.length]; +- for (int f = 0; f < fields.length; f++) { +- phraseQueries[f] = new PhraseQuery(); +- for (int i = 0; i < analyzedTokens.size(); i++) { +- Term t = new Term(fields[f], analyzedTokens +- .get(i).value); +- phraseQueries[f].add(t); +- } +- phraseQueries[f].setBoost(10 * boosts[f]); +- booleanQuery.add(phraseQueries[f], BooleanClause.Occur.SHOULD); +- } +- return booleanQuery; +- } +- /** +- * Obtains analyzed terms from query as one string. Words are double quoted, +- * and separated by space. The analyzed words are needed for highlighting +- * word roots. +- */ +- public String gethighlightTerms() { +- StringBuffer buf = new StringBuffer(); +- for (Iterator it = highlightWords.iterator(); it.hasNext();) { +- buf.append('"'); +- buf.append(it.next()); +- buf.append("\" "); //$NON-NLS-1$ +- } +- return buf.toString(); +- } +-} +diff --git a/eclipse.platform.ua/org.eclipse.help.base/src/org/eclipse/help/internal/search/QueryWordsExactPhrase.java b/org.eclipse.help.base/src/org/eclipse/help/internal/search/QueryWordsExactPhrase.java +deleted file mode 100644 +index 324b8e1..0000000 +--- a/eclipse.platform.ua/org.eclipse.help.base/src/org/eclipse/help/internal/search/QueryWordsExactPhrase.java ++++ /dev/null +@@ -1,50 +0,0 @@ +-/******************************************************************************* +- * Copyright (c) 2000, 2011 IBM Corporation 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 +- * +- * Contributors: +- * IBM Corporation - initial API and implementation +- *******************************************************************************/ +-package org.eclipse.help.internal.search; +-import java.util.ArrayList; +-import java.util.Iterator; +-import java.util.List; +- +-import org.apache.lucene.index.*; +-import org.apache.lucene.search.*; +-/** +- * Represents a quoted token in user search query words +- */ +-public class QueryWordsExactPhrase extends QueryWordsToken { +- private List words; +- public QueryWordsExactPhrase() { +- super(QueryWordsToken.EXACT_PHRASE, ""); //$NON-NLS-1$ +- words = new ArrayList(); +- } +- public void addWord(String word) { +- words.add(word); +- if (words.size() <= 1) +- value = word; +- else +- value += " " + word; //$NON-NLS-1$ +- } +- public List getWords() { +- return words; +- } +- /** +- * Creates a lucene query for a field +- */ +- public Query createLuceneQuery(String field, float boost) { +- PhraseQuery q = new PhraseQuery(); +- for (Iterator it = getWords().iterator(); it.hasNext();) { +- String word = it.next(); +- Term t = new Term("exact_" + field, word); //$NON-NLS-1$ +- q.add(t); +- q.setBoost(boost); +- } +- return q; +- } +-} +diff --git a/eclipse.platform.ua/org.eclipse.help.base/src/org/eclipse/help/internal/search/QueryWordsPhrase.java b/org.eclipse.help.base/src/org/eclipse/help/internal/search/QueryWordsPhrase.java +deleted file mode 100644 +index 8a94e89..0000000 +--- a/eclipse.platform.ua/org.eclipse.help.base/src/org/eclipse/help/internal/search/QueryWordsPhrase.java ++++ /dev/null +@@ -1,51 +0,0 @@ +-/******************************************************************************* +- * Copyright (c) 2000, 2011 IBM Corporation 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 +- * +- * Contributors: +- * IBM Corporation - initial API and implementation +- *******************************************************************************/ +-package org.eclipse.help.internal.search; +-import java.util.ArrayList; +-import java.util.Iterator; +-import java.util.List; +- +-import org.apache.lucene.index.*; +-import org.apache.lucene.search.*; +-/** +- * Represents a phrase (not quoted) token in user search query words It consists +- * of several words created by an analyzer +- */ +-public class QueryWordsPhrase extends QueryWordsToken { +- private List words; +- public QueryWordsPhrase() { +- super(QueryWordsToken.PHRASE, ""); //$NON-NLS-1$ +- words = new ArrayList(); +- } +- public void addWord(String word) { +- words.add(word); +- if (words.size() <= 1) +- value = word; +- else +- value += " " + word; //$NON-NLS-1$ +- } +- public List getWords() { +- return words; +- } +- /** +- * Creates a lucene query for a field +- */ +- public Query createLuceneQuery(String field, float boost) { +- PhraseQuery q = new PhraseQuery(); +- for (Iterator it = getWords().iterator(); it.hasNext();) { +- String word = it.next(); +- Term t = new Term(field, word); +- q.add(t); +- q.setBoost(boost); +- } +- return q; +- } +-} +diff --git a/eclipse.platform.ua/org.eclipse.help.base/src/org/eclipse/help/internal/search/QueryWordsToken.java b/org.eclipse.help.base/src/org/eclipse/help/internal/search/QueryWordsToken.java +deleted file mode 100644 +index 6ba76f2..0000000 +--- a/eclipse.platform.ua/org.eclipse.help.base/src/org/eclipse/help/internal/search/QueryWordsToken.java ++++ /dev/null +@@ -1,81 +0,0 @@ +-/******************************************************************************* +- * Copyright (c) 2000, 2007 IBM Corporation 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 +- * +- * Contributors: +- * IBM Corporation - initial API and implementation +- *******************************************************************************/ +-package org.eclipse.help.internal.search; +-import org.apache.lucene.index.*; +-import org.apache.lucene.search.*; +-/** +- * Represents a token in user search query words +- */ +-public class QueryWordsToken { +- public static final int AND = 0; +- public static final int OR = 1; +- public static final int NOT = 2; +- public static final int EXACT_PHRASE = 3; +- public static final int PHRASE = 4; +- public static final int WORD = 5; +- private static final QueryWordsToken fAND = new QueryWordsToken(AND, "AND"); //$NON-NLS-1$ +- private static final QueryWordsToken fOR = new QueryWordsToken(OR, "OR"); //$NON-NLS-1$ +- private static final QueryWordsToken fNOT = new QueryWordsToken(NOT, "NOT"); //$NON-NLS-1$ +- public int type; +- public String value; +- protected QueryWordsToken(int type, String value) { +- this.type = type; +- this.value = value; +- } +- /** +- * Creates a lucene query for a field +- */ +- public Query createLuceneQuery(String field, float boost) { +- Query q; +- int questionPos = value.indexOf('?'); +- int starPos = value.indexOf('*'); +- if (questionPos >= 0 || starPos >= 0) { +- if (questionPos == -1 && starPos == value.length() - 1) { +- Term t = new Term("exact_" + field, value.substring(0, starPos)); //$NON-NLS-1$ +- q = new PrefixQuery(t); +- ((PrefixQuery) q).setBoost(boost); +- } else { +- Term t = new Term("exact_" + field, value); //$NON-NLS-1$ +- q = new WildcardQuery(t); +- ((WildcardQuery) q).setBoost(boost); +- } +- } else { +- Term t = new Term(field, value); +- q = new TermQuery(t); +- ((TermQuery) q).setBoost(boost); +- } +- // after updating Lucene, set boost on a Query class +- return q; +- } +- public static QueryWordsToken AND() { +- return fAND; +- } +- public static QueryWordsToken OR() { +- return fOR; +- } +- public static QueryWordsToken NOT() { +- return fNOT; +- } +- public static QueryWordsToken word(String word) { +- return new QueryWordsToken(QueryWordsToken.WORD, word); +- } +- public static QueryWordsPhrase phrase() { +- return new QueryWordsPhrase(); +- } +- public static QueryWordsExactPhrase exactPhrase() { +- return new QueryWordsExactPhrase(); +- } +- public static QueryWordsExactPhrase exactPhrase(String word) { +- QueryWordsExactPhrase token = new QueryWordsExactPhrase(); +- token.addWord(word); +- return token; +- } +-} +diff --git a/eclipse.platform.ua/org.eclipse.help.base/src/org/eclipse/help/internal/search/SearchIndex.java b/org.eclipse.help.base/src/org/eclipse/help/internal/search/SearchIndex.java +index 67963a5..131ac65 100644 +--- a/eclipse.platform.ua/org.eclipse.help.base/src/org/eclipse/help/internal/search/SearchIndex.java ++++ b/eclipse.platform.ua/org.eclipse.help.base/src/org/eclipse/help/internal/search/SearchIndex.java +@@ -1,14 +1,13 @@ + /******************************************************************************* +- * Copyright (c) 2000, 2014 IBM Corporation and others. +- * All rights reserved. This program and the accompanying materials +- * are made available under the terms of the Eclipse Public License v1.0 ++ * Copyright (c) 2000, 2015 IBM Corporation 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 + * +- * Contributors: +- * IBM Corporation - initial API and implementation +- * Holger Voormann - fix for bug 426785 (http://eclip.se/426785) +- * Alexander Kurtakov - Bug 460787 ++ * Contributors: IBM Corporation - initial API and implementation ++ * Holger Voormann - fix for bug 426785 (http://eclip.se/426785) ++ * Alexander Kurtakov - Bug 460787 ++ * Sopot Cela - Bug 466829 - Migration to Lucene 5 + *******************************************************************************/ + package org.eclipse.help.internal.search; + +@@ -17,6 +16,7 @@ + import java.io.IOException; + import java.io.InputStream; + import java.io.RandomAccessFile; ++import java.io.StringReader; + import java.net.MalformedURLException; + import java.net.URL; + import java.nio.channels.FileLock; +@@ -33,19 +33,30 @@ + import java.util.zip.ZipEntry; + import java.util.zip.ZipInputStream; + +-import org.apache.lucene.analysis.LimitTokenCountAnalyzer; ++import org.apache.lucene.analysis.miscellaneous.LimitTokenCountAnalyzer; + import org.apache.lucene.document.Document; + import org.apache.lucene.document.Field; ++import org.apache.lucene.document.StoredField; ++import org.apache.lucene.document.StringField; ++import org.apache.lucene.index.DirectoryReader; + import org.apache.lucene.index.IndexReader; + import org.apache.lucene.index.IndexWriter; +-import org.apache.lucene.index.Term; +-import org.apache.lucene.index.TermDocs; +-import org.apache.lucene.index.IndexWriterConfig.OpenMode; + import org.apache.lucene.index.IndexWriterConfig; ++import org.apache.lucene.index.IndexWriterConfig.OpenMode; ++import org.apache.lucene.index.LeafReader; + import org.apache.lucene.index.LogByteSizeMergePolicy; + import org.apache.lucene.index.LogMergePolicy; ++import org.apache.lucene.index.PostingsEnum; ++import org.apache.lucene.index.SlowCompositeReaderWrapper; ++import org.apache.lucene.index.Term; ++import org.apache.lucene.queryparser.classic.FastCharStream; ++import org.apache.lucene.queryparser.classic.MultiFieldQueryParser; ++import org.apache.lucene.queryparser.classic.QueryParserTokenManager; ++import org.apache.lucene.queryparser.classic.Token; ++import org.apache.lucene.search.BooleanClause.Occur; + import org.apache.lucene.search.BooleanQuery; + import org.apache.lucene.search.IndexSearcher; ++import org.apache.lucene.search.MultiTermQuery; + import org.apache.lucene.search.Query; + import org.apache.lucene.search.TopDocs; + import org.apache.lucene.store.Directory; +@@ -59,7 +70,6 @@ + import org.eclipse.core.runtime.OperationCanceledException; + import org.eclipse.core.runtime.Platform; + import org.eclipse.core.runtime.Status; +-import org.eclipse.help.internal.HelpPlugin; + import org.eclipse.help.internal.base.BaseHelpSystem; + import org.eclipse.help.internal.base.HelpBasePlugin; + import org.eclipse.help.internal.base.util.HelpProperties; +@@ -86,7 +96,7 @@ + + private File indexDir; + +- private Directory luceneDirectory; ++ public Directory luceneDirectory; + + private String locale; + +@@ -133,7 +143,7 @@ + private Collection searches = new ArrayList(); + + private FileLock lock; +- private RandomAccessFile raf = null; ++ private RandomAccessFile raf = null; + + /** + * Constructor. +@@ -170,7 +180,7 @@ + inconsistencyFile = new File(indexDir.getParentFile(), locale + ".inconsistent"); //$NON-NLS-1$ + htmlSearchParticipant = new HTMLSearchParticipant(indexDir.getAbsolutePath()); + try { +- luceneDirectory = new NIOFSDirectory(indexDir); ++ luceneDirectory = new NIOFSDirectory(indexDir.toPath()); + } catch (IOException e) { + } + if (!exists()) { +@@ -203,11 +213,11 @@ + public IStatus addDocument(String name, URL url) { + try { + Document doc = new Document(); +- doc.add(new Field(FIELD_NAME, name, Field.Store.YES, Field.Index.NOT_ANALYZED)); ++ doc.add(new StringField(FIELD_NAME, name, Field.Store.YES)); + addExtraFields(doc); + String pluginId = LocalSearchManager.getPluginId(name); + if (relativePath != null) { +- doc.add(new Field(FIELD_INDEX_ID, relativePath, Field.Store.YES, Field.Index.NOT_ANALYZED)); ++ doc.add(new StringField(FIELD_INDEX_ID, relativePath, Field.Store.YES)); + } + // check for the explicit search participant. + SearchParticipant participant = null; +@@ -220,20 +230,22 @@ + if (participant == null) + participant = BaseHelpSystem.getLocalSearchManager().getParticipant(pluginId, name); + if (participant != null) { +- IStatus status = participant.addDocument(this, pluginId, name, url, id, new LuceneSearchDocument(doc)); ++ IStatus status = participant.addDocument(this, pluginId, name, url, id, ++ new LuceneSearchDocument(doc)); + if (status.getSeverity() == IStatus.OK) { + String filters = doc.get("filters"); //$NON-NLS-1$ + indexedDocs.put(name, filters != null ? filters : "0"); //$NON-NLS-1$ + if (id != null) +- doc.add(new Field("id", id, Field.Store.YES, Field.Index.NO)); //$NON-NLS-1$ ++ doc.add(new StoredField("id", id)); //$NON-NLS-1$ + if (pid != null) +- doc.add(new Field("participantId", pid, Field.Store.YES, Field.Index.NO)); //$NON-NLS-1$ ++ doc.add(new StoredField("participantId", pid)); //$NON-NLS-1$ + iw.addDocument(doc); + } + return status; + } + // default to html +- IStatus status = htmlSearchParticipant.addDocument(this, pluginId, name, url, id, new LuceneSearchDocument(doc)); ++ IStatus status = htmlSearchParticipant.addDocument(this, pluginId, name, url, id, ++ new LuceneSearchDocument(doc)); + if (status.getSeverity() == IStatus.OK) { + String filters = doc.get("filters"); //$NON-NLS-1$ + indexedDocs.put(name, filters != null ? filters : "0"); //$NON-NLS-1$ +@@ -245,20 +257,21 @@ + "IO exception occurred while adding document " + name //$NON-NLS-1$ + + " to index " + indexDir.getAbsolutePath() + ".", //$NON-NLS-1$ //$NON-NLS-2$ + e); +- } +- catch (Exception e) { ++ } catch (Exception e) { + return new Status(IStatus.ERROR, HelpBasePlugin.PLUGIN_ID, IStatus.ERROR, + "An unexpected internal error occurred while adding document " //$NON-NLS-1$ + + name + " to index " + indexDir.getAbsolutePath() //$NON-NLS-1$ +- + ".", e); //$NON-NLS-1$ ++ + ".", //$NON-NLS-1$ ++ e); + } + } + + /** +- * Add any extra fields that need to be added to this document. Subclasses +- * should override to add more fields. ++ * Add any extra fields that need to be added to this document. Subclasses should override to ++ * add more fields. + * +- * @param doc the document to add fields to ++ * @param doc ++ * the document to add fields to + */ + protected void addExtraFields(Document doc) { + } +@@ -282,8 +295,9 @@ + indexedDocs = new HelpProperties(INDEXED_DOCS_FILE, indexDir); + indexedDocs.restore(); + setInconsistent(true); +- LimitTokenCountAnalyzer analyzer = new LimitTokenCountAnalyzer(analyzerDescriptor.getAnalyzer(), 1000000); +- IndexWriterConfig writerConfig = new IndexWriterConfig(org.apache.lucene.util.Version.LUCENE_31, analyzer); ++ LimitTokenCountAnalyzer analyzer = new LimitTokenCountAnalyzer(analyzerDescriptor.getAnalyzer(), ++ 1000000); ++ IndexWriterConfig writerConfig = new IndexWriterConfig(analyzer); + writerConfig.setOpenMode(create ? OpenMode.CREATE : OpenMode.APPEND); + LogMergePolicy mergePolicy = new LogByteSizeMergePolicy(); + mergePolicy.setMergeFactor(20); +@@ -307,7 +321,7 @@ + indexedDocs = new HelpProperties(INDEXED_DOCS_FILE, indexDir); + indexedDocs.restore(); + setInconsistent(true); +- ir = IndexReader.open(luceneDirectory, false); ++ ir = DirectoryReader.open(luceneDirectory); + return true; + } catch (IOException e) { + HelpBasePlugin.logError("Exception occurred in search indexing at beginDeleteBatch.", e); //$NON-NLS-1$ +@@ -323,7 +337,7 @@ + if (ir != null) { + ir.close(); + } +- ir = IndexReader.open(luceneDirectory, false); ++ ir = DirectoryReader.open(luceneDirectory); + return true; + } catch (IOException e) { + HelpBasePlugin.logError("Exception occurred in search indexing at beginDeleteBatch.", e); //$NON-NLS-1$ +@@ -334,14 +348,14 @@ + /** + * Deletes a single document from the index. + * +- * @param name - +- * document name ++ * @param name ++ * - document name + * @return IStatus + */ + public IStatus removeDocument(String name) { + Term term = new Term(FIELD_NAME, name); + try { +- ir.deleteDocuments(term); ++ iw.deleteDocuments(term); + indexedDocs.remove(name); + } catch (IOException e) { + return new Status(IStatus.ERROR, HelpBasePlugin.PLUGIN_ID, IStatus.ERROR, +@@ -375,11 +389,11 @@ + } + + /* +- * The searcher's index reader has it's stuff in memory so it won't +- * know about this change. Close it so that it gets reloaded next search. ++ * The searcher's index reader has it's stuff in memory so it won't know about this ++ * change. Close it so that it gets reloaded next search. + */ + if (searcher != null) { +- searcher.close(); ++ searcher.getIndexReader().close(); + searcher = null; + } + return true; +@@ -407,11 +421,11 @@ + saveDependencies(); + + /* +- * The searcher's index reader has it's stuff in memory so it won't +- * know about this change. Close it so that it gets reloaded next search. ++ * The searcher's index reader has it's stuff in memory so it won't know about this ++ * change. Close it so that it gets reloaded next search. + */ + if (searcher != null) { +- searcher.close(); ++ searcher.getIndexReader().close(); + searcher = null; + } + return true; +@@ -469,11 +483,11 @@ + String indexId = indexIds.get(i); + String indexPath = indexPaths.get(i); + try { +- dirList.add(new NIOFSDirectory(new File(indexPath))); ++ dirList.add(new NIOFSDirectory(new File(indexPath).toPath())); + } catch (IOException ioe) { +- HelpBasePlugin +- .logError( +- "Help search indexing directory could not be created for directory " + indexPath, ioe); //$NON-NLS-1$ ++ HelpBasePlugin.logError( ++ "Help search indexing directory could not be created for directory " + indexPath, //$NON-NLS-1$ ++ ioe); + continue; + } + +@@ -525,18 +539,19 @@ + } + + public IStatus removeDuplicates(String name, String[] index_paths) { +- TermDocs hrefDocs = null; +- TermDocs indexDocs = null; +- Term hrefTerm = new Term(FIELD_NAME, name); + try { ++ LeafReader ar = SlowCompositeReaderWrapper.wrap(ir); ++ PostingsEnum hrefDocs = null; ++ PostingsEnum indexDocs = null; ++ Term hrefTerm = new Term(FIELD_NAME, name); + for (int i = 0; i < index_paths.length; i++) { + Term indexTerm = new Term(FIELD_INDEX_ID, index_paths[i]); + if (i == 0) { +- hrefDocs = ir.termDocs(hrefTerm); +- indexDocs = ir.termDocs(indexTerm); ++ hrefDocs = ar.postings(hrefTerm); ++ indexDocs = ar.postings(indexTerm); + } else { +- hrefDocs.seek(hrefTerm); +- indexDocs.seek(indexTerm); ++ hrefDocs = ar.postings(hrefTerm); ++ indexDocs = ar.postings(indexTerm); + } + removeDocuments(hrefDocs, indexDocs); + } +@@ -545,19 +560,6 @@ + "IO exception occurred while removing duplicates of document " + name //$NON-NLS-1$ + + " from index " + indexDir.getAbsolutePath() + ".", //$NON-NLS-1$ //$NON-NLS-2$ + ioe); +- } finally { +- if (hrefDocs != null) { +- try { +- hrefDocs.close(); +- } catch (IOException e) { +- } +- } +- if (indexDocs != null) { +- try { +- indexDocs.close(); +- } catch (IOException e) { +- } +- } + } + return Status.OK_STATUS; + } +@@ -569,33 +571,33 @@ + * @param docs2 + * @throws IOException + */ +- private void removeDocuments(TermDocs doc1, TermDocs docs2) throws IOException { +- if (!doc1.next()) { ++ private void removeDocuments(PostingsEnum doc1, PostingsEnum docs2) throws IOException { ++ if (doc1.nextDoc() == PostingsEnum.NO_MORE_DOCS) { + return; + } +- if (!docs2.next()) { ++ if (docs2.nextDoc() == PostingsEnum.NO_MORE_DOCS) { + return; + } + while (true) { +- if (doc1.doc() < docs2.doc()) { +- if (!doc1.skipTo(docs2.doc())) { +- if (!doc1.next()) { ++ if (doc1.docID() < docs2.docID()) { ++ if (doc1.advance(docs2.docID()) == PostingsEnum.NO_MORE_DOCS) { ++ if (doc1.nextDoc() == PostingsEnum.NO_MORE_DOCS) { + return; + } + } +- } else if (doc1.doc() > docs2.doc()) { +- if (!docs2.skipTo(doc1.doc())) { +- if (!doc1.next()) { ++ } else if (doc1.docID() > docs2.docID()) { ++ if (docs2.advance(doc1.docID()) == PostingsEnum.NO_MORE_DOCS) { ++ if (doc1.nextDoc() == PostingsEnum.NO_MORE_DOCS) { + return; + } + } + } +- if (doc1.doc() == docs2.doc()) { +- ir.deleteDocument(doc1.doc()); +- if (!doc1.next()) { ++ if (doc1.docID() == docs2.docID()) { ++ iw.tryDeleteDocument(ir, doc1.docID()); ++ if (doc1.nextDoc() == PostingsEnum.NO_MORE_DOCS) { + return; + } +- if (!docs2.next()) { ++ if (docs2.nextDoc() == PostingsEnum.NO_MORE_DOCS) { + return; + } + } +@@ -623,20 +625,72 @@ + registerSearch(Thread.currentThread()); + if (closed) + return; +- QueryBuilder queryBuilder = new QueryBuilder(searchQuery.getSearchWord(), analyzerDescriptor); +- Query luceneQuery = queryBuilder.getLuceneQuery(searchQuery.getFieldNames(), searchQuery +- .isFieldSearch()); +- if (HelpPlugin.DEBUG_SEARCH) { +- System.out.println("Search Query: " + luceneQuery.toString()); //$NON-NLS-1$ ++ ++ String[] fields; ++ if (searchQuery.isFieldSearch()){ ++ //sometimes you might want to search other than the default fields ++ fields = (String[]) searchQuery.getFieldNames().toArray(); ++ }else { ++ fields = new String[]{"contents","title"}; //$NON-NLS-1$ //$NON-NLS-2$ + } +- String highlightTerms = queryBuilder.gethighlightTerms(); +- if (luceneQuery != null) { ++ ++ //prepare the parser ++ ++ MultiFieldQueryParser qb = new MultiFieldQueryParser(fields,analyzerDescriptor.getAnalyzer()); ++ qb.setAllowLeadingWildcard(true); ++ qb.setAnalyzeRangeTerms(true); ++ qb.setAutoGeneratePhraseQueries(true); ++ qb.setMultiTermRewriteMethod(MultiTermQuery.CONSTANT_SCORE_BOOLEAN_REWRITE); ++ qb.setLowercaseExpandedTerms(true); ++ qb.setLocale(new Locale(analyzerDescriptor.getLang())); ++ ++ //parse the "pure" query (no boosting) ++ Query luceneQuery = qb.parse(searchQuery.getSearchWord()); ++ ++ //we'll merge the pure query with a some boosted queries ++ Query mergedQuery; ++ ++ if (!isWildcardQuery(searchQuery.getSearchWord())){ ++ mergedQuery = new BooleanQuery(); //merge for all fields before merging with luceneQuery ++ for (int i=0;i set = new HashSet(); ++ ++ if (mergedQuery != null) { + if (searcher == null) { + openSearcher(); + } +- TopDocs topDocs = searcher.search(luceneQuery, null, 1000); +- collector.addHits(LocalSearchManager.asList(topDocs, searcher), highlightTerms); ++ TopDocs topDocs = searcher.search(mergedQuery, 1000); ++ ++ String highlight=null; ++ QueryParserTokenManager manager = new QueryParserTokenManager(new FastCharStream(new StringReader(searchQuery.getSearchWord()))); ++ while (true){ ++ Token nextToken = manager.getNextToken(); ++ String toHighlight = null; ++ if (nextToken.kind==0) break; ++ String image = nextToken.image; ++ toHighlight=image; ++ if ((image.startsWith("\""))&&( image.endsWith("\""))){ //$NON-NLS-1$//$NON-NLS-2$ ++ toHighlight = image.substring(1,image.length()-1); ++ } ++ if (image.equals("AND") || image.equals("OR")) //$NON-NLS-1$ //$NON-NLS-2$ ++ continue; ++ set .add(toHighlight); ++ ++ } ++ highlight = buildHighlight(set); ++ collector.addHits(LocalSearchManager.asList(topDocs, searcher), highlight==null?"":highlight); //$NON-NLS-1$ + } ++ + } catch (BooleanQuery.TooManyClauses tmc) { + collector.addQTCException(new QueryTooComplexException()); + } catch (QueryTooComplexException qe) { +@@ -647,6 +701,19 @@ + } finally { + unregisterSearch(Thread.currentThread()); + } ++ } ++ ++ private boolean isWildcardQuery(String searchWord) { ++ ++ return searchWord.contains("?")|| searchWord.contains("*"); //$NON-NLS-1$//$NON-NLS-2$ ++ } ++ ++ private String buildHighlight(Set set) { ++ StringBuilder sb = new StringBuilder(); ++ for (String string : set) { ++ sb.append("\""+string+"\""); //$NON-NLS-1$//$NON-NLS-2$ ++ } ++ return sb.toString(); + } + + public String getLocale() { +@@ -660,13 +727,13 @@ + if (docPlugins == null) { + Set totalIds = new HashSet(); + IExtensionRegistry registry = Platform.getExtensionRegistry(); +- IExtensionPoint extensionPoint = registry.getExtensionPoint(TocFileProvider.EXTENSION_POINT_ID_TOC); ++ IExtensionPoint extensionPoint = registry ++ .getExtensionPoint(TocFileProvider.EXTENSION_POINT_ID_TOC); + IExtension[] extensions = extensionPoint.getExtensions(); +- for (int i=0;i= 0 ) { ++ if (luceneVersion.compareTo(indexVersion) >= 0) { + // Lucene bundle is newer than the index + return true; + } +@@ -802,7 +871,7 @@ + public void openSearcher() throws IOException { + synchronized (searcherCreateLock) { + if (searcher == null) { +- searcher = new IndexSearcher(IndexReader.open(luceneDirectory, false)); ++ searcher = new IndexSearcher(DirectoryReader.open(luceneDirectory)); + } + } + } +@@ -820,7 +889,7 @@ + if (searches.isEmpty()) { + if (searcher != null) { + try { +- searcher.close(); ++ searcher.getIndexReader().close(); + } catch (IOException ioe) { + } + } +@@ -838,7 +907,8 @@ + * Finds and unzips prebuild index specified in preferences + */ + private void unzipProductIndex() { +- String indexPluginId = Platform.getPreferencesService().getString(HelpBasePlugin.PLUGIN_ID, "productIndex", null, null); //$NON-NLS-1$ ++ String indexPluginId = Platform.getPreferencesService().getString(HelpBasePlugin.PLUGIN_ID, ++ "productIndex", null, null); //$NON-NLS-1$ + if (indexPluginId == null || indexPluginId.length() <= 0) { + return; + } +@@ -901,10 +971,11 @@ + */ + private void cleanOldIndex() { + IndexWriter cleaner = null; +- LimitTokenCountAnalyzer analyzer = new LimitTokenCountAnalyzer(analyzerDescriptor.getAnalyzer(), 10000); ++ LimitTokenCountAnalyzer analyzer = new LimitTokenCountAnalyzer(analyzerDescriptor.getAnalyzer(), ++ 10000); + try { +- cleaner = new IndexWriter(luceneDirectory, new IndexWriterConfig(org.apache.lucene.util.Version.LUCENE_31, analyzer).setOpenMode( +- OpenMode.CREATE)); ++ cleaner = new IndexWriter(luceneDirectory, ++ new IndexWriterConfig(analyzer).setOpenMode(OpenMode.CREATE)); + } catch (IOException ioe) { + } finally { + try { +@@ -957,7 +1028,7 @@ + * if lock already obtained + */ + public synchronized boolean tryLock() throws OverlappingFileLockException { +- if ("none".equals(System.getProperty("osgi.locking"))) { //$NON-NLS-1$//$NON-NLS-2$ ++ if ("none".equals(System.getProperty("osgi.locking"))) { //$NON-NLS-1$//$NON-NLS-2$ + return true; // Act as if lock succeeded + } + if (lock != null) { +@@ -979,7 +1050,7 @@ + lock = null; + logLockFailure(ioe); + } +- if ( raf != null ) { ++ if (raf != null) { + try { + raf.close(); + } catch (IOException e) { +@@ -1025,9 +1096,9 @@ + } + lock = null; + } +- if (raf != null ) { ++ if (raf != null) { + try { +- raf.close(); ++ raf.close(); + } catch (IOException ioe) { + } + raf = null; +@@ -1100,25 +1171,26 @@ + + public IStatus addDocument(String pluginId, String name, URL url, String id, Document doc) { + // try a registered participant for the file format +- SearchParticipant participant = BaseHelpSystem.getLocalSearchManager() +- .getParticipant(pluginId, name); ++ SearchParticipant participant = BaseHelpSystem.getLocalSearchManager().getParticipant(pluginId, name); + if (participant != null) { + try { + return participant.addDocument(this, pluginId, name, url, id, new LuceneSearchDocument(doc)); +- } +- catch (Throwable t) { ++ } catch (Throwable t) { + return new Status(IStatus.ERROR, HelpBasePlugin.PLUGIN_ID, IStatus.ERROR, + "Error while adding document to search participant (addDocument()): " //$NON-NLS-1$ +- + name + ", " + url + "for participant " + participant.getClass().getName(), t); //$NON-NLS-1$ //$NON-NLS-2$ ++ + name + ", " + url + "for participant " + participant.getClass().getName(), //$NON-NLS-1$ //$NON-NLS-2$ ++ t); + } + } + // default to html +- return htmlSearchParticipant.addDocument(this, pluginId, name, url, id, new LuceneSearchDocument(doc)); ++ return htmlSearchParticipant.addDocument(this, pluginId, name, url, id, ++ new LuceneSearchDocument(doc)); + } + +- public IStatus addSearchableDocument(String pluginId, String name, URL url, String id, ISearchDocument doc) { ++ public IStatus addSearchableDocument(String pluginId, String name, URL url, String id, ++ ISearchDocument doc) { + // In the help system the only class that implements ISearchDocument is LuceneSearchDocument +- LuceneSearchDocument luceneDoc = (LuceneSearchDocument)doc; ++ LuceneSearchDocument luceneDoc = (LuceneSearchDocument) doc; + return addDocument(pluginId, name, url, id, luceneDoc.getDocument()); + } + } +diff --git a/eclipse.platform.ua/org.eclipse.help.base/src/org/eclipse/help/internal/search/SmartAnalyzer.java b/org.eclipse.help.base/src/org/eclipse/help/internal/search/SmartAnalyzer.java +index d0a7bb7..444b66c 100644 +--- a/eclipse.platform.ua/org.eclipse.help.base/src/org/eclipse/help/internal/search/SmartAnalyzer.java ++++ b/eclipse.platform.ua/org.eclipse.help.base/src/org/eclipse/help/internal/search/SmartAnalyzer.java +@@ -1,5 +1,5 @@ + /******************************************************************************* +- * Copyright (c) 2000, 2012 IBM Corporation and others. ++ * Copyright (c) 2000, 2015 IBM Corporation 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 +@@ -7,10 +7,9 @@ + * + * Contributors: + * IBM Corporation - initial API and implementation ++ * Sopot Cela - Bug 466829 - Migration to Lucene 5 + *******************************************************************************/ + package org.eclipse.help.internal.search; +- +-import java.io.*; + + import org.apache.lucene.analysis.*; + +@@ -18,7 +17,7 @@ + * Smart Analyzer. Chooses underlying implementation based on the field which + * text is analyzed. + */ +-public final class SmartAnalyzer extends Analyzer { ++public final class SmartAnalyzer extends AnalyzerWrapper { + Analyzer pluggedInAnalyzer; + Analyzer exactAnalyzer; + +@@ -26,19 +25,19 @@ + * Constructor for SmartAnalyzer. + */ + public SmartAnalyzer(String locale, Analyzer pluggedInAnalyzer) { +- super(); ++ super(pluggedInAnalyzer.getReuseStrategy()); + this.pluggedInAnalyzer = pluggedInAnalyzer; + this.exactAnalyzer = new DefaultAnalyzer(locale); + } + /** +- * Creates a TokenStream which tokenizes all the text in the provided +- * Reader. Delegates to DefaultAnalyzer when field used to search for exact ++ * Delegates to DefaultAnalyzer when field used to search for exact + * match, and to plugged-in analyzer for other fields. + */ +- public final TokenStream tokenStream(String fieldName, Reader reader) { ++ @Override ++ public final Analyzer getWrappedAnalyzer(String fieldName) { + if (fieldName != null && fieldName.startsWith("exact_")) { //$NON-NLS-1$ +- return exactAnalyzer.tokenStream(fieldName, reader); ++ return exactAnalyzer; + } +- return pluggedInAnalyzer.tokenStream(fieldName, reader); ++ return pluggedInAnalyzer; + } + } +diff --git a/eclipse.platform.ua/org.eclipse.help.base/src/org/eclipse/help/internal/search/WordTokenStream.java b/org.eclipse.help.base/src/org/eclipse/help/internal/search/WordTokenStream.java +index 0b70cf7..79d5592 100644 +--- a/eclipse.platform.ua/org.eclipse.help.base/src/org/eclipse/help/internal/search/WordTokenStream.java ++++ b/eclipse.platform.ua/org.eclipse.help.base/src/org/eclipse/help/internal/search/WordTokenStream.java +@@ -1,5 +1,5 @@ + /******************************************************************************* +- * Copyright (c) 2000, 2012 IBM Corporation and others. ++ * Copyright (c) 2000, 2015 IBM Corporation 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 +@@ -7,16 +7,18 @@ + * + * Contributors: + * IBM Corporation - initial API and implementation ++ * Sopot Cela - Bug 466829 - Migration to Lucene 5 + *******************************************************************************/ + package org.eclipse.help.internal.search; + +-import com.ibm.icu.text.BreakIterator; + import java.io.IOException; +-import java.io.Reader; + import java.util.Locale; ++ + import org.apache.lucene.analysis.TokenStream; + import org.apache.lucene.analysis.Tokenizer; + import org.apache.lucene.analysis.tokenattributes.CharTermAttribute; ++ ++import com.ibm.icu.text.BreakIterator; + + /** + * WordTokenStream obtains tokens containing words appropriate for use with +@@ -24,7 +26,6 @@ + */ + public final class WordTokenStream extends Tokenizer { + private static final int BUF_LEN = 4096; +- private final Reader reader; + private final BreakIterator boundary; + private StringBuffer strbuf; + +@@ -34,8 +35,8 @@ + /** + * Constructor + */ +- public WordTokenStream(String fieldName, Reader reader, Locale locale) { +- this.reader = reader; ++ public WordTokenStream(Locale locale) { ++ super(); + boundary = BreakIterator.getWordInstance(locale); + + } +@@ -52,9 +53,9 @@ + if(strbuf == null) { + int available; + char[] cbuf = new char[BUF_LEN]; +- while ((available = reader.read(cbuf)) <= 0) { ++ while ((available = input.read(cbuf)) <= 0) { + if (available < 0) { +- reader.close(); ++ input.close(); + return false; + } + } +@@ -62,7 +63,7 @@ + strbuf.append(cbuf, 0, available); + // read more until white space (or EOF) + int c; +- while (0 <= (c = reader.read())) { ++ while (0 <= (c = input.read())) { + strbuf.append((char) c); + if (c == ' ' || c == '\r' || c == '\n' || c == '\t') { + break; +@@ -70,7 +71,7 @@ + } + + if (c < 0) { +- reader.close(); ++ input.close(); + } + + boundary.setText(strbuf.toString()); +@@ -105,9 +106,10 @@ + } + + public void close() throws IOException { ++ super.close(); + /// Unlikely to be called as this is a reused +- if (this.reader != null) { +- this.reader.close(); ++ if (this.input != null) { ++ this.input.close(); + } + } + } +diff --git a/eclipse.platform.ua/org.eclipse.help.webapp/web-archive/org.eclipse.help.infocenter-feature/feature.xml b/org.eclipse.help.webapp/web-archive/org.eclipse.help.infocenter-feature/feature.xml +index 8438100..174e92a 100644 +--- a/eclipse.platform.ua/org.eclipse.help.webapp/web-archive/org.eclipse.help.infocenter-feature/feature.xml ++++ b/eclipse.platform.ua/org.eclipse.help.webapp/web-archive/org.eclipse.help.infocenter-feature/feature.xml +@@ -74,20 +74,6 @@ + unpack="false"/> + + +- +- +- +- + ++ ++ ++ ++ ++ ++ ++ ++ + +diff --git a/eclipse.platform.ua/org.eclipse.ua.tests/META-INF/MANIFEST.MF b/org.eclipse.ua.tests/META-INF/MANIFEST.MF +index 6bcf9bc..23f8910 100644 +--- a/eclipse.platform.ua/org.eclipse.ua.tests/META-INF/MANIFEST.MF ++++ b/eclipse.platform.ua/org.eclipse.ua.tests/META-INF/MANIFEST.MF +@@ -19,14 +19,13 @@ + org.eclipse.ui.forms, + org.eclipse.ui.browser;bundle-version="3.2.300", + org.eclipse.equinox.jsp.jasper;bundle-version="1.0.200", +- org.eclipse.equinox.jsp.jasper.registry;bundle-version="1.0.100" ++ org.eclipse.equinox.jsp.jasper.registry;bundle-version="1.0.100", ++ org.apache.lucene.analyzers-common;bundle-version="5.1.0", ++ org.apache.lucene.core;bundle-version="5.1.0" + Bundle-ActivationPolicy: lazy + Bundle-Vendor: Eclipse.org + Import-Package: javax.servlet;version="3.1.0", +- javax.servlet.http;version="3.1.0", +- org.apache.lucene.index;core=split;version="[3.5.0,4.0.0)", +- org.apache.lucene.search;core=split;version="[3.5.0,4.0.0)", +- org.apache.lucene.store;core=split;version="[3.5.0,4.0.0)" ++ javax.servlet.http;version="3.1.0" + Bundle-RequiredExecutionEnvironment: JavaSE-1.6 + Export-Package: org.eclipse.ua.tests, + org.eclipse.ua.tests.browser, +diff --git a/eclipse.platform.ua/org.eclipse.ua.tests/data/help/searchindex/index291/write.lock b/org.eclipse.ua.tests/data/help/searchindex/index291/write.lock +new file mode 100644 +index 0000000..e69de29 +--- /dev/null ++++ b/eclipse.platform.ua/org.eclipse.ua.tests/data/help/searchindex/index291/write.lock +diff --git a/eclipse.platform.ua/org.eclipse.ua.tests/data/help/searchindex/index510/_0.cfe b/org.eclipse.ua.tests/data/help/searchindex/index510/_0.cfe +new file mode 100644 +index 0000000..09ec2c9 +--- /dev/null ++++ b/eclipse.platform.ua/org.eclipse.ua.tests/data/help/searchindex/index510/_0.cfe +Binary files differ +diff --git a/eclipse.platform.ua/org.eclipse.ua.tests/data/help/searchindex/index510/_0.cfs b/org.eclipse.ua.tests/data/help/searchindex/index510/_0.cfs +new file mode 100644 +index 0000000..3aa288a +--- /dev/null ++++ b/eclipse.platform.ua/org.eclipse.ua.tests/data/help/searchindex/index510/_0.cfs +Binary files differ +diff --git a/eclipse.platform.ua/org.eclipse.ua.tests/data/help/searchindex/index510/_0.si b/org.eclipse.ua.tests/data/help/searchindex/index510/_0.si +new file mode 100644 +index 0000000..d897bfc +--- /dev/null ++++ b/eclipse.platform.ua/org.eclipse.ua.tests/data/help/searchindex/index510/_0.si +Binary files differ +diff --git a/eclipse.platform.ua/org.eclipse.ua.tests/data/help/searchindex/index510/segments_1 b/org.eclipse.ua.tests/data/help/searchindex/index510/segments_1 +new file mode 100644 +index 0000000..4878901 +--- /dev/null ++++ b/eclipse.platform.ua/org.eclipse.ua.tests/data/help/searchindex/index510/segments_1 +Binary files differ +diff --git a/eclipse.platform.ua/org.eclipse.ua.tests/data/help/searchindex/index510/write.lock b/org.eclipse.ua.tests/data/help/searchindex/index510/write.lock +new file mode 100644 +index 0000000..e69de29 +--- /dev/null ++++ b/eclipse.platform.ua/org.eclipse.ua.tests/data/help/searchindex/index510/write.lock +diff --git a/eclipse.platform.ua/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/search/EncodedCharacterSearch.java b/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/search/EncodedCharacterSearch.java +index 1dd4876..02b2e5b 100644 +--- a/eclipse.platform.ua/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/search/EncodedCharacterSearch.java ++++ b/eclipse.platform.ua/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/search/EncodedCharacterSearch.java +@@ -7,6 +7,7 @@ + * + * Contributors: + * IBM Corporation - initial API and implementation ++ * Sopot Cela - Bug 466829 - Migration to Lucene 5 + *******************************************************************************/ + package org.eclipse.ua.tests.help.search; + +@@ -43,7 +44,7 @@ + + public void testUtf8Hebrew() { + SearchTestUtils.searchOneLocale("\u05D0\u05B7\u05E1\u05B0\u05D8\u05B0\u05E8\u05D5\u05B9\u05E0\u05D5\u05B9\u05DE" +- + "\u05B0\u05D9\u05B8\u05D4) \u05DC\u05B4\u05E7\u05BC\u05D5\u05BC\u05D9 (\u05D9\u05E8\u05D7 \u05D0\u05D5 \u05E9\u05DE\u05E9", new String[] {"/org.eclipse.ua.tests/data/help/search/testnlUTF8.htm" }, "en"); ++ + "\u05B0\u05D9\u05B8\u05D4\\) \u05DC\u05B4\u05E7\u05BC\u05D5\u05BC\u05D9 \\(\u05D9\u05E8\u05D7 \u05D0\u05D5 \u05E9\u05DE\u05E9", new String[] {"/org.eclipse.ua.tests/data/help/search/testnlUTF8.htm" }, "en"); + } + + +diff --git a/eclipse.platform.ua/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/search/PrebuiltIndexCompatibility.java b/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/search/PrebuiltIndexCompatibility.java +index 640d4c9..33ae5ba 100644 +--- a/eclipse.platform.ua/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/search/PrebuiltIndexCompatibility.java ++++ b/eclipse.platform.ua/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/search/PrebuiltIndexCompatibility.java +@@ -8,6 +8,7 @@ + * Contributors: + * IBM Corporation - initial API and implementation + * Alexander Kurtakov - Bug 460787 ++ * Sopot Cela - Bug 466829 - Migration to Lucene 5 + *******************************************************************************/ + + package org.eclipse.ua.tests.help.search; +@@ -15,43 +16,38 @@ + import java.io.File; + import java.io.IOException; + import java.net.URL; +-import java.util.ArrayList; + +-import junit.framework.Test; +-import junit.framework.TestCase; +-import junit.framework.TestSuite; +- +-import org.osgi.framework.Bundle; +- ++import org.apache.lucene.analysis.standard.StandardAnalyzer; + import org.apache.lucene.index.CorruptIndexException; +-import org.apache.lucene.index.IndexReader; ++import org.apache.lucene.index.DirectoryReader; + import org.apache.lucene.search.IndexSearcher; + import org.apache.lucene.search.Query; + import org.apache.lucene.search.TopDocs; + import org.apache.lucene.store.Directory; + import org.apache.lucene.store.NIOFSDirectory; +- +-import org.eclipse.help.internal.base.BaseHelpSystem; +-import org.eclipse.help.internal.search.AnalyzerDescriptor; +-import org.eclipse.help.internal.search.PluginIndex; +-import org.eclipse.help.internal.search.QueryBuilder; +-import org.eclipse.help.internal.search.SearchIndexWithIndexingProgress; +-import org.eclipse.ua.tests.plugin.UserAssistanceTestPlugin; +- ++import org.apache.lucene.util.QueryBuilder; + import org.eclipse.core.runtime.FileLocator; + import org.eclipse.core.runtime.NullProgressMonitor; + import org.eclipse.core.runtime.Path; ++import org.eclipse.help.internal.base.BaseHelpSystem; ++import org.eclipse.help.internal.search.PluginIndex; ++import org.eclipse.help.internal.search.SearchIndexWithIndexingProgress; ++import org.eclipse.ua.tests.plugin.UserAssistanceTestPlugin; ++import org.osgi.framework.Bundle; ++ ++import junit.framework.Test; ++import junit.framework.TestCase; ++import junit.framework.TestSuite; + + /** +- * Verify that older versions of the index can be read by this +- * version of Eclipse. ++ * Verify that older versions of the index can be read by this version of ++ * Eclipse. + * +- * How to maintain this test - if when upgrading to a new version +- * of Lucene one of the IndexReadable tests fails you need to +- * make the following changes: +- * 1. Change the corresponding Compatible() test to expect a result of false +- * 2. Comment out the failing test +- * 3. Change the help system to recognize that version of Lucene as being incompatible ++ * How to maintain this test - if when upgrading to a new version of Lucene one ++ * of the IndexReadable tests fails you need to make the following changes: 1. ++ * Change the corresponding Compatible() test to expect a result of false 2. ++ * Comment out the failing test 3. Change the help system to recognize that ++ * version of Lucene as being incompatible + */ + + public class PrebuiltIndexCompatibility extends TestCase { +@@ -64,48 +60,33 @@ + } + + /** +- * Test index built with Lucene 1.9.1 +- */ +- public void test1_9_1_IndexReadable() throws Exception { +- checkReadable("data/help/searchindex/index191"); +- } +- +- /** +- * Test index built with Lucene 2.9.1 +- */ +- public void test2_9_1_IndexReadable() throws Exception { +- checkReadable("data/help/searchindex/index291"); +- } +- +- /** + ** Test compatibility of Lucene 1.9.1 index with current Lucene + */ +- public void test1_9_1Compatible() +- { +- checkCompatible("data/help/searchindex/index191", true); ++ public void test1_9_1Compatible() { ++ checkCompatible("data/help/searchindex/index191", false); + } +- ++ + /** + ** Test compatibility of Lucene 2.9.1 index with current Lucene + */ +- public void test2_9_1Compatible() +- { +- checkCompatible("data/help/searchindex/index291", true); ++ public void test2_9_1Compatible() { ++ checkCompatible("data/help/searchindex/index291", false); + } + +- public void test1_9_1LuceneCompatible() +- { +- checkLuceneCompatible("1.9.1", true); ++ public void test1_9_1LuceneCompatible() { ++ checkLuceneCompatible("1.9.1", false); + } + +- public void test1_4_103NotLuceneCompatible() +- { ++ public void test1_4_103NotLuceneCompatible() { + checkLuceneCompatible("1.4.103", false); + } + +- public void test2_9_1LuceneCompatible() +- { +- checkLuceneCompatible("2.9.1", true); ++ public void test2_9_1LuceneCompatible() { ++ checkLuceneCompatible("2.9.1", false); ++ } ++ ++ public void test5_1_0LuceneCompatible() { ++ checkLuceneCompatible("5.1.0", true); + } + + public void testPluginIndexEqualToItself() { +@@ -114,52 +95,59 @@ + } + + /** +- * Verify that if the paths and plugins are the same two PluginIndex objects are equal ++ * Verify that if the paths and plugins are the same two PluginIndex objects ++ * are equal + */ + public void testPluginIndexEquality() { +- PluginIndex index1a = createPluginIndex("data/help/searchindex/index191"); +- PluginIndex index1b = createPluginIndex("data/help/searchindex/index191"); ++ PluginIndex index1a = createPluginIndex("data/help/searchindex/index510"); ++ PluginIndex index1b = createPluginIndex("data/help/searchindex/index510"); + assertTrue(index1a.equals(index1b)); + } +- ++ + /** +- * Verify that if the paths and plugins are the same two PluginIndex objects are equal ++ * Verify that if the paths and plugins are the same two PluginIndex objects ++ * are equal + */ + public void testPluginIndexHash() { + PluginIndex index1a = createPluginIndex("data/help/searchindex/index191"); + PluginIndex index1b = createPluginIndex("data/help/searchindex/index191"); + assertEquals(index1a.hashCode(), index1b.hashCode()); + } +- ++ + /** +- * Verify that if the paths are different two PluginIndex objects are not equal ++ * Verify that if the paths are different two PluginIndex objects are not ++ * equal + */ + public void testPluginIndexInequality() { + PluginIndex index1 = createPluginIndex("data/help/searchindex/index191"); + PluginIndex index2 = createPluginIndex("data/help/searchindex/index291"); + assertFalse(index1.equals(index2)); + } ++ ++ public void test5_1_0IndexReadable() throws CorruptIndexException, IOException { ++ checkReadable("data/help/searchindex/index510"); ++ } + +- /* +- * Verifies that a prebuilt index can be searched +- */ +- private void checkReadable(String indexPath) throws IOException, +- CorruptIndexException { ++ /* ++ * Verifies that a prebuilt index can be searched ++ */ ++ private void checkReadable(String indexPath) throws IOException, CorruptIndexException { + Path path = new Path(indexPath); +- Bundle bundle = UserAssistanceTestPlugin.getDefault().getBundle(); ++ Bundle bundle = UserAssistanceTestPlugin.getDefault().getBundle(); + URL url = FileLocator.find(bundle, path, null); + URL resolved = FileLocator.resolve(url); + if ("file".equals(resolved.getProtocol())) { //$NON-NLS-1$ + String filePath = resolved.getFile(); +- QueryBuilder queryBuilder = new QueryBuilder("eclipse", new AnalyzerDescriptor("en-us")); +- Query luceneQuery = queryBuilder.getLuceneQuery(new ArrayList() , false); ++ StandardAnalyzer standardAnalyzer = new StandardAnalyzer(); ++ QueryBuilder builder = new QueryBuilder(standardAnalyzer); ++ Query luceneQuery = builder.createBooleanQuery("contents", "eclipse"); + Directory luceneDirectory = null; + IndexSearcher searcher = null; + try { +- luceneDirectory = new NIOFSDirectory(new File(filePath)); +- searcher = new IndexSearcher(IndexReader.open(luceneDirectory, true)); ++ luceneDirectory = new NIOFSDirectory(new File(filePath).toPath()); ++ searcher = new IndexSearcher(DirectoryReader.open(luceneDirectory)); + TopDocs hits = searcher.search(luceneQuery, 500); +- assertEquals(hits.totalHits, 1); ++ assertEquals(1, hits.totalHits ); + } finally { + if (luceneDirectory != null) + try { +@@ -167,13 +155,13 @@ + } catch (IOException x) { + } + if (searcher != null) +- searcher.close(); ++ searcher.getIndexReader().close(); + } + } else { + fail("Cannot resolve to file protocol"); + } + } +- ++ + /* + * Tests the isCompatible method in PluginIndex + */ +@@ -186,22 +174,20 @@ + public PluginIndex createPluginIndex(String versionDirectory) { + PluginIndex pluginIndex; + SearchIndexWithIndexingProgress index = BaseHelpSystem.getLocalSearchManager().getIndex("en_us".toString()); +- BaseHelpSystem.getLocalSearchManager().ensureIndexUpdated( +- new NullProgressMonitor(), +- index); ++ BaseHelpSystem.getLocalSearchManager().ensureIndexUpdated(new NullProgressMonitor(), index); + pluginIndex = new PluginIndex("org.eclipse.ua.tests", "data/help/searchindex/" + versionDirectory, index); + return pluginIndex; + } +- ++ + /* +- * Tests the isLuceneCompatible method in SearchIndex ++ * Tests the isLuceneCompatible method in SearchIndex + */ + private void checkLuceneCompatible(String version, boolean expected) { + SearchIndexWithIndexingProgress index = BaseHelpSystem.getLocalSearchManager().getIndex("en_us".toString()); +- BaseHelpSystem.getLocalSearchManager().ensureIndexUpdated( +- new NullProgressMonitor(), +- index); ++ BaseHelpSystem.getLocalSearchManager().ensureIndexUpdated(new NullProgressMonitor(), index); + assertEquals(expected, index.isLuceneCompatible(version)); + } + ++ ++ + } +diff --git a/eclipse.platform.ua/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/search/SearchParticipantTest.java b/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/search/SearchParticipantTest.java +index 223e42a..2e782c3 100644 +--- a/eclipse.platform.ua/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/search/SearchParticipantTest.java ++++ b/eclipse.platform.ua/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/search/SearchParticipantTest.java +@@ -1,5 +1,5 @@ + /******************************************************************************* +- * Copyright (c) 2010 IBM Corporation and others. ++ * Copyright (c) 2010, 2015 IBM Corporation 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 +@@ -7,6 +7,7 @@ + * + * Contributors: + * IBM Corporation - initial API and implementation ++ * Sopot Cela - Bug 466829 - Migration to Lucene 5 + *******************************************************************************/ + package org.eclipse.ua.tests.help.search; + +@@ -40,7 +41,7 @@ + } + + public void testSearchUsingAndInSeparateDocs() { +- SearchTestUtils.searchAllLocales("jduehdye and olhoykk", new String[0]); ++ SearchTestUtils.searchAllLocales("jduehdye AND olhoykk", new String[0]); + } + + public void testSearchExactMatch() { +--- a/eclipse.platform.common/bundles/org.eclipse.platform.doc.isv/pom.xml ++++ b/eclipse.platform.common/bundles/org.eclipse.platform.doc.isv/pom.xml +@@ -101,7 +101,7 @@ + + + eclipse-plugin +- org.apache.lucene.analysis ++ org.apache.lucene.analyzers-common + 0.0.0 + + diff --git a/SOURCES/eclipse-no-target-platform.patch b/SOURCES/eclipse-no-target-platform.patch deleted file mode 100644 index ae8873b..0000000 --- a/SOURCES/eclipse-no-target-platform.patch +++ /dev/null @@ -1,16 +0,0 @@ ---- eclipse-platform-parent/pom.xml.orig 2015-01-30 11:09:37.156904060 +0000 -+++ eclipse-platform-parent/pom.xml 2015-01-30 11:11:05.154445821 +0000 -@@ -204,13 +204,6 @@ - -- -- -- org.eclipse -- eclipse-sdk-prereqs -- 4.5.0-SNAPSHOT -- -- - - - linux diff --git a/SOURCES/eclipse-secondary-arches.patch b/SOURCES/eclipse-secondary-arches.patch index c25e8f5..7871f28 100644 --- a/SOURCES/eclipse-secondary-arches.patch +++ b/SOURCES/eclipse-secondary-arches.patch @@ -2,7 +2,7 @@ diff --git a/eclipse.platform.swt.binaries/pom.xml b/eclipse.platform.swt.binari index 7dd0536..66d79ee 100644 --- a/eclipse.platform.swt.binaries/pom.xml +++ b/eclipse.platform.swt.binaries/pom.xml -@@ -53,6 +53,8 @@ +@@ -63,6 +63,8 @@ bundles/org.eclipse.swt.gtk.linux.ppc64le bundles/org.eclipse.swt.gtk.linux.s390 bundles/org.eclipse.swt.gtk.linux.s390x @@ -15,7 +15,7 @@ diff --git a/rt.equinox.framework/pom.xml b/rt.equinox.framework/pom.xml index b46cdc6..0fb36a5 100644 --- a/rt.equinox.framework/pom.xml +++ b/rt.equinox.framework/pom.xml -@@ -54,6 +54,8 @@ +@@ -64,6 +64,8 @@ bundles/org.eclipse.equinox.launcher.gtk.aix.ppc bundles/org.eclipse.equinox.launcher.gtk.aix.ppc64 bundles/org.eclipse.equinox.launcher.gtk.hpux.ia64 diff --git a/SOURCES/eclipse-support-symlink-bundles.patch b/SOURCES/eclipse-support-symlink-bundles.patch index 7f71e5a..de8363a 100644 --- a/SOURCES/eclipse-support-symlink-bundles.patch +++ b/SOURCES/eclipse-support-symlink-bundles.patch @@ -1,4 +1,4 @@ -From 0b0f725bdcf10918a25321a66c0abd4ddbbdd870 Mon Sep 17 00:00:00 2001 +From aabcf5acff194b807c4d0bcf68425c3452c90339 Mon Sep 17 00:00:00 2001 From: Roland Grunberg Date: Fri, 12 Sep 2014 10:27:14 -0400 Subject: [PATCH] Add support for regenerating bundle versions for symlinks. @@ -26,15 +26,14 @@ index d88d0a6..07fe087 100644 org.osgi.framework.namespace;version="1.0.0", org.osgi.framework.wiring;version="1.2.0", diff --git rt.equinox.p2/bundles/org.eclipse.equinox.simpleconfigurator/src/org/eclipse/equinox/internal/simpleconfigurator/utils/SimpleConfiguratorUtils.java rt.equinox.p2/bundles/org.eclipse.equinox.simpleconfigurator/src/org/eclipse/equinox/internal/simpleconfigurator/utils/SimpleConfiguratorUtils.java -index ab69b88..12e4d89 100644 +index ab69b88..d6bf121 100644 --- rt.equinox.p2/bundles/org.eclipse.equinox.simpleconfigurator/src/org/eclipse/equinox/internal/simpleconfigurator/utils/SimpleConfiguratorUtils.java +++ rt.equinox.p2/bundles/org.eclipse.equinox.simpleconfigurator/src/org/eclipse/equinox/internal/simpleconfigurator/utils/SimpleConfiguratorUtils.java -@@ -13,9 +13,15 @@ package org.eclipse.equinox.internal.simpleconfigurator.utils; +@@ -13,9 +13,14 @@ package org.eclipse.equinox.internal.simpleconfigurator.utils; import java.io.*; import java.net.*; -+import java.nio.file.Files; -+import java.nio.file.Paths; ++import java.nio.file.*; import java.util.*; +import java.util.jar.JarFile; +import java.util.zip.ZipEntry; @@ -46,14 +45,15 @@ index ab69b88..12e4d89 100644 public class SimpleConfiguratorUtils { -@@ -283,6 +289,15 @@ public class SimpleConfiguratorUtils { +@@ -283,6 +288,16 @@ public class SimpleConfiguratorUtils { String symbolicName = tok.nextToken().trim(); String version = tok.nextToken().trim(); URI location = parseLocation(tok.nextToken().trim()); + if (base != null) { + URI absLoc = URIUtil.append(base, location.toString()); ++ Path absPath = Paths.get(absLoc); + // Symbolic links may change outside Eclipse so regenerate proper bundle version. -+ if (Files.isSymbolicLink(Paths.get(absLoc))) { ++ if (Files.isSymbolicLink(absPath) && absPath.toFile().isFile()) { + // We can't depend on org.eclipse.equinox.internal.frameworkadmin.utils.Utils + Dictionary manifest = getOSGiManifest(absLoc); + version = manifest.get(Constants.BUNDLE_VERSION); @@ -157,5 +157,5 @@ index ab69b88..12e4d89 100644 + } } -- -2.1.0 +2.5.0 diff --git a/SOURCES/eclipse-test-support.patch b/SOURCES/eclipse-test-support.patch index ccabc76..3c1bb99 100644 --- a/SOURCES/eclipse-test-support.patch +++ b/SOURCES/eclipse-test-support.patch @@ -122,7 +122,7 @@ -@@ -1430,6 +1370,15 @@ +@@ -1431,6 +1371,15 @@ value="end longRunningTests" /> @@ -138,7 +138,7 @@