Skip to content

Checker documentation can be accessable from report list #202

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
package org.codechecker.eclipse.plugin.command;

import java.net.MalformedURLException;
import java.net.URL;

import org.codechecker.eclipse.plugin.Logger;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.jdt.annotation.NonNull;
import org.eclipse.jface.action.Action;
import org.eclipse.ui.PartInitException;
import org.eclipse.ui.PlatformUI;

/**
* Action for opening a browser with an arbitrary url.
*/
public class OpenDocsAction extends Action {

private final String url;

/**
* Constructor where you must specify an url.
*
* @param url
* The url to be used. Must not be null
*/
public OpenDocsAction(@NonNull String url) {
super("View Documentation");
this.url = url;
}

@Override
public void run() {
try {
PlatformUI.getWorkbench().getBrowserSupport().createBrowser("CodeChecker")
.openURL(new URL(url));
} catch (PartInitException | MalformedURLException e) {
Logger.log(IStatus.ERROR, "Couldn't go to link.");
}
}

/**
* Holder class for the actual links.
*/
public final class DocTypes {
public static final String SA = "https://clang.llvm.org/docs/analyzer/checkers.html";
public static final String TIDY = "https://clang.llvm.org/extra/clang-tidy/checks/list.html";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,13 @@

import org.codechecker.eclipse.plugin.Activator;
import org.codechecker.eclipse.plugin.Logger;
import org.codechecker.eclipse.plugin.command.OpenDocsAction;
import org.codechecker.eclipse.plugin.command.OpenDocsAction.DocTypes;
import org.codechecker.eclipse.plugin.config.CodeCheckerContext;
import org.codechecker.eclipse.plugin.config.filter.Filter;
import org.codechecker.eclipse.plugin.config.filter.FilterConfiguration;
import org.codechecker.eclipse.plugin.report.BugPathItem;
import org.codechecker.eclipse.plugin.report.ReportInfo;
import org.codechecker.eclipse.plugin.report.SearchList;
import org.codechecker.eclipse.plugin.report.job.AnalyzeJob;
import org.codechecker.eclipse.plugin.report.job.JobDoneChangeListener;
Expand Down Expand Up @@ -43,7 +46,9 @@
import org.eclipse.jface.viewers.IDoubleClickListener;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.viewers.ITreeContentProvider;
import org.eclipse.jface.viewers.ITreeSelection;
import org.eclipse.jface.viewers.LabelProvider;
import org.eclipse.jface.viewers.TreePath;
import org.eclipse.jface.viewers.TreeViewer;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.MouseEvent;
Expand Down Expand Up @@ -223,7 +228,26 @@ private void fillLocalPullDown(IMenuManager manager) {
}

private void fillContextMenu(IMenuManager manager) {
//manager.add(new RerunSelectedAction(this));
IStructuredSelection sel = viewer.getStructuredSelection();
Object selection = sel.getFirstElement();
TreePath tp = ((ITreeSelection) sel).getPaths()[0];
for (int i = 0; i < tp.getSegmentCount(); i++) {
Object segment = tp.getSegment(i);
// We are simply relying on string contain,
// * Can't go from BugPathItem to ReportInfo
// * ReportInfo on the gui wont show the checker
if (selection instanceof ReportInfo || selection instanceof BugPathItem)
break;
if (segment instanceof String) {
if (((String) segment).contains(".")) {
manager.add(new OpenDocsAction(DocTypes.SA));
break;
} else if (((String) segment).contains("-")) {
manager.add(new OpenDocsAction(DocTypes.TIDY));
break;
}
}
}
manager.add(new NewInstanceAction(new ReportListViewCustom()));
manager.add(new Separator());
// Other plug-ins can contribute there actions here
Expand Down