eclipse plugin: Migrate the remaining old-node model...
...class names to the new interfaces
This commit is contained in:
parent
e06e64fb44
commit
2b36faa0ff
10 changed files with 48 additions and 51 deletions
|
@ -10,24 +10,24 @@ package org.wesnoth.ui;
|
|||
|
||||
import org.eclipse.core.resources.IFile;
|
||||
import org.eclipse.emf.ecore.EObject;
|
||||
import org.eclipse.xtext.nodemodel.ICompositeNode;
|
||||
import org.eclipse.xtext.nodemodel.ILeafNode;
|
||||
import org.eclipse.xtext.nodemodel.INode;
|
||||
import org.eclipse.xtext.nodemodel.impl.CompositeNode;
|
||||
import org.eclipse.xtext.nodemodel.impl.LeafNode;
|
||||
import org.eclipse.xtext.ui.editor.utils.EditorUtils;
|
||||
|
||||
public class WMLUtil
|
||||
{
|
||||
public static String debug(EObject root)
|
||||
{
|
||||
CompositeNode node = NodeUtil.getNode(root);
|
||||
ICompositeNode node = NodeUtil.getNode(root);
|
||||
Iterable<INode> contents = NodeUtil.getAllContents(node);
|
||||
StringBuffer text = new StringBuffer();
|
||||
for (INode abstractNode : contents)
|
||||
{
|
||||
if (abstractNode instanceof LeafNode)
|
||||
if (abstractNode instanceof ILeafNode)
|
||||
{
|
||||
System.out.println((((LeafNode) abstractNode).getText()));
|
||||
text.append(((LeafNode) abstractNode).getText());
|
||||
System.out.println((((ILeafNode) abstractNode).getText()));
|
||||
text.append(((ILeafNode) abstractNode).getText());
|
||||
}
|
||||
}
|
||||
return text.toString();
|
||||
|
|
|
@ -16,7 +16,6 @@ import org.eclipse.jface.text.IDocument;
|
|||
import org.eclipse.xtext.nodemodel.ICompositeNode;
|
||||
import org.eclipse.xtext.nodemodel.ILeafNode;
|
||||
import org.eclipse.xtext.nodemodel.INode;
|
||||
import org.eclipse.xtext.nodemodel.impl.LeafNode;
|
||||
import org.eclipse.xtext.parser.IParseResult;
|
||||
import org.eclipse.xtext.resource.XtextResource;
|
||||
import org.eclipse.xtext.ui.editor.XtextEditor;
|
||||
|
@ -46,32 +45,32 @@ public class ClosingEndTagAutoEditStrategy implements IAutoEditStrategy
|
|||
if(parseResult == null)
|
||||
return;
|
||||
ICompositeNode rootNode = parseResult.getRootNode();
|
||||
ILeafNode node = (LeafNode) NodeUtil.findLeafNodeAtOffset(rootNode, command.offset);
|
||||
ILeafNode node = (ILeafNode) NodeUtil.findLeafNodeAtOffset(rootNode, command.offset);
|
||||
|
||||
String tagName = ""; //$NON-NLS-1$
|
||||
EList<INode> children = node.getParent().getParent().getChildren();
|
||||
for(int i = 0 ;i < children.size(); ++i)
|
||||
{
|
||||
if ((children.get(i) instanceof LeafNode) == false)
|
||||
if ((children.get(i) instanceof ILeafNode) == false)
|
||||
continue;
|
||||
// we need one more child
|
||||
if (i+1 >= children.size())
|
||||
continue;
|
||||
if (((LeafNode)children.get(i)).getText().equals("[")) //$NON-NLS-1$
|
||||
if (((ILeafNode)children.get(i)).getText().equals("[")) //$NON-NLS-1$
|
||||
{
|
||||
if (children.get(i+1) instanceof LeafNode)
|
||||
if (children.get(i+1) instanceof ILeafNode)
|
||||
{
|
||||
// in case we have [+
|
||||
if (((LeafNode)children.get(i+1)).getText().equals("+")) //$NON-NLS-1$
|
||||
if (((ILeafNode)children.get(i+1)).getText().equals("+")) //$NON-NLS-1$
|
||||
{
|
||||
if (i+2 >= children.size() ||
|
||||
(children.get(i+2) instanceof LeafNode) == false)
|
||||
(children.get(i+2) instanceof ILeafNode) == false)
|
||||
continue;
|
||||
tagName = ((LeafNode)children.get(i+2)).getText();
|
||||
tagName = ((ILeafNode)children.get(i+2)).getText();
|
||||
}
|
||||
else
|
||||
{
|
||||
tagName = ((LeafNode)children.get(i+1)).getText();
|
||||
tagName = ((ILeafNode)children.get(i+1)).getText();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,7 +19,7 @@ import org.eclipse.swt.graphics.Image;
|
|||
import org.eclipse.xtext.Assignment;
|
||||
import org.eclipse.xtext.RuleCall;
|
||||
import org.eclipse.xtext.nodemodel.ICompositeNode;
|
||||
import org.eclipse.xtext.nodemodel.impl.LeafNode;
|
||||
import org.eclipse.xtext.nodemodel.ILeafNode;
|
||||
import org.eclipse.xtext.ui.editor.contentassist.ContentAssistContext;
|
||||
import org.eclipse.xtext.ui.editor.contentassist.ICompletionProposalAcceptor;
|
||||
import org.wesnoth.installs.WesnothInstallsUtils;
|
||||
|
@ -282,7 +282,7 @@ public class WMLProposalProvider extends AbstractWMLProposalProvider
|
|||
|
||||
String parentIndent = ""; //$NON-NLS-1$
|
||||
if (context.getCurrentNode().getOffset() > 0)
|
||||
parentIndent = ((LeafNode)NodeUtil.findLeafNodeAtOffset(node.getParent(),
|
||||
parentIndent = ((ILeafNode)NodeUtil.findLeafNodeAtOffset(node.getParent(),
|
||||
context.getCurrentNode().getOffset() -
|
||||
// if we have a non-rule proposal, subtract 1
|
||||
(ruleProposal ? 0 : 1)
|
||||
|
|
|
@ -50,7 +50,6 @@ import org.eclipse.ui.ide.FileStoreEditorInput;
|
|||
import org.eclipse.ui.part.FileEditorInput;
|
||||
import org.eclipse.ui.texteditor.IDocumentProvider;
|
||||
import org.eclipse.xtext.nodemodel.ILeafNode;
|
||||
import org.eclipse.xtext.nodemodel.impl.LeafNode;
|
||||
import org.eclipse.xtext.ui.editor.XtextEditor;
|
||||
import org.eclipse.xtext.ui.editor.syntaxcoloring.IHighlightingHelper;
|
||||
import org.wesnoth.Logger;
|
||||
|
@ -112,7 +111,7 @@ public class WMLEditor extends XtextEditor
|
|||
return currentHighlightedNode_;
|
||||
}
|
||||
|
||||
public void setCurrentHighlightedNode(LeafNode leaf)
|
||||
public void setCurrentHighlightedNode(ILeafNode leaf)
|
||||
{
|
||||
currentHighlightedNode_ = leaf;
|
||||
}
|
||||
|
|
|
@ -13,8 +13,8 @@ import org.eclipse.core.commands.ExecutionEvent;
|
|||
import org.eclipse.core.commands.ExecutionException;
|
||||
import org.eclipse.jface.text.ITextSelection;
|
||||
import org.eclipse.swt.graphics.Point;
|
||||
import org.eclipse.xtext.nodemodel.ICompositeNode;
|
||||
import org.eclipse.xtext.nodemodel.INode;
|
||||
import org.eclipse.xtext.nodemodel.impl.CompositeNode;
|
||||
import org.eclipse.xtext.parser.IParseResult;
|
||||
import org.eclipse.xtext.resource.XtextResource;
|
||||
import org.eclipse.xtext.ui.editor.XtextEditor;
|
||||
|
@ -57,7 +57,7 @@ public class WMLDocHandler extends AbstractHandler
|
|||
if (abstractNode == null || abstractNode.eContainer() == null)
|
||||
return;
|
||||
|
||||
CompositeNode container = (CompositeNode)abstractNode.eContainer();
|
||||
ICompositeNode container = (ICompositeNode)abstractNode.eContainer();
|
||||
if (container.getElement() instanceof WMLMacroCall)
|
||||
{
|
||||
WMLMacroCall macro = (WMLMacroCall)container.getElement();
|
||||
|
|
|
@ -12,7 +12,7 @@ import org.eclipse.core.resources.IFile;
|
|||
import org.eclipse.emf.ecore.util.EcoreUtil;
|
||||
import org.eclipse.jface.text.Region;
|
||||
import org.eclipse.xtext.nodemodel.ICompositeNode;
|
||||
import org.eclipse.xtext.nodemodel.impl.LeafNode;
|
||||
import org.eclipse.xtext.nodemodel.ILeafNode;
|
||||
import org.eclipse.xtext.resource.XtextResource;
|
||||
import org.eclipse.xtext.ui.editor.hyperlinking.HyperlinkHelper;
|
||||
import org.eclipse.xtext.ui.editor.hyperlinking.IHyperlinkAcceptor;
|
||||
|
@ -39,7 +39,7 @@ public class WMLHyperlinkHelper extends HyperlinkHelper
|
|||
if (rootNode == null)
|
||||
return;
|
||||
|
||||
LeafNode node = (LeafNode)NodeUtil.findLeafNodeAtOffset(rootNode, offset);
|
||||
ILeafNode node = (ILeafNode)NodeUtil.findLeafNodeAtOffset(rootNode, offset);
|
||||
if (node == null)
|
||||
return;
|
||||
|
||||
|
@ -52,7 +52,7 @@ public class WMLHyperlinkHelper extends HyperlinkHelper
|
|||
Paths paths = Preferences.getPaths( WesnothInstallsUtils.getInstallNameForResource( file ) );
|
||||
|
||||
createMacroHyperlink( file, paths, node, acceptor, resource );
|
||||
LeafNode prevNode = (LeafNode)NodeUtil.findLeafNodeAtOffset(rootNode,
|
||||
ILeafNode prevNode = (ILeafNode)NodeUtil.findLeafNodeAtOffset(rootNode,
|
||||
node.getOffset() - 1);
|
||||
if(prevNode == null)
|
||||
return;
|
||||
|
@ -67,7 +67,7 @@ public class WMLHyperlinkHelper extends HyperlinkHelper
|
|||
* @param acceptor
|
||||
* @param resource
|
||||
*/
|
||||
private void createMacroHyperlink( IFile file, Paths paths, LeafNode node,
|
||||
private void createMacroHyperlink( IFile file, Paths paths, ILeafNode node,
|
||||
IHyperlinkAcceptor acceptor, XtextResource resource)
|
||||
{
|
||||
if (node.eContainer() == null ||
|
||||
|
@ -116,7 +116,7 @@ public class WMLHyperlinkHelper extends HyperlinkHelper
|
|||
* @param key The key (must me 'map_data' in this case)
|
||||
* @param value The value of key, that is, the location of the map
|
||||
*/
|
||||
private void createMapHyperlink( Paths paths, LeafNode key, LeafNode value,
|
||||
private void createMapHyperlink( Paths paths, ILeafNode key, ILeafNode value,
|
||||
IHyperlinkAcceptor acceptor, XtextResource resource )
|
||||
{
|
||||
if (!(key.getText().equals("map_data"))) //$NON-NLS-1$
|
||||
|
|
|
@ -12,10 +12,9 @@ import java.util.Iterator;
|
|||
|
||||
import org.eclipse.emf.ecore.EObject;
|
||||
import org.eclipse.emf.ecore.util.EcoreUtil;
|
||||
import org.eclipse.xtext.nodemodel.ICompositeNode;
|
||||
import org.eclipse.xtext.nodemodel.ILeafNode;
|
||||
import org.eclipse.xtext.nodemodel.INode;
|
||||
import org.eclipse.xtext.nodemodel.impl.CompositeNode;
|
||||
import org.eclipse.xtext.nodemodel.impl.LeafNode;
|
||||
import org.eclipse.xtext.resource.XtextResource;
|
||||
import org.eclipse.xtext.ui.editor.syntaxcoloring.IHighlightedPositionAcceptor;
|
||||
import org.eclipse.xtext.ui.editor.syntaxcoloring.ISemanticHighlightingCalculator;
|
||||
|
@ -145,14 +144,14 @@ public class WMLSemanticHighlightingCalculator implements ISemanticHighlightingC
|
|||
NodeAdapter adapter = NodeUtil.getNodeAdapter(semantic);
|
||||
if (adapter != null)
|
||||
{
|
||||
CompositeNode node = adapter.getParserNode();
|
||||
ICompositeNode node = adapter.getParserNode();
|
||||
if (node != null)
|
||||
{
|
||||
for (INode child : node.getChildren())
|
||||
{
|
||||
if (child instanceof LeafNode)
|
||||
if (child instanceof ILeafNode)
|
||||
{
|
||||
if (feature.equals(((LeafNode) child).getFeature()))
|
||||
if (feature.equals(((ILeafNode) child).getFeature()))
|
||||
{
|
||||
return child;
|
||||
}
|
||||
|
|
|
@ -14,9 +14,9 @@ import org.eclipse.jface.text.IRegion;
|
|||
import org.eclipse.jface.text.Region;
|
||||
import org.eclipse.xtext.AbstractElement;
|
||||
import org.eclipse.xtext.Keyword;
|
||||
import org.eclipse.xtext.nodemodel.ICompositeNode;
|
||||
import org.eclipse.xtext.nodemodel.ILeafNode;
|
||||
import org.eclipse.xtext.nodemodel.INode;
|
||||
import org.eclipse.xtext.nodemodel.impl.CompositeNode;
|
||||
import org.eclipse.xtext.nodemodel.impl.LeafNode;
|
||||
import org.eclipse.xtext.resource.XtextResource;
|
||||
import org.eclipse.xtext.ui.editor.syntaxcoloring.HighlightingReconciler;
|
||||
import org.eclipse.xtext.ui.editor.utils.EditorUtils;
|
||||
|
@ -49,7 +49,7 @@ public class WMLBracketMatching extends DefaultBracketMatcher
|
|||
{
|
||||
if (state == null || state.getContents() == null || state.getContents().isEmpty())
|
||||
return null;
|
||||
CompositeNode rootNode = NodeUtil.getRootNode(state.getContents().get(0));
|
||||
ICompositeNode rootNode = NodeUtil.getRootNode(state.getContents().get(0));
|
||||
if (rootNode == null)
|
||||
return null;
|
||||
INode node = NodeUtil.findLeafNodeAtOffset(rootNode, offset);
|
||||
|
@ -86,25 +86,25 @@ public class WMLBracketMatching extends DefaultBracketMatcher
|
|||
// search for opened/closed tag
|
||||
|
||||
// find opened tag at this offset
|
||||
LeafNode wmlNode = findWMLLeafNodeAtOffset(rootNode, offset, false);
|
||||
ILeafNode wmlNode = findWMLLeafNodeAtOffset(rootNode, offset, false);
|
||||
if (wmlNode == null)
|
||||
{
|
||||
wmlNode = findWMLLeafNodeAtOffset(rootNode, offset, true);
|
||||
}
|
||||
if (wmlNode != null)
|
||||
{
|
||||
LeafNode tmp = null;
|
||||
LeafNode correspondingTag = null;
|
||||
ILeafNode tmp = null;
|
||||
ILeafNode correspondingTag = null;
|
||||
boolean correspondingIsClosed = false;
|
||||
for (int i = 0; i < wmlNode.getParent().getChildren().size(); i++)
|
||||
{
|
||||
if (!(wmlNode.getParent().getChildren().get(i) instanceof LeafNode))
|
||||
if (!(wmlNode.getParent().getChildren().get(i) instanceof ILeafNode))
|
||||
continue;
|
||||
|
||||
if (i > 0 && wmlNode.getParent().getChildren().get(i-1) instanceof LeafNode)
|
||||
tmp = (LeafNode)wmlNode.getParent().getChildren().get(i-1);
|
||||
if (i > 0 && wmlNode.getParent().getChildren().get(i-1) instanceof ILeafNode)
|
||||
tmp = (ILeafNode)wmlNode.getParent().getChildren().get(i-1);
|
||||
|
||||
LeafNode tmpNode = (LeafNode)wmlNode.getParent().getChildren().get(i);
|
||||
ILeafNode tmpNode = (ILeafNode)wmlNode.getParent().getChildren().get(i);
|
||||
|
||||
if ((tmpNode).getText().equals(wmlNode.getText()) &&
|
||||
tmpNode != wmlNode && !tmpNode.isHidden())
|
||||
|
@ -140,24 +140,24 @@ public class WMLBracketMatching extends DefaultBracketMatcher
|
|||
return null;
|
||||
}
|
||||
|
||||
public LeafNode findWMLLeafNodeAtOffset(CompositeNode parseTreeRootNode, int offset, boolean findClosed)
|
||||
public ILeafNode findWMLLeafNodeAtOffset(ICompositeNode parseTreeRootNode, int offset, boolean findClosed)
|
||||
{
|
||||
boolean isClosed = false;
|
||||
for (INode node : parseTreeRootNode.getChildren())
|
||||
{
|
||||
if (node.getTotalOffset() <= offset)
|
||||
{
|
||||
if (node instanceof LeafNode && ((LeafNode) node).getText().equals("[/")) //$NON-NLS-1$
|
||||
if (node instanceof ILeafNode && ((ILeafNode) node).getText().equals("[/")) //$NON-NLS-1$
|
||||
{
|
||||
isClosed = true;
|
||||
}
|
||||
if (node.getTotalOffset() + node.getTotalLength() >= offset)
|
||||
{
|
||||
if (node instanceof LeafNode && isWMLTag(node) && (isClosed == findClosed))
|
||||
return (LeafNode) node;
|
||||
if (node instanceof ILeafNode && isWMLTag(node) && (isClosed == findClosed))
|
||||
return (ILeafNode) node;
|
||||
|
||||
else if (node instanceof CompositeNode)
|
||||
return findWMLLeafNodeAtOffset((CompositeNode) node, offset, findClosed);
|
||||
else if (node instanceof ICompositeNode)
|
||||
return findWMLLeafNodeAtOffset((ICompositeNode) node, offset, findClosed);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -167,6 +167,6 @@ public class WMLBracketMatching extends DefaultBracketMatcher
|
|||
private boolean isWMLTag(INode node)
|
||||
{
|
||||
return (node.eContainer() != null &&
|
||||
node.eContainer() instanceof CompositeNode && ((CompositeNode) node.eContainer()).getElement() instanceof WMLTag);
|
||||
node.eContainer() instanceof ICompositeNode && ((ICompositeNode) node.eContainer()).getElement() instanceof WMLTag);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -84,7 +84,7 @@ public class WMLGrammarUtils
|
|||
*/
|
||||
public static String toStringWMLKeyValue( WMLKeyValue keyValue )
|
||||
{
|
||||
CompositeNode node = NodeUtil.getNode( keyValue );
|
||||
ICompositeNode node = NodeUtil.getNode( keyValue );
|
||||
if ( node == null )
|
||||
return "";
|
||||
|
||||
|
|
|
@ -13,7 +13,7 @@ import org.eclipse.core.resources.ResourcesPlugin;
|
|||
import org.eclipse.core.runtime.Path;
|
||||
import org.eclipse.emf.ecore.resource.Resource;
|
||||
import org.eclipse.xtext.nodemodel.ICompositeNode;
|
||||
import org.eclipse.xtext.nodemodel.impl.LeafNode;
|
||||
import org.eclipse.xtext.nodemodel.ILeafNode;
|
||||
import org.eclipse.xtext.validation.Check;
|
||||
import org.eclipse.xtext.validation.CheckType;
|
||||
import org.wesnoth.Messages;
|
||||
|
@ -50,7 +50,7 @@ public class WMLJavaValidator extends AbstractWMLJavaValidator
|
|||
ICompositeNode node = NodeUtil.getNodeAdapter(tag).getParserNode();
|
||||
if (node != null)
|
||||
{
|
||||
LeafNode parentNode = (LeafNode)
|
||||
ILeafNode parentNode = (ILeafNode)
|
||||
NodeUtil.findLeafNodeAtOffset(node.getParent(),
|
||||
node.getParent().getOffset() + 2);
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue