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
13 changes: 13 additions & 0 deletions config/checkstyle-checks.xml
Original file line number Diff line number Diff line change
Expand Up @@ -443,6 +443,19 @@
value="'@noinspection' Javadoc tags should be accompanied by a
'@noinspectionreason' tag, explaining why we suppressed inspection."/>
</module>
<module name="MatchXpath">
<property name="id" value="settersHaveSinceTag"/>
<property name="query"
value="//CLASS_DEF[./IDENT[ends-with(@text, 'Check') or ends-with(@text, 'Filter')]
and not (./MODIFIERS/ABSTRACT)]
/OBJBLOCK/METHOD_DEF[./IDENT[starts-with(@text, 'set')]
and ./MODIFIERS/LITERAL_PUBLIC
and ./TYPE/LITERAL_VOID
and ./MODIFIERS/BLOCK_COMMENT_BEGIN
/COMMENT_CONTENT[not(contains(@text, '@since'))]]"/>
<message key="matchxpath.match"
value="All property setters of a module should contain a '@since' tag."/>
</module>
<module name="MatchXpath">
<property name="id" value="exampleTestsExtendAbstractExamplesModuleTestSupport"/>
<property name="query"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,9 +109,6 @@ public class CheckConfigurationConfigureDialog extends TitleAreaDialog {
/** The current check configuration. */
private final CheckConfigurationWorkingCopy mConfiguration;

/** Filter for the table viewer to show only element of the selected group. */
private final RuleGroupModuleFilter mGroupFilter = new RuleGroupModuleFilter();

/** Controller for this Dialog. */
private final PageController mController = new PageController();

Expand All @@ -121,6 +118,9 @@ public class CheckConfigurationConfigureDialog extends TitleAreaDialog {
/** The tree filter. */
private final TreeFilter mTreeFilter = new TreeFilter();

/** the current rule group. */
private RuleGroupMetadata mCurrentGroup;

/** Flags if the Check configuration can be modified. */
private boolean mConfigurable;

Expand Down Expand Up @@ -352,7 +352,7 @@ private Control createTableViewer(Composite parent) {
ModuleLabelProvider multiProvider = new ModuleLabelProvider();
mTableViewer.setLabelProvider(multiProvider);
mTableViewer.setContentProvider(new ArrayContentProvider());
mTableViewer.addFilter(mGroupFilter);
mTableViewer.addFilter(new RuleGroupModuleFilter());

mTableViewer.addDoubleClickListener(mController);
mTableViewer.addSelectionChangedListener(mController);
Expand Down Expand Up @@ -618,7 +618,7 @@ public void selectionChanged(SelectionChangedEvent event) {

RuleGroupMetadata group = (RuleGroupMetadata) element;
description = group.getDescription();
mGroupFilter.setCurrentGroup(group);
mCurrentGroup = group;
mConfiguredModulesGroup
.setText(NLS.bind(Messages.CheckConfigurationConfigureDialog_lblConfiguredModules,
group.getGroupName()));
Expand All @@ -630,7 +630,7 @@ public void selectionChanged(SelectionChangedEvent event) {
RuleMetadata rule = (RuleMetadata) element;

description = rule.identity().description();
mGroupFilter.setCurrentGroup(rule.identity().group());
mCurrentGroup = rule.identity().group();
mConfiguredModulesGroup
.setText(NLS.bind(Messages.CheckConfigurationConfigureDialog_lblConfiguredModules,
rule.identity().group().getGroupName()));
Expand Down Expand Up @@ -1005,19 +1005,7 @@ public IDialogSettings getTableSettings() {
* Viewer filter that includes all modules that belong to the currently selected group.
*
*/
private static class RuleGroupModuleFilter extends ViewerFilter {

/** the current rule group. */
private RuleGroupMetadata mCurrentGroup;

/**
* Sets the current rule group.
*
* @param groupMetaData the group metadata
*/
public void setCurrentGroup(RuleGroupMetadata groupMetaData) {
mCurrentGroup = groupMetaData;
}
private class RuleGroupModuleFilter extends ViewerFilter {

@Override
public boolean select(Viewer viewer, Object parentElement, Object element) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public class CreateStatsJob extends Job {
*/
public CreateStatsJob(CheckstyleMarkerFilter filter, String family) {
super(Messages.CreateStatsJob_msgAnalyzeMarkers);
mFilter = (CheckstyleMarkerFilter) filter.clone();
mFilter = filter;
mFamily = family;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@

import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IMarkerDelta;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.IResourceChangeEvent;
import org.eclipse.core.resources.IResourceChangeListener;
Expand All @@ -43,6 +42,7 @@
import org.eclipse.jface.action.IMenuManager;
import org.eclipse.jface.action.IToolBarManager;
import org.eclipse.jface.dialogs.IDialogSettings;
import org.eclipse.jface.text.TextSelection;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.window.Window;
Expand Down Expand Up @@ -79,7 +79,7 @@ public abstract class AbstractStatsView extends ViewPart {
private Composite mMainComposite;

/** The filter for this stats view. */
private CheckstyleMarkerFilter mFilter;
private CheckstyleMarkerFilter filter;

/** The focused resources. */
private IResource[] mFocusedResources;
Expand Down Expand Up @@ -124,6 +124,7 @@ public abstract class AbstractStatsView extends ViewPart {

@Override
public void createPartControl(Composite parent) {
filter = CheckstyleMarkerFilter.restoreState(getDialogSettings(), new IResource[0]);

mMainComposite = parent;

Expand All @@ -136,7 +137,12 @@ public void selectionChanged(IWorkbenchPart part, ISelection selection) {
};

getSite().getPage().addSelectionListener(mFocusListener);
focusSelectionChanged(getSite().getPage().getActivePart(), getSite().getPage().getSelection());
ISelection selection = getSite().getPage().getSelection();
if (selection == null || selection instanceof TextSelection) {
focusSelectionChanged(getSite().getPage().getActiveEditor(), null);
} else {
focusSelectionChanged(null, selection);
}

// create and register the listener for resource changes
mResourceListener = new IResourceChangeListener() {
Expand Down Expand Up @@ -177,13 +183,12 @@ public void dispose() {
public final void openFiltersDialog() {

CheckstyleMarkerFilterDialog dialog = new CheckstyleMarkerFilterDialog(
mMainComposite.getShell(), (CheckstyleMarkerFilter) getFilter().clone());
mMainComposite.getShell(), filter);

if (dialog.open() == Window.OK) {
CheckstyleMarkerFilter filter = dialog.getFilter();
filter = dialog.getFilter();
filter.saveState(getDialogSettings());

mFilter = filter;
refresh();
}
}
Expand All @@ -199,20 +204,6 @@ protected void initActionBars(IActionBars actionBars) {
initToolBar(actionBars.getToolBarManager());
}

/**
* Returns the filter of this view.
*
* @return the filter
*/
protected final CheckstyleMarkerFilter getFilter() {
if (mFilter == null) {
mFilter = new CheckstyleMarkerFilter();
mFilter.restoreState(getDialogSettings());
}

return mFilter;
}

/**
* Returns the statistics data.
*
Expand All @@ -232,7 +223,7 @@ protected final void refresh() {
.getAdapter(IWorkbenchSiteProgressService.class);

// rebuild statistics data
CreateStatsJob job = new CreateStatsJob(getFilter(), getViewId());
CreateStatsJob job = new CreateStatsJob(filter, getViewId());
job.setPriority(Job.DECORATE);
job.setRule(ResourcesPlugin.getWorkspace().getRoot());
job.addJobChangeListener(new JobChangeAdapter() {
Expand Down Expand Up @@ -317,7 +308,7 @@ private void focusSelectionChanged(IWorkbenchPart part, ISelection selection) {
boolean updateNeeded = updateNeeded(mFocusedResources, focusedResources);
if (updateNeeded) {
mFocusedResources = focusedResources;
getFilter().setFocusResource(focusedResources);
filter = filter.withFocusResources(focusedResources);
refresh();
}
}
Expand Down Expand Up @@ -371,12 +362,11 @@ public static IFile getFile(IEditorInput editorInput) {
*/
private boolean updateNeeded(IResource[] oldResources, IResource[] newResources) {
// determine if an update if refiltering is required
CheckstyleMarkerFilter filter = getFilter();
if (!filter.isEnabled()) {
if (!filter.enabled()) {
return false;
}

int onResource = filter.getOnResource();
int onResource = filter.onResource();
if (onResource == CheckstyleMarkerFilter.ON_ANY_RESOURCE
|| onResource == CheckstyleMarkerFilter.ON_WORKING_SET) {
return false;
Expand All @@ -391,10 +381,8 @@ private boolean updateNeeded(IResource[] oldResources, IResource[] newResources)
return false;
}
if (onResource == CheckstyleMarkerFilter.ON_ANY_RESOURCE_OF_SAME_PROJECT) {
Collection<IProject> oldProjects = CheckstyleMarkerFilter.getProjectsAsCollection(oldResources);
Collection<IProject> newProjects = CheckstyleMarkerFilter.getProjectsAsCollection(newResources);

return oldProjects.size() != newProjects.size() || !newProjects.containsAll(oldProjects);
return CheckstyleMarkerFilter.getProjects(oldResources)
.equals(CheckstyleMarkerFilter.getProjects(newResources));
}

return true;
Expand Down
Loading
Loading