eclipse plugin: add markers for wmllint and wmlscope
This commit is contained in:
parent
c6b01824d5
commit
0140292313
10 changed files with 184 additions and 198 deletions
|
@ -26,11 +26,11 @@
|
|||
</builder>
|
||||
</extension>
|
||||
<extension
|
||||
id="xmlProblem"
|
||||
name="XML Problem"
|
||||
id="org.wesnoth.marker.wmllint"
|
||||
name="WMLLint suggestion"
|
||||
point="org.eclipse.core.resources.markers">
|
||||
<super
|
||||
type="org.eclipse.core.resources.problemmarker">
|
||||
type="org.eclipse.core.resources.taskmarker">
|
||||
</super>
|
||||
<persistent
|
||||
value="true">
|
||||
|
@ -725,5 +725,16 @@
|
|||
</presentation>
|
||||
</config>
|
||||
</extension>
|
||||
<extension
|
||||
id="org.wesnoth.marker.wmlscope"
|
||||
name="WMLScope problem"
|
||||
point="org.eclipse.core.resources.markers">
|
||||
<super
|
||||
type="org.eclipse.core.resources.problemmarker">
|
||||
</super>
|
||||
<persistent
|
||||
value="true">
|
||||
</persistent>
|
||||
</extension>
|
||||
|
||||
</plugin>
|
||||
|
|
|
@ -13,9 +13,11 @@ import java.util.Map.Entry;
|
|||
import org.eclipse.core.resources.IProject;
|
||||
import org.eclipse.jface.resource.ImageDescriptor;
|
||||
import org.eclipse.swt.widgets.Shell;
|
||||
import org.eclipse.ui.PlatformUI;
|
||||
import org.eclipse.ui.plugin.AbstractUIPlugin;
|
||||
import org.osgi.framework.BundleContext;
|
||||
import org.wesnoth.preferences.Preferences;
|
||||
import org.wesnoth.utils.GUIUtils;
|
||||
import org.wesnoth.utils.PreprocessorUtils;
|
||||
import org.wesnoth.utils.ProjectCache;
|
||||
import org.wesnoth.utils.ProjectUtils;
|
||||
|
@ -70,21 +72,21 @@ public class Activator extends AbstractUIPlugin
|
|||
*/
|
||||
public static Activator getDefault()
|
||||
{
|
||||
// if (checkingConditions == false &&
|
||||
// PlatformUI.isWorkbenchRunning())
|
||||
// {
|
||||
// if (!checkConditions())
|
||||
// {
|
||||
// GUIUtils.showInfoMessageBox(
|
||||
// "Hello!\n" +
|
||||
// "Welcome to 'Wesnoth User Made Content Eclipse Plugin'.\n" +
|
||||
// "Since this is the first time you are using it " +
|
||||
// "I'll guide you through setting it up.\n\n" +
|
||||
// "First you'll have to setup your preferences.\n" +
|
||||
// "Press OK to continue.");
|
||||
// WorkspaceUtils.setupWorkspace(true);
|
||||
// }
|
||||
// }
|
||||
if (checkingConditions == false &&
|
||||
PlatformUI.isWorkbenchRunning())
|
||||
{
|
||||
if (!checkConditions())
|
||||
{
|
||||
GUIUtils.showInfoMessageBox(
|
||||
"Hello!\n" +
|
||||
"Welcome to 'Wesnoth User Made Content Eclipse Plugin'.\n" +
|
||||
"Since this is the first time you are using it " +
|
||||
"I'll guide you through setting it up.\n\n" +
|
||||
"First you'll have to setup your preferences.\n" +
|
||||
"Press OK to continue.");
|
||||
WorkspaceUtils.setupWorkspace(true);
|
||||
}
|
||||
}
|
||||
return plugin;
|
||||
}
|
||||
|
||||
|
|
|
@ -72,7 +72,10 @@ public class Constants
|
|||
/** Builder Constants **/
|
||||
public static final String BUIILDER_WESNOTH = "Wesnoth_Eclipse_Plugin.projectBuilder";
|
||||
public static final String BUILDER_XTEXT = XtextProjectHelper.BUILDER_ID;
|
||||
public static final String BUILDER_MARKER_TYPE = "Wesnoth_Eclipse_Plugin.configProblem";
|
||||
|
||||
/** Markers **/
|
||||
public static final String MARKER_WMLSCOPE = "org.wesnoth.marker.wmlscope";
|
||||
public static final String MARKER_WMLLINT = "org.wesnoth.marker.wmllint";
|
||||
|
||||
/** Nature Constants **/
|
||||
public static final String NATURE_WESNOTH = "Wesnoth_Eclipse_Plugin.wesnothNature";
|
||||
|
|
|
@ -1,121 +0,0 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2010 by Timotei Dolean <timotei21@gmail.com>
|
||||
*
|
||||
* 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
|
||||
*******************************************************************************/
|
||||
package org.wesnoth.builder;
|
||||
|
||||
import java.util.StringTokenizer;
|
||||
|
||||
import org.eclipse.core.resources.IMarker;
|
||||
import org.wesnoth.Logger;
|
||||
|
||||
|
||||
public class MarkerToken
|
||||
{
|
||||
private MarkerTokenType type_ = MarkerTokenType.INFO;
|
||||
private String message_ = "";
|
||||
private int line_ ;
|
||||
private int columnStart_;
|
||||
private int columnEnd_;
|
||||
|
||||
public MarkerToken(MarkerTokenType type,String message,int line,
|
||||
int columnStart,int columnEnd)
|
||||
{
|
||||
type_ = type;
|
||||
message_ = message;
|
||||
line_ = line;
|
||||
columnStart_ = columnStart;
|
||||
columnEnd_ = columnEnd;
|
||||
}
|
||||
|
||||
/**
|
||||
* Parses the current line and returns a marker token
|
||||
* Current used format: Type#line:column#message
|
||||
* @param line the line to parse
|
||||
* @return
|
||||
*/
|
||||
public static MarkerToken parseToken(String line)
|
||||
{
|
||||
// severity#Line{:columnStart-columnEnd}#message
|
||||
//TODO: speak with esr about the error format
|
||||
StringTokenizer tokenizer = new StringTokenizer(line,"#");
|
||||
if (tokenizer.countTokens() < 3)
|
||||
return null;
|
||||
try
|
||||
{
|
||||
int lineIndex=1,columnIndexStart=0,columnIndexEnd=0;
|
||||
MarkerTokenType type =
|
||||
MarkerTokenType.valueOf(tokenizer.nextToken().toUpperCase());
|
||||
|
||||
if (tokenizer.countTokens() > 1) // we have the line+column indexes
|
||||
{
|
||||
String[] tmp = tokenizer.nextToken().split(":");
|
||||
|
||||
if (tmp.length >0)
|
||||
lineIndex = Integer.parseInt(tmp[0]);
|
||||
if (tmp.length > 1)
|
||||
{
|
||||
// get columnstart-columnEnd
|
||||
String[] colTmp = tmp[1].split("-");
|
||||
columnIndexStart = Integer.parseInt(colTmp[0]);
|
||||
if(colTmp.length > 1)
|
||||
columnIndexEnd = Integer.parseInt(colTmp[1]);
|
||||
}
|
||||
}
|
||||
return new MarkerToken(type, tokenizer.nextToken(), lineIndex,
|
||||
columnIndexStart,columnIndexEnd);
|
||||
}
|
||||
catch (Exception e) {
|
||||
Logger.getInstance().logException(e);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/** Returns the of the marker
|
||||
* @return the line
|
||||
*/
|
||||
public int getLine() {
|
||||
return line_;
|
||||
}
|
||||
/** Returns the message of the marker
|
||||
* @return the message of the marker
|
||||
*/
|
||||
public String getMessage() {
|
||||
return message_;
|
||||
}
|
||||
/** Returns the column start index of the marker
|
||||
* @return the column_
|
||||
*/
|
||||
public int getColumnStart() {
|
||||
return columnStart_;
|
||||
}
|
||||
/** Returns the column end index of the marker
|
||||
* @return the columnEnd_
|
||||
*/
|
||||
public int getColumnEnd() {
|
||||
return columnEnd_;
|
||||
}
|
||||
/**
|
||||
* @return the type of the marker
|
||||
*/
|
||||
public MarkerTokenType getType() {
|
||||
return type_;
|
||||
}
|
||||
}
|
||||
enum MarkerTokenType
|
||||
{
|
||||
ERROR, WARNING, INFO;
|
||||
public int toMarkerSeverity()
|
||||
{
|
||||
if (this == ERROR)
|
||||
return IMarker.SEVERITY_ERROR;
|
||||
else if (this == WARNING)
|
||||
return IMarker.SEVERITY_WARNING;
|
||||
|
||||
return IMarker.SEVERITY_INFO;
|
||||
}
|
||||
}
|
|
@ -17,7 +17,6 @@ import java.util.Map;
|
|||
|
||||
import org.eclipse.core.resources.IContainer;
|
||||
import org.eclipse.core.resources.IFile;
|
||||
import org.eclipse.core.resources.IMarker;
|
||||
import org.eclipse.core.resources.IProject;
|
||||
import org.eclipse.core.resources.IResource;
|
||||
import org.eclipse.core.resources.IResourceDelta;
|
||||
|
@ -27,7 +26,6 @@ import org.eclipse.core.resources.IncrementalProjectBuilder;
|
|||
import org.eclipse.core.runtime.CoreException;
|
||||
import org.eclipse.core.runtime.IProgressMonitor;
|
||||
import org.eclipse.core.runtime.Path;
|
||||
import org.eclipse.jface.text.IDocument;
|
||||
import org.wesnoth.Constants;
|
||||
import org.wesnoth.Logger;
|
||||
import org.wesnoth.preferences.Preferences;
|
||||
|
@ -189,7 +187,6 @@ public class WesnothProjectBuilder extends IncrementalProjectBuilder
|
|||
try
|
||||
{
|
||||
IFile file = (IFile) resource;
|
||||
deleteMarkers(file);
|
||||
|
||||
monitor.subTask("Preprocessing file " + file.getName() + " ...");
|
||||
|
||||
|
@ -302,44 +299,6 @@ public class WesnothProjectBuilder extends IncrementalProjectBuilder
|
|||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds the specified MarkerToken in the selected file
|
||||
* @param file
|
||||
* @param token
|
||||
* @param document
|
||||
*/
|
||||
private void addMarker(IFile file, MarkerToken token, IDocument document)
|
||||
{
|
||||
try
|
||||
{
|
||||
IMarker marker = file.createMarker(Constants.BUILDER_MARKER_TYPE);
|
||||
marker.setAttribute(IMarker.MESSAGE, token.getMessage());
|
||||
if (token.getColumnEnd() != 0)
|
||||
{
|
||||
marker.setAttribute(IMarker.CHAR_START,
|
||||
document.getLineOffset(token.getLine() - 1) + token.getColumnStart());
|
||||
marker.setAttribute(IMarker.CHAR_END,
|
||||
document.getLineOffset(token.getLine() - 1) + token.getColumnEnd());
|
||||
}
|
||||
marker.setAttribute(IMarker.LINE_NUMBER, token.getLine());
|
||||
marker.setAttribute(IMarker.SEVERITY,token.getType().toMarkerSeverity());
|
||||
} catch (Exception e)
|
||||
{
|
||||
Logger.getInstance().logException(e);
|
||||
}
|
||||
}
|
||||
|
||||
private void deleteMarkers(IFile file)
|
||||
{
|
||||
try
|
||||
{
|
||||
file.deleteMarkers(Constants.BUILDER_MARKER_TYPE, false, IResource.DEPTH_ZERO);
|
||||
} catch (CoreException e)
|
||||
{
|
||||
Logger.getInstance().logException(e);
|
||||
}
|
||||
}
|
||||
|
||||
class ResourceDeltaVisitor implements IResourceDeltaVisitor
|
||||
{
|
||||
private IProgressMonitor monitor_;
|
||||
|
|
|
@ -21,6 +21,19 @@ public class TestHandler extends AbstractHandler
|
|||
@Override
|
||||
public Object execute(ExecutionEvent event) throws ExecutionException
|
||||
{
|
||||
// IFile file = ResourcesPlugin.getWorkspace().getRoot().getFileForLocation(new Path("E:\\work\\java\\runtime-EclipseApplication\\A_Simple_Campaign\\scenarios\\atemplate.cfg"));
|
||||
// try
|
||||
// {
|
||||
// file.deleteMarkers(Constants.MARKER_WMLSCOPE, false, IResource.DEPTH_INFINITE);
|
||||
// IMarker a= file.createMarker(Constants.MARKER_WMLLINT);
|
||||
// a.setAttribute(IMarker.LINE_NUMBER, 3);
|
||||
// a.setAttribute(IMarker.SEVERITY, IMarker.SEVERITY_WARNING);
|
||||
// }
|
||||
// catch (CoreException e)
|
||||
// {
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
|
||||
// DialogSettings set = new DialogSettings("proj");
|
||||
// IDialogSettings section2 = set.addNewSection("scenario");
|
||||
// section2.put("filename", "name");
|
||||
|
@ -221,3 +234,4 @@ public class TestHandler extends AbstractHandler
|
|||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -38,7 +38,7 @@ public class Preferences extends AbstractPreferenceInitializer
|
|||
store.setDefault(Constants.P_WMLLINT_VERBOSE_LEVEL, 0);
|
||||
|
||||
store.setDefault(Constants.P_WMLSCOPE_VERBOSE_LEVEL, 0);
|
||||
store.setDefault(Constants.P_WMLSCOPE_COLLISIONS, true);
|
||||
store.setDefault(Constants.P_WMLSCOPE_COLLISIONS, false);
|
||||
|
||||
// upload manager
|
||||
store.setDefault(Constants.P_WAU_PASSWORD, "");
|
||||
|
|
|
@ -26,14 +26,17 @@ import javax.xml.parsers.SAXParserFactory;
|
|||
import org.eclipse.core.resources.IContainer;
|
||||
import org.eclipse.core.resources.IFile;
|
||||
import org.eclipse.core.resources.IFolder;
|
||||
import org.eclipse.core.resources.IMarker;
|
||||
import org.eclipse.core.resources.IProject;
|
||||
import org.eclipse.core.resources.IResource;
|
||||
import org.eclipse.core.resources.ResourcesPlugin;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
import org.eclipse.core.runtime.IStatus;
|
||||
import org.eclipse.core.runtime.NullProgressMonitor;
|
||||
import org.eclipse.core.runtime.Path;
|
||||
import org.eclipse.jface.dialogs.DialogSettings;
|
||||
import org.eclipse.swt.SWT;
|
||||
import org.wesnoth.Constants;
|
||||
import org.wesnoth.Logger;
|
||||
import org.wesnoth.templates.ReplaceableParameter;
|
||||
import org.wesnoth.templates.TemplateProvider;
|
||||
|
@ -41,7 +44,6 @@ import org.xml.sax.InputSource;
|
|||
import org.xml.sax.SAXException;
|
||||
import org.xml.sax.helpers.DefaultHandler;
|
||||
|
||||
|
||||
public class ResourceUtils
|
||||
{
|
||||
/**
|
||||
|
@ -475,4 +477,67 @@ public class ResourceUtils
|
|||
String fileContentString = ResourceUtils.getFileContents(new File(fileName));
|
||||
return (fileContentString.contains("[scenario]") && fileContentString.contains("[/scenario]"));
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes all markers of type specified from the resource
|
||||
* @param resource
|
||||
* @param type
|
||||
*/
|
||||
public static void deleteMarkers(IResource resource, String type)
|
||||
{
|
||||
try
|
||||
{
|
||||
resource.deleteMarkers(type, false, IResource.DEPTH_INFINITE);
|
||||
} catch (CoreException e)
|
||||
{
|
||||
Logger.getInstance().logException(e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Parses the current line of the file and add the marker (if any) on the file.
|
||||
* Current used format: "sourcefile", line x: error message
|
||||
* @param line the line to parse
|
||||
* @param type the created marker or null if there was none
|
||||
* @return
|
||||
*/
|
||||
public static IMarker addMarkerForLine(String line, String type)
|
||||
{
|
||||
// error template, is the one used by GCC:
|
||||
// "sourcefile", line <linenumber>: error message
|
||||
try
|
||||
{
|
||||
final String pivot = ", line ";
|
||||
int pivotIndex = line.indexOf(pivot, 2);
|
||||
System.out.println(line);
|
||||
String sourceFile = line.substring(1, pivotIndex - 1);
|
||||
int lineNumber = Integer.parseInt(
|
||||
line.substring(pivotIndex + pivot.length(),
|
||||
line.indexOf(":", pivotIndex + pivot.length() + 1)));
|
||||
String message = line.substring(line.indexOf(" ", pivotIndex + pivot.length() + 1));
|
||||
|
||||
// Get the file
|
||||
IFile file = ResourcesPlugin.getWorkspace().getRoot().
|
||||
getFileForLocation(new Path(sourceFile));
|
||||
if (file.exists() == false)
|
||||
return null;
|
||||
|
||||
IMarker marker = file.createMarker(type);
|
||||
marker.setAttribute(IMarker.SOURCE_ID, sourceFile);
|
||||
marker.setAttribute(IMarker.MESSAGE, message);
|
||||
marker.setAttribute(IMarker.LINE_NUMBER, lineNumber);
|
||||
|
||||
// wmllint should be info or warning
|
||||
if (type.equals(Constants.MARKER_WMLLINT))
|
||||
marker.setAttribute(IMarker.SEVERITY, IMarker.SEVERITY_INFO);
|
||||
else
|
||||
marker.setAttribute(IMarker.SEVERITY, IMarker.SEVERITY_ERROR);
|
||||
return marker;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Logger.getInstance().logException(e);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -18,6 +18,7 @@ import java.util.List;
|
|||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
import org.eclipse.core.resources.IFile;
|
||||
import org.eclipse.core.resources.IResource;
|
||||
import org.eclipse.core.resources.WorkspaceJob;
|
||||
import org.eclipse.core.runtime.IProgressMonitor;
|
||||
import org.eclipse.core.runtime.IStatus;
|
||||
|
@ -118,9 +119,9 @@ public class WMLTools
|
|||
* @param resourcePath the full path of the target where "wmllint" will be runned on
|
||||
* @param dryrun true to run "wmllint" in dry mode - i.e. no changes in the config file.
|
||||
*/
|
||||
public static ExternalToolInvoker runWMLLint(String resourcePath, boolean dryrun)
|
||||
public static ExternalToolInvoker runWMLLint(String resourcePath, boolean dryrun, boolean showProgress)
|
||||
{
|
||||
return runWMLLint(resourcePath, dryrun, new OutputStream[0], new OutputStream[0]);
|
||||
return runWMLLint(resourcePath, dryrun, showProgress, new OutputStream[0], new OutputStream[0]);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -132,7 +133,7 @@ public class WMLTools
|
|||
* @param stderr The array of streams where to output the stderr content
|
||||
*/
|
||||
public static ExternalToolInvoker runWMLLint(String resourcePath, boolean dryrun,
|
||||
OutputStream[] stdout, OutputStream[] stderr)
|
||||
boolean showProgress, OutputStream[] stdout, OutputStream[] stderr)
|
||||
{
|
||||
if (!checkPrerequisites(resourcePath, "wmllint"))
|
||||
return null;
|
||||
|
@ -148,7 +149,7 @@ public class WMLTools
|
|||
for(int i=1; i <= verboseLevel; i++)
|
||||
arguments.add("-v");
|
||||
|
||||
if (verboseLevel <= 1)
|
||||
if (verboseLevel <= 0 && showProgress)
|
||||
arguments.add("--progress");
|
||||
|
||||
if (dryrun || Preferences.getBool(Constants.P_WMLLINT_DRYRUN) == true)
|
||||
|
@ -171,9 +172,9 @@ public class WMLTools
|
|||
* @param resourcePath the full path of the target where "wmlindent" will be runned on
|
||||
* @return
|
||||
*/
|
||||
public static ExternalToolInvoker runWMLScope(String resourcePath)
|
||||
public static ExternalToolInvoker runWMLScope(String resourcePath, boolean showProgress)
|
||||
{
|
||||
return runWMLScope(resourcePath, new OutputStream[0], new OutputStream[0]);
|
||||
return runWMLScope(resourcePath, showProgress, new OutputStream[0], new OutputStream[0]);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -184,7 +185,7 @@ public class WMLTools
|
|||
* @param stderr The array of streams where to output the stderr content
|
||||
* @return
|
||||
*/
|
||||
public static ExternalToolInvoker runWMLScope(String resourcePath,
|
||||
public static ExternalToolInvoker runWMLScope(String resourcePath, boolean showProgress,
|
||||
OutputStream[] stdout, OutputStream[] stderr)
|
||||
{
|
||||
if (!checkPrerequisites(resourcePath, "wmlscope"))
|
||||
|
@ -198,18 +199,19 @@ public class WMLTools
|
|||
arguments.add(wmlscopeFile.getAbsolutePath());
|
||||
int verboseLevel = Preferences.getInt(Constants.P_WMLSCOPE_VERBOSE_LEVEL);
|
||||
|
||||
if (verboseLevel == 0)
|
||||
arguments.add("--progress");
|
||||
else
|
||||
if (verboseLevel > 0)
|
||||
{
|
||||
arguments.add("-w");
|
||||
arguments.add(String.valueOf(verboseLevel));
|
||||
}
|
||||
else if (showProgress)
|
||||
arguments.add("--progress");
|
||||
|
||||
if (Preferences.getBool(Constants.P_WMLSCOPE_COLLISIONS) == true)
|
||||
arguments.add("--collisions");
|
||||
|
||||
arguments.add("--crossreference");
|
||||
arguments.add("--unchecked");
|
||||
arguments.add("--unresolved");
|
||||
|
||||
// add default core directory
|
||||
arguments.add(Preferences.getString(Constants.P_WESNOTH_WORKING_DIR) +
|
||||
|
@ -264,6 +266,7 @@ public class WMLTools
|
|||
OutputStream[] stderr = new OutputStream[]{ console.newMessageStream() };
|
||||
|
||||
String location;
|
||||
IResource resource = null;
|
||||
|
||||
IFile selFile = WorkspaceUtils.getSelectedFile();
|
||||
if (targetPath != null)
|
||||
|
@ -271,9 +274,15 @@ public class WMLTools
|
|||
else
|
||||
{
|
||||
if (selFile != null)
|
||||
{
|
||||
location = selFile.getLocation().toOSString();
|
||||
resource = selFile;
|
||||
}
|
||||
else
|
||||
location = WorkspaceUtils.getSelectedContainer().getLocation().toOSString();
|
||||
{
|
||||
resource = WorkspaceUtils.getSelectedContainer();
|
||||
location = resource.getLocation().toOSString();
|
||||
}
|
||||
}
|
||||
|
||||
switch(tool)
|
||||
|
@ -291,10 +300,10 @@ public class WMLTools
|
|||
stdout, stderr);
|
||||
break;
|
||||
case WMLLINT:
|
||||
toolInvoker = WMLTools.runWMLLint(location, true, stdout, stderr);
|
||||
toolInvoker = WMLTools.runWMLLint(location, true, false, stdout, stderr);
|
||||
break;
|
||||
case WMLSCOPE:
|
||||
toolInvoker = WMLTools.runWMLScope(location, stdout, stderr);
|
||||
toolInvoker = WMLTools.runWMLScope(location, false, stdout, stderr);
|
||||
break;
|
||||
}
|
||||
monitor.worked(50);
|
||||
|
@ -335,10 +344,25 @@ public class WMLTools
|
|||
stderrWatcher.start();
|
||||
stdoutWatcher.start();
|
||||
toolInvoker.waitForTool();
|
||||
if (selFile != null && targetPath == null)
|
||||
if (tool == Tools.WMLINDENT &&
|
||||
selFile != null && targetPath == null)
|
||||
{
|
||||
EditorUtils.replaceEditorText(toolInvoker.getOutputContent());
|
||||
}
|
||||
|
||||
if (tool == Tools.WMLSCOPE)
|
||||
{
|
||||
if (resource != null)
|
||||
resource.deleteMarkers(Constants.MARKER_WMLSCOPE, false, IResource.DEPTH_INFINITE);
|
||||
parseAndAddMarkers(toolInvoker.getOutputContent(), Constants.MARKER_WMLSCOPE);
|
||||
}
|
||||
else if (tool == Tools.WMLLINT)
|
||||
{
|
||||
if (resource != null)
|
||||
resource.deleteMarkers(Constants.MARKER_WMLLINT, false, IResource.DEPTH_INFINITE);
|
||||
parseAndAddMarkers(toolInvoker.getOutputContent(), Constants.MARKER_WMLLINT);
|
||||
}
|
||||
|
||||
monitor.worked(50);
|
||||
monitor.done();
|
||||
}
|
||||
|
@ -390,6 +414,32 @@ public class WMLTools
|
|||
return runPythonScript(arguments, null, true, true, stdout, stderr);
|
||||
}
|
||||
|
||||
/**
|
||||
* Parses the output and adds markers accordingly
|
||||
*/
|
||||
public static void parseAndAddMarkers(String output, String markerType)
|
||||
{
|
||||
String[] lines = StringUtils.getLines(output);
|
||||
boolean startMD5 = false;
|
||||
for(String line : lines)
|
||||
{
|
||||
if (line.startsWith("#") ||
|
||||
line.matches("^[\\t ]*$") ||
|
||||
line.startsWith("wmllint:"))
|
||||
continue;
|
||||
if (line.startsWith("%%"))
|
||||
{
|
||||
startMD5 = !startMD5;
|
||||
continue;
|
||||
}
|
||||
// skip parsing collisions
|
||||
if (startMD5)
|
||||
continue;
|
||||
|
||||
ResourceUtils.addMarkerForLine(line, markerType);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if a wmlTool (that is in the wml tools directory) and
|
||||
* an additional file that is target of the tool exist / are valid.
|
||||
|
@ -436,6 +486,8 @@ public class WMLTools
|
|||
* @param stdin A string that will be written to stdin of the python script
|
||||
* @param stdout An array of streams where to write the stdout from the script
|
||||
* @param stderr An array of streams where to write the stderr from the script
|
||||
* @param stderrMonitoring True to start stderr monitoring on tool
|
||||
* @param stdoutMonitoring True to start stdout monitoring on tool
|
||||
* @return
|
||||
*/
|
||||
public static ExternalToolInvoker runPythonScript(List<String> arguments, String stdin,
|
||||
|
|
|
@ -182,6 +182,7 @@ public class WorkspaceUtils
|
|||
return (IContainer) selection.getFirstElement();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Gets the selected resource(file/folder/project) or null if none selected
|
||||
* @return
|
||||
|
|
Loading…
Add table
Reference in a new issue