Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion bundles/org.eclipse.ui.genericeditor/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: %Bundle-Name
Bundle-SymbolicName: org.eclipse.ui.genericeditor;singleton:=true
Bundle-Version: 1.3.700.qualifier
Bundle-Version: 1.3.800.qualifier
Bundle-Vendor: %Bundle-Vendor
Bundle-RequiredExecutionEnvironment: JavaSE-17
Require-Bundle: org.eclipse.ui.workbench.texteditor;bundle-version="3.10.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,16 +42,19 @@ protected boolean isIncluded(Annotation annotation) {
return false;
}
AnnotationPreference preference= EditorsUI.getAnnotationPreferenceLookup().getAnnotationPreference(annotation);
if (preference == null)
if (preference == null) {
return false;
}
String key= preference.getTextPreferenceKey();
if (key != null) {
if (!EditorsUI.getPreferenceStore().getBoolean(key))
if (!EditorsUI.getPreferenceStore().getBoolean(key)) {
return false;
}
} else {
key= preference.getHighlightPreferenceKey();
if (key == null || !EditorsUI.getPreferenceStore().getBoolean(key))
if (key == null || !EditorsUI.getPreferenceStore().getBoolean(key)) {
return false;
}
}
return true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public class AutoEditStrategyRegistry {

private static final String EXTENSION_POINT_ID = GenericEditorPlugin.BUNDLE_ID + ".autoEditStrategies"; //$NON-NLS-1$

private Map<IConfigurationElement, GenericContentTypeRelatedExtension<IAutoEditStrategy>> extensions = new LinkedHashMap<>();
private final Map<IConfigurationElement, GenericContentTypeRelatedExtension<IAutoEditStrategy>> extensions = new LinkedHashMap<>();
private boolean outOfSync = true;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public class CharacterPairMatcherRegistry {

private static final String EXTENSION_POINT_ID = GenericEditorPlugin.BUNDLE_ID + ".characterPairMatchers"; //$NON-NLS-1$

private Map<IConfigurationElement, GenericContentTypeRelatedExtension<ICharacterPairMatcher>> extensions = new HashMap<>();
private final Map<IConfigurationElement, GenericContentTypeRelatedExtension<ICharacterPairMatcher>> extensions = new HashMap<>();
private boolean outOfSync = true;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,11 @@
*/
public class CompositeContentAssistProcessor implements IContentAssistProcessorExtension, IContentAssistProcessor {

private List<IContentAssistProcessor> fContentAssistProcessors;
private final List<IContentAssistProcessor> fContentAssistProcessors;

/**
* Constructor
*
*
* @param contentAssistProcessors the children that will actually populate the
* output of this content assist processor.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
*/
public class CompositeQuickAssistProcessor implements IQuickAssistProcessor {

private List<IQuickAssistProcessor> fProcessors;
private final List<IQuickAssistProcessor> fProcessors;

public CompositeQuickAssistProcessor(List<IQuickAssistProcessor> processors) {
this.fProcessors = processors;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
import org.eclipse.jface.text.reconciler.IReconcilingStrategy;

public class CompositeReconciler implements IReconciler, IReconcilerExtension {
private List<IReconciler> fReconcilers;
private final List<IReconciler> fReconcilers;

public CompositeReconciler(List<IReconciler> reconcilers) {
fReconcilers = reconcilers.stream().filter(Objects::nonNull).collect(Collectors.toList());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@

public class CompositeReconcilerStrategy
implements IReconcilingStrategy, IReconcilingStrategyExtension, ITextViewerLifecycle {
private List<IReconcilingStrategy> fReconcilingStrategies;
private final List<IReconcilingStrategy> fReconcilingStrategies;

public CompositeReconcilerStrategy(List<IReconcilingStrategy> strategies) {
this.fReconcilingStrategies = strategies;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public class ContentAssistProcessorRegistry {

static class ContentAssistProcessorDelegate implements IContentAssistProcessor {
private final IContentAssistProcessor delegate;
private IContentType targetContentType;
private final IContentType targetContentType;

public ContentAssistProcessorDelegate(IContentAssistProcessor delegate, IContentType targetContentType) {
this.delegate = delegate;
Expand Down Expand Up @@ -128,7 +128,7 @@ public IContextInformationValidator getContextInformationValidator() {
}
}

private Map<IConfigurationElement, GenericContentTypeRelatedExtension<IContentAssistProcessor>> extensions = new LinkedHashMap<>();
private final Map<IConfigurationElement, GenericContentTypeRelatedExtension<IContentAssistProcessor>> extensions = new LinkedHashMap<>();
private boolean outOfSync = true;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,11 @@
*/
final class ContentTypeRelatedExtensionTracker<T> implements ServiceTrackerCustomizer<T, LazyServiceSupplier<T>> {

private BundleContext bundleContext;
private ServiceTracker<T, LazyServiceSupplier<T>> serviceTracker;
private final BundleContext bundleContext;
private final ServiceTracker<T, LazyServiceSupplier<T>> serviceTracker;
private Consumer<LazyServiceSupplier<T>> addAction;
private Consumer<LazyServiceSupplier<T>> removeAction;
private Display display;
private final Display display;

ContentTypeRelatedExtensionTracker(BundleContext bundleContext, Class<T> serviceType, Display display) {
this.bundleContext = bundleContext;
Expand Down Expand Up @@ -89,8 +89,8 @@ public Collection<LazyServiceSupplier<T>> getTracked() {
}

public static final class LazyServiceSupplier<S> implements Supplier<S> {
private ServiceReference<S> reference;
private BundleContext bundleContext;
private final ServiceReference<S> reference;
private final BundleContext bundleContext;
private boolean disposed;
private S serviceObject;
private IContentType contentType;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

public class DefaultWordHighlightReconciler extends Reconciler {

private DefaultWordHighlightStrategy fStrategy;
private final DefaultWordHighlightStrategy fStrategy;

public DefaultWordHighlightReconciler() {
fStrategy = new DefaultWordHighlightStrategy();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,13 +66,12 @@ public class DefaultWordHighlightStrategy implements IReconcilingStrategy, IReco

private Annotation[] fOccurrenceAnnotations = null;

private ISelectionChangedListener editorSelectionChangedListener = event -> applyHighlights(event.getSelection());
private final ISelectionChangedListener editorSelectionChangedListener = event -> applyHighlights(event.getSelection());

private void applyHighlights(ISelection selection) {
if (!(selection instanceof ITextSelection)) {
if (!(selection instanceof ITextSelection textSelection)) {
return;
}
ITextSelection textSelection = (ITextSelection) selection;
if (sourceViewer == null || !enabled) {
removeOccurrenceAnnotations();
return;
Expand Down Expand Up @@ -140,10 +139,12 @@ private static String findCurrentWord(String text, int offset) {
if (m.lookingAt()) {
wordEnd = m.group();
}
if (wordStart != null && wordEnd != null)
if (wordStart != null && wordEnd != null) {
return wordStart + wordEnd;
if (wordStart != null)
}
if (wordStart != null) {
return wordStart;
}
return wordEnd;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public class ExtensionBasedTextEditor extends TextEditor {
private static final String HIGHLIGHT_BRACKET_AT_CARET_LOCATION = GenericEditorPreferenceConstants.EDITOR_HIGHLIGHT_BRACKET_AT_CARET_LOCATION;
private static final String ENCLOSING_BRACKETS = GenericEditorPreferenceConstants.EDITOR_ENCLOSING_BRACKETS;

private ExtensionBasedTextViewerConfiguration configuration;
private final ExtensionBasedTextViewerConfiguration configuration;
private Image contentTypeImage;
private ImageDescriptor contentTypeImageDescripter;

Expand Down Expand Up @@ -118,8 +118,9 @@ public void doOperation(int operation) {
private boolean openFirstHyperlink() {
ITextSelection sel = (ITextSelection) this.getSelection();
int offset = sel.getOffset();
if (offset == -1)
if (offset == -1) {
return false;
}

IRegion region = new Region(offset, 0);
IHyperlink hyperlink = findFirstHyperlink(region);
Expand All @@ -134,22 +135,26 @@ private IHyperlink findFirstHyperlink(IRegion region) {
int activeHyperlinkStateMask = getSourceViewerConfiguration().getHyperlinkStateMask(this);
synchronized (fHyperlinkDetectors) {
for (IHyperlinkDetector detector : fHyperlinkDetectors) {
if (detector == null)
if (detector == null) {
continue;
}

if (detector instanceof IHyperlinkDetectorExtension2) {
int stateMask = ((IHyperlinkDetectorExtension2) detector).getStateMask();
if (stateMask != -1 && stateMask != activeHyperlinkStateMask)
if (stateMask != -1 && stateMask != activeHyperlinkStateMask) {
continue;
else if (stateMask == -1 && activeHyperlinkStateMask != fHyperlinkStateMask)
} else if (stateMask == -1 && activeHyperlinkStateMask != fHyperlinkStateMask) {
continue;
} else if (activeHyperlinkStateMask != fHyperlinkStateMask)
}
} else if (activeHyperlinkStateMask != fHyperlinkStateMask) {
continue;
}

boolean canShowMultipleHyperlinks = fHyperlinkPresenter.canShowMultipleHyperlinks();
IHyperlink[] hyperlinks = detector.detectHyperlinks(this, region, canShowMultipleHyperlinks);
if (hyperlinks == null)
if (hyperlinks == null) {
continue;
}

Assert.isLegal(hyperlinks.length > 0);

Expand Down Expand Up @@ -243,12 +248,14 @@ public void gotoMatchingBracket() {

ISourceViewer sourceViewer = getSourceViewer();
IDocument document = sourceViewer.getDocument();
if (document == null)
if (document == null) {
return;
}

IRegion selection = getSignedSelection(sourceViewer);
if (fPreviousSelections == null)
if (fPreviousSelections == null) {
initializePreviousSelectionList();
}

ICharacterPairMatcherExtension fBracketMatcher = (ICharacterPairMatcherExtension) pairMatcher;
IRegion region = fBracketMatcher.match(document, selection.getOffset(), selection.getLength());
Expand Down Expand Up @@ -283,16 +290,16 @@ public void gotoMatchingBracket() {
int offset = region.getOffset();
int length = region.getLength();

if (length < 1)
if (length < 1) {
return;
}

int anchor = pairMatcher.getAnchor();
// http://dev.eclipse.org/bugs/show_bug.cgi?id=34195
int targetOffset = (ICharacterPairMatcher.RIGHT == anchor) ? offset + 1 : offset + length - 1;

boolean visible = false;
if (sourceViewer instanceof ITextViewerExtension5) {
ITextViewerExtension5 extension = (ITextViewerExtension5) sourceViewer;
if (sourceViewer instanceof ITextViewerExtension5 extension) {
visible = (extension.modelOffset2WidgetOffset(targetOffset) > -1);
} else {
IRegion visibleRegion = sourceViewer.getVisibleRegion();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@
public final class ExtensionBasedTextViewerConfiguration extends TextSourceViewerConfiguration
implements IDocumentPartitioningListener {

private ITextEditor editor;
private final ITextEditor editor;
private Set<IContentType> resolvedContentTypes;
private Set<IContentType> fallbackContentTypes = Set.of();
private IDocument watchedDocument;
Expand Down Expand Up @@ -386,8 +386,8 @@ class ExtensionBaseInformationProvider
public Object getInformation2(ITextViewer textViewer, IRegion subject) {
currentHovers = new LinkedHashMap<>();
for (ITextHover hover : this.fHovers) {
Object res = hover instanceof ITextHoverExtension2
? ((ITextHoverExtension2) hover).getHoverInfo2(textViewer, subject)
Object res = hover instanceof ITextHoverExtension2 i
? i.getHoverInfo2(textViewer, subject)
: hover.getHoverInfo(textViewer, subject);
if (res != null) {
currentHovers.put(hover, res);
Expand Down Expand Up @@ -432,7 +432,7 @@ public IInformationControlCreator getInformationPresenterControlCreator() {
return null;
} else if (currentHovers.size() == 1) {
ITextHover hover = this.currentHovers.keySet().iterator().next();
return hover instanceof ITextHoverExtension ? ((ITextHoverExtension) hover).getHoverControlCreator()
return hover instanceof ITextHoverExtension i ? i.getHoverControlCreator()
: new AbstractReusableInformationControlCreator() {
@Override
protected IInformationControl doCreateInformationControl(Shell parent) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ public boolean matches(ISourceViewer viewer, ITextEditor editor) {

/**
* Returns the name of the contribution.
*
*
* @return the name of the contribution.
*/
public String getContributionName() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
* <li>Using a ContentTypeRelatedExtensionTracker to dynamically track
* IContentAssistProcessor in the OSGi service registry
* </ul>
*
*
* @author christoph
*/
public class GenericEditorContentAssistant extends ContentAssistant implements IPropertyChangeListener {
Expand All @@ -55,7 +55,7 @@ public class GenericEditorContentAssistant extends ContentAssistant implements I
/**
* Creates a new GenericEditorContentAssistant instance for the given content
* types and contentAssistProcessorTracker
*
*
* @param contentAssistProcessorTracker the tracker to use for tracking
* additional
* {@link IContentAssistProcessor}s in the
Expand All @@ -74,7 +74,7 @@ public GenericEditorContentAssistant(
/**
* Creates a new GenericEditorContentAssistant instance for the given content
* types and contentAssistProcessorTracker
*
*
* @param contentAssistProcessorTracker the tracker to use for tracking
* additional
* {@link IContentAssistProcessor}s in the
Expand Down Expand Up @@ -118,7 +118,7 @@ protected IInformationControl doCreateInformationControl(Shell parent) {
/**
* Updates the {@link IContentAssistProcessor} registrations according to the
* documents content-type tokens
*
*
* @param document the document to use for updating the tokens
*/
public void updateTokens(IDocument document) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,10 @@ public void start(BundleContext context) throws Exception {

if (PlatformUI.isWorkbenchRunning()) {
themeListener = event -> {
if (IThemeManager.CHANGE_CURRENT_THEME.equals(event.getProperty()))
if (IThemeManager.CHANGE_CURRENT_THEME.equals(event.getProperty())) {
GenericEditorPluginPreferenceInitializer
.setThemeBasedPreferences(GenericEditorPreferenceConstants.getPreferenceStore(), true);
}
};
PlatformUI.getWorkbench().getThemeManager().addPropertyChangeListener(themeListener);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@
* "org.eclipse.ui.genericeditor.icons".
*/
public class GenericEditorWithContentTypeIcon implements IEditorDescriptor {
private IEditorDescriptor editorDescriptor;
private String fileName;
private final IEditorDescriptor editorDescriptor;
private final String fileName;

public GenericEditorWithContentTypeIcon(String fileName, IEditorDescriptor editorDescriptor) {
Assert.isNotNull(editorDescriptor);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
*/
public class GenericEditorWithIconAssociationOverride implements IEditorAssociationOverride {

private Map<String, IEditorDescriptor> descriptorMap = new HashMap<>();
private final Map<String, IEditorDescriptor> descriptorMap = new HashMap<>();

@Override
public IEditorDescriptor[] overrideEditors(IEditorInput editorInput, IContentType contentType,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
public class IconsRegistry {

private static final String EXTENSION_POINT_ID = GenericEditorPlugin.BUNDLE_ID + ".icons"; //$NON-NLS-1$
private Map<IContentType, ImageDescriptor> extensions = new LinkedHashMap<>();
private final Map<IContentType, ImageDescriptor> extensions = new LinkedHashMap<>();
private boolean outOfSync = true;

public IconsRegistry() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public class PresentationReconcilerRegistry {

private static final String EXTENSION_POINT_ID = GenericEditorPlugin.BUNDLE_ID + ".presentationReconcilers"; //$NON-NLS-1$

private Map<IConfigurationElement, GenericContentTypeRelatedExtension<IPresentationReconciler>> extensions = new HashMap<>();
private final Map<IConfigurationElement, GenericContentTypeRelatedExtension<IPresentationReconciler>> extensions = new HashMap<>();
private boolean outOfSync = true;

/**
Expand All @@ -52,7 +52,7 @@ public PresentationReconcilerRegistry() {
/**
* Get the contributed {@link IPresentationReconciler}s that are relevant to
* hook on source viewer according to document content types.
*
*
* @param sourceViewer the source viewer we're hooking completion to.
* @param editor the text editor
* @param contentTypes the content types of the document we're editing.
Expand Down
Loading
Loading