Codebase list eclipse-platform-text / 00637a1
New upstream version 4.17 Emmanuel Bourg 3 years ago
118 changed file(s) with 1964 addition(s) and 744 deletion(s). Raw diff Collapse all Expand all
22 <extension>
33 <groupId>org.eclipse.tycho.extras</groupId>
44 <artifactId>tycho-pomless</artifactId>
5 <version>1.7.0</version>
5 <version>2.0.0</version>
66 </extension>
77 </extensions>
11 Bundle-ManifestVersion: 2
22 Bundle-Name: %Plugin.name
33 Bundle-SymbolicName: org.eclipse.core.filebuffers.tests;singleton:=true
4 Bundle-Version: 3.11.500.qualifier
4 Bundle-Version: 3.11.600.qualifier
55 Bundle-Activator: org.eclipse.core.filebuffers.tests.FileBuffersTestPlugin
66 Bundle-ActivationPolicy: lazy
77 Bundle-Vendor: %Plugin.providerName
1313 <parent>
1414 <artifactId>tests-pom</artifactId>
1515 <groupId>eclipse.platform.text</groupId>
16 <version>4.16.0-SNAPSHOT</version>
16 <version>4.17.0-SNAPSHOT</version>
1717 <relativePath>../tests-pom/</relativePath>
1818 </parent>
1919 <groupId>org.eclipse.core</groupId>
2020 <artifactId>org.eclipse.core.filebuffers.tests</artifactId>
21 <version>3.11.500-SNAPSHOT</version>
21 <version>3.11.600-SNAPSHOT</version>
2222 <packaging>eclipse-test-plugin</packaging>
2323 <properties>
2424 <testSuite>${project.artifactId}</testSuite>
140140 if (srcChildren == null) {
141141 throw new IOException("Content from directory '" + src.getAbsolutePath() + "' can not be listed."); //$NON-NLS-1$ //$NON-NLS-2$
142142 }
143 for(int i = 0; i < srcChildren.length; ++i){
144 File srcChild= new File(src, srcChildren[i]);
145 File dstChild= new File(dst, srcChildren[i]);
143 for (String srcChild2 : srcChildren) {
144 File srcChild= new File(src, srcChild2);
145 File dstChild= new File(dst, srcChild2);
146146 copy(srcChild, dstChild);
147147 }
148148 } else
00 <?xml version="1.0" encoding="UTF-8" standalone="no"?>
11 <component id="org.eclipse.jface.text" version="2">
2 <resource path="META-INF/MANIFEST.MF">
3 <filter comment="Bug 552134 - org.eclipse.rcp misses dependency to org.eclipse.jface.text" id="924844039">
2 <resource path="META-INF/MANIFEST.MF" type="org.eclipse.jface.text.Assert">
3 <filter comment="Planned deletion" id="305422471">
44 <message_arguments>
5 <message_argument value="3.16.300"/>
6 <message_argument value="3.16.200"/>
7 </message_arguments>
8 </filter>
9 <filter comment="Version wrongly bumped again in Bug 483846 - [typing] Spaces only mode: backspace key to remove many spaces " id="931135546">
10 <message_arguments>
11 <message_argument value="3.16.100"/>
12 <message_argument value="3.15.300"/>
13 </message_arguments>
14 </filter>
15 </resource>
16 <resource path="src/org/eclipse/jface/text/ITextViewer.java" type="org.eclipse.jface.text.ITextViewer">
17 <filter comment="Method introduction unlikely to collide with existing implementations." id="404000815">
18 <message_arguments>
19 <message_argument value="org.eclipse.jface.text.ITextViewer"/>
20 <message_argument value="getLastKnownSelection()"/>
5 <message_argument value="org.eclipse.jface.text.Assert"/>
6 <message_argument value="org.eclipse.jface.text_3.16.300"/>
217 </message_arguments>
228 </filter>
239 </resource>
11 Bundle-ManifestVersion: 2
22 Bundle-Name: %pluginName
33 Bundle-SymbolicName: org.eclipse.jface.text
4 Bundle-Version: 3.16.300.qualifier
4 Bundle-Version: 3.16.400.qualifier
55 Bundle-Vendor: %providerName
66 Bundle-Localization: plugin
77 Export-Package:
855855 try {
856856 catchupWithProjectionAnnotationModel(event);
857857 } catch (BadLocationException x) {
858 throw new IllegalArgumentException();
858 throw new IllegalArgumentException(x);
859859 }
860860
861861 } else
893893 try {
894894 catchupWithProjectionAnnotationModel(null);
895895 } catch (BadLocationException x1) {
896 throw new IllegalArgumentException();
896 throw new IllegalArgumentException(x1);
897897 } finally {
898898 synchronized (fLock) {
899899 fPendingRequests.clear();
7272 private Label fSeparator;
7373 /** The font of the optional status text label.*/
7474 private Font fStatusTextFont;
75 /**
76 * The color of the optional status text label or <code>null</code> if none.
77 *
78 * @since 3.6
79 */
80 private Color fStatusTextForegroundColor;
8175 /** The maximal widget width. */
8276 private int fMaxWidth;
8377 /** The maximal widget height. */
172166 GridData gd2= new GridData(GridData.FILL_VERTICAL | GridData.FILL_HORIZONTAL | GridData.HORIZONTAL_ALIGN_BEGINNING | GridData.VERTICAL_ALIGN_BEGINNING);
173167 fStatusField.setLayoutData(gd2);
174168
175 fStatusTextForegroundColor= new Color(fStatusField.getDisplay(), blend(display.getSystemColor(SWT.COLOR_INFO_BACKGROUND).getRGB(), display.getSystemColor(SWT.COLOR_INFO_FOREGROUND).getRGB(), 0.56f));
176 fStatusField.setForeground(fStatusTextForegroundColor);
169 Color statusTextForegroundColor= new Color(fStatusField.getDisplay(),
170 blend(display.getSystemColor(SWT.COLOR_INFO_BACKGROUND).getRGB(), display.getSystemColor(SWT.COLOR_INFO_FOREGROUND).getRGB(), 0.56f));
171 fStatusField.setForeground(statusTextForegroundColor);
177172
178173 fStatusField.setBackground(display.getSystemColor(SWT.COLOR_INFO_BACKGROUND));
179174 }
239234 if (fStatusTextFont != null && !fStatusTextFont.isDisposed())
240235 fStatusTextFont.dispose();
241236 fStatusTextFont= null;
242 if (fStatusTextForegroundColor != null && !fStatusTextForegroundColor.isDisposed())
243 fStatusTextForegroundColor.dispose();
244 fStatusTextForegroundColor= null;
245237
246238 fTextFont= null;
247239 fShell= null;
8686 * @since 3.4.2
8787 */
8888 private Font fStatusLabelFont;
89 /**
90 * Color for the label in the status line or <code>null</code> if none.
91 *
92 * @since 3.6
93 */
94 private Color fStatusLabelForeground;
9589 /** The toolbar manager used by the toolbar or <code>null</code> if none. */
9690 private final ToolBarManager fToolBarManager;
9791 /** Status line toolbar or <code>null</code> if none. */
516510 fStatusLabelFont.dispose();
517511 fStatusLabelFont= null;
518512 }
519 if (fStatusLabelForeground != null) {
520 fStatusLabelForeground.dispose();
521 fStatusLabelForeground= null;
522 }
523513 }
524514
525515 @Override
634624
635625 private void setStatusLabelColors(Color foreground, Color background) {
636626 if (foreground == null || background == null) return;
637 if (fStatusLabelForeground != null) {
638 fStatusLabelForeground.dispose();
639 }
640 fStatusLabelForeground = new Color(fStatusLabel.getDisplay(), Colors.blend(background.getRGB(), foreground.getRGB(), 0.56f));
641 fStatusLabel.setForeground(fStatusLabelForeground);
627 Color statusLabelForeground= new Color(fStatusLabel.getDisplay(), Colors.blend(background.getRGB(), foreground.getRGB(), 0.56f));
628 fStatusLabel.setForeground(statusLabelForeground);
642629 fStatusLabel.setBackground(background);
643630 }
644631
292292 displayProposals();
293293 }
294294 }, true, false, true);
295 fFilteredProposals= new ArrayList<>(fComputedProposals != null ? fComputedProposals : Collections.emptyList());
296295 return getErrorMessage();
297296 }
298297
603603 fProposalShell.setFont(JFaceResources.getDefaultFont());
604604 fProposalTable= new Table(fProposalShell, SWT.H_SCROLL | SWT.V_SCROLL | SWT.VIRTUAL);
605605
606 Listener listener= event -> handleSetData(event);
606 Listener listener= this::handleSetData;
607607 fProposalTable.addListener(SWT.SetData, listener);
608608
609609 fIsColoredLabelsSupportEnabled= fContentAssistant.isColoredLabelsSupportEnabled();
9090 private boolean fIsUsingNativeLinkColor;
9191 /** The link color specification. May be <code>null</code>. */
9292 private RGB fRGB;
93 /** Tells whether to dispose the color on uninstall. */
94 private boolean fDisposeColor;
9593 /** The currently active region. */
9694 private IRegion fActiveRegion;
9795 /** The currently active style range as position. */
108106 */
109107 public DefaultHyperlinkPresenter(IPreferenceStore store) {
110108 fPreferenceStore= store;
111 fDisposeColor= true;
112109 }
113110
114111 /**
129126 */
130127 public DefaultHyperlinkPresenter(RGB color) {
131128 fRGB= color;
132 fDisposeColor= true;
133129 }
134130
135131 @Override
193189 document.removeDocumentListener(this);
194190
195191 if (fColor != null) {
196 if (fDisposeColor)
197 fColor.dispose();
198192 fColor= null;
199193 }
200194
217211 public void setColor(Color color) {
218212 Assert.isNotNull(fTextViewer);
219213 Assert.isTrue(fPreferenceStore == null, "Cannot set color if preference store is set"); //$NON-NLS-1$
220 if (fColor != null && fDisposeColor)
221 fColor.dispose();
222214 fColor= color;
223215 }
224216
349341 @Override
350342 public void propertyChange(PropertyChangeEvent event) {
351343 if (HYPERLINK_COLOR.equals(event.getProperty())) {
352 if (fColor != null && fDisposeColor)
353 fColor.dispose();
354344 fColor= createColorFromPreferenceStore();
355345 return;
356346 }
3737 Color getColor(RGB rgb);
3838
3939 /**
40 * Tells this object to dispose all its managed colors.
40 * Tells this object to dispose all its managed objects- Note that colors do not need dispose
41 * anymore
42 *
4143 */
42 void dispose();
44 default void dispose() {
45 // nothing to do anymore as colors do not require disposal
46 }
4347 }
1313 <parent>
1414 <artifactId>eclipse.platform.text</artifactId>
1515 <groupId>eclipse.platform.text</groupId>
16 <version>4.16.0-SNAPSHOT</version>
16 <version>4.17.0-SNAPSHOT</version>
1717 </parent>
1818 <groupId>org.eclipse.core</groupId>
1919 <artifactId>org.eclipse.jface.text.examples</artifactId>
11 Bundle-ManifestVersion: 2
22 Bundle-Name: %Plugin.name
33 Bundle-SymbolicName: org.eclipse.jface.text.tests
4 Bundle-Version: 3.11.1100.qualifier
4 Bundle-Version: 3.11.1200.qualifier
55 Bundle-Vendor: %Plugin.providerName
66 Bundle-Localization: plugin
77 Export-Package:
1313 <parent>
1414 <artifactId>tests-pom</artifactId>
1515 <groupId>eclipse.platform.text</groupId>
16 <version>4.16.0-SNAPSHOT</version>
16 <version>4.17.0-SNAPSHOT</version>
1717 <relativePath>../tests-pom/</relativePath>
1818 </parent>
1919 <groupId>org.eclipse.jface</groupId>
2020 <artifactId>org.eclipse.jface.text.tests</artifactId>
21 <version>3.11.1100-SNAPSHOT</version>
21 <version>3.11.1200-SNAPSHOT</version>
2222 <packaging>eclipse-test-plugin</packaging>
2323 <properties>
2424 <testSuite>${project.artifactId}</testSuite>
2222 import org.eclipse.jface.text.tests.contentassist.ContextInformationPresenterTest;
2323 import org.eclipse.jface.text.tests.contentassist.ContextInformationTest;
2424 import org.eclipse.jface.text.tests.contentassist.FilteringAsyncContentAssistTests;
25 import org.eclipse.jface.text.tests.contentassist.IncrementalAsyncContentAssistTests;
2526 import org.eclipse.jface.text.tests.reconciler.AbstractReconcilerTest;
2627 import org.eclipse.jface.text.tests.rules.DefaultPartitionerTest;
2728 import org.eclipse.jface.text.tests.rules.DefaultPartitionerZeroLengthTest;
5253 DefaultPairMatcherTest2.class,
5354 AsyncContentAssistTest.class,
5455 FilteringAsyncContentAssistTests.class,
56 IncrementalAsyncContentAssistTests.class,
5557 ContextInformationTest.class,
5658 ContextInformationPresenterTest.class,
5759
9797 public Color getColor(RGB rgb) {
9898 return null;
9999 }
100
101 @Override
102 public void dispose() {
103 }
104100 });
105101 projectionSupport.install();
106102 fViewer.doOperation(ProjectionViewer.TOGGLE);
99 *******************************************************************************/
1010 package org.eclipse.jface.text.tests.contentassist;
1111
12 import static java.util.Collections.singletonList;
1213 import static org.junit.Assert.assertEquals;
1314 import static org.junit.Assert.assertTrue;
1415
1516 import java.lang.reflect.Field;
17 import java.util.ArrayList;
18 import java.util.Arrays;
1619 import java.util.List;
1720 import java.util.concurrent.CountDownLatch;
1821 import java.util.function.Predicate;
3437 import org.eclipse.jface.text.Document;
3538 import org.eclipse.jface.text.DocumentEvent;
3639 import org.eclipse.jface.text.IDocument;
40 import org.eclipse.jface.text.IInformationControlCreator;
3741 import org.eclipse.jface.text.ITextViewer;
3842 import org.eclipse.jface.text.contentassist.ContentAssistant;
3943 import org.eclipse.jface.text.contentassist.ContextInformationValidator;
4044 import org.eclipse.jface.text.contentassist.ICompletionProposal;
4145 import org.eclipse.jface.text.contentassist.ICompletionProposalExtension;
4246 import org.eclipse.jface.text.contentassist.ICompletionProposalExtension2;
47 import org.eclipse.jface.text.contentassist.ICompletionProposalExtension3;
4348 import org.eclipse.jface.text.contentassist.IContentAssistProcessor;
4449 import org.eclipse.jface.text.contentassist.IContextInformation;
4550 import org.eclipse.jface.text.contentassist.IContextInformationValidator;
202207 IDocument document = viewer.getDocument();
203208
204209 ca.addContentAssistProcessor(new ImmediateContentAssistProcessor("xx"), IDocument.DEFAULT_CONTENT_TYPE);
205 ca.addContentAssistProcessor(new DelayedContentAssistProcessor("yy", 3000, false),
210 ca.addContentAssistProcessor(new DelayedContentAssistProcessor(singletonList("yy"), 3000, false),
206211 IDocument.DEFAULT_CONTENT_TYPE);
207212
208213 ca.install(viewer);
246251 public void testCA_WithFirstDelayedThenImmediateProposals() throws Exception {
247252 IDocument document = viewer.getDocument();
248253
249 ca.addContentAssistProcessor(new LongInitialContentAssistProcessor("abc", 500, true),
254 ca.addContentAssistProcessor(new LongInitialContentAssistProcessor(singletonList("abc"), 500, true),
250255 IDocument.DEFAULT_CONTENT_TYPE);
251256
252257 ca.install(viewer);
286291 IDocument document = viewer.getDocument();
287292
288293 ca.addContentAssistProcessor(new ImmediateContentAssistProcessor("xxxx"), IDocument.DEFAULT_CONTENT_TYPE);
289 ca.addContentAssistProcessor(new DelayedContentAssistProcessor("yyyy", 5000, false),
294 ca.addContentAssistProcessor(new DelayedContentAssistProcessor(singletonList("yyyy"), 5000, false),
290295 IDocument.DEFAULT_CONTENT_TYPE);
291296
292297 ca.install(viewer);
353358
354359 }
355360
356 private class ImmediateContentAssistProcessor implements IContentAssistProcessor {
357
358 final private String template;
361 static class ImmediateContentAssistProcessor implements IContentAssistProcessor {
362
363 final private List<String> templates;
359364 final private boolean incomplete;
360365
361 ImmediateContentAssistProcessor(String template) {
362 this(template, false);
363 }
364
365 ImmediateContentAssistProcessor(String template, boolean incomplete) {
366 this.template = template;
366 ImmediateContentAssistProcessor(String... templates) {
367 this(Arrays.asList(templates), false);
368 }
369
370 ImmediateContentAssistProcessor(List<String> templates, boolean incomplete) {
371 this.templates= templates;
367372 this.incomplete = incomplete;
368373 }
369374
370375 @Override
371376 public ICompletionProposal[] computeCompletionProposals(ITextViewer textViewer, int offset) {
377 List<ICompletionProposal> proposals= new ArrayList<>();
372378 try {
373379 IDocument document= textViewer.getDocument();
374 if (document != null && (document.getLength() == 0 || isSubstringFoundOrderedInString(document.get(0, offset), template))) {
375 if (incomplete) {
376 return new ICompletionProposal[] {
377 new IncompleteCompletionProposal(template, offset, 0, offset, template) };
378 } else {
379 CompletionProposal proposal = new CompletionProposal(template, offset, 0, offset, template);
380 return new ICompletionProposal[] { proposal };
380 for (String template : templates) {
381 if (document != null && (document.getLength() == 0 || isSubstringFoundOrderedInString(document.get(0, offset), template))) {
382 if (incomplete) {
383 proposals.add(new IncompleteCompletionProposal(template, offset, 0, offset, template));
384 } else {
385 proposals.add(new CompletionProposal(template, offset, 0, offset, template));
386 }
381387 }
382388 }
383389 } catch (BadLocationException e) {
384390 throw new IllegalStateException("Error computing proposals");
385391 }
386 return new ICompletionProposal[0];
392 return proposals.toArray(new ICompletionProposal[0]);
387393 }
388394
389395 @Override
413419
414420 }
415421
416 private class DelayedContentAssistProcessor extends ImmediateContentAssistProcessor {
422 static class DelayedContentAssistProcessor extends ImmediateContentAssistProcessor {
417423
418424 protected long delay;
419425
420 DelayedContentAssistProcessor(String template, long delay, boolean incomplete) {
421 super(template, incomplete);
426 DelayedContentAssistProcessor(List<String> templates, long delay, boolean incomplete) {
427 super(templates, incomplete);
422428 this.delay = delay;
423429 }
424430
431437 throw new IllegalStateException("Cannot generate delayed content assist proposals!");
432438 }
433439 }
434 return super.computeCompletionProposals(viewer, offset);
440 return super.computeCompletionProposals(textViewer, offset);
435441 }
436442 }
437443
438444 private class LongInitialContentAssistProcessor extends DelayedContentAssistProcessor {
439445
440 LongInitialContentAssistProcessor(String template, long delay, boolean incomplete) {
441 super(template, delay, incomplete);
446 LongInitialContentAssistProcessor(List<String> templates, long delay, boolean incomplete) {
447 super(templates, delay, incomplete);
442448 }
443449
444450 @Override
453459
454460 final CountDownLatch blocked= new CountDownLatch(1);
455461
456 BlockingProcessor(String template) {
457 super(template, false);
462 BlockingProcessor(String... templates) {
463 super(Arrays.asList(templates), false);
458464 }
459465
460466 @Override
483489 }
484490
485491 @SuppressWarnings("unchecked")
486 private static List<ICompletionProposal> getFilteredProposals(ContentAssistant ca) throws Exception {
492 static List<ICompletionProposal> getFilteredProposals(ContentAssistant ca) throws Exception {
487493 Field f = ContentAssistant.class.getDeclaredField("fProposalPopup");
488494 f.setAccessible(true);
489495 Object caPopup = f.get(ca);
565571 }
566572 }
567573
568 private static class CompletionProposal extends IncompleteCompletionProposal
569 implements ICompletionProposalExtension, ICompletionProposalExtension2 {
574 static class CompletionProposal extends IncompleteCompletionProposal
575 implements ICompletionProposalExtension, ICompletionProposalExtension2, ICompletionProposalExtension3 {
570576
571577 public CompletionProposal(String replacementString, int replacementOffset, int replacementLength,
572578 int cursorPosition, String displayString) {
623629 return 0;
624630 }
625631
632 @Override
633 public int getPrefixCompletionStart(IDocument document, int completionOffset) {
634 return 0;
635 }
636
637 @Override
638 public CharSequence getPrefixCompletionText(IDocument document, int completionOffset) {
639 return getDisplayString();
640 }
641
642 @Override
643 public IInformationControlCreator getInformationControlCreator() {
644 return null;
645 }
646
647 @Override
648 public String toString() {
649 return getDisplayString();
650 }
626651 }
627652
628653 @SuppressWarnings("boxing")
0 /*******************************************************************************
1 * Copyright (c) 2020 Julian Honnen
2 * All rights reserved. This program and the accompanying materials
3 * are made available under the terms of the Eclipse Public License v1.0
4 * which accompanies this distribution, and is available at
5 * https://www.eclipse.org/legal/epl-v10.html
6 *
7 * Contributors:
8 * Julian Honnen - initial API and implementation
9 *******************************************************************************/
10 package org.eclipse.jface.text.tests.contentassist;
11
12 import static java.util.stream.Collectors.toList;
13 import static org.junit.Assert.assertEquals;
14
15 import java.util.Arrays;
16 import java.util.Comparator;
17 import java.util.List;
18
19 import org.junit.After;
20 import org.junit.Before;
21 import org.junit.Test;
22
23 import org.eclipse.swt.SWT;
24 import org.eclipse.swt.widgets.Shell;
25
26 import org.eclipse.jface.text.Document;
27 import org.eclipse.jface.text.IDocument;
28 import org.eclipse.jface.text.contentassist.ContentAssistant;
29 import org.eclipse.jface.text.contentassist.ICompletionProposal;
30 import org.eclipse.jface.text.source.SourceViewer;
31 import org.eclipse.jface.text.tests.util.DisplayHelper;
32
33 public class IncrementalAsyncContentAssistTests {
34
35 private Shell shell;
36
37 private SourceViewer viewer;
38
39 private ContentAssistant ca;
40
41 @Before
42 public void setup() {
43 tearDown();
44
45 shell= new Shell();
46 shell.setSize(300, 300);
47 shell.open();
48
49 viewer= new SourceViewer(shell, null, SWT.NONE);
50 Document document= new Document();
51 viewer.setDocument(document);
52 ca= new ContentAssistant(true);
53
54 Comparator<ICompletionProposal> comparator= Comparator.comparing(ICompletionProposal::getDisplayString);
55 ca.setSorter(comparator::compare);
56 }
57
58 @After
59 public void tearDown() {
60 if (shell != null) {
61 ca.uninstall();
62 if (!shell.isDisposed()) {
63 shell.dispose();
64 }
65 shell= null;
66 }
67 }
68
69 @Test
70 public void testIncrementalComplete() throws Exception {
71 ca.addContentAssistProcessor(new FilteringAsyncContentAssistTests.ImmediateContentAssistProcessor("testC", "testB", "testA"), IDocument.DEFAULT_CONTENT_TYPE);
72
73 viewer.getDocument().set("t");
74
75 ca.install(viewer);
76 viewer.setSelectedRange(1, 0);
77
78 ca.completePrefix();
79
80 DisplayHelper.sleep(shell.getDisplay(), 300);
81
82 List<String> filteredProposals= FilteringAsyncContentAssistTests.getFilteredProposals(ca).stream() //
83 .map(ICompletionProposal::getDisplayString) //
84 .collect(toList());
85 assertEquals(Arrays.asList("testA", "testB", "testC"), filteredProposals);
86 }
87
88 @Test
89 public void testIncrementalComplete_async() throws Exception {
90 long delay= 200;
91 ca.addContentAssistProcessor(new FilteringAsyncContentAssistTests.DelayedContentAssistProcessor(Arrays.asList("testC", "testB", "testA"), delay, false), IDocument.DEFAULT_CONTENT_TYPE);
92
93 viewer.getDocument().set("t");
94
95 ca.install(viewer);
96 viewer.setSelectedRange(1, 0);
97
98 ca.completePrefix();
99
100 DisplayHelper.sleep(shell.getDisplay(), delay + 100);
101
102 List<String> filteredProposals= FilteringAsyncContentAssistTests.getFilteredProposals(ca).stream() //
103 .map(ICompletionProposal::getDisplayString) //
104 .collect(toList());
105 assertEquals(Arrays.asList("testA", "testB", "testC"), filteredProposals);
106 }
107
108 @Test
109 public void testIncrementalCompleteOfSingleProposal() throws Exception {
110 ca.enableAutoInsert(true);
111 ca.addContentAssistProcessor(new FilteringAsyncContentAssistTests.ImmediateContentAssistProcessor("testA"), IDocument.DEFAULT_CONTENT_TYPE);
112
113 ca.install(viewer);
114 viewer.setSelectedRange(0, 0);
115
116 ca.completePrefix();
117
118 DisplayHelper.sleep(shell.getDisplay(), 300);
119
120 assertEquals("testA", viewer.getDocument().get());
121 }
122
123 }
00 <?xml version="1.0" encoding="UTF-8" standalone="no"?>
11 <component id="org.eclipse.search" version="2">
2 <resource path="META-INF/MANIFEST.MF">
3 <filter comment="Revert of Java 11 update, version cannot be decreased anymore" id="926941240">
4 <message_arguments>
5 <message_argument value="3.12.0"/>
6 <message_argument value="3.11.1000"/>
7 </message_arguments>
8 </filter>
9 </resource>
210 <resource path="search/org/eclipse/search/internal/ui/SearchDialog.java" type="org.eclipse.search.internal.ui.SearchDialog">
311 <filter id="571519004">
412 <message_arguments>
11 Bundle-ManifestVersion: 2
22 Bundle-Name: %pluginName
33 Bundle-SymbolicName: org.eclipse.search; singleton:=true
4 Bundle-Version: 3.11.1000.qualifier
4 Bundle-Version: 3.12.0.qualifier
55 Bundle-Activator: org.eclipse.search.internal.ui.SearchPlugin
66 Bundle-ActivationPolicy: lazy
77 Bundle-Vendor: %providerName
org.eclipse.search/icons/full/eview16/searchres.gif less more
Binary diff not shown
171171 ListenerAndLabelProvider listenerAndLP= new ListenerAndLabelProvider();
172172
173173 fListViewer.setLabelProvider(listenerAndLP);
174 fListViewer.setContentProvider(new ArrayContentProvider());
174 fListViewer.setContentProvider(ArrayContentProvider.getInstance());
175175 fListViewer.addSelectionChangedListener(listenerAndLP);
176176 fListViewer.addCheckStateListener(listenerAndLP);
177177 fListViewer.setInput(fAllFilters);
294294 parent.setLayoutData(new GridData(GridData.FILL_BOTH));
295295
296296 fViewer= new TableViewer(parent, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER | SWT.FULL_SELECTION);
297 fViewer.setContentProvider(new ArrayContentProvider());
297 fViewer.setContentProvider(ArrayContentProvider.getInstance());
298298
299299 final Table table= fViewer.getTable();
300300 table.addMouseListener(new MouseAdapter() {
332332
333333 String message= SearchMessages.SearchPageSelectionDialog_message;
334334
335 ListSelectionDialog dialog= new ListSelectionDialog(getShell(), input, new ArrayContentProvider(), labelProvider, message) {
335 ListSelectionDialog dialog = new ListSelectionDialog(getShell(), input, ArrayContentProvider.getInstance(),
336 labelProvider, message) {
336337 Button fLastUsedPageButton;
337338
338339 @Override
332332 if (Thread.currentThread() == display.getThread())
333333 handleNewSearchResult();
334334 else {
335 display.syncExec(() -> handleNewSearchResult());
335 display.syncExec(this::handleNewSearchResult);
336336 }
337337 SearchPlugin.getWorkspace().addResourceChangeListener(this);
338338 }
113113 fPotentialMatchFgColor= new Color(SearchPlugin.getActiveWorkbenchShell().getDisplay(), SearchPreferencePage.getPotentialMatchForegroundColor());
114114
115115 setUseHashlookup(true);
116 setContentProvider(new ArrayContentProvider());
116 setContentProvider(ArrayContentProvider.getInstance());
117117
118118 ILabelProvider labelProvider= new SearchResultLabelProvider(new FileLabelProvider(FileLabelProvider.SHOW_LABEL));
119119 setLabelProvider(labelProvider);
125125 ListDialog dlg= new ListDialog(SearchPlugin.getActiveWorkbenchShell());
126126 dlg.setInput(input);
127127 dlg.setTitle(title);
128 dlg.setContentProvider(new ArrayContentProvider());
128 dlg.setContentProvider(ArrayContentProvider.getInstance());
129129 dlg.setLabelProvider(labelProvider);
130130 dlg.setMessage(message);
131131 if (selectedAction != null) {
11 Bundle-ManifestVersion: 2
22 Bundle-Name: %pluginName
33 Bundle-SymbolicName: org.eclipse.search.tests
4 Bundle-Version: 3.9.600.qualifier
4 Bundle-Version: 3.9.700.qualifier
55 Bundle-Activator: org.eclipse.search.tests.SearchTestPlugin
66 Bundle-Vendor: %providerName
77 Bundle-Localization: plugin
1313 <parent>
1414 <artifactId>tests-pom</artifactId>
1515 <groupId>eclipse.platform.text</groupId>
16 <version>4.16.0-SNAPSHOT</version>
16 <version>4.17.0-SNAPSHOT</version>
1717 <relativePath>../tests-pom/</relativePath>
1818 </parent>
1919 <groupId>org.eclipse.search</groupId>
2020 <artifactId>org.eclipse.search.tests</artifactId>
21 <version>3.9.600-SNAPSHOT</version>
21 <version>3.9.700-SNAPSHOT</version>
2222 <packaging>eclipse-test-plugin</packaging>
2323 <properties>
2424 <testSuite>${project.artifactId}</testSuite>
142142 if (srcChildren == null) {
143143 throw new IOException("Content from directory '" + src.getAbsolutePath() + "' can not be listed."); //$NON-NLS-1$ //$NON-NLS-2$
144144 }
145 for(int i = 0; i < srcChildren.length; ++i){
146 File srcChild= new File(src, srcChildren[i]);
147 File dstChild= new File(dst, srcChildren[i]);
145 for (String srcChild2 : srcChildren) {
146 File srcChild= new File(src, srcChild2);
147 File dstChild= new File(dst, srcChild2);
148148 copy(srcChild, dstChild);
149149 }
150150 } else
0 <?xml version="1.0" encoding="UTF-8" standalone="no"?>
1 <component id="org.eclipse.text" version="2">
2 <resource path="META-INF/MANIFEST.MF" type="org.eclipse.jface.text.Assert">
3 <filter comment="Planned deletion" id="305324134">
4 <message_arguments>
5 <message_argument value="org.eclipse.jface.text.Assert"/>
6 <message_argument value="org.eclipse.text_3.10.200"/>
7 </message_arguments>
8 </filter>
9 <filter comment="Planned deletion" id="305324134">
10 <message_arguments>
11 <message_argument value="org.eclipse.jface.text.Assert"/>
12 <message_argument value="org.eclipse.text_3.10.300"/>
13 </message_arguments>
14 </filter>
15 </resource>
16 </component>
11 Bundle-ManifestVersion: 2
22 Bundle-Name: %pluginName
33 Bundle-SymbolicName: org.eclipse.text
4 Bundle-Version: 3.10.200.qualifier
4 Bundle-Version: 3.10.300.qualifier
55 Bundle-Vendor: %providerName
66 Bundle-Localization: plugin
77 Export-Package:
+0
-196
org.eclipse.text/src/org/eclipse/jface/text/Assert.java less more
0 /*******************************************************************************
1 * Copyright (c) 2000, 2009 IBM Corporation and others.
2 *
3 * This program and the accompanying materials
4 * are made available under the terms of the Eclipse Public License 2.0
5 * which accompanies this distribution, and is available at
6 * https://www.eclipse.org/legal/epl-2.0/
7 *
8 * SPDX-License-Identifier: EPL-2.0
9 *
10 * Contributors:
11 * IBM Corporation - initial API and implementation
12 *******************************************************************************/
13 package org.eclipse.jface.text;
14
15
16 /**
17 * <code>Assert</code> is useful for for embedding runtime sanity checks
18 * in code. The static predicate methods all test a condition and throw some
19 * type of unchecked exception if the condition does not hold.
20 * <p>
21 * Assertion failure exceptions, like most runtime exceptions, are
22 * thrown when something is misbehaving. Assertion failures are invariably
23 * unspecified behavior; consequently, clients should never rely on
24 * these being thrown (or not thrown). <b>If you find yourself in the
25 * position where you need to catch an assertion failure, you have most
26 * certainly written your program incorrectly.</b>
27 * </p>
28 * <p>
29 * Note that an <code>assert</code> statement is slated to be added to the
30 * Java language in JDK 1.4, rending this class obsolete.
31 * </p>
32 *
33 * @deprecated As of 3.3, replaced by {@link org.eclipse.core.runtime.Assert}
34 * @noinstantiate This class is not intended to be instantiated by clients.
35 *
36 * @noreference This class is planned to be deleted, see Bug 528191
37 *
38 */
39 @Deprecated
40 public final class Assert {
41
42 /**
43 * <code>AssertionFailedException</code> is a runtime exception thrown
44 * by some of the methods in <code>Assert</code>.
45 * <p>
46 * This class is not declared public to prevent some misuses; programs that catch
47 * or otherwise depend on assertion failures are susceptible to unexpected
48 * breakage when assertions in the code are added or removed.
49 * </p>
50 * <p>
51 * This class is not intended to be serialized.
52 * </p>
53 */
54 private static class AssertionFailedException extends RuntimeException {
55
56 /**
57 * Serial version UID for this class.
58 * <p>
59 * Note: This class is not intended to be serialized.
60 * </p>
61 * @since 3.1
62 */
63 private static final long serialVersionUID= 3689918374733886002L;
64
65 /**
66 * Constructs a new exception with the given message.
67 *
68 * @param detail the detailed message
69 */
70 public AssertionFailedException(String detail) {
71 super(detail);
72 }
73 }
74
75 /* This class is not intended to be instantiated. */
76 private Assert() {
77 }
78
79 /**
80 * Asserts that an argument is legal. If the given boolean is
81 * not <code>true</code>, an <code>IllegalArgumentException</code>
82 * is thrown.
83 *
84 * @param expression the outcome of the check
85 * @return <code>true</code> if the check passes (does not return
86 * if the check fails)
87 * @exception IllegalArgumentException if the legality test failed
88 */
89 public static boolean isLegal(boolean expression) {
90 // succeed as quickly as possible
91 if (expression) {
92 return true;
93 }
94 return isLegal(expression, "");//$NON-NLS-1$
95 }
96
97 /**
98 * Asserts that an argument is legal. If the given boolean is
99 * not <code>true</code>, an <code>IllegalArgumentException</code>
100 * is thrown.
101 * The given message is included in that exception, to aid debugging.
102 *
103 * @param expression the outcome of the check
104 * @param message the message to include in the exception
105 * @return <code>true</code> if the check passes (does not return
106 * if the check fails)
107 * @exception IllegalArgumentException if the legality test failed
108 */
109 public static boolean isLegal(boolean expression, String message) {
110 if (!expression)
111 throw new IllegalArgumentException("assertion failed; " + message); //$NON-NLS-1$
112 return expression;
113 }
114
115 /**
116 * Asserts that the given object is not <code>null</code>. If this
117 * is not the case, some kind of unchecked exception is thrown.
118 * <p>
119 * As a general rule, parameters passed to API methods must not be
120 * <code>null</code> unless <b>explicitly</b> allowed in the method's
121 * specification. Similarly, results returned from API methods are never
122 * <code>null</code> unless <b>explicitly</b> allowed in the method's
123 * specification. Implementations are encouraged to make regular use of
124 * <code>Assert.isNotNull</code> to ensure that <code>null</code>
125 * parameters are detected as early as possible.
126 * </p>
127 *
128 * @param object the value to test
129 * @exception RuntimeException an unspecified unchecked exception if the object
130 * is <code>null</code>
131 */
132 public static void isNotNull(Object object) {
133 // succeed as quickly as possible
134 if (object != null) {
135 return;
136 }
137 isNotNull(object, "");//$NON-NLS-1$
138 }
139
140 /**
141 * Asserts that the given object is not <code>null</code>. If this
142 * is not the case, some kind of unchecked exception is thrown.
143 * The given message is included in that exception, to aid debugging.
144 * <p>
145 * As a general rule, parameters passed to API methods must not be
146 * <code>null</code> unless <b>explicitly</b> allowed in the method's
147 * specification. Similarly, results returned from API methods are never
148 * <code>null</code> unless <b>explicitly</b> allowed in the method's
149 * specification. Implementations are encouraged to make regular use of
150 * <code>Assert.isNotNull</code> to ensure that <code>null</code>
151 * parameters are detected as early as possible.
152 * </p>
153 *
154 * @param object the value to test
155 * @param message the message to include in the exception
156 * @exception RuntimeException an unspecified unchecked exception if the object
157 * is <code>null</code>
158 */
159 public static void isNotNull(Object object, String message) {
160 if (object == null)
161 throw new AssertionFailedException("null argument;" + message);//$NON-NLS-1$
162 }
163
164 /**
165 * Asserts that the given boolean is <code>true</code>. If this
166 * is not the case, some kind of unchecked exception is thrown.
167 *
168 * @param expression the outcome of the check
169 * @return <code>true</code> if the check passes (does not return
170 * if the check fails)
171 */
172 public static boolean isTrue(boolean expression) {
173 // succeed as quickly as possible
174 if (expression) {
175 return true;
176 }
177 return isTrue(expression, "");//$NON-NLS-1$
178 }
179
180 /**
181 * Asserts that the given boolean is <code>true</code>. If this
182 * is not the case, some kind of unchecked exception is thrown.
183 * The given message is included in that exception, to aid debugging.
184 *
185 * @param expression the outcome of the check
186 * @param message the message to include in the exception
187 * @return <code>true</code> if the check passes (does not return
188 * if the check fails)
189 */
190 public static boolean isTrue(boolean expression, String message) {
191 if (!expression)
192 throw new AssertionFailedException("Assertion failed: "+message);//$NON-NLS-1$
193 return expression;
194 }
195 }
1818 <parent>
1919 <artifactId>tests-pom</artifactId>
2020 <groupId>eclipse.platform.text</groupId>
21 <version>4.16.0-SNAPSHOT</version>
21 <version>4.17.0-SNAPSHOT</version>
2222 <relativePath>../tests-pom/</relativePath>
2323 </parent>
2424 <groupId>org.eclipse.text</groupId>
11 Bundle-ManifestVersion: 2
22 Bundle-Name: %Plugin.name
33 Bundle-SymbolicName: org.eclipse.text.tests
4 Bundle-Version: 3.12.600.qualifier
4 Bundle-Version: 3.12.700.qualifier
55 Bundle-Vendor: %Plugin.providerName
66 Bundle-Localization: plugin
77 Export-Package:
1313 <parent>
1414 <artifactId>tests-pom</artifactId>
1515 <groupId>eclipse.platform.text</groupId>
16 <version>4.16.0-SNAPSHOT</version>
16 <version>4.17.0-SNAPSHOT</version>
1717 <relativePath>../tests-pom/</relativePath>
1818 </parent>
1919 <groupId>org.eclipse.text</groupId>
2020 <artifactId>org.eclipse.text.tests</artifactId>
21 <version>3.12.600-SNAPSHOT</version>
21 <version>3.12.700-SNAPSHOT</version>
2222 <packaging>eclipse-test-plugin</packaging>
2323 <properties>
2424 <testSuite>${project.artifactId}</testSuite>
145145
146146 if (!expectedSet.isEmpty()) {
147147 String message= "Missing annotations in result with models [" + getAnnotationModelNames(insideModel, beforeModel, afterModel) + "]";
148 for (Iterator<Annotation> iterator= expectedSet.iterator(); iterator.hasNext();) {
149 Annotation missing= iterator.next();
148 for (Annotation missing : expectedSet) {
150149 message= message + "\n" + getName(missing);
151150 }
152151 assertTrue(message, false);
12781278 }
12791279
12801280 private void assertExist(ArrayList<AnnotationData> added) {
1281 for (int i= 0, size= added.size(); i < size; i++) {
1282 AnnotationData data= added.get(i);
1281 for (AnnotationData data : added) {
12831282 IAnnotationModel model= getModel(data.annotationNumber);
12841283 assertTrue(model.getPosition(data.annotation) == data.position);
12851284 }
12871286 ArrayList<Annotation> annotations= getAllAnnotations();
12881287 assertEquals(added.size(), annotations.size());
12891288
1290 for (int i= 0, size= annotations.size(); i < size; i++) {
1291 Annotation annotation= annotations.get(i);
1292
1289 for (Annotation annotation : annotations) {
12931290 AnnotationData data= getAnnotationData(added, annotation);
12941291 assertNotNull(data);
12951292
12981295 }
12991296
13001297 private void assertExistNew(ArrayList<AnnotationData> added) {
1301 for (int i= 0, size= added.size(); i < size; i++) {
1302 AnnotationData data= added.get(i);
1298 for (AnnotationData data : added) {
13031299 IAnnotationModel model= getModel(data.annotationNumber);
13041300 assertTrue(model.getPosition(data.annotation) == data.position);
13051301 }
13071303 ArrayList<Annotation> annotations= getAllAnnotationsNew();
13081304 assertEquals(added.size(), annotations.size());
13091305
1310 for (int i= 0, size= annotations.size(); i < size; i++) {
1311 Annotation annotation= annotations.get(i);
1312
1306 for (Annotation annotation : annotations) {
13131307 AnnotationData data= getAnnotationData(added, annotation);
13141308 assertNotNull(data);
13151309
13181312 }
13191313
13201314 private AnnotationData getAnnotationData(ArrayList<AnnotationData> datas, Annotation annotation) {
1321 for (int i= 0, size= datas.size(); i < size; i++) {
1322 AnnotationData data= datas.get(i);
1315 for (AnnotationData data : datas) {
13231316 if (data.annotation == annotation)
13241317 return data;
13251318 }
00 /*******************************************************************************
1 * Copyright (c) 2019 Thomas Wolf and others.
1 * Copyright (c) 2019, 2020 Thomas Wolf and others.
22 *
33 * This program and the accompanying materials
44 * are made available under the terms of the Eclipse Public License 2.0
1212 import static org.junit.Assert.assertEquals;
1313 import static org.junit.Assert.assertNotNull;
1414 import static org.junit.Assert.assertNull;
15 import static org.junit.Assert.assertThrows;
1516
1617 import java.util.Collections;
1718 import java.util.List;
1819
19 import org.junit.Rule;
2020 import org.junit.Test;
21 import org.junit.rules.ExpectedException;
2221
2322 import org.eclipse.jface.text.MultiStringMatcher;
2423 import org.eclipse.jface.text.MultiStringMatcher.Match;
2524
2625 public class MultiStringMatcherTest {
27
28 @Rule
29 public ExpectedException thrown = ExpectedException.none();
3026
3127 private static Match run(String text, String... needles) {
3228 return run(text, 0, needles);
443439 public void addAfterBuild() throws Exception {
444440 MultiStringMatcher.Builder b = MultiStringMatcher.builder().add("he", "she").add("his", "hers");
445441 b.build();
446 thrown.expect(IllegalStateException.class);
447 b.add("us");
442 assertThrows(IllegalStateException.class, () -> b.add("us"));
448443 }
449444
450445 @Test
451446 public void reuseBuilder() throws Exception {
452447 MultiStringMatcher.Builder b = MultiStringMatcher.builder().add("he", "she").add("his", "hers");
453448 b.build();
454 thrown.expect(IllegalStateException.class);
455 b.build();
449 assertThrows(IllegalStateException.class, () -> b.build());
456450 }
457451
458452 @Test
1616
1717 import java.util.ArrayList;
1818 import java.util.Comparator;
19 import java.util.Iterator;
2019 import java.util.List;
2120
2221 import org.junit.After;
325324
326325 private static void compare(List<TextEdit> org, List<TextEdit> copy) {
327326 assertTrue("Same length", org.size() == copy.size());
328 for (Iterator<TextEdit> iter= copy.iterator(); iter.hasNext();) {
329 TextEdit edit= iter.next();
327 for (TextEdit edit : copy) {
330328 assertTrue("Original is part of copy list", !org.contains(edit));
331329 if (edit instanceof MoveSourceEdit) {
332330 MoveSourceEdit source= (MoveSourceEdit)edit;
1717 import static org.junit.Assert.fail;
1818
1919 import java.util.ArrayList;
20 import java.util.Iterator;
2120 import java.util.List;
2221
2322 import org.junit.Assert;
191190 events.add(new DocumentEvent(reference, 9, 2, "asd"));
192191 events.add(new DocumentEvent(reference, 0, 2, "asd"));
193192
194 for (Iterator<DocumentEvent> iterator= events.iterator(); iterator.hasNext();) {
195 DocumentEvent event= iterator.next();
193 for (DocumentEvent event : events) {
196194 currentLength += event.getText().length() - event.getLength();
197195 }
198196
203201 events.add(event);
204202 }
205203
206 for (Iterator<DocumentEvent> iterator= events.iterator(); iterator.hasNext();) {
207 DocumentEvent event= iterator.next();
204 for (DocumentEvent event : events) {
208205
209206 // System.err.println(event.getOffset() + ", " + event.getLength() + ", [" + event.getText() + "]") ;
210207
244241 events.add(new DocumentEvent(reference, 9, 2, "asd"));
245242 events.add(new DocumentEvent(reference, 0, 2, "asd"));
246243
247 for (Iterator<DocumentEvent> iterator= events.iterator(); iterator.hasNext();) {
248 DocumentEvent event= iterator.next();
244 for (DocumentEvent event : events) {
249245 currentLength += event.getText().length() - event.getLength();
250246 }
251247
256252 events.add(event);
257253 }
258254
259 for (Iterator<DocumentEvent> iterator= events.iterator(); iterator.hasNext();) {
260 DocumentEvent event= iterator.next();
261
255 for (DocumentEvent event : events) {
262256 reference.replace(event.getOffset(), event.getLength(), event.getText());
263257 if (Math.random() < 0.3) {
264258 check(reference, testee);
00 <?xml version="1.0" encoding="UTF-8" standalone="no"?>
11 <component id="org.eclipse.ui.editors" version="2">
2 <resource path="src/org/eclipse/ui/editors/text/EncodingActionGroup.java" type="org.eclipse.ui.editors.text.EncodingActionGroup">
3 <filter id="338944126">
4 <message_arguments>
5 <message_argument value="org.eclipse.ui.editors.text.EncodingActionGroup"/>
6 <message_argument value="dispose()"/>
7 </message_arguments>
8 </filter>
9 <filter id="338944126">
10 <message_arguments>
11 <message_argument value="org.eclipse.ui.editors.text.EncodingActionGroup"/>
12 <message_argument value="fillActionBars(IActionBars)"/>
13 </message_arguments>
14 </filter>
15 <filter id="338944126">
16 <message_arguments>
17 <message_argument value="org.eclipse.ui.editors.text.EncodingActionGroup"/>
18 <message_argument value="retarget(ITextEditor)"/>
19 </message_arguments>
20 </filter>
21 <filter id="338944126">
22 <message_arguments>
23 <message_argument value="org.eclipse.ui.editors.text.EncodingActionGroup"/>
24 <message_argument value="update()"/>
25 </message_arguments>
26 </filter>
27 <filter id="338948223">
28 <message_arguments>
29 <message_argument value="org.eclipse.ui.editors.text.EncodingActionGroup"/>
30 <message_argument value="EncodingActionGroup()"/>
31 </message_arguments>
32 </filter>
33 <filter id="338948223">
34 <message_arguments>
35 <message_argument value="org.eclipse.ui.editors.text.EncodingActionGroup"/>
36 <message_argument value="EncodingActionGroup(ITextEditor)"/>
37 </message_arguments>
38 </filter>
39 </resource>
402 <resource path="src/org/eclipse/ui/editors/text/ITextEditorHelpContextIds.java" type="org.eclipse.ui.editors.text.ITextEditorHelpContextIds">
413 <filter id="571473929">
424 <message_arguments>
11 Bundle-ManifestVersion: 2
22 Bundle-Name: %pluginName
33 Bundle-SymbolicName: org.eclipse.ui.editors; singleton:=true
4 Bundle-Version: 3.13.200.qualifier
4 Bundle-Version: 3.13.300.qualifier
55 Bundle-Activator: org.eclipse.ui.internal.editors.text.EditorsPlugin
66 Bundle-ActivationPolicy: lazy
77 Bundle-Vendor: %providerName
org.eclipse.ui.editors/icons/full/dtool16/last_edit_pos.gif less more
Binary diff not shown
org.eclipse.ui.editors/icons/full/dtool16/new_untitled_text_file.gif less more
Binary diff not shown
org.eclipse.ui.editors/icons/full/dtool16/next_nav.gif less more
Binary diff not shown
org.eclipse.ui.editors/icons/full/dtool16/prev_nav.gif less more
Binary diff not shown
org.eclipse.ui.editors/icons/full/etool16/last_edit_pos.gif less more
Binary diff not shown
org.eclipse.ui.editors/icons/full/etool16/new_untitled_text_file.gif less more
Binary diff not shown
org.eclipse.ui.editors/icons/full/etool16/next_nav.gif less more
Binary diff not shown
org.eclipse.ui.editors/icons/full/etool16/prev_nav.gif less more
Binary diff not shown
org.eclipse.ui.editors/icons/full/obj16/file_obj.gif less more
Binary diff not shown
org.eclipse.ui.editors/icons/full/obj16/quick_assist_obj.gif less more
Binary diff not shown
org.eclipse.ui.editors/icons/full/obj16/quick_fix_error_obj.gif less more
Binary diff not shown
org.eclipse.ui.editors/icons/full/obj16/quick_fix_warning_obj.gif less more
Binary diff not shown
8181 spelling.label= Spelling Errors
8282 revisionInfo.label= Revision Information
8383
84 goToLastEditPosition.label= Last Edit Lo&cation
85 goToLastEditPosition.tooltip= Last Edit Location
84 goToLastEditPosition.label= Previous Edit Lo&cation
85 goToLastEditPosition.tooltip= Previous Edit Location
86 goToNextEditPosition.label= Next Edit Lo&cation
87 goToNextEditPosition.tooltip= Next Edit Location
8688
8789 textEditorNavigationActionSet.label= Editor Navigation
8890
469469 id="org.eclipse.ui.edit.text.actionSet.navigation">
470470 <action
471471 toolbarPath="org.eclipse.ui.workbench.navigate/history.group"
472 id="org.eclipse.ui.edit.text.gotoNextEditPosition"
473 class="org.eclipse.ui.texteditor.GotoNextEditPositionAction"
474 definitionId="org.eclipse.ui.edit.text.gotoNextEditPosition"
475 disabledIcon="$nl$/icons/full/dtool16/next_edit_pos.png"
476 icon="$nl$/icons/full/etool16/next_edit_pos.png"
477 helpContextId="org.eclipse.ui.goto_next_edit_position_action_context"
478 label="%goToNextEditPosition.label"
479 menubarPath="navigate/"
480 tooltip="%goToNextEditPosition.tooltip"
481 initialEnabled="false">
482 </action>
483 <action
484 toolbarPath="org.eclipse.ui.workbench.navigate/history.group"
472485 id="org.eclipse.ui.edit.text.gotoLastEditPosition"
473486 class="org.eclipse.ui.texteditor.GotoLastEditPositionAction"
474487 definitionId="org.eclipse.ui.edit.text.gotoLastEditPosition"
259259
260260
261261 fDecorationViewer= new ComboViewer(optionsComposite, SWT.READ_ONLY);
262 fDecorationViewer.setContentProvider(new ArrayContentProvider());
262 fDecorationViewer.setContentProvider(ArrayContentProvider.getInstance());
263263 fDecorationViewer.setLabelProvider(new ArrayLabelProvider());
264264 fDecorationViewer.setComparator(new ViewerComparator(Collator.getInstance()));
265265
271271 fShowInTextCheckBox.setLayoutData(gd);
272272
273273 fDecorationViewer= new ComboViewer(optionsComposite, SWT.READ_ONLY);
274 fDecorationViewer.setContentProvider(new ArrayContentProvider());
274 fDecorationViewer.setContentProvider(ArrayContentProvider.getInstance());
275275 fDecorationViewer.setLabelProvider(new ArrayLabelProvider());
276276 fDecorationViewer.setComparator(new ViewerComparator(Collator.getInstance()));
277277
9191 * @since 3.3
9292 */
9393 private void dispose(Map<RGB, Color> colorTable) {
94 if (colorTable == null)
95 return;
96
97 Iterator<Color> iter= colorTable.values().iterator();
98 while (iter.hasNext())
99 iter.next().dispose();
100
101 colorTable.clear();
94 if (colorTable != null) {
95 colorTable.clear();
96 }
10297 }
10398
10499 }
7878 private Label fSeparator;
7979 /** The font of the optional status text label.*/
8080 private Font fStatusTextFont;
81 /**
82 * The color of the optional status text label or <code>null</code> if none.
83 *
84 * @since 3.6
85 */
86 private Color fStatusTextForegroundColor;
8781 /** The maximal widget width. */
8882 private int fMaxWidth;
8983 /** The maximal widget height. */
181175 GridData gd2= new GridData(GridData.FILL_VERTICAL | GridData.FILL_HORIZONTAL | GridData.HORIZONTAL_ALIGN_BEGINNING | GridData.VERTICAL_ALIGN_BEGINNING);
182176 fStatusField.setLayoutData(gd2);
183177
184 fStatusTextForegroundColor= new Color(fStatusField.getDisplay(), blend(display.getSystemColor(SWT.COLOR_INFO_BACKGROUND).getRGB(), display.getSystemColor(SWT.COLOR_INFO_FOREGROUND).getRGB(), 0.56f));
185 fStatusField.setForeground(fStatusTextForegroundColor);
178 Color statusTextForegroundColor= new Color(fStatusField.getDisplay(),
179 blend(display.getSystemColor(SWT.COLOR_INFO_BACKGROUND).getRGB(), display.getSystemColor(SWT.COLOR_INFO_FOREGROUND).getRGB(), 0.56f));
180 fStatusField.setForeground(statusTextForegroundColor);
186181
187182 fStatusField.setBackground(display.getSystemColor(SWT.COLOR_INFO_BACKGROUND));
188183 }
252247 if (fStatusTextFont != null && !fStatusTextFont.isDisposed())
253248 fStatusTextFont.dispose();
254249 fStatusTextFont= null;
255 if (fStatusTextForegroundColor != null && !fStatusTextForegroundColor.isDisposed())
256 fStatusTextForegroundColor.dispose();
257 fStatusTextForegroundColor= null;
258250
259251 fTextFont= null;
260252 fShell= null;
2020 import java.nio.charset.StandardCharsets;
2121 import java.nio.charset.UnsupportedCharsetException;
2222 import java.text.BreakIterator;
23 import java.text.DateFormat;
2324 import java.text.MessageFormat;
25 import java.util.Date;
2426 import java.util.Iterator;
2527
2628 import org.eclipse.swt.SWT;
13731375 options.printTextForeground= true;
13741376 options.printTextBackground= true;
13751377 options.jobName= getTitle();
1376 options.header= StyledTextPrintOptions.SEPARATOR + getTitle();
1378 options.header= getTitle() + StyledTextPrintOptions.SEPARATOR + StyledTextPrintOptions.SEPARATOR
1379 + DateFormat.getDateTimeInstance(DateFormat.FULL, DateFormat.SHORT).format(new Date());
13771380 options.footer= StyledTextPrintOptions.SEPARATOR + NLSUtility.format(TextEditorMessages.AbstractDecoratedTextEditor_printPageNumber, StyledTextPrintOptions.PAGE_TAG);
13781381
13791382 if (isLineNumberRulerVisible()) {
11 Bundle-ManifestVersion: 2
22 Bundle-Name: %Plugin.name
33 Bundle-SymbolicName: org.eclipse.ui.editors.tests;singleton:=true
4 Bundle-Version: 3.11.700.qualifier
4 Bundle-Version: 3.11.800.qualifier
55 Bundle-Vendor: %Plugin.providerName
66 Bundle-Localization: plugin
77 Export-Package: org.eclipse.ui.editors.tests
1313 <parent>
1414 <artifactId>tests-pom</artifactId>
1515 <groupId>eclipse.platform.text</groupId>
16 <version>4.16.0-SNAPSHOT</version>
16 <version>4.17.0-SNAPSHOT</version>
1717 <relativePath>../tests-pom/</relativePath>
1818 </parent>
1919 <groupId>org.eclipse.ui</groupId>
2020 <artifactId>org.eclipse.ui.editors.tests</artifactId>
21 <version>3.11.700-SNAPSHOT</version>
21 <version>3.11.800-SNAPSHOT</version>
2222 <packaging>eclipse-test-plugin</packaging>
2323 <properties>
2424 <testSuite>${project.artifactId}</testSuite>
3434 import org.eclipse.core.runtime.CoreException;
3535 import org.eclipse.core.runtime.ILog;
3636 import org.eclipse.core.runtime.IProgressMonitor;
37 import org.eclipse.core.runtime.IProgressMonitorWithBlocking;
3837 import org.eclipse.core.runtime.IStatus;
3938 import org.eclipse.core.runtime.NullProgressMonitor;
4039 import org.eclipse.core.runtime.OperationCanceledException;
109108 assertNotNull(progressMonitor);
110109 assertFalse(progressMonitor instanceof NullProgressMonitor);
111110 assertFalse(progressMonitor instanceof EventLoopProgressMonitor);
112 assertTrue(progressMonitor instanceof IProgressMonitorWithBlocking);
113111
114112 // Because this monitor is not EventLoopProgressMonitor, it will not
115113 // process UI events while waiting on workspace lock
3232 import org.eclipse.core.internal.resources.File;
3333
3434 import org.eclipse.core.runtime.IProgressMonitor;
35 import org.eclipse.core.runtime.IProgressMonitorWithBlocking;
3635 import org.eclipse.core.runtime.NullProgressMonitor;
3736 import org.eclipse.core.runtime.jobs.Job;
3837
9392 assertNotNull(progressMonitor);
9493 assertFalse(progressMonitor instanceof NullProgressMonitor);
9594 assertFalse(progressMonitor instanceof EventLoopProgressMonitor);
96 assertTrue(progressMonitor instanceof IProgressMonitorWithBlocking);
9795
9896 // Because this monitor is not EventLoopProgressMonitor, it will not
9997 // process UI events while waiting on workspace lock
11 Bundle-ManifestVersion: 2
22 Bundle-Name: %Bundle-Name
33 Bundle-SymbolicName: org.eclipse.ui.genericeditor;singleton:=true
4 Bundle-Version: 1.1.700.qualifier
4 Bundle-Version: 1.1.800.qualifier
55 Bundle-Vendor: %Bundle-Vendor
66 Bundle-RequiredExecutionEnvironment: JavaSE-1.8
77 Require-Bundle: org.eclipse.ui.workbench.texteditor;bundle-version="3.10.0",
0 Bug 566471 - I20200828-0150 - Comparator Errors Found
11 Bundle-ManifestVersion: 2
22 Bundle-Name: Examples for Generic Editor
33 Bundle-SymbolicName: org.eclipse.ui.genericeditor.examples;singleton:=true
4 Bundle-Version: 1.1.600.qualifier
4 Bundle-Version: 1.1.700.qualifier
55 Bundle-Vendor: Eclipse.org
66 Bundle-RequiredExecutionEnvironment: JavaSE-1.8
77 Require-Bundle: org.eclipse.ui.genericeditor;bundle-version="1.0.0",
0 Bug 521182 - [compiler] method reference on null object should throw NPE at runtime (JLS compliance)
0 Bug 521182 - [compiler] method reference on null object should throw NPE at runtime (JLS compliance)
1 Bug 566471 - I20200828-0150 - Comparator Errors Found
11 Bundle-ManifestVersion: 2
22 Bundle-Name: %Plugin.name
33 Bundle-SymbolicName: org.eclipse.ui.genericeditor.tests;singleton:=true
4 Bundle-Version: 1.1.500.qualifier
4 Bundle-Version: 1.1.600.qualifier
55 Bundle-Vendor: %Plugin.providerName
66 Bundle-Localization: plugin
77 Export-Package: org.eclipse.ui.genericeditor.tests,
0 # To force a version qualifier update add the bug here
1 Bug 566471 - I20200828-0150 - Comparator Errors Found
1313 <parent>
1414 <artifactId>tests-pom</artifactId>
1515 <groupId>eclipse.platform.text</groupId>
16 <version>4.16.0-SNAPSHOT</version>
16 <version>4.17.0-SNAPSHOT</version>
1717 <relativePath>../tests-pom/</relativePath>
1818 </parent>
1919 <groupId>org.eclipse.ui</groupId>
2020 <artifactId>org.eclipse.ui.genericeditor.tests</artifactId>
21 <version>1.1.500-SNAPSHOT</version>
21 <version>1.1.600-SNAPSHOT</version>
2222 <packaging>eclipse-test-plugin</packaging>
2323 <properties>
2424 <testSuite>${project.artifactId}</testSuite>
00 <?xml version="1.0" encoding="UTF-8" standalone="no"?>
11 <component id="org.eclipse.ui.workbench.texteditor" version="2">
2 <resource path="META-INF/MANIFEST.MF">
3 <filter comment="Bug 549604" id="926941240">
4 <message_arguments>
5 <message_argument value="3.13.0"/>
6 <message_argument value="3.12.0"/>
7 </message_arguments>
8 </filter>
9 </resource>
10 <resource path="src/org/eclipse/ui/texteditor/AbstractTextEditor.java" type="org.eclipse.ui.texteditor.AbstractTextEditor">
11 <filter comment="Bug 549604" id="336658481">
12 <message_arguments>
13 <message_argument value="org.eclipse.ui.texteditor.AbstractTextEditor"/>
14 <message_argument value="PREFERENCE_SHOW_CARET_OFFSET"/>
15 </message_arguments>
16 </filter>
17 <filter comment="Bug 549604" id="336658481">
18 <message_arguments>
19 <message_argument value="org.eclipse.ui.texteditor.AbstractTextEditor"/>
20 <message_argument value="PREFERENCE_SHOW_SELECTION_SIZE"/>
21 </message_arguments>
22 </filter>
23 </resource>
242 <resource path="src/org/eclipse/ui/texteditor/ITextEditorActionConstants.java" type="org.eclipse.ui.texteditor.ITextEditorActionConstants">
253 <filter id="571473929">
264 <message_arguments>
4343 org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod=enabled
4444 org.eclipse.jdt.core.compiler.problem.discouragedReference=error
4545 org.eclipse.jdt.core.compiler.problem.emptyStatement=warning
46 org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled
4647 org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
4748 org.eclipse.jdt.core.compiler.problem.explicitlyClosedAutoCloseable=warning
4849 org.eclipse.jdt.core.compiler.problem.fallthroughCase=warning
99100 org.eclipse.jdt.core.compiler.problem.redundantSuperinterface=info
100101 org.eclipse.jdt.core.compiler.problem.reportMethodCanBePotentiallyStatic=ignore
101102 org.eclipse.jdt.core.compiler.problem.reportMethodCanBeStatic=ignore
103 org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning
102104 org.eclipse.jdt.core.compiler.problem.specialParameterHidingField=disabled
103105 org.eclipse.jdt.core.compiler.problem.staticAccessReceiver=error
104106 org.eclipse.jdt.core.compiler.problem.suppressOptionalErrors=disabled
131133 org.eclipse.jdt.core.compiler.problem.unusedTypeParameter=warning
132134 org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning
133135 org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning
136 org.eclipse.jdt.core.compiler.release=disabled
134137 org.eclipse.jdt.core.compiler.source=1.8
138 org.eclipse.jdt.core.formatter.align_assignment_statements_on_columns=false
135139 org.eclipse.jdt.core.formatter.align_fields_grouping_blank_lines=2147483647
136140 org.eclipse.jdt.core.formatter.align_type_members_on_columns=false
141 org.eclipse.jdt.core.formatter.align_variable_declarations_on_columns=false
142 org.eclipse.jdt.core.formatter.align_with_spaces=false
143 org.eclipse.jdt.core.formatter.alignment_for_additive_operator=16
137144 org.eclipse.jdt.core.formatter.alignment_for_arguments_in_allocation_expression=16
138145 org.eclipse.jdt.core.formatter.alignment_for_arguments_in_annotation=0
139146 org.eclipse.jdt.core.formatter.alignment_for_arguments_in_enum_constant=16
140147 org.eclipse.jdt.core.formatter.alignment_for_arguments_in_explicit_constructor_call=16
141148 org.eclipse.jdt.core.formatter.alignment_for_arguments_in_method_invocation=16
142149 org.eclipse.jdt.core.formatter.alignment_for_arguments_in_qualified_allocation_expression=16
150 org.eclipse.jdt.core.formatter.alignment_for_assertion_message=16
143151 org.eclipse.jdt.core.formatter.alignment_for_assignment=0
144152 org.eclipse.jdt.core.formatter.alignment_for_binary_expression=16
153 org.eclipse.jdt.core.formatter.alignment_for_bitwise_operator=16
145154 org.eclipse.jdt.core.formatter.alignment_for_compact_if=16
155 org.eclipse.jdt.core.formatter.alignment_for_compact_loops=16
146156 org.eclipse.jdt.core.formatter.alignment_for_conditional_expression=80
147 org.eclipse.jdt.core.formatter.alignment_for_enum_constants=0
157 org.eclipse.jdt.core.formatter.alignment_for_conditional_expression_chain=0
158 org.eclipse.jdt.core.formatter.alignment_for_enum_constants=16
148159 org.eclipse.jdt.core.formatter.alignment_for_expressions_in_array_initializer=16
149160 org.eclipse.jdt.core.formatter.alignment_for_expressions_in_for_loop_header=0
161 org.eclipse.jdt.core.formatter.alignment_for_logical_operator=16
150162 org.eclipse.jdt.core.formatter.alignment_for_method_declaration=0
163 org.eclipse.jdt.core.formatter.alignment_for_module_statements=16
151164 org.eclipse.jdt.core.formatter.alignment_for_multiple_fields=16
165 org.eclipse.jdt.core.formatter.alignment_for_multiplicative_operator=16
152166 org.eclipse.jdt.core.formatter.alignment_for_parameterized_type_references=0
153167 org.eclipse.jdt.core.formatter.alignment_for_parameters_in_constructor_declaration=16
154168 org.eclipse.jdt.core.formatter.alignment_for_parameters_in_method_declaration=16
169 org.eclipse.jdt.core.formatter.alignment_for_record_components=16
170 org.eclipse.jdt.core.formatter.alignment_for_relational_operator=0
155171 org.eclipse.jdt.core.formatter.alignment_for_resources_in_try=80
156172 org.eclipse.jdt.core.formatter.alignment_for_selector_in_method_invocation=16
173 org.eclipse.jdt.core.formatter.alignment_for_shift_operator=0
174 org.eclipse.jdt.core.formatter.alignment_for_string_concatenation=16
157175 org.eclipse.jdt.core.formatter.alignment_for_superclass_in_type_declaration=16
158176 org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_enum_declaration=16
177 org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_record_declaration=16
159178 org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_type_declaration=16
160179 org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_constructor_declaration=16
161180 org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_method_declaration=16
163182 org.eclipse.jdt.core.formatter.alignment_for_type_parameters=0
164183 org.eclipse.jdt.core.formatter.alignment_for_union_type_in_multicatch=16
165184 org.eclipse.jdt.core.formatter.blank_lines_after_imports=1
185 org.eclipse.jdt.core.formatter.blank_lines_after_last_class_body_declaration=0
166186 org.eclipse.jdt.core.formatter.blank_lines_after_package=1
187 org.eclipse.jdt.core.formatter.blank_lines_before_abstract_method=1
167188 org.eclipse.jdt.core.formatter.blank_lines_before_field=0
168189 org.eclipse.jdt.core.formatter.blank_lines_before_first_class_body_declaration=0
169190 org.eclipse.jdt.core.formatter.blank_lines_before_imports=1
172193 org.eclipse.jdt.core.formatter.blank_lines_before_new_chunk=1
173194 org.eclipse.jdt.core.formatter.blank_lines_before_package=0
174195 org.eclipse.jdt.core.formatter.blank_lines_between_import_groups=1
196 org.eclipse.jdt.core.formatter.blank_lines_between_statement_group_in_switch=0
175197 org.eclipse.jdt.core.formatter.blank_lines_between_type_declarations=1
176198 org.eclipse.jdt.core.formatter.brace_position_for_annotation_type_declaration=end_of_line
177199 org.eclipse.jdt.core.formatter.brace_position_for_anonymous_type_declaration=end_of_line
183205 org.eclipse.jdt.core.formatter.brace_position_for_enum_declaration=end_of_line
184206 org.eclipse.jdt.core.formatter.brace_position_for_lambda_body=end_of_line
185207 org.eclipse.jdt.core.formatter.brace_position_for_method_declaration=end_of_line
208 org.eclipse.jdt.core.formatter.brace_position_for_record_constructor=end_of_line
209 org.eclipse.jdt.core.formatter.brace_position_for_record_declaration=end_of_line
186210 org.eclipse.jdt.core.formatter.brace_position_for_switch=end_of_line
187211 org.eclipse.jdt.core.formatter.brace_position_for_type_declaration=end_of_line
212 org.eclipse.jdt.core.formatter.comment.align_tags_descriptions_grouped=true
213 org.eclipse.jdt.core.formatter.comment.align_tags_names_descriptions=false
188214 org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_block_comment=false
189215 org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_javadoc_comment=false
216 org.eclipse.jdt.core.formatter.comment.count_line_length_from_starting_position=true
190217 org.eclipse.jdt.core.formatter.comment.format_block_comments=true
191218 org.eclipse.jdt.core.formatter.comment.format_header=false
192219 org.eclipse.jdt.core.formatter.comment.format_html=true
193220 org.eclipse.jdt.core.formatter.comment.format_javadoc_comments=true
194221 org.eclipse.jdt.core.formatter.comment.format_line_comments=true
195222 org.eclipse.jdt.core.formatter.comment.format_source_code=true
196 org.eclipse.jdt.core.formatter.comment.indent_parameter_description=true
197 org.eclipse.jdt.core.formatter.comment.indent_root_tags=true
223 org.eclipse.jdt.core.formatter.comment.indent_parameter_description=false
224 org.eclipse.jdt.core.formatter.comment.indent_root_tags=false
225 org.eclipse.jdt.core.formatter.comment.indent_tag_description=false
198226 org.eclipse.jdt.core.formatter.comment.insert_new_line_before_root_tags=insert
199 org.eclipse.jdt.core.formatter.comment.insert_new_line_for_parameter=insert
227 org.eclipse.jdt.core.formatter.comment.insert_new_line_between_different_tags=do not insert
228 org.eclipse.jdt.core.formatter.comment.insert_new_line_for_parameter=do not insert
200229 org.eclipse.jdt.core.formatter.comment.line_length=80
201230 org.eclipse.jdt.core.formatter.comment.new_lines_at_block_boundaries=true
202231 org.eclipse.jdt.core.formatter.comment.new_lines_at_javadoc_boundaries=true
207236 org.eclipse.jdt.core.formatter.disabling_tag=@formatter\:off
208237 org.eclipse.jdt.core.formatter.enabling_tag=@formatter\:on
209238 org.eclipse.jdt.core.formatter.format_guardian_clause_on_one_line=false
210 org.eclipse.jdt.core.formatter.format_line_comment_starting_on_first_column=true
239 org.eclipse.jdt.core.formatter.format_line_comment_starting_on_first_column=false
211240 org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_annotation_declaration_header=true
212241 org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_constant_header=true
213242 org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_declaration_header=true
243 org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_record_header=true
214244 org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_type_header=true
215245 org.eclipse.jdt.core.formatter.indent_breaks_compare_to_cases=true
216246 org.eclipse.jdt.core.formatter.indent_empty_lines=false
242272 org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_declaration=insert
243273 org.eclipse.jdt.core.formatter.insert_new_line_in_empty_method_body=insert
244274 org.eclipse.jdt.core.formatter.insert_new_line_in_empty_type_declaration=insert
275 org.eclipse.jdt.core.formatter.insert_space_after_additive_operator=insert
245276 org.eclipse.jdt.core.formatter.insert_space_after_and_in_type_parameter=insert
277 org.eclipse.jdt.core.formatter.insert_space_after_arrow_in_switch_case=insert
278 org.eclipse.jdt.core.formatter.insert_space_after_arrow_in_switch_default=insert
246279 org.eclipse.jdt.core.formatter.insert_space_after_assignment_operator=insert
247280 org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation=do not insert
248281 org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation_type_declaration=do not insert
249282 org.eclipse.jdt.core.formatter.insert_space_after_binary_operator=insert
283 org.eclipse.jdt.core.formatter.insert_space_after_bitwise_operator=insert
250284 org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_arguments=do not insert
251285 org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_parameters=insert
252286 org.eclipse.jdt.core.formatter.insert_space_after_closing_brace_in_block=insert
272306 org.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_field_declarations=insert
273307 org.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_local_declarations=insert
274308 org.eclipse.jdt.core.formatter.insert_space_after_comma_in_parameterized_type_reference=insert
309 org.eclipse.jdt.core.formatter.insert_space_after_comma_in_record_components=insert
275310 org.eclipse.jdt.core.formatter.insert_space_after_comma_in_superinterfaces=insert
311 org.eclipse.jdt.core.formatter.insert_space_after_comma_in_switch_case_expressions=insert
276312 org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_arguments=insert
277313 org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_parameters=insert
278314 org.eclipse.jdt.core.formatter.insert_space_after_ellipsis=insert
279315 org.eclipse.jdt.core.formatter.insert_space_after_lambda_arrow=insert
316 org.eclipse.jdt.core.formatter.insert_space_after_logical_operator=insert
317 org.eclipse.jdt.core.formatter.insert_space_after_multiplicative_operator=insert
318 org.eclipse.jdt.core.formatter.insert_space_after_not_operator=do not insert
280319 org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_parameterized_type_reference=do not insert
281320 org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_arguments=do not insert
282321 org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_parameters=do not insert
293332 org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_declaration=do not insert
294333 org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_invocation=do not insert
295334 org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_parenthesized_expression=do not insert
335 org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_record_declaration=do not insert
296336 org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_switch=do not insert
297337 org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_synchronized=do not insert
298338 org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_try=do not insert
301341 org.eclipse.jdt.core.formatter.insert_space_after_prefix_operator=do not insert
302342 org.eclipse.jdt.core.formatter.insert_space_after_question_in_conditional=insert
303343 org.eclipse.jdt.core.formatter.insert_space_after_question_in_wildcard=do not insert
344 org.eclipse.jdt.core.formatter.insert_space_after_relational_operator=insert
304345 org.eclipse.jdt.core.formatter.insert_space_after_semicolon_in_for=insert
305346 org.eclipse.jdt.core.formatter.insert_space_after_semicolon_in_try_resources=insert
347 org.eclipse.jdt.core.formatter.insert_space_after_shift_operator=insert
348 org.eclipse.jdt.core.formatter.insert_space_after_string_concatenation=insert
306349 org.eclipse.jdt.core.formatter.insert_space_after_unary_operator=do not insert
350 org.eclipse.jdt.core.formatter.insert_space_before_additive_operator=insert
307351 org.eclipse.jdt.core.formatter.insert_space_before_and_in_type_parameter=insert
352 org.eclipse.jdt.core.formatter.insert_space_before_arrow_in_switch_case=insert
353 org.eclipse.jdt.core.formatter.insert_space_before_arrow_in_switch_default=insert
308354 org.eclipse.jdt.core.formatter.insert_space_before_assignment_operator=insert
309355 org.eclipse.jdt.core.formatter.insert_space_before_at_in_annotation_type_declaration=insert
310356 org.eclipse.jdt.core.formatter.insert_space_before_binary_operator=insert
357 org.eclipse.jdt.core.formatter.insert_space_before_bitwise_operator=insert
311358 org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_parameterized_type_reference=do not insert
312359 org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_arguments=do not insert
313360 org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_parameters=do not insert
324371 org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_method_declaration=do not insert
325372 org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_method_invocation=do not insert
326373 org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_parenthesized_expression=do not insert
374 org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_record_declaration=do not insert
327375 org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_switch=do not insert
328376 org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_synchronized=do not insert
329377 org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_try=do not insert
350398 org.eclipse.jdt.core.formatter.insert_space_before_comma_in_multiple_field_declarations=do not insert
351399 org.eclipse.jdt.core.formatter.insert_space_before_comma_in_multiple_local_declarations=do not insert
352400 org.eclipse.jdt.core.formatter.insert_space_before_comma_in_parameterized_type_reference=do not insert
401 org.eclipse.jdt.core.formatter.insert_space_before_comma_in_record_components=do not insert
353402 org.eclipse.jdt.core.formatter.insert_space_before_comma_in_superinterfaces=do not insert
403 org.eclipse.jdt.core.formatter.insert_space_before_comma_in_switch_case_expressions=do not insert
354404 org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_arguments=do not insert
355405 org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_parameters=do not insert
356406 org.eclipse.jdt.core.formatter.insert_space_before_ellipsis=do not insert
357407 org.eclipse.jdt.core.formatter.insert_space_before_lambda_arrow=insert
408 org.eclipse.jdt.core.formatter.insert_space_before_logical_operator=insert
409 org.eclipse.jdt.core.formatter.insert_space_before_multiplicative_operator=insert
358410 org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_parameterized_type_reference=do not insert
359411 org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_arguments=do not insert
360412 org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_parameters=do not insert
366418 org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enum_constant=insert
367419 org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enum_declaration=insert
368420 org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_method_declaration=insert
421 org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_record_constructor=insert
422 org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_record_declaration=insert
369423 org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_switch=insert
370424 org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_type_declaration=insert
371425 org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_allocation_expression=do not insert
381435 org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_declaration=do not insert
382436 org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_invocation=do not insert
383437 org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_parenthesized_expression=do not insert
438 org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_record_declaration=do not insert
384439 org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_switch=insert
385440 org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_synchronized=insert
386441 org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_try=insert
391446 org.eclipse.jdt.core.formatter.insert_space_before_prefix_operator=do not insert
392447 org.eclipse.jdt.core.formatter.insert_space_before_question_in_conditional=insert
393448 org.eclipse.jdt.core.formatter.insert_space_before_question_in_wildcard=do not insert
449 org.eclipse.jdt.core.formatter.insert_space_before_relational_operator=insert
394450 org.eclipse.jdt.core.formatter.insert_space_before_semicolon=do not insert
395451 org.eclipse.jdt.core.formatter.insert_space_before_semicolon_in_for=do not insert
396452 org.eclipse.jdt.core.formatter.insert_space_before_semicolon_in_try_resources=do not insert
453 org.eclipse.jdt.core.formatter.insert_space_before_shift_operator=insert
454 org.eclipse.jdt.core.formatter.insert_space_before_string_concatenation=insert
397455 org.eclipse.jdt.core.formatter.insert_space_before_unary_operator=do not insert
398456 org.eclipse.jdt.core.formatter.insert_space_between_brackets_in_array_type_reference=do not insert
399457 org.eclipse.jdt.core.formatter.insert_space_between_empty_braces_in_array_initializer=do not insert
405463 org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_invocation=do not insert
406464 org.eclipse.jdt.core.formatter.join_lines_in_comments=true
407465 org.eclipse.jdt.core.formatter.join_wrapped_lines=true
466 org.eclipse.jdt.core.formatter.keep_annotation_declaration_on_one_line=one_line_never
467 org.eclipse.jdt.core.formatter.keep_anonymous_type_declaration_on_one_line=one_line_never
468 org.eclipse.jdt.core.formatter.keep_code_block_on_one_line=one_line_never
408469 org.eclipse.jdt.core.formatter.keep_else_statement_on_same_line=false
409470 org.eclipse.jdt.core.formatter.keep_empty_array_initializer_on_one_line=false
471 org.eclipse.jdt.core.formatter.keep_enum_constant_declaration_on_one_line=one_line_never
472 org.eclipse.jdt.core.formatter.keep_enum_declaration_on_one_line=one_line_never
473 org.eclipse.jdt.core.formatter.keep_if_then_body_block_on_one_line=one_line_never
410474 org.eclipse.jdt.core.formatter.keep_imple_if_on_one_line=false
475 org.eclipse.jdt.core.formatter.keep_lambda_body_block_on_one_line=one_line_never
476 org.eclipse.jdt.core.formatter.keep_loop_body_block_on_one_line=one_line_never
477 org.eclipse.jdt.core.formatter.keep_method_body_on_one_line=one_line_never
478 org.eclipse.jdt.core.formatter.keep_record_constructor_on_one_line=one_line_never
479 org.eclipse.jdt.core.formatter.keep_record_declaration_on_one_line=one_line_never
480 org.eclipse.jdt.core.formatter.keep_simple_do_while_body_on_same_line=false
481 org.eclipse.jdt.core.formatter.keep_simple_for_body_on_same_line=false
482 org.eclipse.jdt.core.formatter.keep_simple_getter_setter_on_one_line=false
483 org.eclipse.jdt.core.formatter.keep_simple_while_body_on_same_line=false
411484 org.eclipse.jdt.core.formatter.keep_then_statement_on_same_line=false
485 org.eclipse.jdt.core.formatter.keep_type_declaration_on_one_line=one_line_never
412486 org.eclipse.jdt.core.formatter.lineSplit=120
413487 org.eclipse.jdt.core.formatter.never_indent_block_comments_on_first_column=false
414488 org.eclipse.jdt.core.formatter.never_indent_line_comments_on_first_column=false
489 org.eclipse.jdt.core.formatter.number_of_blank_lines_after_code_block=0
490 org.eclipse.jdt.core.formatter.number_of_blank_lines_at_beginning_of_code_block=0
415491 org.eclipse.jdt.core.formatter.number_of_blank_lines_at_beginning_of_method_body=0
492 org.eclipse.jdt.core.formatter.number_of_blank_lines_at_end_of_code_block=0
493 org.eclipse.jdt.core.formatter.number_of_blank_lines_at_end_of_method_body=0
494 org.eclipse.jdt.core.formatter.number_of_blank_lines_before_code_block=0
416495 org.eclipse.jdt.core.formatter.number_of_empty_lines_to_preserve=1
417496 org.eclipse.jdt.core.formatter.parentheses_positions_in_annotation=common_lines
418497 org.eclipse.jdt.core.formatter.parentheses_positions_in_catch_clause=common_lines
422501 org.eclipse.jdt.core.formatter.parentheses_positions_in_lambda_declaration=common_lines
423502 org.eclipse.jdt.core.formatter.parentheses_positions_in_method_delcaration=common_lines
424503 org.eclipse.jdt.core.formatter.parentheses_positions_in_method_invocation=common_lines
504 org.eclipse.jdt.core.formatter.parentheses_positions_in_record_declaration=common_lines
425505 org.eclipse.jdt.core.formatter.parentheses_positions_in_switch_statement=common_lines
426506 org.eclipse.jdt.core.formatter.parentheses_positions_in_try_clause=common_lines
427507 org.eclipse.jdt.core.formatter.put_empty_statement_on_new_line=true
428508 org.eclipse.jdt.core.formatter.tabulation.char=tab
429509 org.eclipse.jdt.core.formatter.tabulation.size=4
510 org.eclipse.jdt.core.formatter.text_block_indentation=0
430511 org.eclipse.jdt.core.formatter.use_on_off_tags=false
431512 org.eclipse.jdt.core.formatter.use_tabs_only_for_leading_indentations=false
513 org.eclipse.jdt.core.formatter.wrap_before_additive_operator=true
514 org.eclipse.jdt.core.formatter.wrap_before_assertion_message_operator=true
432515 org.eclipse.jdt.core.formatter.wrap_before_assignment_operator=false
433516 org.eclipse.jdt.core.formatter.wrap_before_binary_operator=true
517 org.eclipse.jdt.core.formatter.wrap_before_bitwise_operator=true
434518 org.eclipse.jdt.core.formatter.wrap_before_conditional_operator=true
519 org.eclipse.jdt.core.formatter.wrap_before_logical_operator=true
520 org.eclipse.jdt.core.formatter.wrap_before_multiplicative_operator=true
435521 org.eclipse.jdt.core.formatter.wrap_before_or_operator_multicatch=true
522 org.eclipse.jdt.core.formatter.wrap_before_relational_operator=true
523 org.eclipse.jdt.core.formatter.wrap_before_shift_operator=true
524 org.eclipse.jdt.core.formatter.wrap_before_string_concatenation=true
436525 org.eclipse.jdt.core.formatter.wrap_outer_expressions_when_nested=true
437526 org.eclipse.jdt.core.incompatibleJDKLevel=ignore
438527 org.eclipse.jdt.core.incompleteClasspath=error
00 eclipse.preferences.version=1
11 editor_save_participant_org.eclipse.jdt.ui.postsavelistener.cleanup=true
22 formatter_profile=org.eclipse.jdt.ui.default.eclipse_profile
3 formatter_settings_version=12
3 formatter_settings_version=20
44 org.eclipse.jdt.ui.exception.name=e
55 org.eclipse.jdt.ui.gettersetter.use.is=true
66 org.eclipse.jdt.ui.ignorelowercasenames=true
11 Bundle-ManifestVersion: 2
22 Bundle-Name: %pluginName
33 Bundle-SymbolicName: org.eclipse.ui.workbench.texteditor; singleton:=true
4 Bundle-Version: 3.14.200.qualifier
4 Bundle-Version: 3.15.0.qualifier
55 Bundle-Activator: org.eclipse.ui.internal.texteditor.TextEditorPlugin
66 Bundle-ActivationPolicy: lazy
77 Bundle-Vendor: %providerName
6464 lowerCase.description= Changes the selection to lower case
6565 lowerCase.label= To Lower Case
6666
67 goToLastEditPosition.label= Last Edit Location
68 goToLastEditPosition.description= Last edit location
67 goToLastEditPosition.label= Previous Edit Location
68 goToLastEditPosition.description= Previous edit location
69 goToNextEditPosition.label= Next Edit Location
70 goToNextEditPosition.description= Next edit location
6971
7072 command.clearMark.description = Clear the mark
7173 command.clearMark.name = Clear Mark
196198 blockSelectionModeFont.label= Text Editor Block Selection Font
197199 blockSelectionModeFont.description= The block selection mode font is used by text editors in block (column) mode. A monospace font should be used.
198200
199 MinimapView.name=Minimap
201 MinimapView.name=Minimap
356356 description="%goToLastEditPosition.description"
357357 categoryId="org.eclipse.ui.category.navigate"
358358 id="org.eclipse.ui.edit.text.gotoLastEditPosition">
359 </command>
360 <command
361 name="%goToNextEditPosition.label"
362 description="%goToNextEditPosition.description"
363 categoryId="org.eclipse.ui.category.navigate"
364 id="org.eclipse.ui.edit.text.gotoNextEditPosition">
359365 </command>
360366 <command
361367 name="%smartEnter.label"
590596 commandId="org.eclipse.ui.edit.text.gotoLastEditPosition"
591597 contextId="org.eclipse.ui.contexts.window"
592598 schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"
593 sequence="CTRL+Q"/> <!-- Command+Q is quit on carbon, so don't overwrite it -->
599 sequence="M3+CTRL+ARROW_LEFT"/>
600 <key
601 commandId="org.eclipse.ui.edit.text.gotoNextEditPosition"
602 contextId="org.eclipse.ui.contexts.window"
603 schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"
604 sequence="M3+CTRL+ARROW_RIGHT"/>
605 <key
606 commandId="org.eclipse.ui.edit.text.gotoLastEditPosition"
607 contextId="org.eclipse.ui.contexts.window"
608 schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"
609 sequence="CTRL+Q"/><!-- legacy mapping -->
594610 <key
595611 commandId="org.eclipse.ui.edit.text.smartEnter"
596612 contextId="org.eclipse.ui.textEditorScope"
3131 private final String fEditorId;
3232 /** The position */
3333 private final Position fPosition;
34 /**
35 * how many characters may come in between two edit positions for them to
36 * still be lumped into same bucket in position history (designed to prevent
37 * filling history with meaningless noise of very similar positions)
38 */
39 public static final int PROXIMITY_THRESHOLD = 30;
3440
3541 /**
3642 * Creates a new edit position.
7278 public Position getPosition() {
7379 return fPosition;
7480 }
81
82 /**
83 * @param a Position to compare the other arg against
84 * @param b Another position to compare the first arg against
85 * @param threshold The maximum allowed distance between Position args for them
86 * to be considered co-located
87 * @return true if both Position args are colocated as defined by the threshold
88 * param
89 * @since 3.15
90 */
91 public static boolean areCoLocated(Position a, Position b, int threshold) {
92 if (a == null || b == null) {
93 return false;
94 }
95 int center1 = a.offset + (a.length / 2);
96 int center2 = b.offset + (b.length / 2);
97 int centerDistance = Math.abs(center1 - center2);
98 int minWithoutOverlap = a.length / 2 + b.length / 2;
99 return centerDistance < (minWithoutOverlap + threshold);
100 }
101
102 /**
103 * @since 3.15
104 */
105 public static boolean areCoLocated(Position a, Position b) {
106 return EditPosition.areCoLocated(a, b, EditPosition.PROXIMITY_THRESHOLD);
107 }
108
109 /**
110 * @since 3.15
111 */
112 public static boolean areCoLocated(EditPosition a, EditPosition b, int threshold) {
113 return a != null && b != null && a.getEditorInput().getName()
114 .equals(b.getEditorInput().getName())
115 && EditPosition.areCoLocated(a.getPosition(), b.getPosition(), threshold);
116 }
117
118 /**
119 * @since 3.15
120 */
121 public static boolean areCoLocated(EditPosition a, EditPosition b) {
122 return EditPosition.areCoLocated(a, b, EditPosition.PROXIMITY_THRESHOLD);
123 }
75124 }
2727
2828 public static String Editor_error_gotoLastEditPosition_title;
2929 public static String Editor_error_gotoLastEditPosition_message;
30 public static String Editor_error_gotoNextEditPosition_title;
31 public static String Editor_error_gotoNextEditPosition_message;
3032
3133 static {
3234 NLS.initializeMessages(BUNDLE_NAME, EditorMessages.class);
1616
1717 Editor_error_gotoLastEditPosition_title= Problems going to last edit position
1818 Editor_error_gotoLastEditPosition_message= Unable to go to the last edit position.
19 Editor_error_gotoNextEditPosition_title= Problems going to next edit position
20 Editor_error_gotoNextEditPosition_message= Unable to go to the next edit position.
0 /*******************************************************************************
1 * Copyright (c) 2020 Ari Kast and others.
2 *
3 * This program and the accompanying materials
4 * are made available under the terms of the Eclipse Public License 2.0
5 * which accompanies this distribution, and is available at
6 * https://www.eclipse.org/legal/epl-2.0/
7 *
8 * SPDX-License-Identifier: EPL-2.0
9 *
10 * Contributors:
11 * Ari Kast - initial API and implementation
12 *******************************************************************************/
13
14 package org.eclipse.ui.internal.texteditor;
15
16 import java.lang.reflect.Array;
17
18 /**
19 * @author Ari Kast
20 *
21 * Tracks history in order of insertion. It can operate either as a ring
22 * or as a line: in ring mode, if history size is N, then calling
23 * goBackward N times brings you full circle back to your current
24 * location in linear mode, if history size is N, then calling
25 * goBackward N times brings you to the beginning, after which
26 * additional calls to goBackward will have no effect until either
27 * goForward is called or a new entry is added. Both linear and ring
28 * mode overwrite history as needed when buffer is full
29 * @param <T> the type of the object instances being tracked in history
30 *
31 * @since 3.15
32 */
33 public class HistoryTracker<T> {
34 // the actual historical data
35 T[] fHistory;
36
37 // function to determine whether history elements can be merged
38 CandidateEvaluator<T> fEvaluator;
39
40 // pointer to current location in history queue
41 Navigator<T> fBrowsePoint;
42
43 // pointer to most recent insertion to history queue. New insertions always
44 // go to index fMostRecent + 1
45 Navigator<T> fInsertionPoint;
46
47 // the size of the dataset contained in history queue
48 // grows til it reaches history.length, and generally wont
49 // shrink
50 int fSize;
51
52 // controls whether navigation wraps around in circular fashion
53 // or if it is purely linear
54 boolean fUseCircularNavigation;
55
56 /**
57 * @param historySize the buffer size. additional insertions will
58 * overwrite oldest insertions
59 * @param clazz the class type of the objects being tracked
60 * @param evaluator The expression which compares incoming elements
61 * against existing elements. If this expression
62 * yields true, then the element(s) for which it
63 * was true is/are replaced
64 * @param useCircularNavigation when true the history operates in ring mode,
65 * otherwise it is linear
66 */
67 @SuppressWarnings("unchecked")
68 public HistoryTracker(int historySize, Class<T> clazz, CandidateEvaluator<T> evaluator,
69 boolean useCircularNavigation) {
70 historySize = Math.max(historySize, 1); // size < 1 makes no sense, so
71 // enforce at least size 1
72 fHistory = (T[]) Array.newInstance(clazz, historySize);
73 this.fEvaluator = evaluator;
74 this.fUseCircularNavigation = useCircularNavigation;
75 fBrowsePoint = new Navigator<>(this);
76 fInsertionPoint = new Navigator<>(this);
77 }
78
79 public T browseBackward() {
80 if (canGoBackward()) {
81 fBrowsePoint.decr();
82 }
83 return getCurrentBrowsePoint();
84 }
85
86 public T browseForward() {
87 if (canGoForward()) {
88 fBrowsePoint.incr();
89 }
90 return getCurrentBrowsePoint();
91 }
92
93 private boolean canGoBackward() {
94 return fSize > 0 && (fUseCircularNavigation || fBrowsePoint.getPriorIndex() != fInsertionPoint.getIndex());
95 }
96
97 private boolean canGoForward() {
98 return fSize > 0 && (fUseCircularNavigation || fBrowsePoint.getIndex() != fInsertionPoint.getIndex());
99 }
100
101 public T getCurrentBrowsePoint() {
102 return fBrowsePoint.currentItem();
103 }
104
105 public T getNext() {
106 if (canGoForward()) {
107 return getAt(fBrowsePoint.getNextIndex());
108 } else {
109 return fBrowsePoint.currentItem();
110 }
111 }
112
113 T getAt(int index) {
114 if (fSize == 0) {
115 return null;
116 }
117
118 int i = moddedIndex(index);
119 return fHistory[i];
120 }
121
122 /**
123 * This method always adds the parameter element at the current history
124 * location. If history is full (capacity == size) then an existing element is
125 * overwritten in the process. If there exists an element such that
126 * evaluator.canReplace() yields true, then that element is prioritized for
127 * being overwritten
128 *
129 * @param newItem The object instance being added to history
130 * @return The element which was evicted to make room for the incoming element.
131 * Returns null if nothing was evicted
132 */
133 public T addOrReplace(T newItem) {
134
135 T answer = null;
136 // if a replacement candidate exists, delete it since this
137 // incoming will be replacing it
138
139 /**
140 * This loop could potentially degrade to N^2 performance in case of multiple
141 * deletions, but in practice it 1) shouldnt matter for our small history sizes,
142 * and 2) will seldom delete more than 1 item for O(N) performance.
143 *
144 * If performance is ever a concern, several improvements could be made: 1)
145 * perform all deletions in a single pass, then do a single additional pass for
146 * compaction for a total of 2 passes 2) uncomment the "break" statement as
147 * explained below 3) use a different data structure altogether, eg maybe an
148 * ordered tree of some kind
149 */
150 for (int i = fInsertionPoint.getIndex(); i > fInsertionPoint.getIndex() - fSize; i--) {
151 T candidate = getAt(i);
152 if (candidate != null && fEvaluator.canReplace(newItem, candidate)) {
153 answer = deleteAt(i);
154 /**
155 * if performance is ever a concern, the below break could be uncommented so
156 * that this method only de-dupes first match instead of all matches. generally
157 * first match would be sufficient, except there can be drift over time eg if
158 * history contains [10,20,30] and vicinity threshold defined as distance 2,
159 * then you insert the following series: 11, 12, 13, 14, 15, 16, 17, 18, 19, 20
160 * even if each insert overwrote the prior, you still could end up with dataset
161 * [20, 20, 30]. By not breaking here we prevent that state from occuring, but
162 * at some computation cost. Therefore if cost (performance) ever a problem, we
163 * could just accept that occasional suboptimal history state for better
164 * performance
165 */
166 // break;
167 }
168 }
169
170 T replaced = addLast(newItem);
171 if (answer == null) {
172 answer = replaced;
173 }
174
175 return answer;
176 }
177
178 private T addLast(T newItem) {
179 if (newItem == null) {
180 return deleteLast();
181 }
182
183 if (fSize >= fHistory.length) {
184 // no space, so just overwrite next slot
185 fInsertionPoint.incr();
186 fBrowsePoint.jumpTo(fInsertionPoint);
187 return replaceAt(newItem, fInsertionPoint);
188 } else {
189 // there's at least one empty slot so data size can grow
190 expand();
191 fInsertionPoint.incr();
192 fBrowsePoint.jumpTo(fInsertionPoint);
193 return shiftInsert(newItem);
194 }
195
196 }
197
198 // inserts here and shifts existing values until either empty space is found
199 // or end is reached, in which case last evaluated slot is discarded
200 private T shiftInsert(T newItem) {
201
202 T answer = replaceAt(newItem, fInsertionPoint);
203 T tmp = answer;
204
205 // shift from here to the end until empty slot found
206 for (int i = fInsertionPoint.getIndex() + 1; i < fSize; i++) {
207 tmp = replaceAt(tmp, i);
208 }
209
210 return answer;
211 }
212
213 // deletes and shifts to fill in the hole created by deletion
214 private T deleteAt(int index) {
215 if (fSize == 0) {
216 return null;
217 }
218 int modIndex = moddedIndex(index);
219 T answer = replaceAt(null, modIndex);
220
221 // shift to fill in any gaps to keep data contiguous so that mod
222 // calculations work
223 T priorVal = null;
224 for (int i = fSize - 1; i >= modIndex; i--) {
225 priorVal = replaceAt(priorVal, i);
226 }
227
228 if (answer != null) {
229 fSize--;
230 }
231
232 // adjust insertion point if it was affected by the shift
233 if (fInsertionPoint.getIndex() >= modIndex && fSize > 0) {
234 fInsertionPoint.decr();
235 }
236
237 // adjust browse point if it was affected by the shift
238 if (fBrowsePoint.getIndex() >= modIndex && fSize > 0) {
239 fBrowsePoint.decr();
240 }
241
242 return answer;
243 }
244
245 public T deleteLast() {
246 T answer = deleteAt(fInsertionPoint.getIndex());
247 return answer;
248 }
249
250 private T replaceAt(T newItem, int index) {
251 if (fSize == 0) {
252 return null;
253 }
254 int i = moddedIndex(index);
255
256 T replaced = getAt(i);
257 fHistory[i] = newItem;
258 return replaced;
259 }
260
261 private T replaceAt(T newItem, Navigator<T> navigator) {
262 return replaceAt(newItem, navigator.getIndex());
263 }
264
265 public T replaceLast(T newItem) {
266 if (newItem == null) {
267 return deleteLast();
268 }
269 fBrowsePoint.jumpTo(fInsertionPoint);
270 return replaceAt(newItem, fInsertionPoint);
271 }
272
273 void expand() {
274 fSize = Math.max(fSize, (fSize + 1) % (fHistory.length + 1));
275 }
276
277 private int moddedIndex(int index) {
278 return Math.floorMod(index, fSize);
279 }
280
281 public boolean isEmpty() {
282 return fInsertionPoint.currentItem() == null;
283 }
284
285 public int getSize() {
286 return fSize;
287 }
288
289 public Navigator<T> navigator() {
290 Navigator<T> answer = new Navigator<>(this);
291 answer.jumpTo(fInsertionPoint);
292 return answer;
293 }
294
295 // for internal use, not public
296 Navigator<T> navigator(int index) {
297 Navigator<T> answer = new Navigator<>(this);
298 answer.jumpTo(index);
299 return answer;
300 }
301
302 /**
303 * This method is intended for testing/troubleshooting, not for general use
304 * Beware it has O(N) performance
305 *
306 * @param item The item to check whether this history contains
307 * @return true if history contains item
308 */
309 public boolean contains(T item) {
310 if (item == null) {
311 return false;
312 }
313
314 for (int i = 0; i < fSize; i++) {
315 if (item.equals(getAt(i))) {
316 return true;
317 }
318 }
319 return false;
320 }
321
322 /**
323 * This method is intended for testing/troubleshooting
324 *
325 * @return true if the state of this object is healthy/as expected
326 */
327 public boolean isHealthy() {
328 // make sure nulls are consolidated not scattered
329 boolean priorWasNull = false;
330 int flipCount = 0;
331 for (int i = 0; i < fHistory.length; i++) {
332 boolean isNull = (fHistory[i] == null);
333 if (priorWasNull != isNull) {
334 flipCount++;
335 priorWasNull = isNull;
336 }
337 }
338 return flipCount < 2;
339 }
340
341 /**
342 *
343 * used during history compaction to consolidate like candidates in the history
344 */
345 public static interface CandidateEvaluator<T> {
346 public boolean canReplace(T a, T b);
347 }
348
349 /**
350 * for easy traversing thru history
351 */
352 public static class Navigator<T> {
353 HistoryTracker<T> historyTracker;
354 int fIndex;
355
356 public Navigator(HistoryTracker<T> tracker) {
357 this.historyTracker = tracker;
358 fIndex = Math.floorMod(-1, tracker.fHistory.length);
359 }
360
361 void incr() {
362 if (historyTracker.fSize == 0) {
363 return;
364 }
365
366 fIndex = getNextIndex();
367 }
368
369 void decr() {
370 if (historyTracker.fSize == 0) {
371 return;
372 }
373
374 fIndex = getPriorIndex();
375 }
376
377 int getIndex() {
378 return fIndex;
379 }
380
381 int getNextIndex() {
382 return historyTracker.moddedIndex(fIndex + 1);
383 }
384
385 int getPriorIndex() {
386 return historyTracker.moddedIndex(fIndex - 1);
387 }
388
389 public T currentItem() {
390 return historyTracker.getAt(fIndex);
391 }
392
393 public T nextItem() {
394 incr();
395 return historyTracker.getAt(fIndex);
396 }
397
398 public T priorItem() {
399 decr();
400 return historyTracker.getAt(fIndex);
401 }
402
403 void jumpTo(Navigator<T> b) {
404 this.fIndex = b.fIndex;
405 }
406
407 public void jumpTo(int index) {
408 fIndex = historyTracker.moddedIndex(index);
409 }
410 }
411 }
4646 */
4747 public final class TextEditorPlugin extends AbstractUIPlugin implements IRegistryChangeListener {
4848
49 /** how many edit locations will be remembered in history */
50 public static final int EDIT_LOCATION_HISTORY_SIZE = 15;
51
4952 /** The plug-in instance */
5053 private static TextEditorPlugin fgPlugin;
5154
52 /** The last edit position */
53 private EditPosition fLastEditPosition;
55 /**
56 * tracks whether cursor has moved since fEditPositionHistory was used to return
57 * to prior or next location. If cursor has moved, then goto last edit location
58 * simply returns to last edit location. But if cursor has not moved, that means
59 * the command was invoked twice in a row without intervening other actions; in
60 * that case we are in a traversal state of BACKWARD (or FORWARD), so we start
61 * traversing backward (or forward) through history to prior (or next) edit
62 * locations.
63 */
64 TraversalDirection fEditHistoryTraversalDirection = TraversalDirection.NONE;
65
66 // an ordered history of prior edit positions
67 private HistoryTracker<EditPosition> fEditPositionHistory = new HistoryTracker<>(
68 EDIT_LOCATION_HISTORY_SIZE, EditPosition.class,
69 (a, b) -> b.getPosition().isDeleted || b.getPosition().isDeleted
70 || EditPosition.areCoLocated(a, b),
71 false);
72
5473 /** The action which goes to the last edit position */
55 private Set<IAction> fLastEditPositionDependentActions;
74 private Set<IAction> fEditPositionDependentActions;
5675
5776 /**
5877 * The quick diff extension registry.
104123 */
105124 public static final String REFERENCE_PROVIDER_EXTENSION_POINT= "quickDiffReferenceProvider"; //$NON-NLS-1$
106125
126 public TraversalDirection getEditHistoryTraversalDirection() {
127 return fEditHistoryTraversalDirection;
128 }
129
130 public void setEditHistoryTraversalDirection(TraversalDirection direction) {
131 this.fEditHistoryTraversalDirection = direction;
132 }
133
134 public HistoryTracker<EditPosition> getEditPositionHistory() {
135 return fEditPositionHistory;
136 }
137
138 public void setEditPositionHistory(HistoryTracker<EditPosition> editPositionHistory) {
139 fEditPositionHistory = editPositionHistory;
140 }
141
107142 /**
108143 * Returns the last edit position.
109144 *
110 * @return the last edit position or <code>null</code> if there is no last edit position
145 * @return the last edit position or <code>null</code> if there is no last
146 * edit position
111147 * @see EditPosition
112148 */
113149 public EditPosition getLastEditPosition() {
114 return fLastEditPosition;
115 }
116
117 /**
118 * Sets the last edit position.
119 *
120 * @param lastEditPosition the last edit position
121 * @see EditPosition
122 */
123 public void setLastEditPosition(EditPosition lastEditPosition) {
124 fLastEditPosition= lastEditPosition;
125 if (fLastEditPosition != null && fLastEditPositionDependentActions != null) {
126 Iterator<IAction> iter= fLastEditPositionDependentActions.iterator();
150 return fEditPositionHistory.getCurrentBrowsePoint();
151 }
152
153 public EditPosition getNextEditPosition() {
154 return fEditPositionHistory.getNext();
155 }
156
157 public EditPosition backtrackEditPosition() {
158 return fEditPositionHistory.browseBackward();
159 }
160
161 public EditPosition advanceEditPosition() {
162 return fEditPositionHistory.browseForward();
163 }
164
165 public void enableLastEditPositionDependentActions() {
166 EditPosition last = fEditPositionHistory.getCurrentBrowsePoint();
167
168 if (last != null && getDependentActions() != null) {
169 Iterator<IAction> iter = getDependentActions().iterator();
127170 while (iter.hasNext())
128171 iter.next().setEnabled(true);
129 fLastEditPositionDependentActions= null;
172 setDependentActions(null);
130173 }
131174 }
132175
136179 * @param action the goto last edit position action
137180 */
138181 public void addLastEditPositionDependentAction(IAction action) {
139 if (fLastEditPosition != null)
182 if (!fEditPositionHistory.isEmpty()) {
140183 return;
141 if (fLastEditPositionDependentActions == null)
142 fLastEditPositionDependentActions= new HashSet<>();
143 fLastEditPositionDependentActions.add(action);
184 }
185
186 addDependentAction(action);
144187 }
145188
146189 /**
149192 * @param action the action that depends on the last edit position
150193 */
151194 public void removeLastEditPositionDependentAction(IAction action) {
152 if (fLastEditPosition != null)
195 if (!fEditPositionHistory.isEmpty()) {
153196 return;
154 if (fLastEditPositionDependentActions != null)
155 fLastEditPositionDependentActions.remove(action);
156 }
157
197 }
198
199 removeDependentAction(action);
200 }
201
202 private Set<IAction> getDependentActions() {
203 return fEditPositionDependentActions;
204 }
205
206 private void setDependentActions(Set<IAction> actions) {
207 fEditPositionDependentActions = actions;
208 }
209
210 public void addDependentAction(IAction action) {
211 if (getDependentActions() == null) {
212 setDependentActions(new HashSet<>());
213 }
214 getDependentActions().add(action);
215 }
216
217 public void removeDependentAction(IAction action) {
218 if (getDependentActions() != null) {
219 getDependentActions().remove(action);
220 }
221 }
158222
159223 @Override
160224 public void start(BundleContext context) throws Exception {
215279 public CodeMiningProviderRegistry getCodeMiningProviderRegistry() {
216280 return fCodeMiningProviderRegistry;
217281 }
282
283 public static enum TraversalDirection {
284 NONE, BACKWARD, FORWARD;
285 }
218286 }
1313 package org.eclipse.ui.internal.texteditor.rulers;
1414
1515 import java.util.Collections;
16 import java.util.Iterator;
1716 import java.util.LinkedHashMap;
1817 import java.util.LinkedHashSet;
1918 import java.util.Map;
147146 */
148147 public void removeVertex(E vertex) {
149148 Set<E> targets= fOut.removeAll(vertex);
150 for (Iterator<E> it= targets.iterator(); it.hasNext();)
151 fIn.remove(it.next(), vertex);
149 for (E e : targets)
150 fIn.remove(e, vertex);
152151 Set<E> origins= fIn.removeAll(vertex);
153 for (Iterator<E> it= origins.iterator(); it.hasNext();)
154 fOut.remove(it.next(), vertex);
152 for (E e : origins)
153 fOut.remove(e, vertex);
155154 }
156155
157156 /**
199198 if (start == end)
200199 return true;
201200
202 Set<E> children= fOut.get(start);
203 for (Iterator<E> it= children.iterator(); it.hasNext();)
201 for (E e : fOut.get(start))
204202 // recursion
205 if (hasPath(it.next(), end))
203 if (hasPath(e, end))
206204 return true;
207205 return false;
208206 }
214214 import org.eclipse.ui.dnd.IDragAndDropService;
215215 import org.eclipse.ui.internal.texteditor.EditPosition;
216216 import org.eclipse.ui.internal.texteditor.FocusedInformationPresenter;
217 import org.eclipse.ui.internal.texteditor.HistoryTracker;
217218 import org.eclipse.ui.internal.texteditor.NLSUtility;
218219 import org.eclipse.ui.internal.texteditor.TextEditorPlugin;
219220 import org.eclipse.ui.internal.texteditor.rulers.StringSetSerializer;
604605 *
605606 * @since 3.0
606607 */
607 private Position fLocalLastEditPosition;
608608
609609 /** The posted updater code. */
610610 private Runnable fRunnable = () -> {
615615
616616 // remember the last edit position
617617 if (isDirty() && fUpdateLastEditPosition) {
618 HistoryTracker<EditPosition> positionHistory = TextEditorPlugin.getDefault()
619 .getEditPositionHistory();
618620 fUpdateLastEditPosition = false;
619621 ISelection sel = getSelectionProvider().getSelection();
620622 IEditorInput input = getEditorInput();
621623 IDocument document = getDocumentProvider().getDocument(input);
622
623 if (fLocalLastEditPosition != null) {
624 if (document != null) {
625 document.removePosition(fLocalLastEditPosition);
626 }
627 fLocalLastEditPosition = null;
628 }
624 IEditorSite editorSite = getEditorSite();
625 if (editorSite instanceof MultiPageEditorSite)
626 editorSite = ((MultiPageEditorSite) editorSite).getMultiPageEditor().getEditorSite();
629627
630628 if (sel instanceof ITextSelection && !sel.isEmpty()) {
631629 ITextSelection s = (ITextSelection) sel;
632 fLocalLastEditPosition = new Position(s.getOffset(), s.getLength());
630 Position newPosition = new Position(s.getOffset(), s.getLength());
631 EditPosition newEditPosition = new EditPosition(input, editorSite.getId(), newPosition);
632 EditPosition replaced = positionHistory.addOrReplace(newEditPosition);
633633 if (document != null) {
634 if (replaced != null) {
635 document.removePosition(replaced.getPosition());
636 }
634637 try {
635 document.addPosition(fLocalLastEditPosition);
638 if (positionHistory.getSize() > 0) {
639 document.addPosition(positionHistory.getCurrentBrowsePoint().getPosition());
640 }
636641 } catch (BadLocationException ex) {
637 fLocalLastEditPosition = null;
642 positionHistory.deleteLast();
638643 }
639644 }
640645 }
641646
642 IEditorSite editorSite = getEditorSite();
643 if (editorSite instanceof MultiPageEditorSite)
644 editorSite = ((MultiPageEditorSite) editorSite).getMultiPageEditor().getEditorSite();
645 TextEditorPlugin.getDefault()
646 .setLastEditPosition(new EditPosition(input, editorSite.getId(), fLocalLastEditPosition));
647 TextEditorPlugin.getDefault().enableLastEditPositionDependentActions();
647648 }
648649 }
649650 };
680681
681682 @Override
682683 public void inputDocumentAboutToBeChanged(IDocument oldInput, IDocument newInput) {
683 if (oldInput != null && fLocalLastEditPosition != null) {
684 oldInput.removePosition(fLocalLastEditPosition);
685 fLocalLastEditPosition= null;
684 HistoryTracker<EditPosition> positionHistory = TextEditorPlugin.getDefault().getEditPositionHistory();
685 if (oldInput != null && !positionHistory.isEmpty()) {
686 for (int i = 0; i < positionHistory.getSize(); i++)
687 oldInput.removePosition(positionHistory.browseBackward().getPosition());
686688 }
687689 }
688690
689691 @Override
690692 public void inputDocumentChanged(IDocument oldInput, IDocument newInput) {
693 discardHistoryFor(oldInput);
694 }
695
696 private void discardHistoryFor(IDocument input) {
697 HistoryTracker<EditPosition> positionHistory = TextEditorPlugin.getDefault().getEditPositionHistory();
698 if (input != null && !positionHistory.isEmpty()) {
699 for (int i = 0; i < positionHistory.getSize(); i++)
700 input.removePosition(positionHistory.browseBackward().getPosition());
701 }
702
691703 }
692704 }
693705
17381750 */
17391751 @Override
17401752 public void dispose() {
1741 for (Iterator<IContributedRulerColumn> iter= new ArrayList<>(fColumns).iterator(); iter.hasNext();)
1742 removeColumn(getRuler(), iter.next());
1753 for (IContributedRulerColumn iContributedRulerColumn : new ArrayList<>(fColumns))
1754 removeColumn(getRuler(), iContributedRulerColumn);
17431755 fColumns.clear();
17441756 }
17451757 }
23772389 */
23782390 private SelectionListener fSelectionListener;
23792391 /** The editor's font. */
2380 private Font fFont; /**
2381 * The editor's foreground color.
2382 * @since 2.0
2383 */
2384 private Color fForegroundColor;
2385 /**
2386 * The editor's background color.
2387 * @since 2.0
2388 */
2389 private Color fBackgroundColor;
2390 /**
2391 * The editor's selection foreground color.
2392 * @since 3.0
2393 */
2394 private Color fSelectionForegroundColor;
2395 /**
2396 * The editor's selection background color.
2397 * @since 3.0
2398 */
2399 private Color fSelectionBackgroundColor;
2392 private Font fFont;
24002393 /**
24012394 * The find scope's highlight color.
24022395 * @since 2.0
30913084 private Runnable fRunnable = () -> {
30923085 // check whether editor has not been disposed yet
30933086 if (fSourceViewer != null && fSourceViewer.getDocument() != null) {
3094 handleCursorPositionChanged();
3087 handleCursorPositionChangedWrapper();
30953088 updateSelectionDependentActions();
30963089 }
30973090 };
31283121
31293122 @Override
31303123 public void keyPressed(KeyEvent e) {
3131 handleCursorPositionChanged();
3124 handleCursorPositionChangedWrapper();
31323125 }
31333126
31343127 @Override
31453138
31463139 @Override
31473140 public void mouseUp(MouseEvent e) {
3148 handleCursorPositionChanged();
3141 handleCursorPositionChangedWrapper();
31493142 }
31503143 };
31513144 }
32503243
32513244 RulerColumnRegistry registry= RulerColumnRegistry.getDefault();
32523245 List<RulerColumnDescriptor> descriptors= registry.getColumnDescriptors();
3253 for (Iterator<RulerColumnDescriptor> it= descriptors.iterator(); it.hasNext();) {
3254 final RulerColumnDescriptor descriptor= it.next();
3246 for (RulerColumnDescriptor descriptor : descriptors) {
32553247 support.setColumnVisible(descriptor, adapter == null || adapter.isEnabled(descriptor));
32563248 }
32573249 }
39313923 : createColor(store, PREFERENCE_COLOR_FOREGROUND, styledText.getDisplay());
39323924 styledText.setForeground(color);
39333925
3934 if (fForegroundColor != null)
3935 fForegroundColor.dispose();
3936
3937 fForegroundColor= color;
3938
39393926 // ---------- background color ----------------------
39403927 color= store.getBoolean(PREFERENCE_COLOR_BACKGROUND_SYSTEM_DEFAULT)
39413928 ? null
39423929 : createColor(store, PREFERENCE_COLOR_BACKGROUND, styledText.getDisplay());
39433930 styledText.setBackground(color);
39443931
3945 if (fBackgroundColor != null)
3946 fBackgroundColor.dispose();
3947
3948 fBackgroundColor= color;
3949
39503932 // ----------- selection foreground color --------------------
39513933 color= store.getBoolean(PREFERENCE_COLOR_SELECTION_FOREGROUND_SYSTEM_DEFAULT)
39523934 ? null
39533935 : createColor(store, PREFERENCE_COLOR_SELECTION_FOREGROUND, styledText.getDisplay());
39543936 styledText.setSelectionForeground(color);
39553937
3956 if (fSelectionForegroundColor != null)
3957 fSelectionForegroundColor.dispose();
3958
3959 fSelectionForegroundColor= color;
39603938
39613939 // ---------- selection background color ----------------------
39623940 color= store.getBoolean(PREFERENCE_COLOR_SELECTION_BACKGROUND_SYSTEM_DEFAULT)
39643942 : createColor(store, PREFERENCE_COLOR_SELECTION_BACKGROUND, styledText.getDisplay());
39653943 styledText.setSelectionBackground(color);
39663944
3967 if (fSelectionBackgroundColor != null)
3968 fSelectionBackgroundColor.dispose();
3969
3970 fSelectionBackgroundColor= color;
39713945 }
39723946 }
39733947
39913965 if (target != null && target instanceof IFindReplaceTargetExtension)
39923966 ((IFindReplaceTargetExtension) target).setScopeHighlightColor(color);
39933967
3994 if (fFindScopeHighlightColor != null)
3995 fFindScopeHighlightColor.dispose();
3996
3997 fFindScopeHighlightColor= color;
39983968 }
39993969 }
40003970
43334303
43344304 disposeNonDefaultCaret();
43354305 fInitialCaret= null;
4336
4337 if (fForegroundColor != null) {
4338 fForegroundColor.dispose();
4339 fForegroundColor= null;
4340 }
4341
4342 if (fBackgroundColor != null) {
4343 fBackgroundColor.dispose();
4344 fBackgroundColor= null;
4345 }
4346
4347 if (fSelectionForegroundColor != null) {
4348 fSelectionForegroundColor.dispose();
4349 fSelectionForegroundColor= null;
4350 }
4351
4352 if (fSelectionBackgroundColor != null) {
4353 fSelectionBackgroundColor.dispose();
4354 fSelectionBackgroundColor= null;
4355 }
4356
4357 if (fFindScopeHighlightColor != null) {
4358 fFindScopeHighlightColor.dispose();
4359 fFindScopeHighlightColor= null;
4360 }
43614306
43624307 if (fFontPropertyChangeListener != null) {
43634308 JFaceResources.getFontRegistry().removeListener(fFontPropertyChangeListener);
46334578 if (PREFERENCE_RULER_CONTRIBUTIONS.equals(property)) {
46344579 String[] difference= StringSetSerializer.getDifference((String) event.getOldValue(), (String) event.getNewValue());
46354580 IColumnSupport support= getAdapter(IColumnSupport.class);
4636 for (int i= 0; i < difference.length; i++) {
4637 RulerColumnDescriptor desc= RulerColumnRegistry.getDefault().getColumnDescriptor(difference[i]);
4581 for (String element : difference) {
4582 RulerColumnDescriptor desc= RulerColumnRegistry.getDefault().getColumnDescriptor(element);
46384583 if (desc != null && support.isColumnSupported(desc)) {
46394584 boolean newState= !support.isColumnVisible(desc);
46404585 support.setColumnVisible(desc, newState);
53565301 private IAction findContributedAction(String actionID) {
53575302 List<IConfigurationElement> actions= new ArrayList<>();
53585303 IConfigurationElement[] elements= Platform.getExtensionRegistry().getConfigurationElementsFor(PlatformUI.PLUGIN_ID, "editorActions"); //$NON-NLS-1$
5359 for (int i= 0; i < elements.length; i++) {
5360 IConfigurationElement element= elements[i];
5304 for (IConfigurationElement element : elements) {
53615305 if (TAG_CONTRIBUTION_TYPE.equals(element.getName())) {
53625306 IWorkbenchPartSite site = getSite();
53635307 if (site == null) {
53665310 if (!site.getId().equals(element.getAttribute("targetID"))) //$NON-NLS-1$
53675311 continue;
53685312
5369 IConfigurationElement[] children= element.getChildren("action"); //$NON-NLS-1$
5370 for (int j= 0; j < children.length; j++) {
5371 IConfigurationElement child= children[j];
5313 for (IConfigurationElement child : element.getChildren("action")) { //$NON-NLS-1$
53725314 if (actionID.equals(child.getAttribute("actionID"))) //$NON-NLS-1$
53735315 actions.add(child);
53745316 }
55375479 IAction action;
55385480
55395481 StyledText textWidget= fSourceViewer.getTextWidget();
5540 for (int i= 0; i < ACTION_MAP.length; i++) {
5541 IdMapEntry entry= ACTION_MAP[i];
5482 for (IdMapEntry entry : ACTION_MAP) {
55425483 action= new TextNavigationAction(textWidget, entry.getAction());
55435484 action.setActionDefinitionId(entry.getActionId());
55445485 setAction(entry.getActionId(), action);
61036044 menu.add(new Separator(ITextEditorActionConstants.GROUP_REST));
61046045 menu.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS));
61056046
6106 for (Iterator<IMenuListener> i= fRulerContextMenuListeners.iterator(); i.hasNext();)
6107 i.next().menuAboutToShow(menu);
6047 for (IMenuListener iMenuListener : fRulerContextMenuListeners)
6048 iMenuListener.menuAboutToShow(menu);
61086049
61096050 addAction(menu, ITextEditorActionConstants.RULER_MANAGE_BOOKMARKS);
61106051 addAction(menu, ITextEditorActionConstants.RULER_MANAGE_TASKS);
63816322 * @since 2.1
63826323 */
63836324 protected void editorSaved() {
6384 INavigationLocation[] locations= getSite().getPage().getNavigationHistory().getLocations();
63856325 IEditorInput input= getEditorInput();
6386 for (int i= 0; i < locations.length; i++) {
6387 if (locations[i] instanceof TextSelectionNavigationLocation) {
6388 if(input.equals(locations[i].getInput())) {
6389 TextSelectionNavigationLocation location= (TextSelectionNavigationLocation) locations[i];
6326 for (INavigationLocation location2 : getSite().getPage().getNavigationHistory().getLocations()) {
6327 if (location2 instanceof TextSelectionNavigationLocation) {
6328 if(input.equals(location2.getInput())) {
6329 TextSelectionNavigationLocation location= (TextSelectionNavigationLocation) location2;
63906330 location.partSaved(this);
63916331 }
63926332 }
66706610 }
66716611
66726612 /**
6673 * Handles a potential change of the cursor position.
6674 * Subclasses may extend.
6613 * Prepares to handles a potential change of the cursor position. Wraps the
6614 * actual handler which cannot itself be modified for fear of disrupting
6615 * existing subclasses which may have overridden it without calling
6616 * super.handleCursorPositionChanged()
6617 *
6618 * @since 3.15
6619 */
6620 private void handleCursorPositionChangedWrapper() {
6621 TextEditorPlugin.getDefault()
6622 .setEditHistoryTraversalDirection(TextEditorPlugin.TraversalDirection.NONE);
6623 handleCursorPositionChanged();
6624 }
6625
6626 /**
6627 * Handles a potential change of the cursor position. Subclasses may extend.
66756628 *
66766629 * @since 2.0
66776630 */
73477300 */
73487301 protected final void updateIndentPrefixes() {
73497302 SourceViewerConfiguration configuration= getSourceViewerConfiguration();
7350 String[] types= configuration.getConfiguredContentTypes(fSourceViewer);
7351 for (int i= 0; i < types.length; i++) {
7352 String[] prefixes= configuration.getIndentPrefixes(fSourceViewer, types[i]);
7303 for (String type : configuration.getConfiguredContentTypes(fSourceViewer)) {
7304 String[] prefixes= configuration.getIndentPrefixes(fSourceViewer, type);
73537305 if (prefixes != null && prefixes.length > 0)
7354 fSourceViewer.setIndentPrefixes(prefixes, types[i]);
7306 fSourceViewer.setIndentPrefixes(prefixes, type);
73557307 }
73567308 }
73577309
00 /*******************************************************************************
1 * Copyright (c) 2015 Red Hat Inc.
1 * Copyright (c) 2020 Red Hat Inc.
22 *
33 * This program and the accompanying materials
44 * are made available under the terms of the Eclipse Public License 2.0
99 *
1010 * Contributors:
1111 * Mickael Istria (Red Hat Inc.) - 469918 Zoom In/Out
12 * John Taylor <johnpaultaylorii@gmail.com> - Bug 564099
1213 *******************************************************************************/
1314 package org.eclipse.ui.texteditor;
1415
15 import java.util.Arrays;
16 import java.util.ArrayList;
17 import java.util.Collections;
1618 import java.util.HashMap;
1719 import java.util.HashSet;
20 import java.util.LinkedHashSet;
1821 import java.util.LinkedList;
22 import java.util.List;
1923 import java.util.Map;
24 import java.util.Queue;
2025 import java.util.Set;
2126
2227 import org.eclipse.swt.graphics.FontData;
7479 if (fontProperty == null) {
7580 fontProperty= JFaceResources.TEXT_FONT;
7681 }
77 Set<String> fontsToSet= getAffectedFontNames(fontProperty, fontRegistry);
78 FontData[] initialFontData= null;
79 String currentFontName= fontProperty;
80 while (currentFontName != null && (initialFontData= fontRegistry.getFontData(currentFontName)) == null) {
81 currentFontName= fgFontToDefault.get(currentFontName);
82 }
83
84 FontData[] newFontData= createFontDescriptor(initialFontData).getFontData();
85 if (newFontData != null) {
86 fontsToSet.stream().forEach(fontName -> fontRegistry.put(fontName, newFontData));
87 }
82 List<String> fontsToSet = getAffectedFontNames(fontProperty, fontRegistry);
83 for (String fontName : fontsToSet) {
84 FontData[] currentFontData = null;
85 String currentFontName = fontName;
86 while (currentFontName != null && (currentFontData = fontRegistry.getFontData(currentFontName)) == null) {
87 currentFontName = fgFontToDefault.get(currentFontName);
88 }
89 FontData[] newFontData = createFontDescriptor(currentFontData).getFontData();
90 if (newFontData != null) {
91 fontRegistry.put(fontName, newFontData);
92 }
93 }
94
8895 return Status.OK_STATUS;
8996 }
9097
132139 * are set to default or inherit from reference font or a common parent that is affected
133140 * too.
134141 */
135 private Set<String> getAffectedFontNames(String referenceFontName, FontRegistry fontRegistry) {
142 private List<String> getAffectedFontNames(String referenceFontName, FontRegistry fontRegistry) {
136143 synchronized (AbstractTextZoomHandler.class) {
137144 if (fgFontToDefault == null) {
138145 // TODO: This should rely on ThemeRegistry and IThemeElementDefinition,
139146 // but those aren't visible at that time. So we're recreating the font hierarchy
140147 fgFontToDefault= new HashMap<>();
141148 fgDefaultToFonts= new HashMap<>();
142 IConfigurationElement[] themeElements= Platform.getExtensionRegistry().getConfigurationElementsFor("org.eclipse.ui.themes"); //$NON-NLS-1$
143 for (int i= 0; i < themeElements.length; i++) {
144 IConfigurationElement extension= themeElements[i];
149 for (IConfigurationElement extension : Platform.getExtensionRegistry()
150 .getConfigurationElementsFor("org.eclipse.ui.themes")) { //$NON-NLS-1$
145151 if ("fontDefinition".equals(extension.getName())) { //$NON-NLS-1$
146152 String fontId= extension.getAttribute("id"); //$NON-NLS-1$
147153 String defaultsTo= extension.getAttribute("defaultsTo"); //$NON-NLS-1$
157163 }
158164 }
159165 }
160 Set<String> res= new HashSet<>();
161 FontData[] referenceFontData= fontRegistry.getFontData(referenceFontName);
162 if (fontRegistry.hasValueFor(referenceFontName)) {
163 res.add(referenceFontName);
164 }
166
165167 String currentFontName= referenceFontName;
166 String rootFontName= referenceFontName;
168
167169 // identify "root" font to change
170 String rootFontName = currentFontName;
168171 do {
169172 currentFontName= fgFontToDefault.get(currentFontName);
170 if (currentFontName != null && Arrays.equals(referenceFontData, fontRegistry.getFontData(currentFontName))) {
173 if (currentFontName != null) {
171174 rootFontName= currentFontName;
172175 }
173176 } while (currentFontName != null);
174 LinkedList<String> fontsToProcess= new LinkedList<>();
177
178 // propagate to "children" fonts
179 Set<String> fontNames = new LinkedHashSet<>();
180 Set<String> alreadyProcessed = new HashSet<>();
181 Queue<String> fontsToProcess = new LinkedList<>();
175182 fontsToProcess.add(rootFontName);
176 // propage to "children" fonts
177 Set<String> alreadyProcessed= new HashSet<>();
178183 while (!fontsToProcess.isEmpty()) {
179 currentFontName= fontsToProcess.get(0);
180 fontsToProcess.remove(0);
181 // with recent Java, use currentFOntName = fontsToProcess.poll instead of the 2 lines above
184 currentFontName = fontsToProcess.poll();
182185 if (!alreadyProcessed.contains(currentFontName)) { // avoid infinite loop
183186 alreadyProcessed.add(currentFontName);
184 FontData[] currentFontData= fontRegistry.getFontData(currentFontName);
185 if (currentFontData == null || Arrays.equals(referenceFontData, currentFontData)) {
186187 if (fontRegistry.hasValueFor(currentFontName)) {
187 res.add(currentFontName);
188 fontNames.add(currentFontName);
188189 }
189190 Set<String> children= fgDefaultToFonts.get(currentFontName);
190191 if (children != null) {
191192 fontsToProcess.addAll(children);
192193 }
193194 }
194 }
195 }
196 return res;
195 }
196
197 // Order matters. Child fonts must be set before parent fonts to avoid
198 // double impacts.
199 List<String> result = new ArrayList<>(fontNames);
200 Collections.reverse(result);
201 return result;
197202 }
198203
199204 }
10711071 if (!getAnnotationType().equals(preference.getAnnotationType()))
10721072 return;
10731073
1074 for (int i= 0; i < ATTRIBUTES.length; i++) {
1075 if (!hasValue(ATTRIBUTES[i]))
1076 setValue(ATTRIBUTES[i], preference.getValue(ATTRIBUTES[i]));
1074 for (Object element : ATTRIBUTES) {
1075 if (!hasValue(element))
1076 setValue(element, preference.getValue(element));
10771077 }
10781078
10791079 if (fAnnotationImageProvider == null)
167167 fHippieCompletion.setActionDefinitionId(ITextEditorActionDefinitionIds.HIPPIE_COMPLETION);
168168
169169 fStatusFields= new HashMap<>(3);
170 for (int i= 0; i < STATUS_FIELD_DEFS.length; i++) {
171 StatusFieldDef fieldDef= STATUS_FIELD_DEFS[i];
170 for (StatusFieldDef fieldDef : STATUS_FIELD_DEFS) {
172171 fStatusFields.put(fieldDef, new StatusLineContributionItem(fieldDef.category, fieldDef.visible, fieldDef.widthInChars));
173172 }
174173 }
208207
209208 if (fActiveEditorPart instanceof ITextEditorExtension) {
210209 ITextEditorExtension extension= (ITextEditorExtension) fActiveEditorPart;
211 for (int i= 0; i < STATUS_FIELD_DEFS.length; i++)
212 extension.setStatusField(null, STATUS_FIELD_DEFS[i].category);
210 for (StatusFieldDef element : STATUS_FIELD_DEFS)
211 extension.setStatusField(null, element.category);
213212 }
214213
215214 fActiveEditorPart= part;
216215 ITextEditor editor= (part instanceof ITextEditor) ? (ITextEditor) part : null;
217216
218217 IActionBars actionBars= getActionBars();
219 for (int i= 0; i < ACTIONS.length; i++)
220 actionBars.setGlobalActionHandler(ACTIONS[i], getAction(editor, ACTIONS[i]));
218 for (String element : ACTIONS)
219 actionBars.setGlobalActionHandler(element, getAction(editor, element));
221220 actionBars.setGlobalActionHandler(ITextEditorActionDefinitionIds.SHOW_WHITESPACE_CHARACTERS, getAction(editor, ITextEditorActionConstants.SHOW_WHITESPACE_CHARACTERS));
222221 actionBars.setGlobalActionHandler(ITextEditorActionDefinitionIds.BLOCK_SELECTION_MODE, getAction(editor, ITextEditorActionConstants.BLOCK_SELECTION_MODE));
223222 if (editor instanceof AbstractTextEditor && ((AbstractTextEditor)editor).isWordWrapSupported())
230229 fGotoLine.setAction(getAction(editor, ITextEditorActionConstants.GOTO_LINE));
231230 fHippieCompletion.setAction(getAction(editor, ITextEditorActionConstants.HIPPIE_COMPLETION));
232231
233 for (int i= 0; i < STATUS_FIELD_DEFS.length; i++) {
232 for (StatusFieldDef element : STATUS_FIELD_DEFS) {
234233 if (fActiveEditorPart instanceof ITextEditorExtension) {
235 StatusLineContributionItem statusField= fStatusFields.get(STATUS_FIELD_DEFS[i]);
236 statusField.setActionHandler(getAction(editor, STATUS_FIELD_DEFS[i].actionId));
234 StatusLineContributionItem statusField= fStatusFields.get(element);
235 statusField.setActionHandler(getAction(editor, element.actionId));
237236 ITextEditorExtension extension= (ITextEditorExtension) fActiveEditorPart;
238 extension.setStatusField(statusField, STATUS_FIELD_DEFS[i].category);
237 extension.setStatusField(statusField, element.category);
239238 }
240239 }
241240 }
301300 @Override
302301 public void contributeToStatusLine(IStatusLineManager statusLineManager) {
303302 super.contributeToStatusLine(statusLineManager);
304 for (int i= 0; i < STATUS_FIELD_DEFS.length; i++)
305 statusLineManager.add(fStatusFields.get(STATUS_FIELD_DEFS[i]));
303 for (StatusFieldDef element : STATUS_FIELD_DEFS)
304 statusLineManager.add(fStatusFields.get(element));
306305 }
307306
308307 @Override
8686 IRegion[] ranges= JFaceTextUtil.getCoveredRanges(viewer, selection);
8787 if (ranges.length > 1 && viewer instanceof ITextViewerExtension)
8888 ((ITextViewerExtension) viewer).getRewriteTarget().beginCompoundChange();
89 for (int i= 0; i < ranges.length; i++) {
90 IRegion region= ranges[i];
89 for (IRegion region : ranges) {
9190 String target= document.get(region.getOffset(), region.getLength());
9291 String replacement= (fToUpper ? target.toUpperCase() : target.toLowerCase());
9392 if (!target.equals(replacement)) {
467467 if ((button.getStyle() & SWT.RADIO) != 0) {
468468 Composite buttonParent= button.getParent();
469469 if (buttonParent != null) {
470 Control[] children= buttonParent.getChildren();
471 for (int i= 0; i < children.length; i++)
472 ((Button)children[i]).setSelection(false);
470 for (Control child : buttonParent.getChildren())
471 ((Button)child).setSelection(false);
473472 }
474473 button.setSelection(true);
475474 } else {
16381637 */
16391638 private void updateCombo(Combo combo, List<String> content) {
16401639 combo.removeAll();
1641 for (int i= 0; i < content.size(); i++) {
1642 combo.add(content.get(i).toString());
1640 for (String element : content) {
1641 combo.add(element.toString());
16431642 }
16441643 }
16451644
6868
6969 @Override
7070 public void run() {
71 EditPosition editPosition= TextEditorPlugin.getDefault().getLastEditPosition();
72 if (editPosition == null)
73 return;
71 if (TextEditorPlugin.TraversalDirection.BACKWARD == TextEditorPlugin.getDefault()
72 .getEditHistoryTraversalDirection()) {
73 TextEditorPlugin.getDefault().backtrackEditPosition();
74 }
75 EditPosition editPosition = TextEditorPlugin.getDefault().getLastEditPosition();
76 try {
7477
75 final Position pos= editPosition.getPosition();
76 if (pos == null || pos.isDeleted)
77 return;
78 if (editPosition == null) {
79 return;
80 }
7881
79 IWorkbenchWindow window= getWindow();
80 if (window == null)
81 return;
82 final Position pos = editPosition.getPosition();
83 if (pos == null || pos.isDeleted) {
84 return;
85 }
8286
83 IWorkbenchPage page= window.getActivePage();
87 IWorkbenchWindow window = getWindow();
88 if (window == null) {
89 return;
90 }
8491
85 IEditorPart editor;
86 try {
87 editor= page.openEditor(editPosition.getEditorInput(), editPosition.getEditorId());
88 } catch (PartInitException ex) {
89 IStatus status= new Status(IStatus.ERROR, TextEditorPlugin.PLUGIN_ID, IStatus.OK, "Go to Last Edit Location failed", ex); //$NON-NLS-1$
90 TextEditorPlugin.getDefault().getLog().log(status);
91 return;
92 }
92 IWorkbenchPage page = window.getActivePage();
9393
94 // Optimization - could also use else branch
95 if (editor instanceof ITextEditor) {
96 ITextEditor textEditor= (ITextEditor)editor;
97 textEditor.selectAndReveal(pos.offset, pos.length);
98 return;
99 }
94 IEditorPart editor;
95 try {
96 editor = page.openEditor(editPosition.getEditorInput(), editPosition.getEditorId());
97 } catch (PartInitException ex) {
98 IStatus status = new Status(IStatus.ERROR, TextEditorPlugin.PLUGIN_ID, IStatus.OK,
99 "Go to Previous Edit Location failed", ex); //$NON-NLS-1$
100 TextEditorPlugin.getDefault().getLog().log(status);
101 return;
102 }
100103
101 /*
102 * Workaround: send out a text selection
103 * XXX: Needs to be improved, see https://bugs.eclipse.org/bugs/show_bug.cgi?id=32214
104 */
105 if (editor != null) {
106 IEditorSite site= editor.getEditorSite();
107 if (site == null)
104 // Optimization - could also use else branch
105 if (editor instanceof ITextEditor) {
106 ITextEditor textEditor = (ITextEditor) editor;
107 textEditor.selectAndReveal(pos.offset, pos.length);
108108 return;
109 }
109110
110 ISelectionProvider provider= editor.getEditorSite().getSelectionProvider();
111 if (provider == null)
112 return;
111 /*
112 * Workaround: send out a text selection XXX: Needs to be improved,
113 * see https://bugs.eclipse.org/bugs/show_bug.cgi?id=32214
114 */
115 if (editor != null) {
116 IEditorSite site = editor.getEditorSite();
117 if (site == null) {
118 return;
119 }
113120
114 provider.setSelection(new TextSelection(pos.offset, pos.length));
121 ISelectionProvider provider = editor.getEditorSite().getSelectionProvider();
122 if (provider == null) {
123 return;
124 }
125
126 provider.setSelection(new TextSelection(pos.offset, pos.length));
127 }
128 } finally {
129 TextEditorPlugin.getDefault()
130 .setEditHistoryTraversalDirection(TextEditorPlugin.TraversalDirection.BACKWARD);
115131 }
116132 }
117133
126142 // adding the same action twice has no effect.
127143 TextEditorPlugin.getDefault().addLastEditPositionDependentAction(action);
128144 // this is always the same action for this instance
129 fAction= action;
145 fAction = action;
130146 }
131147 }
132148
136152 * @return the workbench window
137153 */
138154 private IWorkbenchWindow getWindow() {
139 if (fWindow == null)
155 if (fWindow == null) {
140156 fWindow= PlatformUI.getWorkbench().getActiveWorkbenchWindow();
157 }
141158 return fWindow;
142159 }
143160
0 /*******************************************************************************
1 * Copyright (c) 2020 IBM Corporation and others.
2 *
3 * This program and the accompanying materials
4 * are made available under the terms of the Eclipse Public License 2.0
5 * which accompanies this distribution, and is available at
6 * https://www.eclipse.org/legal/epl-2.0/
7 *
8 * SPDX-License-Identifier: EPL-2.0
9 *
10 * Contributors:
11 * Ari Kast - initial API and implementation
12 *******************************************************************************/
13 package org.eclipse.ui.texteditor;
14
15 import org.eclipse.core.runtime.IStatus;
16 import org.eclipse.core.runtime.Status;
17
18 import org.eclipse.jface.action.Action;
19 import org.eclipse.jface.action.IAction;
20 import org.eclipse.jface.viewers.ISelection;
21 import org.eclipse.jface.viewers.ISelectionProvider;
22
23 import org.eclipse.jface.text.Position;
24 import org.eclipse.jface.text.TextSelection;
25
26 import org.eclipse.ui.IEditorPart;
27 import org.eclipse.ui.IEditorSite;
28 import org.eclipse.ui.IWorkbenchPage;
29 import org.eclipse.ui.IWorkbenchWindow;
30 import org.eclipse.ui.IWorkbenchWindowActionDelegate;
31 import org.eclipse.ui.PartInitException;
32 import org.eclipse.ui.PlatformUI;
33 import org.eclipse.ui.internal.texteditor.EditPosition;
34 import org.eclipse.ui.internal.texteditor.TextEditorPlugin;
35
36
37 /**
38 * Goes to next edit position, ie travels forward in the edit position history
39 * Acts as a complement to GotoLastEditPositionAction which travels backward in
40 * the history.
41 *
42 * @since 3.15
43 */
44 public class GotoNextEditPositionAction extends Action implements IWorkbenchWindowActionDelegate {
45
46 /** The workbench window */
47 private IWorkbenchWindow fWindow;
48 /** The action */
49 private IAction fAction;
50
51 /**
52 * Creates a goto next edit action.
53 */
54 public GotoNextEditPositionAction() {
55 PlatformUI.getWorkbench().getHelpSystem().setHelp(this,
56 IAbstractTextEditorHelpContextIds.GOTO_NEXT_EDIT_POSITION_ACTION);
57 setId(ITextEditorActionDefinitionIds.GOTO_NEXT_EDIT_POSITION);
58 setActionDefinitionId(ITextEditorActionDefinitionIds.GOTO_NEXT_EDIT_POSITION);
59 setEnabled(false);
60 }
61
62 @Override
63 public void init(IWorkbenchWindow window) {
64 fWindow= window;
65 }
66
67 @Override
68 public void run(IAction action) {
69 run();
70 }
71
72 @Override
73 public void run() {
74 if (TextEditorPlugin.TraversalDirection.FORWARD == TextEditorPlugin.getDefault()
75 .getEditHistoryTraversalDirection()) {
76 TextEditorPlugin.getDefault().advanceEditPosition();
77 }
78 EditPosition editPosition = TextEditorPlugin.getDefault().getNextEditPosition();
79 try {
80
81 if (editPosition == null)
82 return;
83
84 final Position pos = editPosition.getPosition();
85 if (pos == null || pos.isDeleted)
86 return;
87
88 IWorkbenchWindow window = getWindow();
89 if (window == null)
90 return;
91
92 IWorkbenchPage page = window.getActivePage();
93
94 IEditorPart editor;
95 try {
96 editor = page.openEditor(editPosition.getEditorInput(), editPosition.getEditorId());
97 } catch (PartInitException ex) {
98 IStatus status = new Status(IStatus.ERROR, TextEditorPlugin.PLUGIN_ID, IStatus.OK,
99 "Go to Next Edit Location failed", ex); //$NON-NLS-1$
100 TextEditorPlugin.getDefault().getLog().log(status);
101 return;
102 }
103
104 // Optimization - could also use else branch
105 if (editor instanceof ITextEditor) {
106 ITextEditor textEditor = (ITextEditor) editor;
107 textEditor.selectAndReveal(pos.offset, pos.length);
108 return;
109 }
110
111 /*
112 * Workaround: send out a text selection XXX: Needs to be improved,
113 * see https://bugs.eclipse.org/bugs/show_bug.cgi?id=32214
114 */
115 if (editor != null) {
116 IEditorSite site = editor.getEditorSite();
117 if (site == null)
118 return;
119
120 ISelectionProvider provider = editor.getEditorSite().getSelectionProvider();
121 if (provider == null)
122 return;
123
124 provider.setSelection(new TextSelection(pos.offset, pos.length));
125 }
126 } finally {
127 TextEditorPlugin.getDefault()
128 .setEditHistoryTraversalDirection(TextEditorPlugin.TraversalDirection.FORWARD);
129 }
130 }
131
132 @Override
133 public void selectionChanged(IAction action, ISelection selection) {
134 boolean enabled= TextEditorPlugin.getDefault().getLastEditPosition() != null;
135 setEnabled(enabled);
136 action.setEnabled(enabled);
137
138 // This is no longer needed once the action is enabled.
139 if (!enabled) {
140 // adding the same action twice has no effect.
141 TextEditorPlugin.getDefault().addLastEditPositionDependentAction(action);
142 // this is always the same action for this instance
143 fAction = action;
144 }
145 }
146
147 /**
148 * Returns the workbench window.
149 *
150 * @return the workbench window
151 */
152 private IWorkbenchWindow getWindow() {
153 if (fWindow == null)
154 fWindow= PlatformUI.getWorkbench().getActiveWorkbenchWindow();
155 return fWindow;
156 }
157
158 @Override
159 public void dispose() {
160 fWindow= null;
161 TextEditorPlugin.getDefault().removeLastEditPositionDependentAction(fAction);
162 }
163 }
1717 import java.util.Arrays;
1818 import java.util.Collection;
1919 import java.util.Collections;
20 import java.util.Iterator;
2120 import java.util.List;
2221 import java.util.Objects;
2322 import java.util.stream.Collectors;
212211 if (prefix == null || prefix.isEmpty())
213212 return NO_PROPOSALS;
214213
215 List<String> suggestions= getSuggestions(viewer, offset, prefix);
216
217214 List<ICompletionProposal> result= new ArrayList<>();
218 for (Iterator<String> it= suggestions.iterator(); it.hasNext();) {
219 String string= it.next();
215 for (String string : getSuggestions(viewer, offset, prefix)) {
220216 if (!string.isEmpty())
221217 result.add(createProposal(string, prefix, offset));
222218 }
135135 return false;
136136
137137 String targetId= getTargetId();
138 for (int i= 0; i < targets.length; i++) {
139 if (targetId.equals(targets[i].getId())) {
140 fTarget= targets[i];
138 for (HyperlinkDetectorTargetDescriptor target : targets) {
139 if (targetId.equals(target.getId())) {
140 fTarget= target;
141141 return true;
142142 }
143143 }
224224 private static HyperlinkDetectorDescriptor[] createDescriptors(IConfigurationElement[] elements) {
225225 HyperlinkDetectorTargetDescriptor[] targets= HyperlinkDetectorTargetDescriptor.getContributedHyperlinkDetectorTargets();
226226 List<HyperlinkDetectorDescriptor> result= new ArrayList<>(elements.length);
227 for (int i= 0; i < elements.length; i++) {
228 IConfigurationElement element= elements[i];
227 for (IConfigurationElement element : elements) {
229228 if (HYPERLINK_DETECTOR_ELEMENT.equals(element.getName())) {
230229 HyperlinkDetectorDescriptor desc= new HyperlinkDetectorDescriptor(element);
231230 if (desc.isValid(targets))
161161 initHyperlinkDetectorDescriptors();
162162
163163 List<HyperlinkDetectorDelegate> result= new ArrayList<>();
164 for (int i= 0; i < fHyperlinkDetectorDescriptors.length; i++) {
165 if (targetId.equals(fHyperlinkDetectorDescriptors[i].getTargetId())) {
166 HyperlinkDetectorDelegate detector= new HyperlinkDetectorDelegate(fHyperlinkDetectorDescriptors[i]);
164 for (HyperlinkDetectorDescriptor fHyperlinkDetectorDescriptor : fHyperlinkDetectorDescriptors) {
165 if (targetId.equals(fHyperlinkDetectorDescriptor.getTargetId())) {
166 HyperlinkDetectorDelegate detector= new HyperlinkDetectorDelegate(fHyperlinkDetectorDescriptor);
167167 result.add(detector);
168168 detector.setContext(context);
169169 }
126126
127127 private static HyperlinkDetectorTargetDescriptor[] createDescriptors(IConfigurationElement[] elements) {
128128 List<HyperlinkDetectorTargetDescriptor> result= new ArrayList<>(elements.length);
129 for (int i= 0; i < elements.length; i++) {
130 IConfigurationElement element= elements[i];
129 for (IConfigurationElement element : elements) {
131130 if (TARGET_ELEMENT.equals(element.getName())) {
132131 HyperlinkDetectorTargetDescriptor desc= new HyperlinkDetectorTargetDescriptor(element);
133132 if (desc.isValid())
298298 String GOTO_LAST_EDIT_POSITION_ACTION= PREFIX + "goto_last_edit_position" + ACTION_POSTFIX; //$NON-NLS-1$
299299
300300 /**
301 * Help context id for the action.
302 * Value: <code>"org.eclipse.ui.move_lines_action_context"</code>
301 * Help context id for the action. Value:
302 * <code>"org.eclipse.ui.goto_next_edit_position_action_context"</code>
303 *
304 * @since 3.15
305 */
306 String GOTO_NEXT_EDIT_POSITION_ACTION = PREFIX + "goto_next_edit_position" + ACTION_POSTFIX; //$NON-NLS-1$
307
308 /**
309 * Help context id for the action. Value:
310 * <code>"org.eclipse.ui.move_lines_action_context"</code>
311 *
303312 * @since 3.0
304313 */
305314 String MOVE_LINES_ACTION= PREFIX + "move_lines" + ACTION_POSTFIX; //$NON-NLS-1$
441441 String GOTO_LAST_EDIT_POSITION= "org.eclipse.ui.edit.text.gotoLastEditPosition"; //$NON-NLS-1$
442442
443443 /**
444 * Action definition id of go to next edit position action. Value:
445 * <code>"org.eclipse.ui.edit.text.gotoNextEditPosition"</code>
446 *
447 * @since 3.15
448 */
449 String GOTO_NEXT_EDIT_POSITION= "org.eclipse.ui.edit.text.gotoNextEditPosition"; //$NON-NLS-1$
450
451 /**
444452 * Action definition id of go to next annotation action.
445453 * Value: <code>"org.eclipse.ui.edit.text.gotoNextAnnotation"</code>
446454 * @since 3.0
7979 fScrolledComposite.addDisposeListener(e -> {
8080 JFaceResources.getFontRegistry().removeListener(fPropertyChangeListener);
8181 fScrolledComposite = null;
82 fSeparatorColor.dispose();
8382 fSeparatorColor = null;
8483 fHeader = null;
8584 fBanner = null;
107107
108108 if (fStackLayout.topControl != front) {
109109 fStackLayout.topControl= front;
110 fParent.layout();
110 if (front != null) {
111 front.requestLayout();
112 }
111113 updateStatusFields();
112114 }
113115
00 /*******************************************************************************
1 * Copyright (c) 2000, 2016 IBM Corporation and others.
1 * Copyright (c) 2000, 2020 IBM Corporation and others.
22 *
33 * This program and the accompanying materials
44 * are made available under the terms of the Eclipse Public License 2.0
1010 * Contributors:
1111 * IBM Corporation - initial API and implementation
1212 * Tom Eicher (Avaloq Evolution AG) - block selection mode
13 * Pierre-Yves Bigourdan, pyvesdev@gmail.com - Bug 564929: Delete line shortcut does not delete last editor line
1314 *******************************************************************************/
1415 package org.eclipse.ui.texteditor;
1516
268269 resultOffset= document.getLineOffset(line);
269270 int endLine= selection.getEndLine();
270271 resultLength= document.getLineOffset(endLine) + document.getLineLength(endLine) - resultOffset;
272 if (resultLength == 0 && line > 0) {
273 // Selection is on the last empty line of the editor. Delete
274 // delimiter of the previous line to effectively remove it.
275 String previousLineDelimiter= document.getLineDelimiter(line - 1);
276 if (previousLineDelimiter != null) {
277 resultOffset-= previousLineDelimiter.length();
278 resultLength= previousLineDelimiter.length();
279 }
280 }
271281 break;
272282
273283 case DeleteLineAction.TO_BEGINNING:
1818 import java.util.Collections;
1919 import java.util.Comparator;
2020 import java.util.HashMap;
21 import java.util.Iterator;
2221 import java.util.List;
2322 import java.util.ListIterator;
2423 import java.util.Map;
151150 List<RulerColumnDescriptor> descriptors= new ArrayList<>();
152151 Map<String, RulerColumnDescriptor> descriptorMap= new HashMap<>();
153152
154 for (Iterator<IConfigurationElement> iter= elements.iterator(); iter.hasNext();) {
155 IConfigurationElement element= iter.next();
153 for (IConfigurationElement element : elements) {
156154 try {
157155 RulerColumnDescriptor desc= new RulerColumnDescriptor(element, this);
158156 String id= desc.getId();
00 eclipse.preferences.version=1
1 editor_save_participant_org.eclipse.jdt.ui.postsavelistener.cleanup=true
12 formatter_profile=_JDT UI Code Style Conventions
23 formatter_settings_version=12
34 org.eclipse.jdt.ui.exception.name=e
89 org.eclipse.jdt.ui.ondemandthreshold=99
910 org.eclipse.jdt.ui.overrideannotation=true
1011 org.eclipse.jdt.ui.staticondemandthreshold=99
12 sp_cleanup.add_default_serial_version_id=true
13 sp_cleanup.add_generated_serial_version_id=false
14 sp_cleanup.add_missing_annotations=true
15 sp_cleanup.add_missing_deprecated_annotations=true
16 sp_cleanup.add_missing_methods=false
17 sp_cleanup.add_missing_nls_tags=false
18 sp_cleanup.add_missing_override_annotations=true
19 sp_cleanup.add_missing_override_annotations_interface_methods=true
20 sp_cleanup.add_serial_version_id=false
21 sp_cleanup.always_use_blocks=true
22 sp_cleanup.always_use_parentheses_in_expressions=false
23 sp_cleanup.always_use_this_for_non_static_field_access=false
24 sp_cleanup.always_use_this_for_non_static_method_access=false
25 sp_cleanup.convert_functional_interfaces=false
26 sp_cleanup.convert_to_enhanced_for_loop=false
27 sp_cleanup.convert_to_enhanced_for_loop_if_loop_var_used=false
28 sp_cleanup.correct_indentation=false
29 sp_cleanup.format_source_code=true
30 sp_cleanup.format_source_code_changes_only=true
31 sp_cleanup.insert_inferred_type_arguments=false
32 sp_cleanup.lazy_logical_operator=false
33 sp_cleanup.make_local_variable_final=true
34 sp_cleanup.make_parameters_final=false
35 sp_cleanup.make_private_fields_final=true
36 sp_cleanup.make_type_abstract_if_missing_method=false
37 sp_cleanup.make_variable_declarations_final=false
38 sp_cleanup.merge_conditional_blocks=false
39 sp_cleanup.never_use_blocks=false
40 sp_cleanup.never_use_parentheses_in_expressions=true
41 sp_cleanup.number_suffix=false
42 sp_cleanup.on_save_use_additional_actions=true
43 sp_cleanup.organize_imports=true
44 sp_cleanup.push_down_negation=false
45 sp_cleanup.qualify_static_field_accesses_with_declaring_class=false
46 sp_cleanup.qualify_static_member_accesses_through_instances_with_declaring_class=true
47 sp_cleanup.qualify_static_member_accesses_through_subtypes_with_declaring_class=true
48 sp_cleanup.qualify_static_member_accesses_with_declaring_class=false
49 sp_cleanup.qualify_static_method_accesses_with_declaring_class=false
50 sp_cleanup.remove_private_constructors=true
51 sp_cleanup.remove_redundant_modifiers=false
52 sp_cleanup.remove_redundant_semicolons=false
53 sp_cleanup.remove_redundant_type_arguments=false
54 sp_cleanup.remove_trailing_whitespaces=true
55 sp_cleanup.remove_trailing_whitespaces_all=true
56 sp_cleanup.remove_trailing_whitespaces_ignore_empty=false
57 sp_cleanup.remove_unnecessary_array_creation=false
58 sp_cleanup.remove_unnecessary_casts=true
59 sp_cleanup.remove_unnecessary_nls_tags=false
60 sp_cleanup.remove_unused_imports=false
61 sp_cleanup.remove_unused_local_variables=false
62 sp_cleanup.remove_unused_private_fields=true
63 sp_cleanup.remove_unused_private_members=false
64 sp_cleanup.remove_unused_private_methods=true
65 sp_cleanup.remove_unused_private_types=true
66 sp_cleanup.simplify_lambda_expression_and_method_ref=false
67 sp_cleanup.sort_members=false
68 sp_cleanup.sort_members_all=false
69 sp_cleanup.use_anonymous_class_creation=false
70 sp_cleanup.use_autoboxing=false
71 sp_cleanup.use_blocks=false
72 sp_cleanup.use_blocks_only_for_return_and_throw=false
73 sp_cleanup.use_directly_map_method=false
74 sp_cleanup.use_lambda=true
75 sp_cleanup.use_parentheses_in_expressions=false
76 sp_cleanup.use_this_for_non_static_field_access=false
77 sp_cleanup.use_this_for_non_static_field_access_only_if_necessary=true
78 sp_cleanup.use_this_for_non_static_method_access=false
79 sp_cleanup.use_this_for_non_static_method_access_only_if_necessary=true
80 sp_cleanup.use_unboxing=false
81 sp_cleanup.use_var=false
11 Bundle-ManifestVersion: 2
22 Bundle-Name: %Plugin.name
33 Bundle-SymbolicName: org.eclipse.ui.workbench.texteditor.tests
4 Bundle-Version: 3.12.500.qualifier
4 Bundle-Version: 3.12.600.qualifier
55 Bundle-Vendor: %Plugin.providerName
66 Bundle-Localization: plugin
77 Export-Package:
0 # To force a version qualifier update add the bug here
1 Bug 566471 - I20200828-0150 - Comparator Errors Found
1313 <parent>
1414 <artifactId>tests-pom</artifactId>
1515 <groupId>eclipse.platform.text</groupId>
16 <version>4.16.0-SNAPSHOT</version>
16 <version>4.17.0-SNAPSHOT</version>
1717 <relativePath>../tests-pom/</relativePath>
1818 </parent>
1919 <groupId>org.eclipse.ui</groupId>
2020 <artifactId>org.eclipse.ui.workbench.texteditor.tests</artifactId>
21 <version>3.12.500-SNAPSHOT</version>
21 <version>3.12.600-SNAPSHOT</version>
2222 <packaging>eclipse-test-plugin</packaging>
2323 <properties>
2424 <testSuite>${project.artifactId}</testSuite>
0 /*******************************************************************************
1 * Copyright (c) 2000, 2016 IBM Corporation and others.
2 *
3 * This program and the accompanying materials
4 * are made available under the terms of the Eclipse Public License 2.0
5 * which accompanies this distribution, and is available at
6 * https://www.eclipse.org/legal/epl-2.0/
7 *
8 * SPDX-License-Identifier: EPL-2.0
9 *
10 * Contributors:
11 * IBM Corporation - initial API and implementation
12 *******************************************************************************/
13 package org.eclipse.ui.workbench.texteditor.tests;
14
15 import static org.junit.Assert.assertEquals;
16 import static org.junit.Assert.assertFalse;
17 import static org.junit.Assert.assertNotEquals;
18 import static org.junit.Assert.assertTrue;
19
20 import java.util.Random;
21
22 import org.junit.FixMethodOrder;
23 import org.junit.Rule;
24 import org.junit.Test;
25 import org.junit.rules.TestName;
26 import org.junit.runners.MethodSorters;
27
28 import org.eclipse.ui.internal.texteditor.HistoryTracker;
29
30 /**
31 * Tests the FindReplaceDialog.
32 *
33 * @since 3.1
34 */
35 @FixMethodOrder(MethodSorters.NAME_ASCENDING)
36 public class TextEditorPluginTest {
37
38 @Rule
39 public TestName testName = new TestName();
40
41 Random rand = new Random(55); //pseudo-random for repeatability
42
43 @Test
44 public void testEditPositionHistory() {
45 HistoryTracker<Integer> history= new HistoryTracker<>(3,
46 Integer.class,
47 (a, b) -> Math.abs(a - b) < 5, true);
48
49 assertEquals(0, history.getSize());
50 history.addOrReplace(10);
51 assertEquals(1, history.getSize());
52 assertTrue(10 == history.getCurrentBrowsePoint());
53
54 history.addOrReplace(20);
55 assertEquals(2, history.getSize());
56 assertTrue(20 == history.getCurrentBrowsePoint());
57
58 history.addOrReplace(30);
59 assertEquals(3, history.getSize());
60 assertTrue(30 == history.getCurrentBrowsePoint());
61
62 checkContent(history, new Integer[] { 10, 20, 30 });
63
64
65 int replaced = history.addOrReplace(40);
66 assertEquals(3, history.getSize());
67 assertEquals(10, replaced);
68 assertEquals(Integer.valueOf(40), history.getCurrentBrowsePoint());
69
70 HistoryTracker.Navigator<Integer> nav = history.navigator();
71 assertEquals(Integer.valueOf(40), nav.currentItem());
72 assertEquals(Integer.valueOf(30), nav.priorItem());
73 assertEquals(Integer.valueOf(20), nav.priorItem());
74 assertEquals(Integer.valueOf(40), nav.priorItem());
75 checkContent(history, new Integer[] { 20, 30, 40 });
76
77 assertFalse(history.contains(10));
78
79 replaced = history.addOrReplace(22);
80 assertTrue(history.contains(22));
81 assertFalse(history.contains(20));
82 assertEquals(20, replaced);
83 checkContent(history, new Integer[] { 30, 40, 22 });
84 //assertTrue(22 == history.getCurrentBrowsePoint());
85
86 replaced = history.addOrReplace(31);
87 assertTrue(history.contains(31));
88 assertFalse(history.contains(30));
89 assertEquals(30, replaced);
90 assertTrue(31 == history.getCurrentBrowsePoint());
91 checkContent(history, new Integer[] { 40, 22, 31 });
92
93 replaced = history.addOrReplace(60);
94 assertTrue(history.contains(60));
95 assertTrue(60 == history.getCurrentBrowsePoint());
96 assertEquals(3, history.getSize());
97 checkContent(history, new Integer[] { 22, 31, 60 });
98
99 assertTrue(31 == history.browseBackward());
100 assertTrue(31 == history.getCurrentBrowsePoint());
101 assertEquals(3, history.getSize());
102
103 //consuming size times should bring you full circle back to origin
104 testBacktrackCycle(history);
105
106 //try editing after backtracking less than full cycle
107 history.browseBackward();
108 Integer last = history.getCurrentBrowsePoint();
109 assertEquals(Integer.valueOf(22), last);
110 history.addOrReplace(11);
111 checkContent(history, new Integer[] { 31, 60, 11 });
112
113 testBacktrackCycle(history);
114 history.browseBackward();
115 assertEquals(Integer.valueOf(60), history.getCurrentBrowsePoint());
116 }
117
118 <T> void checkContent(HistoryTracker<T> history, T[] data) {
119 HistoryTracker.Navigator<T> nav = history.navigator();
120 assertEquals(data[data.length - 1], nav.currentItem());
121
122 for(int i=data.length - 2; i>0; i--) {
123 assertEquals(data[i], nav.priorItem());
124 }
125 assertEquals(history.getSize(), data.length);
126 }
127
128 @Test
129 public void testEditPositionHistory2() {
130 HistoryTracker<Integer> history= new HistoryTracker<>(3,
131 Integer.class,
132 (a, b) -> Math.abs(a - b) < 5, true);
133
134 assertEquals(0, history.getSize());
135 history.addOrReplace(10);
136 assertEquals(1, history.getSize());
137 assertTrue(10 == history.getCurrentBrowsePoint());
138
139 history.addOrReplace(20);
140 assertEquals(2, history.getSize());
141 assertTrue(20 == history.getCurrentBrowsePoint());
142
143 history.addOrReplace(30);
144 assertEquals(3, history.getSize());
145 assertTrue(30 == history.getCurrentBrowsePoint());
146
147 int replaced = history.addOrReplace(22);
148 assertEquals(3, history.getSize());
149 assertEquals(20, replaced);
150 assertEquals(Integer.valueOf(22), history.getCurrentBrowsePoint());
151
152 assertEquals(Integer.valueOf(30), history.browseBackward());
153 assertEquals(Integer.valueOf(10), history.browseBackward());
154 assertEquals(Integer.valueOf(22), history.browseBackward());
155
156 testBacktrackCycle(history);
157 }
158
159 @Test
160 public void testHistoryEviction() {
161 HistoryTracker<Integer> history= new HistoryTracker<>(3,
162 Integer.class,
163 (a, b) -> Math.abs(a - b) < 5,
164 true);
165
166 assertEquals(0, history.getSize());
167 history.addOrReplace(10);
168 assertEquals(1, history.getSize());
169 assertTrue(10 == history.getCurrentBrowsePoint());
170
171 history.addOrReplace(10);
172 assertEquals(1, history.getSize());
173 assertTrue(10 == history.getCurrentBrowsePoint());
174
175 history.addOrReplace(11);
176 assertEquals(1, history.getSize());
177 assertTrue(11 == history.getCurrentBrowsePoint());
178 }
179
180 @Test
181 public void testHistoryEviction2() {
182 HistoryTracker<Integer> history= new HistoryTracker<>(3,
183 Integer.class,
184 (a, b) -> Math.abs(a - b) < 5,
185 true);
186
187 history.addOrReplace(10);
188 history.addOrReplace(20);
189 history.addOrReplace(30);
190 assertEquals(Integer.valueOf(20), history.browseBackward());
191 assertEquals(Integer.valueOf(10), history.addOrReplace(40));
192 }
193
194 @Test
195 public void testHistoryEviction3() {
196 HistoryTracker<Integer> history= new HistoryTracker<>(3,
197 Integer.class,
198 (a, b) -> Math.abs(a - b) < 5,
199 true);
200
201 history.addOrReplace(10);
202 history.addOrReplace(11);
203 history.addOrReplace(20);
204 history.addOrReplace(21);
205 history.addOrReplace(12);
206 checkContent(history, new Integer[] { 21, 12 });
207 }
208
209 @Test
210 public void testLinearEditPositionHistory() {
211 HistoryTracker<Integer> history= new HistoryTracker<>(3,
212 Integer.class,
213 (a, b) -> Math.abs(a - b) < 5,
214 false);
215
216 assertEquals(0, history.getSize());
217 history.addOrReplace(10);
218 assertEquals(1, history.getSize());
219 assertTrue(10 == history.getCurrentBrowsePoint());
220
221 history.addOrReplace(20);
222 assertEquals(2, history.getSize());
223 assertTrue(20 == history.getCurrentBrowsePoint());
224
225 history.addOrReplace(30);
226 assertEquals(3, history.getSize());
227 assertTrue(30 == history.getCurrentBrowsePoint());
228
229 int replaced = history.addOrReplace(22);
230 assertEquals(3, history.getSize());
231 assertEquals(20, replaced);
232 assertEquals(Integer.valueOf(22), history.getCurrentBrowsePoint());
233
234 assertEquals(Integer.valueOf(30), history.browseBackward());
235 assertEquals(Integer.valueOf(10), history.browseBackward());
236 assertEquals(Integer.valueOf(10), history.browseBackward());
237
238 assertEquals(Integer.valueOf(30), history.browseForward());
239 assertEquals(Integer.valueOf(22), history.browseForward());
240 assertEquals(Integer.valueOf(22), history.browseForward());
241
242 }
243
244 @Test
245 public void testLinearEditPositionHistory2() {
246 HistoryTracker<Integer> history= new HistoryTracker<>(3,
247 Integer.class,
248 (a, b) -> Math.abs(a - b) < 5,
249 false);
250
251 history.addOrReplace(10);
252 history.addOrReplace(20);
253 history.addOrReplace(30);
254
255 int replaced = history.addOrReplace(22);
256 assertEquals(3, history.getSize());
257 assertEquals(20, replaced);
258 assertEquals(Integer.valueOf(22), history.getCurrentBrowsePoint());
259
260 //end reached, go no further
261 assertEquals(Integer.valueOf(22), history.getNext());
262
263 assertEquals(Integer.valueOf(30), history.browseBackward());
264 assertEquals(Integer.valueOf(10), history.browseBackward());
265
266 //beginning reached, go no further
267 assertEquals(Integer.valueOf(10), history.browseBackward());
268 }
269
270 @Test
271 public void testMRUOrderAlwaysPreserved() {
272 HistoryTracker<Integer> history= new HistoryTracker<>(3,
273 Integer.class,
274 (a, b) -> Math.abs(a - b) < 5,
275 false);
276
277 history.addOrReplace(10);
278 history.addOrReplace(20);
279 history.addOrReplace(30);
280
281 assertEquals(Integer.valueOf(20), history.browseBackward());
282 history.addOrReplace(11);
283 assertEquals(Integer.valueOf(11), history.getCurrentBrowsePoint());
284
285 assertEquals(Integer.valueOf(30), history.browseBackward());
286 assertEquals(Integer.valueOf(20), history.browseBackward());
287 }
288
289 @Test
290 public void testMRUOrderAlwaysPreserved2() {
291 HistoryTracker<Integer> history= new HistoryTracker<>(3,
292 Integer.class,
293 (a, b) -> Math.abs(a - b) < 5,
294 false);
295
296 history.addOrReplace(10);
297 history.addOrReplace(20);
298 history.addOrReplace(30);
299
300 assertEquals(Integer.valueOf(20), history.browseBackward());
301 history.addOrReplace(40);
302 assertEquals(Integer.valueOf(40), history.getCurrentBrowsePoint());
303
304 assertEquals(Integer.valueOf(30), history.browseBackward());
305 assertEquals(Integer.valueOf(20), history.browseBackward());
306 assertEquals(Integer.valueOf(20), history.browseBackward());
307
308 }
309
310 private <T> void testBacktrackCycle(HistoryTracker<T> history) {
311 T last = history.getCurrentBrowsePoint();
312 for(int i=0; i<history.getSize() -1; i++) {
313 history.browseBackward();
314 assertNotEquals(last, history.getCurrentBrowsePoint());
315 }
316 history.browseBackward();
317 assertEquals(last, history.getCurrentBrowsePoint());
318 }
319
320 @Test
321 public void testEditPositionHistoryChaos() {
322 final int HISTORY_SIZE= 10;
323 HistoryTracker<Integer> history= new HistoryTracker<>(HISTORY_SIZE,
324 Integer.class,
325 (a, b) -> Math.abs(a - b) < 5, true);
326
327 for(int i=0;i<100;i++) {
328 if(rand.nextBoolean()) {
329 addRandom(history);
330 } else {
331 goBack(history);
332 }
333 assertTrue(history.isHealthy());
334 assertTrue(history.getSize() <= HISTORY_SIZE);
335 }
336 }
337
338 @Test
339 public void testLinearEditPositionHistoryChaos() {
340 final int HISTORY_SIZE= 10;
341 HistoryTracker<Integer> history= new HistoryTracker<>(HISTORY_SIZE,
342 Integer.class,
343 (a,b) -> Math.abs(a - b) < 5,
344 false
345 );
346
347 int backsInARow = 0;
348 for(int i=0;i<100;i++) {
349 if(rand.nextBoolean()) {
350 backsInARow = 0;
351 addRandom(history);
352 } else {
353 backsInARow ++;
354 goBackLinear(history, backsInARow < history.getSize());
355 }
356 assertTrue(history.isHealthy());
357 assertTrue(history.getSize() <= HISTORY_SIZE);
358 }
359 }
360
361
362 private void addRandom(HistoryTracker<Integer> history) {
363 Integer latest = rand.nextInt(50);
364 history.addOrReplace(latest);
365 assertEquals(latest, history.getCurrentBrowsePoint());
366 }
367
368 private void goBack(HistoryTracker<Integer> history) {
369 int size = history.getSize();
370 Integer latest = history.getCurrentBrowsePoint();
371 Integer prior = history.browseBackward();
372 if (size > 1) {
373 assertNotEquals(latest, prior);
374 }
375 }
376
377 private void goBackLinear(HistoryTracker<Integer> history, boolean shouldMove) {
378 Integer latest= history.getCurrentBrowsePoint();
379 Integer prior = history.browseBackward();
380 if(shouldMove)
381 assertNotEquals(latest, prior);
382 else
383 assertEquals(latest, prior);
384 }
385
386 }
0 /*******************************************************************************
1 * Copyright (c) 2020 Pierre-Yves Bigourdan and others.
2 *
3 * This program and the accompanying materials
4 * are made available under the terms of the Eclipse Public License 2.0
5 * which accompanies this distribution, and is available at
6 * https://www.eclipse.org/legal/epl-2.0/
7 *
8 * SPDX-License-Identifier: EPL-2.0
9 *
10 * Contributors:
11 * Pierre-Yves Bigourdan - initial API and implementation
12 *******************************************************************************/
13 package org.eclipse.ui.workbench.texteditor.tests;
14
15 import static org.junit.Assert.assertEquals;
16 import static org.junit.Assert.assertThrows;
17
18 import org.junit.Before;
19 import org.junit.Test;
20
21 import org.eclipse.swt.SWT;
22 import org.eclipse.swt.dnd.Clipboard;
23 import org.eclipse.swt.dnd.TextTransfer;
24 import org.eclipse.swt.widgets.Display;
25 import org.eclipse.swt.widgets.Shell;
26
27 import org.eclipse.jface.action.IAction;
28
29 import org.eclipse.jface.text.Document;
30 import org.eclipse.jface.text.TextSelection;
31 import org.eclipse.jface.text.TextViewer;
32
33 import org.eclipse.ui.texteditor.DeleteLineAction;
34 import org.eclipse.ui.texteditor.TextViewerDeleteLineTarget;
35
36 public class TextViewerDeleteLineTargetTest {
37
38 private Document document;
39
40 private TextViewerDeleteLineTarget underTest;
41
42 @Before
43 public void setUp() {
44 document= new Document("first line\n" +
45 "\n" +
46 "third line\n");
47
48 TextViewer textViewer= new TextViewer(new Shell(), SWT.NONE);
49 textViewer.setDocument(document);
50
51 underTest= new TextViewerDeleteLineTarget(textViewer);
52 }
53
54 @Test
55 public void testWholeLineDeletion() throws Exception {
56 underTest.deleteLine(document, new TextSelection(document, 1, 3), DeleteLineAction.WHOLE, false);
57
58 assertEquals("\n" +
59 "third line\n", document.get());
60 }
61
62 @Test
63 public void testWholeLineDeletionOnLastEmptyLine() throws Exception {
64 underTest.deleteLine(document, new TextSelection(document, 23, 0), DeleteLineAction.WHOLE, false);
65
66 assertEquals("first line\n" +
67 "\n" +
68 "third line", document.get());
69 }
70
71 @Test
72 public void testWholeLineDeletionWithCopyToClipboard() throws Exception {
73 Clipboard clipboard= new Clipboard(Display.getCurrent());
74 try {
75 underTest.deleteLine(document, new TextSelection(document, 1, 4), DeleteLineAction.WHOLE, true);
76
77 assertEquals("first line\n", clipboard.getContents(TextTransfer.getInstance()));
78 } finally {
79 clipboard.dispose();
80 }
81 }
82
83 @Test
84 public void testLineDeletionToBeginning() throws Exception {
85 underTest.deleteLine(document, new TextSelection(document, 6, 0), DeleteLineAction.TO_BEGINNING, false);
86
87 assertEquals("line\n" +
88 "\n" +
89 "third line\n", document.get());
90 }
91
92 @Test
93 public void testLineDeletionToEnd() throws Exception {
94 underTest.deleteLine(document, new TextSelection(document, 17, 0), DeleteLineAction.TO_END, false);
95
96 assertEquals("first line\n" +
97 "\n" +
98 "third\n", document.get());
99 }
100
101 @Test
102 public void testThrowsExceptionWithUnsupportedDeleteLineActionType() throws Exception {
103 assertThrows(IllegalArgumentException.class, () -> underTest.deleteLine(document, 0, 0, IAction.AS_RADIO_BUTTON, false));
104 }
105
106 }
00 /*******************************************************************************
1 * Copyright (c) 2000, 2016 IBM Corporation and others.
1 * Copyright (c) 2000, 2020 IBM Corporation and others.
22 *
33 * This program and the accompanying materials
44 * are made available under the terms of the Eclipse Public License 2.0
4141 AbstractTextZoomHandlerTest.class,
4242 DocumentLineDifferTest.class,
4343 MinimapPageTest.class,
44 MinimapWidgetTest.class
44 MinimapWidgetTest.class,
45 TextEditorPluginTest.class,
46 TextViewerDeleteLineTargetTest.class
4547 })
4648 public class WorkbenchTextEditorTestSuite {
4749 // see @SuiteClasses
1414 <parent>
1515 <groupId>org.eclipse</groupId>
1616 <artifactId>eclipse-platform-parent</artifactId>
17 <version>4.16.0-SNAPSHOT</version>
17 <version>4.17.0-SNAPSHOT</version>
1818 <relativePath>../eclipse-platform-parent</relativePath>
1919 </parent>
2020
2121 <groupId>eclipse.platform.text</groupId>
2222 <artifactId>eclipse.platform.text</artifactId>
23 <version>4.16.0-SNAPSHOT</version>
23 <version>4.17.0-SNAPSHOT</version>
2424 <packaging>pom</packaging>
2525
2626 <properties>
1313 <parent>
1414 <artifactId>eclipse.platform.text</artifactId>
1515 <groupId>eclipse.platform.text</groupId>
16 <version>4.16.0-SNAPSHOT</version>
16 <version>4.17.0-SNAPSHOT</version>
1717 </parent>
1818 <artifactId>tests-pom</artifactId>
19 <version>4.16.0-SNAPSHOT</version>
19 <version>4.17.0-SNAPSHOT</version>
2020 <packaging>pom</packaging>
2121 <properties>
2222 <code.ignoredWarnings>${tests.ignoredWarnings}</code.ignoredWarnings>