Author: timotei
Date: Tue Jul 26 17:27:10 2011
New Revision: 50412
URL: http://svn.gna.org/viewcvs/wesnoth?rev=50412&view=rev
Log:
eclipse plugin: Switch over to using a Multimap
for storing the variables in each WML Config fil
Added:
trunk/utils/umc_dev/org.wesnoth/src/org/wesnoth/wml/core/WMLVariable.java
- copied, changed from r50411,
trunk/utils/umc_dev/org.wesnoth/src/org/wesnoth/wml/core/Variable.java
Removed:
trunk/utils/umc_dev/org.wesnoth/src/org/wesnoth/wml/core/Variable.java
Modified:
trunk/utils/umc_dev/org.wesnoth/src/org/wesnoth/projects/ProjectCache.java
trunk/utils/umc_dev/org.wesnoth/src/org/wesnoth/utils/WMLSaxHandler.java
trunk/utils/umc_dev/org.wesnoth/src/org/wesnoth/wml/core/SimpleWMLParser.java
trunk/utils/umc_dev/org.wesnoth/src/org/wesnoth/wml/core/WMLConfig.java
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=50412&r1=50411&r2=50412&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 Jul 26 17:27:10 2011
@@ -27,8 +27,8 @@
import org.wesnoth.preprocessor.PreprocessorUtils;
import org.wesnoth.utils.ResourceUtils;
import org.wesnoth.utils.WorkspaceUtils;
-import org.wesnoth.wml.core.Variable;
import org.wesnoth.wml.core.WMLConfig;
+import org.wesnoth.wml.core.WMLVariable;
/**
* A class that stores some project specific infos
@@ -119,8 +119,9 @@
{
if (variable.getName().startsWith("var") == false)
//$NON-NLS-1$
continue;
- tmp.getVariables().add(
- new Variable(variable.get("name"),
//$NON-NLS-1$
+ tmp.getVariables().put(
+ variable.get( "name" ),
+ new WMLVariable(variable.get("name"),
//$NON-NLS-1$
variable.get("location"), //$NON-NLS-1$
variable.getInt("offset")));
//$NON-NLS-1$
}
@@ -208,7 +209,7 @@
IDialogSettings variablesSection =
configSection.addNewSection("variables"); //$NON-NLS-1$
int varCnt = 0;
- for(Variable var : config.getVariables())
+ for(WMLVariable var : config.getVariables().values( ))
{
IDialogSettings varSection =
variablesSection.addNewSection("var" + varCnt); //$NON-NLS-1$
varSection.put("name", var.getName()); //$NON-NLS-1$
Modified:
trunk/utils/umc_dev/org.wesnoth/src/org/wesnoth/utils/WMLSaxHandler.java
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/utils/umc_dev/org.wesnoth/src/org/wesnoth/utils/WMLSaxHandler.java?rev=50412&r1=50411&r2=50412&view=diff
==============================================================================
--- trunk/utils/umc_dev/org.wesnoth/src/org/wesnoth/utils/WMLSaxHandler.java
(original)
+++ trunk/utils/umc_dev/org.wesnoth/src/org/wesnoth/utils/WMLSaxHandler.java
Tue Jul 26 17:27:10 2011
@@ -11,7 +11,7 @@
import java.util.Stack;
import org.wesnoth.wml.core.WMLConfig;
-import org.wesnoth.wml.core.Variable;
+import org.wesnoth.wml.core.WMLVariable;
import org.xml.sax.Attributes;
import org.xml.sax.SAXException;
import org.xml.sax.helpers.DefaultHandler;
@@ -23,7 +23,7 @@
public class WMLSaxHandler extends DefaultHandler
{
private Stack<String> stack_;
- private Variable tmpVar_;
+ private WMLVariable tmpVar_;
private String filePath_;
private WMLConfig cfg_;
@@ -50,12 +50,12 @@
if (rawName.equals("set_variable")) //$NON-NLS-1$
{
STATUS = SET_VARIABLE;
- tmpVar_ = new Variable();
+ tmpVar_ = new WMLVariable();
}
else if (rawName.equals("set_variables")) //$NON-NLS-1$
{
STATUS = SET_VARIABLE_ARRAY;
- tmpVar_ = new Variable();
+ tmpVar_ = new WMLVariable();
tmpVar_.setIsArray(true);
}
else if (rawName.equals("campaign")) //$NON-NLS-1$
@@ -101,7 +101,7 @@
tmpVar_.setOffset(start);
tmpVar_.setLocation(filePath_);
- cfg_.getVariables().add(tmpVar_);
+ cfg_.getVariables().put(name, tmpVar_);
}
}
}
Modified:
trunk/utils/umc_dev/org.wesnoth/src/org/wesnoth/wml/core/SimpleWMLParser.java
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/utils/umc_dev/org.wesnoth/src/org/wesnoth/wml/core/SimpleWMLParser.java?rev=50412&r1=50411&r2=50412&view=diff
==============================================================================
---
trunk/utils/umc_dev/org.wesnoth/src/org/wesnoth/wml/core/SimpleWMLParser.java
(original)
+++
trunk/utils/umc_dev/org.wesnoth/src/org/wesnoth/wml/core/SimpleWMLParser.java
Tue Jul 26 17:27:10 2011
@@ -14,8 +14,11 @@
import org.wesnoth.utils.ResourceUtils;
import org.wesnoth.utils.WMLUtils;
import org.wesnoth.wml.WMLKey;
+import org.wesnoth.wml.WMLMacroCall;
import org.wesnoth.wml.WMLRoot;
import org.wesnoth.wml.WMLTag;
+
+import com.google.common.base.Preconditions;
/**
* A simple WML Parser that parses a xtext WML Config file resource
@@ -39,10 +42,7 @@
*/
public SimpleWMLParser( IFile file, WMLConfig config )
{
- if ( config == null )
- throw new IllegalArgumentException( "The config must not be null."
);
-
- config_ = config;
+ config_ = Preconditions.checkNotNull( config );
file_ = file;
}
@@ -58,6 +58,7 @@
while ( itor.hasNext( ) ) {
EObject object = itor.next( );
+ System.out.println( object );
if ( object instanceof WMLTag ) {
currentTag = ( WMLTag ) object;
@@ -78,15 +79,35 @@
config_.ScenarioId = WMLUtils.getKeyValue(
key.getValue( ) );
else if ( currentTagName.equals( "campaign" ) )
config_.CampaignId = WMLUtils.getKeyValue(
key.getValue( ) );
+ } else if ( keyName.equals( "name" ) ) {
+ if ( currentTagName.equals( "set_variable" ) ||
+ currentTagName.equals( "set_variables" ) ) {
+ handleSetVariable( object );
+ }
}
+ }
+ }
+ else if ( object instanceof WMLMacroCall ) {
+ WMLMacroCall macroCall = ( WMLMacroCall ) object;
+ String macroCallName = macroCall.getName( );
+ if ( macroCallName.equals( "VARIABLE" ) ) {
+ handleSetVariable( object );
}
}
}
System.out.println( "parsed config: " + config_ );
+ }
+
+ protected void handleSetVariable( EObject context )
+ {
}
+ protected void handleUnsetVariable( EObject context )
+ {
+
+ }
public WMLConfig getParsedConfig()
{
Removed: trunk/utils/umc_dev/org.wesnoth/src/org/wesnoth/wml/core/Variable.java
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/utils/umc_dev/org.wesnoth/src/org/wesnoth/wml/core/Variable.java?rev=50411&view=auto
==============================================================================
--- trunk/utils/umc_dev/org.wesnoth/src/org/wesnoth/wml/core/Variable.java
(original)
+++ trunk/utils/umc_dev/org.wesnoth/src/org/wesnoth/wml/core/Variable.java
(removed)
@@ -1,65 +1,0 @@
-/*******************************************************************************
- * Copyright (c) 2010 - 2011 by Timotei Dolean <[email protected]>
- *
- * 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.wml.core;
-
-/**
- * Represents a WML Variable
- */
-public class Variable
-{
- private String name_;
- private String location_;
- private int offset_;
- private boolean isArray_;
-
- public Variable()
- {
- this("", "", 0); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- public Variable(String name, String location, int offset)
- {
- name_ = name;
- location_ = location;
- offset_ = offset;
- }
-
- public String getName()
- {
- return name_;
- }
- public void setName(String name)
- {
- name_ = name;
- }
- public String getLocation()
- {
- return location_;
- }
- public void setLocation(String location)
- {
- location_ = location;
- }
- public int getOffset()
- {
- return offset_;
- }
- public void setOffset(int offset)
- {
- offset_ = offset;
- }
- public boolean isArray()
- {
- return isArray_;
- }
- public void setIsArray(boolean isArray)
- {
- isArray_ = isArray;
- }
-}
Modified:
trunk/utils/umc_dev/org.wesnoth/src/org/wesnoth/wml/core/WMLConfig.java
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/utils/umc_dev/org.wesnoth/src/org/wesnoth/wml/core/WMLConfig.java?rev=50412&r1=50411&r2=50412&view=diff
==============================================================================
--- trunk/utils/umc_dev/org.wesnoth/src/org/wesnoth/wml/core/WMLConfig.java
(original)
+++ trunk/utils/umc_dev/org.wesnoth/src/org/wesnoth/wml/core/WMLConfig.java Tue
Jul 26 17:27:10 2011
@@ -8,8 +8,8 @@
*******************************************************************************/
package org.wesnoth.wml.core;
-import java.util.ArrayList;
-import java.util.List;
+import com.google.common.collect.ArrayListMultimap;
+import com.google.common.collect.Multimap;
/**
* A class that stores WML config file specific information
@@ -32,12 +32,12 @@
*/
public boolean IsCampaign;
- private List<Variable> variables_;
+ private Multimap<String, WMLVariable> variables_;
private String filename_;
public WMLConfig(String filename)
{
- variables_ = new ArrayList<Variable>();
+ variables_ = ArrayListMultimap.create( );
filename_ = filename;
}
@@ -46,7 +46,7 @@
return filename_;
}
- public List<Variable> getVariables()
+ public Multimap<String, WMLVariable> getVariables()
{
return variables_;
}
Copied:
trunk/utils/umc_dev/org.wesnoth/src/org/wesnoth/wml/core/WMLVariable.java (from
r50411, trunk/utils/umc_dev/org.wesnoth/src/org/wesnoth/wml/core/Variable.java)
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/utils/umc_dev/org.wesnoth/src/org/wesnoth/wml/core/WMLVariable.java?p2=trunk/utils/umc_dev/org.wesnoth/src/org/wesnoth/wml/core/WMLVariable.java&p1=trunk/utils/umc_dev/org.wesnoth/src/org/wesnoth/wml/core/Variable.java&r1=50411&r2=50412&rev=50412&view=diff
==============================================================================
--- trunk/utils/umc_dev/org.wesnoth/src/org/wesnoth/wml/core/Variable.java
(original)
+++ trunk/utils/umc_dev/org.wesnoth/src/org/wesnoth/wml/core/WMLVariable.java
Tue Jul 26 17:27:10 2011
@@ -11,19 +11,19 @@
/**
* Represents a WML Variable
*/
-public class Variable
+public class WMLVariable
{
private String name_;
private String location_;
private int offset_;
private boolean isArray_;
- public Variable()
+ public WMLVariable()
{
this("", "", 0); //$NON-NLS-1$ //$NON-NLS-2$
}
- public Variable(String name, String location, int offset)
+ public WMLVariable(String name, String location, int offset)
{
name_ = name;
location_ = location;
_______________________________________________
Wesnoth-commits mailing list
[email protected]
https://mail.gna.org/listinfo/wesnoth-commits