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 config/checkstyle-checks.xml
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,7 @@
</module>
<module name="NeedBraces">
<property name="id" value="needBracesForLambda"/>
<!-- <property name="tokens" value="LAMBDA"/> -->
<property name="tokens" value="LAMBDA"/>
<property name="allowSingleLineStatement" value="true"/>
</module>
<module name="RightCurly">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -202,8 +202,10 @@ private static Element writeModule(Module module, Branch parent) {

// write properties of the module
module.getProperties().stream().filter(property -> property.getValue() != null)
.filter(property -> !property.getValue().isEmpty()).filter(property -> !Objects
.equals(property.getValue(), property.getMetaData().getDefaultValue()))
.filter(property -> !property.getValue().isEmpty()).filter(property -> {
return !Objects.equals(property.getValue(),
property.getMetaData().getDefaultValue());
})
.forEach(property -> {
final Element propertyEl = moduleEl.addElement(XMLTags.PROPERTY_TAG);
propertyEl.addAttribute(XMLTags.NAME_TAG, property.getMetaData().getName());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -490,10 +490,12 @@ private static void parseMetadata(InputStream metadataStream, ResourceBundle met
final Collection<RuleGroupMetadata> groups = MetadataXmlReader.parseMetadata(metadataStream,
metadataBundle, groupId);
groups.forEach(
group -> ruleGroupMetadata.merge(group.getGroupName(), group, (groupA, groupB) -> {
groupA.getRuleMetadata().addAll(groupB.getRuleMetadata());
return groupA;
}));
group -> {
ruleGroupMetadata.merge(group.getGroupName(), group, (groupA, groupB) -> {
groupA.getRuleMetadata().addAll(groupB.getRuleMetadata());
return groupA;
});
});
for (RuleGroupMetadata group : groups) {
for (RuleMetadata module : group.getRuleMetadata()) {
ruleMetadataByName.put(module.identity().internalName(), module);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,11 +123,15 @@ private List<AbstractFTransformationClass> loadTransformationClasses(
new ClassGraph().addClassLoader(loader).enableAnnotationInfo().scan()) {
return scanResult.getClassesWithAnnotation(formatterKeyAnnotation).stream()
.collect(Collectors.toUnmodifiableMap(
classInfo -> "org.eclipse.jdt.core.formatter."
+ classInfo.getAnnotationInfo(formatterKeyAnnotation).getParameterValues()
.getValue("value"),
classInfo -> (Class<? extends AbstractFTransformationClass>) classInfo
.loadClass()));
classInfo -> {
return "org.eclipse.jdt.core.formatter."
+ classInfo.getAnnotationInfo(formatterKeyAnnotation)
.getParameterValues().getValue("value");
},
classInfo -> {
return (Class<? extends AbstractFTransformationClass>) classInfo
.loadClass();
}));
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,68 +38,105 @@
public enum CheckstyleUIPluginImages {

/** Image descriptor for the plugin logo. */
PLUGIN_LOGO(() -> AbstractUIPlugin.imageDescriptorFromPlugin(CheckstyleUIPlugin.PLUGIN_ID,
"icons/eclipse-cs-little.png")),
PLUGIN_LOGO(() -> {
return AbstractUIPlugin.imageDescriptorFromPlugin(CheckstyleUIPlugin.PLUGIN_ID,
"icons/eclipse-cs-little.png");
}),
/** Image descriptor for the error marker. */
MARKER_ERROR(() -> AbstractUIPlugin.imageDescriptorFromPlugin(CheckstyleUIPlugin.PLUGIN_ID,
"icons/checkstyle_error.gif")),
MARKER_ERROR(() -> {
return AbstractUIPlugin.imageDescriptorFromPlugin(CheckstyleUIPlugin.PLUGIN_ID,
"icons/checkstyle_error.gif");
}),
/** Image descriptor for the warning marker. */
MARKER_WARNING(() -> AbstractUIPlugin.imageDescriptorFromPlugin(CheckstyleUIPlugin.PLUGIN_ID,
"icons/checkstyle_warning.gif")),
MARKER_WARNING(() -> {
return AbstractUIPlugin.imageDescriptorFromPlugin(CheckstyleUIPlugin.PLUGIN_ID,
"icons/checkstyle_warning.gif");
}),
/** Image descriptor for the info marker. */
MARKER_INFO(() -> AbstractUIPlugin.imageDescriptorFromPlugin(CheckstyleUIPlugin.PLUGIN_ID,
"icons/checkstyle_info.gif")),
MARKER_INFO(() -> {
return AbstractUIPlugin.imageDescriptorFromPlugin(CheckstyleUIPlugin.PLUGIN_ID,
"icons/checkstyle_info.gif");
}),
/** Image descriptor for the help icon. */
HELP_ICON(() -> PlatformUI.getWorkbench().getSharedImages()
.getImageDescriptor(ISharedImages.IMG_LCL_LINKTO_HELP)),
HELP_ICON(() -> {
return PlatformUI.getWorkbench().getSharedImages()
.getImageDescriptor(ISharedImages.IMG_LCL_LINKTO_HELP);
}),
/** Image descriptor for the add correction icon. */
CORRECTION_ADD(() -> AbstractUIPlugin.imageDescriptorFromPlugin(CheckstyleUIPlugin.PLUGIN_ID,
"icons/add_correction.png")),
CORRECTION_ADD(() -> {
return AbstractUIPlugin.imageDescriptorFromPlugin(CheckstyleUIPlugin.PLUGIN_ID,
"icons/add_correction.png");
}),
/** Image descriptor for the add braces correction icon. */
CORRECTION_ADD_BRACES(() -> AbstractUIPlugin
.imageDescriptorFromPlugin(CheckstyleUIPlugin.PLUGIN_ID, "icons/correction_cast.png")),
CORRECTION_ADD_BRACES(() -> {
return AbstractUIPlugin
.imageDescriptorFromPlugin(CheckstyleUIPlugin.PLUGIN_ID, "icons/correction_cast.png");
}),
/** Image descriptor for the change correction icon. */
CORRECTION_CHANGE(() -> AbstractUIPlugin.imageDescriptorFromPlugin(CheckstyleUIPlugin.PLUGIN_ID,
"icons/correction_change.png")),
CORRECTION_CHANGE(() -> {
return AbstractUIPlugin.imageDescriptorFromPlugin(CheckstyleUIPlugin.PLUGIN_ID,
"icons/correction_change.png");
}),
/** Image descriptor for the remove correction icon. */
CORRECTION_REMOVE(() -> AbstractUIPlugin.imageDescriptorFromPlugin(CheckstyleUIPlugin.PLUGIN_ID,
"icons/remove_correction.png")),
CORRECTION_REMOVE(() -> {
return AbstractUIPlugin.imageDescriptorFromPlugin(CheckstyleUIPlugin.PLUGIN_ID,
"icons/remove_correction.png");
}),
/** Image descriptor for the tick icon. */
TICK_ICON(() -> AbstractUIPlugin.imageDescriptorFromPlugin(CheckstyleUIPlugin.PLUGIN_ID,
"icons/tick.gif")),
TICK_ICON(() -> {
return AbstractUIPlugin.imageDescriptorFromPlugin(CheckstyleUIPlugin.PLUGIN_ID,
"icons/tick.gif");
}),

/** Image descriptor for the filter icon. */
FILTER_ICON(() -> ResourceLocator
.imageDescriptorFromBundle("org.eclipse.ui.ide",
"platform:/plugin/org.eclipse.ui.ide/icons/full/elcl16/filter_ps.png")
.orElse(MARKER_ERROR.getImageDescriptor())),
FILTER_ICON(() -> {
return ResourceLocator.imageDescriptorFromBundle("org.eclipse.ui.ide",
"platform:/plugin/org.eclipse.ui.ide/icons/full/elcl16/filter_ps.png")
.orElse(MARKER_ERROR.getImageDescriptor());
}),
/** Image descriptor for the Checkstyle violation view icon. */
LIST_VIEW_ICON(() -> AbstractUIPlugin.imageDescriptorFromPlugin(CheckstyleUIPlugin.PLUGIN_ID,
"icons/listingView.gif")),
LIST_VIEW_ICON(() -> {
return AbstractUIPlugin.imageDescriptorFromPlugin(CheckstyleUIPlugin.PLUGIN_ID,
"icons/listingView.gif");
}),

/** Image descriptor for the checked overlay icon. */
CHECKED_OVERLAY(() -> AbstractUIPlugin.imageDescriptorFromPlugin(CheckstyleUIPlugin.PLUGIN_ID,
"icons/ovr/checked.png")),
CHECKED_OVERLAY(() -> {
return AbstractUIPlugin.imageDescriptorFromPlugin(CheckstyleUIPlugin.PLUGIN_ID,
"icons/ovr/checked.png");
}),
/** Image descriptor for the module group icon. */
MODULEGROUP_ICON(() -> AbstractUIPlugin.imageDescriptorFromPlugin(CheckstyleUIPlugin.PLUGIN_ID,
"icons/modulegroup.gif")),
MODULEGROUP_ICON(() -> {
return AbstractUIPlugin.imageDescriptorFromPlugin(CheckstyleUIPlugin.PLUGIN_ID,
"icons/modulegroup.gif");
}),
/** Image descriptor for the ticked module group icon. */
MODULEGROUP_TICKED_ICON(() -> new DecorationOverlayIcon(MODULEGROUP_ICON.getImageDescriptor(),
CHECKED_OVERLAY.getImageDescriptor(), IDecoration.TOP_LEFT)),
MODULEGROUP_TICKED_ICON(() -> {
return new DecorationOverlayIcon(MODULEGROUP_ICON.getImageDescriptor(),
CHECKED_OVERLAY.getImageDescriptor(), IDecoration.TOP_LEFT);
}),
/** Image descriptor for the module icon. */
MODULE_ICON(() -> AbstractUIPlugin.imageDescriptorFromPlugin(CheckstyleUIPlugin.PLUGIN_ID,
"icons/module.gif")),
MODULE_ICON(() -> {
return AbstractUIPlugin.imageDescriptorFromPlugin(CheckstyleUIPlugin.PLUGIN_ID,
"icons/module.gif");
}),
/** Image descriptor for the ticked module icon. */
MODULE_TICKED_ICON(() -> new DecorationOverlayIcon(MODULE_ICON.getImageDescriptor(),
CHECKED_OVERLAY.getImageDescriptor(), IDecoration.TOP_LEFT)),
MODULE_TICKED_ICON(() -> {
return new DecorationOverlayIcon(MODULE_ICON.getImageDescriptor(),
CHECKED_OVERLAY.getImageDescriptor(), IDecoration.TOP_LEFT);
}),
/** Image descriptor for the refresh icon. */
REFRESH_ICON(() -> ResourceLocator
.imageDescriptorFromBundle("org.eclipse.search",
"platform:/plugin/org.eclipse.search/icons/full/elcl16/refresh.png")
.orElse(MARKER_ERROR.getImageDescriptor())),
REFRESH_ICON(() -> {
return ResourceLocator
.imageDescriptorFromBundle("org.eclipse.search",
"platform:/plugin/org.eclipse.search/icons/full/elcl16/refresh.png")
.orElse(MARKER_ERROR.getImageDescriptor());
}),
/** Image descriptor for the checkstyle project icon. */
CHECKSTYLE_ICON(() -> AbstractUIPlugin.imageDescriptorFromPlugin(CheckstyleUIPlugin.PLUGIN_ID,
"icons/checkstyle_command.png"));
CHECKSTYLE_ICON(() -> {
return AbstractUIPlugin.imageDescriptorFromPlugin(CheckstyleUIPlugin.PLUGIN_ID,
"icons/checkstyle_command.png");
});

/**
* Lazy creation factory.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,11 +90,14 @@ public CheckConfigurationPropertiesDialogView(Composite parent, int style,
GridDataFactory.swtDefaults().applyTo(mConfigType.getCombo());
mConfigType.setContentProvider(ArrayContentProvider.getInstance());
mConfigType.setLabelProvider(LabelProvider.createTextImageProvider(
element -> ((IConfigurationType) element).getName(), element -> ConfigurationTypesUI
.getConfigurationTypeImage((IConfigurationType) element)));
mConfigType.addSelectionChangedListener(event -> changeSelectedConfigurationType.accept(
(IConfigurationType) event.getStructuredSelection().getFirstElement(),
mConfigType.getCombo().getEnabled()));
element -> ((IConfigurationType) element).getName(), element -> {
return ConfigurationTypesUI.getConfigurationTypeImage((IConfigurationType) element);
}));
mConfigType.addSelectionChangedListener(event -> {
changeSelectedConfigurationType.accept(
(IConfigurationType) event.getStructuredSelection().getFirstElement(),
mConfigType.getCombo().getEnabled());
});

mEditorPlaceHolder = new Composite(this, SWT.NULL);
GridLayoutFactory.swtDefaults().equalWidth(true).margins(0, 0).applyTo(mEditorPlaceHolder);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,10 @@ public CheckConfigurationWorkingSetEditorConfigTable(Composite parent, int style
col1.getColumn().setText(Messages.CheckstylePreferencePage_colCheckConfig);
col1.setLabelProvider(ColumnLabelProvider.createTextImageProvider(
element -> ((ICheckConfiguration) element).getName(),
element -> ConfigurationTypesUI.getConfigurationTypeImage(
((ICheckConfiguration) element).getType())));
element -> {
return ConfigurationTypesUI.getConfigurationTypeImage(
((ICheckConfiguration) element).getType());
}));
tableColumnLayout.setColumnData(col1.getColumn(), new ColumnWeightData(1));

final TableViewerColumn col2 = new TableViewerColumn(tableViewer, SWT.NULL);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,10 @@ public ConfiguredModulesTable(Composite parent, int style, ViewerFilter ruleGrou

createColumns(tableColumnLayout, table);

tableViewer.addDoubleClickListener(event -> callbacks.openModule()
.accept((Module) ((IStructuredSelection) event.getSelection()).getFirstElement()));
tableViewer.addDoubleClickListener(event -> {
callbacks.openModule()
.accept((Module) ((IStructuredSelection) event.getSelection()).getFirstElement());
});
tableViewer.addSelectionChangedListener(event -> {
String description = null;
if (event.getStructuredSelection().getFirstElement() instanceof Module module) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,10 @@ public FileSetEditDialogCommonArea(Composite parent, int style,
mComboViewer.setLabelProvider(CheckConfigurationLabelProvider.INSTANCE);
mComboViewer.setComparator(CheckConfigurationViewerSorter.INSTANCE);
GridDataFactory.create(GridData.FILL_HORIZONTAL).applyTo(mComboViewer.getControl());
mComboViewer.addSelectionChangedListener(event -> selectionChanged
.accept((ICheckConfiguration) event.getStructuredSelection().getFirstElement()));
mComboViewer.addSelectionChangedListener(event -> {
selectionChanged
.accept((ICheckConfiguration) event.getStructuredSelection().getFirstElement());
});

final Button mConfigureButton = new Button(comboComposite, SWT.PUSH);
mConfigureButton.setText(Messages.FileSetEditDialog_btnConfigure);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -392,8 +392,9 @@ private void createColumns(TableColumnLayout tableColumnLayout) {
tableColumnLayout.setColumnData(severityCol.getColumn(),
new ColumnPixelData(severityCol.getColumn().getWidth()));
TableViewerEnhancer.setColumnComparator(severityCol.getColumn(),
Comparator.comparingInt(marker -> -((IMarker) marker).getAttribute(IMarker.SEVERITY,
Integer.MAX_VALUE)));
Comparator.comparingInt(marker -> {
return -((IMarker) marker).getAttribute(IMarker.SEVERITY, Integer.MAX_VALUE);
}));

final TableViewerColumn fileCol = new TableViewerColumn(tableViewer, SWT.LEFT);
fileCol.getColumn().setText(Messages.MarkerStatsView_fileColumn);
Expand All @@ -413,8 +414,9 @@ private void createColumns(TableColumnLayout tableColumnLayout) {

final TableViewerColumn lineCol = new TableViewerColumn(tableViewer, SWT.RIGHT);
lineCol.getColumn().setText(Messages.MarkerStatsView_lineColumn);
lineCol.setLabelProvider(ColumnLabelProvider.createTextProvider(element -> String
.valueOf(((IMarker) element).getAttribute(IMarker.LINE_NUMBER, 0))));
lineCol.setLabelProvider(ColumnLabelProvider.createTextProvider(element -> {
return String.valueOf(((IMarker) element).getAttribute(IMarker.LINE_NUMBER, 0));
}));
lineCol.getColumn().pack();
tableColumnLayout.setColumnData(lineCol.getColumn(),
new ColumnPixelData(lineCol.getColumn().getWidth()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,10 @@ public abstract class AbstractQuickfixTestCase {
protected final void testQuickfix(final String testDataXml,
final AbstractASTResolution quickfix) throws Exception {
try (InputStream stream = getClass().getResourceAsStream(testDataXml)) {
assertThat(stream).withFailMessage(() -> "Cannot find resource " + testDataXml
+ " in package " + getClass().getPackage().getName()).isNotNull();
assertThat(stream).withFailMessage(() -> {
return "Cannot find resource " + testDataXml
+ " in package " + getClass().getPackage().getName();
}).isNotNull();
testQuickfix(stream, quickfix);
}
}
Expand Down
Loading