Author: timotei
Date: Tue Aug 2 21:35:10 2011
New Revision: 50569
URL: http://svn.gna.org/viewcvs/wesnoth?rev=50569&view=rev
Log:
eclipse plugin: Add a new parameter for install name
for the wml tools
Modified:
trunk/utils/umc_dev/org.wesnoth/src/org/wesnoth/builder/WesnothProjectBuilder.java
trunk/utils/umc_dev/org.wesnoth/src/org/wesnoth/preprocessor/Define.java
trunk/utils/umc_dev/org.wesnoth/src/org/wesnoth/projects/ProjectCache.java
trunk/utils/umc_dev/org.wesnoth/src/org/wesnoth/utils/ResourceUtils.java
trunk/utils/umc_dev/org.wesnoth/src/org/wesnoth/utils/WMLTools.java
Modified:
trunk/utils/umc_dev/org.wesnoth/src/org/wesnoth/builder/WesnothProjectBuilder.java
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/utils/umc_dev/org.wesnoth/src/org/wesnoth/builder/WesnothProjectBuilder.java?rev=50569&r1=50568&r2=50569&view=diff
==============================================================================
---
trunk/utils/umc_dev/org.wesnoth/src/org/wesnoth/builder/WesnothProjectBuilder.java
(original)
+++
trunk/utils/umc_dev/org.wesnoth/src/org/wesnoth/builder/WesnothProjectBuilder.java
Tue Aug 2 21:35:10 2011
@@ -19,13 +19,6 @@
import java.util.Queue;
import java.util.concurrent.LinkedBlockingDeque;
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.resources.IResourceDelta;
-import org.eclipse.core.resources.IncrementalProjectBuilder;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IProgressMonitor;
import org.wesnoth.Constants;
import org.wesnoth.Logger;
import org.wesnoth.Messages;
@@ -43,6 +36,14 @@
import org.wesnoth.utils.WorkspaceUtils;
import org.wesnoth.wml.SimpleWMLParser;
import org.wesnoth.wml.WMLConfig;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.IResourceDelta;
+import org.eclipse.core.resources.IncrementalProjectBuilder;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
/**
* The builder does the following steps in order to create and ensure
@@ -324,10 +325,11 @@
}
@SuppressWarnings( "unused" )
- private void runWMLLint( IProgressMonitor monitor, IFile file )
+ private void runWMLLint( String installName, IProgressMonitor monitor,
IFile file )
{
monitor.subTask( String.format( "Running WMLlint on file %s ...",
file.getName( ) ) );
- ExternalToolInvoker tool =
WMLTools.runWMLLint(file.getLocation().toOSString(), false, false);
+ ExternalToolInvoker tool = WMLTools.runWMLLint( installName,
+ file.getLocation().toOSString(), false, false );
tool.waitForTool();
try {
@@ -351,10 +353,11 @@
* @throws CoreException
*/
@SuppressWarnings( "unused" )
- private void runWMLScope( IProgressMonitor monitor, IFile file )
+ private void runWMLScope( String installName, IProgressMonitor monitor,
IFile file )
{
monitor.subTask( String.format( "Running WMLScope on file %s ...",
file.getName( ) ) );
- ExternalToolInvoker tool = WMLTools.runWMLScope(
file.getLocation().toOSString(), false );
+ ExternalToolInvoker tool = WMLTools.runWMLScope( installName,
+ file.getLocation().toOSString(), false );
tool.waitForTool();
try {
Modified:
trunk/utils/umc_dev/org.wesnoth/src/org/wesnoth/preprocessor/Define.java
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/utils/umc_dev/org.wesnoth/src/org/wesnoth/preprocessor/Define.java?rev=50569&r1=50568&r2=50569&view=diff
==============================================================================
--- trunk/utils/umc_dev/org.wesnoth/src/org/wesnoth/preprocessor/Define.java
(original)
+++ trunk/utils/umc_dev/org.wesnoth/src/org/wesnoth/preprocessor/Define.java
Tue Aug 2 21:35:10 2011
@@ -103,10 +103,11 @@
* @param file
* @return Returns a map of defines
*/
- public static Map<String, Define> readDefines(String file)
+ public static Map<String, Define> readDefines( String installName,
String file )
{
DefinesSAXHandler handler = (DefinesSAXHandler) ResourceUtils.
- getWMLSAXHandlerFromResource(file, new
DefinesSAXHandler());
+ getWMLSAXHandlerFromResource( installName, file,
+ new DefinesSAXHandler( ) );
if (handler != null){
Logger.getInstance().log("loaded " +
handler.getDefines().size() + " defines for file:" + file); //$NON-NLS-1$
//$NON-NLS-1$ //$NON-NLS-2$
Modified:
trunk/utils/umc_dev/org.wesnoth/src/org/wesnoth/projects/ProjectCache.java
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/utils/umc_dev/org.wesnoth/src/org/wesnoth/projects/ProjectCache.java?rev=50569&r1=50568&r2=50569&view=diff
==============================================================================
--- trunk/utils/umc_dev/org.wesnoth/src/org/wesnoth/projects/ProjectCache.java
(original)
+++ trunk/utils/umc_dev/org.wesnoth/src/org/wesnoth/projects/ProjectCache.java
Tue Aug 2 21:35:10 2011
@@ -21,7 +21,6 @@
import java.util.Map;
import java.util.Set;
-import org.eclipse.core.resources.IProject;
import org.wesnoth.Constants;
import org.wesnoth.Logger;
import org.wesnoth.builder.DependencyListBuilder;
@@ -33,6 +32,8 @@
import org.wesnoth.wml.WMLTag;
import org.wesnoth.wml.WMLVariable;
+import org.eclipse.core.resources.IProject;
+
/**
* A class that stores some project specific infos
* for current session.
@@ -202,7 +203,7 @@
if (definesFile_.exists() == false)
return;
- defines_ = Define.readDefines(definesFile_.getAbsolutePath());
+ defines_ = Define.readDefines( getInstallName( ),
definesFile_.getAbsolutePath( ) );
definesTimestamp_ = definesFile_.lastModified( );
}
Modified:
trunk/utils/umc_dev/org.wesnoth/src/org/wesnoth/utils/ResourceUtils.java
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/utils/umc_dev/org.wesnoth/src/org/wesnoth/utils/ResourceUtils.java?rev=50569&r1=50568&r2=50569&view=diff
==============================================================================
--- trunk/utils/umc_dev/org.wesnoth/src/org/wesnoth/utils/ResourceUtils.java
(original)
+++ trunk/utils/umc_dev/org.wesnoth/src/org/wesnoth/utils/ResourceUtils.java
Tue Aug 2 21:35:10 2011
@@ -27,6 +27,19 @@
import javax.xml.parsers.SAXParser;
import javax.xml.parsers.SAXParserFactory;
+
+import org.wesnoth.Constants;
+import org.wesnoth.Logger;
+import org.wesnoth.Messages;
+import org.wesnoth.builder.DependencyListNode;
+import org.wesnoth.preferences.Preferences.Paths;
+import org.wesnoth.projects.ProjectUtils;
+import org.wesnoth.templates.ReplaceableParameter;
+import org.wesnoth.templates.TemplateProvider;
+import org.wesnoth.wml.SimpleWMLParser;
+import org.wesnoth.wml.WMLMacroCall;
+import org.wesnoth.wml.WMLRoot;
+import org.wesnoth.wml.WmlFactory2;
import org.eclipse.core.resources.IContainer;
import org.eclipse.core.resources.IFile;
@@ -47,18 +60,7 @@
import org.eclipse.emf.ecore.resource.ResourceSet;
import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
import org.eclipse.swt.SWT;
-import org.wesnoth.Constants;
-import org.wesnoth.Logger;
-import org.wesnoth.Messages;
-import org.wesnoth.builder.DependencyListNode;
-import org.wesnoth.preferences.Preferences.Paths;
-import org.wesnoth.projects.ProjectUtils;
-import org.wesnoth.templates.ReplaceableParameter;
-import org.wesnoth.templates.TemplateProvider;
-import org.wesnoth.wml.SimpleWMLParser;
-import org.wesnoth.wml.WMLMacroCall;
-import org.wesnoth.wml.WMLRoot;
-import org.wesnoth.wml.WmlFactory2;
+
import org.xml.sax.InputSource;
import org.xml.sax.SAXException;
import org.xml.sax.helpers.DefaultHandler;
@@ -491,10 +493,10 @@
* @param saxHandler The SAX Handler used to handle the parsed wml
* @return
*/
- public static DefaultHandler getWMLSAXHandlerFromResource(String
resourcePath,
- DefaultHandler saxHandler)
- {
- ExternalToolInvoker parser =
WMLTools.runWMLParser2(resourcePath);
+ public static DefaultHandler getWMLSAXHandlerFromResource( String
installName,
+ String resourcePath, DefaultHandler saxHandler)
+ {
+ ExternalToolInvoker parser = WMLTools.runWMLParser2(
installName, resourcePath);
if (parser == null)
return null;
try{
Modified: trunk/utils/umc_dev/org.wesnoth/src/org/wesnoth/utils/WMLTools.java
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/utils/umc_dev/org.wesnoth/src/org/wesnoth/utils/WMLTools.java?rev=50569&r1=50568&r2=50569&view=diff
==============================================================================
--- trunk/utils/umc_dev/org.wesnoth/src/org/wesnoth/utils/WMLTools.java
(original)
+++ trunk/utils/umc_dev/org.wesnoth/src/org/wesnoth/utils/WMLTools.java Tue Aug
2 21:35:10 2011
@@ -19,6 +19,13 @@
import java.util.Locale;
import java.util.concurrent.atomic.AtomicInteger;
+import org.wesnoth.Constants;
+import org.wesnoth.Logger;
+import org.wesnoth.Messages;
+import org.wesnoth.installs.WesnothInstallsUtils;
+import org.wesnoth.preferences.Preferences;
+import org.wesnoth.preferences.Preferences.Paths;
+
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.WorkspaceJob;
@@ -27,12 +34,6 @@
import org.eclipse.core.runtime.Status;
import org.eclipse.ui.IEditorReference;
import org.eclipse.ui.console.MessageConsole;
-import org.wesnoth.Constants;
-import org.wesnoth.Logger;
-import org.wesnoth.Messages;
-import org.wesnoth.installs.WesnothInstallsUtils;
-import org.wesnoth.preferences.Preferences;
-import org.wesnoth.preferences.Preferences.Paths;
public class WMLTools
{
@@ -46,10 +47,11 @@
* @param stderr The array of streams where to output the stderr content
* @return null if there were errors or an ExternalToolInvoker instance
*/
- public static ExternalToolInvoker runWMLIndent(String resourcePath,
String stdin,
- boolean dryrun, OutputStream[] stdout, OutputStream[]
stderr)
- {
- Paths paths = Preferences.getPaths(
WesnothInstallsUtils.getInstallNameForResource( resourcePath ) );
+ public static ExternalToolInvoker runWMLIndent( String installName,
+ String resourcePath, String stdin, boolean dryrun,
+ OutputStream[] stdout, OutputStream[] stderr )
+ {
+ Paths paths = Preferences.getPaths( installName );
//wmlindent only check first
if ( !checkWMLTool( paths, Tools.WMLINDENT.toString( ) ) )
//$NON-NLS-1$
@@ -82,9 +84,10 @@
* @param resourcePath
* @return null if there were errors or an ExternalToolInvoker instance
*/
- public static ExternalToolInvoker runWMLParser2(String resourcePath)
- {
- Paths paths = Preferences.getPaths(
WesnothInstallsUtils.getInstallNameForResource( resourcePath ) );
+ public static ExternalToolInvoker runWMLParser2( String installName,
+ String resourcePath )
+ {
+ Paths paths = Preferences.getPaths( installName );
if ( !ResourceUtils.isValidFilePath( resourcePath ) ||
!checkWMLTool( paths, "wesnoth/wmlparser2.py" ) ) //$NON-NLS-1$
@@ -129,9 +132,11 @@
* @param showProgress true to show the progress of the tool
* @return null if there were errors or an ExternalToolInvoker instance
*/
- public static ExternalToolInvoker runWMLLint(String resourcePath,
boolean dryrun, boolean showProgress)
- {
- return runWMLLint(resourcePath, dryrun, showProgress, new
OutputStream[0], new OutputStream[0]);
+ public static ExternalToolInvoker runWMLLint( String installName,
+ String resourcePath, boolean dryrun, boolean showProgress )
+ {
+ return runWMLLint( installName, resourcePath, dryrun,
showProgress,
+ new OutputStream[0], new OutputStream[0]);
}
/**
@@ -143,10 +148,11 @@
* @param stdout The array of streams where to output the stdout content
* @param stderr The array of streams where to output the stderr content
*/
- public static ExternalToolInvoker runWMLLint(String resourcePath,
boolean dryrun,
- boolean showProgress, OutputStream[] stdout,
OutputStream[] stderr)
- {
- Paths paths = Preferences.getPaths(
WesnothInstallsUtils.getInstallNameForResource( resourcePath ) );
+ public static ExternalToolInvoker runWMLLint( String installName,
+ String resourcePath, boolean dryrun, boolean showProgress,
+ OutputStream[] stdout, OutputStream[] stderr )
+ {
+ Paths paths = Preferences.getPaths( installName );
if ( !ResourceUtils.isValidFilePath( resourcePath ) ||
!checkWMLTool( paths, Tools.WMLLINT.toString( ) ) )
@@ -184,9 +190,11 @@
* @param resourcePath the full path of the target where "wmlindent"
will be runned on
* @return null if there were errors or an ExternalToolInvoker instance
*/
- public static ExternalToolInvoker runWMLScope(String resourcePath,
boolean showProgress)
- {
- return runWMLScope(resourcePath, showProgress, new
OutputStream[0], new OutputStream[0]);
+ public static ExternalToolInvoker runWMLScope( String installName,
+ String resourcePath, boolean showProgress )
+ {
+ return runWMLScope( installName, resourcePath, showProgress,
+ new OutputStream[0], new OutputStream[0] );
}
/**
@@ -197,10 +205,11 @@
* @param stderr The array of streams where to output the stderr content
* @return null if there were errors or an ExternalToolInvoker instance
*/
- public static ExternalToolInvoker runWMLScope(String resourcePath,
boolean showProgress,
- OutputStream[] stdout, OutputStream[] stderr)
- {
- Paths paths = Preferences.getPaths(
WesnothInstallsUtils.getInstallNameForResource( resourcePath ) );
+ public static ExternalToolInvoker runWMLScope( String installName,
+ String resourcePath, boolean showProgress,
+ OutputStream[] stdout, OutputStream[] stderr )
+ {
+ Paths paths = Preferences.getPaths( installName );
if ( !ResourceUtils.isValidFilePath( resourcePath ) ||
!checkWMLTool( paths, Tools.WMLSCOPE.toString( ) ) )
@@ -241,8 +250,9 @@
* @param targetPath If this is not null if will use the targetpath as
the
* argument for launching the tool
*/
- public static void runWMLToolAsWorkspaceJob(final Tools tool, final
String targetPath)
- {
+ public static void runWMLToolAsWorkspaceJob( final Tools tool, final
String targetPath )
+ {
+ //TODO: remove/rework this hackish method.
if (tool == Tools.WESNOTH_ADDON_MANAGER)
return;
@@ -280,6 +290,7 @@
String location;
IResource resource = null;
+ String installName =
Preferences.getDefaultInstallName( );
IFile selFile =
WorkspaceUtils.getSelectedFile();
if (targetPath != null)
@@ -296,6 +307,8 @@
resource =
WorkspaceUtils.getSelectedContainer();
location =
resource.getLocation().toOSString();
}
+
+ installName =
WesnothInstallsUtils.getInstallNameForResource( resource );
}
switch(tool)
@@ -305,18 +318,20 @@
{
String stdin =
EditorUtils.getEditorDocument().get();
// don't output
to stdout as we will put that in the editor
- toolInvoker =
WMLTools.runWMLIndent(null, stdin, false,
-
null, stdout);
+ toolInvoker =
WMLTools.runWMLIndent( installName,
+ null,
stdin, false, null, stdout );
}
else
- toolInvoker =
WMLTools.runWMLIndent(location, null, false,
-
stdout, stderr);
+ toolInvoker =
WMLTools.runWMLIndent( installName,
+
location, null, false, stdout, stderr );
break;
case WMLLINT:
- toolInvoker =
WMLTools.runWMLLint(location, true, false, stdout, stderr);
+ toolInvoker =
WMLTools.runWMLLint( installName,
+ location, true,
false, stdout, stderr );
break;
case WMLSCOPE:
- toolInvoker =
WMLTools.runWMLScope(location, false, stdout, stderr);
+ toolInvoker =
WMLTools.runWMLScope( installName,
+ location,
false, stdout, stderr );
break;
}
monitor.worked(50);
_______________________________________________
Wesnoth-commits mailing list
[email protected]
https://mail.gna.org/listinfo/wesnoth-commits