From a15709a102f4ab059655c48c4cb7ee2fa8263082 Mon Sep 17 00:00:00 2001 From: Karsten Thoms Date: Tue, 2 Feb 2016 22:53:15 +0100 Subject: [480638] Enable debugging for Check files Change-Id: I18b30f8db6f926ea2549e11f5fb0fce04ca0dedf Signed-off-by: Karsten Thoms --- plugins/org.eclipse.xtend.ui/plugin.xml | 10 +++-- .../eclipse/xtend/ui/debug/CheckPluginAdapter.java | 46 ++++++++++++++++++++++ 2 files changed, 52 insertions(+), 4 deletions(-) create mode 100644 plugins/org.eclipse.xtend.ui/src/org/eclipse/xtend/ui/debug/CheckPluginAdapter.java diff --git a/plugins/org.eclipse.xtend.ui/plugin.xml b/plugins/org.eclipse.xtend.ui/plugin.xml index 060457d4..3f9cf629 100644 --- a/plugins/org.eclipse.xtend.ui/plugin.xml +++ b/plugins/org.eclipse.xtend.ui/plugin.xml @@ -49,9 +49,11 @@ pluginClass="org.eclipse.xtend.ui.debug.ExpressionPluginAdapter" runtimeClass="org.eclipse.internal.xtend.expression.debug.ExpressionElementAdapter"> + + - - - - + diff --git a/plugins/org.eclipse.xtend.ui/src/org/eclipse/xtend/ui/debug/CheckPluginAdapter.java b/plugins/org.eclipse.xtend.ui/src/org/eclipse/xtend/ui/debug/CheckPluginAdapter.java new file mode 100644 index 00000000..20f97036 --- /dev/null +++ b/plugins/org.eclipse.xtend.ui/src/org/eclipse/xtend/ui/debug/CheckPluginAdapter.java @@ -0,0 +1,46 @@ +/******************************************************************************* + * Copyright (c) 2015 itemis AG (http://www.itemis.eu) 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 + *******************************************************************************/ +package org.eclipse.xtend.ui.debug; + +import java.util.ArrayList; +import java.util.List; + +import org.eclipse.core.resources.IResource; +import org.eclipse.internal.xtend.expression.ast.ISyntaxElement; +import org.eclipse.internal.xtend.expression.ast.SyntaxElement; +import org.eclipse.internal.xtend.xtend.ast.Check; + + +/** + * @author kia7si - Initial contribution and API + * @author Karsten Thoms (itemis) - maintenance + * @since 2.2 + */ +public class CheckPluginAdapter extends ExpressionPluginAdapter { + @Override + protected String getRequiredExtension() { + return "chk"; + } + + @Override + protected ISyntaxElement findElementForPosition(IResource resource, int position, int line) { + ISyntaxElement rootElem = getContainingRootElement(resource, position); + + if(rootElem instanceof Check) + return getContainingElementOfCheckStatement((Check)rootElem, position); + + return super.getContainingElement((SyntaxElement)rootElem, position); + } + + private ISyntaxElement getContainingElementOfCheckStatement(Check rootElem, int position) { + List children = new ArrayList(); + children.add(rootElem.getMsg()); + children.add(rootElem.getConstraint()); + return getContainingChild(rootElem, children, position); + } +} \ No newline at end of file -- cgit v1.2.3