mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-22 14:12:10 +02:00
fixed grep example and added details provider for it
This commit is contained in:
parent
7e3b1acf38
commit
352e59b270
3 changed files with 39 additions and 3 deletions
|
@ -29,7 +29,7 @@
|
|||
defaultSeverity="Warning"
|
||||
description="Finds a strings in the code defined by user"
|
||||
id="org.eclipse.cdt.codan.examples.checkers.GrepCheckerProblemWarning"
|
||||
messagePattern="{0}"
|
||||
messagePattern="Found string {0}"
|
||||
name="Search string warning">
|
||||
</problem>
|
||||
<problem
|
||||
|
@ -38,7 +38,7 @@
|
|||
defaultSeverity="Error"
|
||||
description="Finds a strings in the code defined by user"
|
||||
id="org.eclipse.cdt.codan.examples.checkers.GrepCheckerProblemError"
|
||||
messagePattern="{0}"
|
||||
messagePattern="Found string {0}"
|
||||
name="Search string error">
|
||||
</problem>
|
||||
</checker>
|
||||
|
@ -48,6 +48,10 @@
|
|||
<problemDetails
|
||||
class="org.eclipse.cdt.codan.examples.uicontrib.FlexlintHelpLink"
|
||||
>
|
||||
</problemDetails>
|
||||
<problemDetails
|
||||
class="org.eclipse.cdt.codan.examples.uicontrib.GrepCheckerHelpLink"
|
||||
>
|
||||
</problemDetails>
|
||||
</extension>
|
||||
</plugin>
|
||||
|
|
|
@ -78,7 +78,7 @@ public class GrepChecker extends AbstractCheckerWithProblemPreferences {
|
|||
for (int i = 0; i < values.length; i++) {
|
||||
String str = (String) values[i];
|
||||
if (line.contains(str)) {
|
||||
reportProblem(problem.getId(), file, iline, "Found " + str);
|
||||
reportProblem(problem.getId(), file, iline, str);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,32 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2010 Alena Laskavaia and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Alena Laskavaia - initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.codan.examples.uicontrib;
|
||||
|
||||
import org.eclipse.cdt.codan.internal.core.model.CodanProblemMarker;
|
||||
import org.eclipse.cdt.codan.ui.AbstractCodanProblemDetailsProvider;
|
||||
|
||||
/**
|
||||
* Example of codan problem details provider for flexlint integration
|
||||
*/
|
||||
public class GrepCheckerHelpLink extends AbstractCodanProblemDetailsProvider {
|
||||
@Override
|
||||
public boolean isApplicable(String id) {
|
||||
return id.startsWith("org.eclipse.cdt.codan.examples.checkers.GrepCheckerProblem");
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String getStyledProblemDescription() {
|
||||
String arg = CodanProblemMarker.getProblemArgument(marker, 0);
|
||||
String url = "http://www.google.ca/search?q=" + arg;
|
||||
return "Google " + "<a href=\"" + url + "\">" + arg + "</a>";
|
||||
}
|
||||
}
|
Loading…
Add table
Reference in a new issue