diff options
author | Karsten Thoms | 2015-07-31 09:15:03 +0000 |
---|---|---|
committer | Karsten Thoms | 2015-07-31 09:15:03 +0000 |
commit | ff74ef85ed9bdba2da1296ee073f03053f494cce (patch) | |
tree | 5ea70b060be74834687880eb4c61f5bd6c8ec58c | |
parent | 8b096b0ce7885f363c63b830f66462ad287011b8 (diff) | |
download | org.eclipse.xpand-ff74ef85ed9bdba2da1296ee073f03053f494cce.tar.gz org.eclipse.xpand-ff74ef85ed9bdba2da1296ee073f03053f494cce.tar.xz org.eclipse.xpand-ff74ef85ed9bdba2da1296ee073f03053f494cce.zip |
[465802] Enable breakpoints for Xtend files
Applied and modified patch
https://bugs.eclipse.org/bugs/attachment.cgi?id=255020
7 files changed, 319 insertions, 108 deletions
diff --git a/plugins/org.eclipse.xpand.ui/src/org/eclipse/xpand/ui/debug/XpandPluginAdapter.java b/plugins/org.eclipse.xpand.ui/src/org/eclipse/xpand/ui/debug/XpandPluginAdapter.java index e5f999a6..97d9069b 100644 --- a/plugins/org.eclipse.xpand.ui/src/org/eclipse/xpand/ui/debug/XpandPluginAdapter.java +++ b/plugins/org.eclipse.xpand.ui/src/org/eclipse/xpand/ui/debug/XpandPluginAdapter.java @@ -17,6 +17,7 @@ import java.io.InputStream; import java.util.ArrayList; import java.util.List; +import org.eclipse.core.resources.IResource; import org.eclipse.core.runtime.FileLocator; import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.Path; @@ -56,6 +57,7 @@ import org.eclipse.xtend.ui.debug.ExpressionPluginAdapter; * The IPluginAdapter implementation for Xpand statements. * * @author Clemens Kadura (zAJKa) + * @author Aykut Kilic (itemis) - Bug#465802 */ public class XpandPluginAdapter extends ExpressionPluginAdapter { @@ -189,6 +191,62 @@ public class XpandPluginAdapter extends ExpressionPluginAdapter { } @Override + protected ISyntaxElement findElementForPosition(final IResource resource, + final int position, final int line) { + ISyntaxElement body = super.findElementForPosition(resource, position,line); + if (body != null) + return body; + + ISyntaxElement rootElem = getContainingRootElement(resource, position); + if (rootElem == null) + return null; + List<ISyntaxElement> bodies = getBody(rootElem); // this is not body but + // is + // root element. + for (ISyntaxElement item : bodies) { + if (contains(item, position)) { + body = item; + break; + } + } + + if (body instanceof FileStatement) { + return getContainingElementOfFileStatement(((FileStatement) body), + position, line); + } + + return body; + } + + private boolean contains(final ISyntaxElement elem, final int position) { + return elem.getStart() <= position && elem.getEnd() >= position; + } + + private ISyntaxElement getContainingElementOfFileStatement( + final FileStatement fileStatement, final int position, + final int line) { + for (Statement statement : fileStatement.getBody()) { + if (statement instanceof ExpressionStatement) { + ISyntaxElement result = getContainingElementOfExpressionStatement( + (ExpressionStatement) statement, position, line); + if (result != null) + return result; + } + } + + return null; + } + + private ISyntaxElement getContainingElementOfExpressionStatement( + final ExpressionStatement exprStatement, final int position, + final int line) { + if (exprStatement.getLine() == line) + return exprStatement.getExpression(); + + return null; + } + + @Override protected boolean isValidReturnElement(ISyntaxElement element) { if (element instanceof TextStatement) return false; diff --git a/plugins/org.eclipse.xtend.shared.ui/src/org/eclipse/xtend/shared/ui/editor/BreakpointActionGroup.java b/plugins/org.eclipse.xtend.shared.ui/src/org/eclipse/xtend/shared/ui/editor/BreakpointActionGroup.java index aafab7be..5b5a82fc 100644 --- a/plugins/org.eclipse.xtend.shared.ui/src/org/eclipse/xtend/shared/ui/editor/BreakpointActionGroup.java +++ b/plugins/org.eclipse.xtend.shared.ui/src/org/eclipse/xtend/shared/ui/editor/BreakpointActionGroup.java @@ -30,6 +30,7 @@ import org.eclipse.ui.editors.text.TextEditor; * menu. That way "in line" breakpoints can be handled. * * @author Dennis Hübner + * @author Aykut Kilic (itemis) - Bug#465802 */ public class BreakpointActionGroup extends ActionGroup { @@ -98,6 +99,22 @@ public class BreakpointActionGroup extends ActionGroup { return textWidget.getLine(line); } + /** + * @since 2.2 + */ + public int getFirstCharPosOfLine(final int line) { + int result = textWidget.getOffsetAtLine(line); + String lineText = textWidget.getLine(line); + + for (char c : lineText.toCharArray()) { + if (!Character.isWhitespace(c)) + break; + result++; + } + + return result; + } + // ------------------------------------------------------------------------- @Override diff --git a/plugins/org.eclipse.xtend.shared.ui/src/org/eclipse/xtend/shared/ui/editor/ToggleBreakpointAction.java b/plugins/org.eclipse.xtend.shared.ui/src/org/eclipse/xtend/shared/ui/editor/ToggleBreakpointAction.java index 9a3786dd..85201340 100644 --- a/plugins/org.eclipse.xtend.shared.ui/src/org/eclipse/xtend/shared/ui/editor/ToggleBreakpointAction.java +++ b/plugins/org.eclipse.xtend.shared.ui/src/org/eclipse/xtend/shared/ui/editor/ToggleBreakpointAction.java @@ -25,6 +25,7 @@ import org.eclipse.xtend.shared.ui.Messages; /** * Toggle breakpoint action that can be used both at vertical ruler and editor context menu. * + * @author Aykut Kilic (itemis) - Bug#465802 */ public class ToggleBreakpointAction extends Action { @@ -48,8 +49,9 @@ public class ToggleBreakpointAction extends Action { } int line = group.getLastSelectedLine() + 1; - int start = group.getLastSelectedOffset(); - int end = group.isRulerSelected() ? group.getOffsetAtLine(line) : start; + int start = group.getFirstCharPosOfLine(line); + int end = start; + if (group.isRulerSelected()) { setEnabled(true); } else { @@ -72,10 +74,11 @@ public class ToggleBreakpointAction extends Action { protected void toggleBreakpoint() throws CoreException { IResource resource = (IResource) editor.getEditorInput().getAdapter(IResource.class); - // Hint: doc line numbers start at 0, but markers at 1, therefore + 1 + // THIS IS THE CORRECT FILE. (THERE ARE SOME DUPLICATES :/ ) + int line = group.getLastSelectedLine() + 1; - int start = group.getLastSelectedOffset(); - int end = start + group.getLine(line - 1).length(); + int start = group.getFirstCharPosOfLine(line - 1); + int end = start; PluginAdapter adapter = PluginExtensionManager.getDefault().getAdapterByResourceExtension(resource.getFileExtension()); if (adapter == null) { diff --git a/plugins/org.eclipse.xtend.ui/src/org/eclipse/xtend/ui/debug/ExpressionPluginAdapter.java b/plugins/org.eclipse.xtend.ui/src/org/eclipse/xtend/ui/debug/ExpressionPluginAdapter.java index a4ec0973..253285fc 100644 --- a/plugins/org.eclipse.xtend.ui/src/org/eclipse/xtend/ui/debug/ExpressionPluginAdapter.java +++ b/plugins/org.eclipse.xtend.ui/src/org/eclipse/xtend/ui/debug/ExpressionPluginAdapter.java @@ -15,7 +15,6 @@ import static org.eclipse.internal.xtend.expression.debug.ExpressionElementAdapt import java.io.IOException; import java.io.InputStream; import java.util.ArrayList; -import java.util.Collections; import java.util.HashSet; import java.util.List; import java.util.Set; @@ -30,6 +29,7 @@ import org.eclipse.emf.mwe.ui.debug.model.MWEBreakpoint; import org.eclipse.emf.mwe.ui.debug.processing.PluginAdapter; import org.eclipse.emf.mwe.ui.workflow.util.PluginConfigurationElementUtil; import org.eclipse.internal.xtend.expression.ast.BooleanOperation; +import org.eclipse.internal.xtend.expression.ast.Case; import org.eclipse.internal.xtend.expression.ast.Cast; import org.eclipse.internal.xtend.expression.ast.ChainExpression; import org.eclipse.internal.xtend.expression.ast.Expression; @@ -37,8 +37,10 @@ import org.eclipse.internal.xtend.expression.ast.FeatureCall; import org.eclipse.internal.xtend.expression.ast.ISyntaxElement; import org.eclipse.internal.xtend.expression.ast.IfExpression; import org.eclipse.internal.xtend.expression.ast.LetExpression; +import org.eclipse.internal.xtend.expression.ast.ListLiteral; import org.eclipse.internal.xtend.expression.ast.OperationCall; import org.eclipse.internal.xtend.expression.ast.SwitchExpression; +import org.eclipse.internal.xtend.expression.ast.SyntaxElement; import org.eclipse.internal.xtend.expression.debug.BaseSpecialTreatment; import org.eclipse.internal.xtend.expression.debug.EvaluatedElementWrapper; import org.eclipse.internal.xtend.expression.debug.ExpressionModelPresentation; @@ -46,13 +48,13 @@ import org.eclipse.internal.xtend.xtend.ast.Around; import org.eclipse.internal.xtend.xtend.ast.CreateExtensionStatement; import org.eclipse.internal.xtend.xtend.ast.ExpressionExtensionStatement; import org.eclipse.internal.xtend.xtend.ast.ExtensionFile; +import org.eclipse.internal.xtend.xtend.ast.JavaExtensionStatement; import org.eclipse.swt.graphics.Image; import org.eclipse.swt.graphics.ImageData; import org.eclipse.swt.widgets.Display; import org.eclipse.xtend.shared.ui.Activator; import org.eclipse.xtend.shared.ui.core.IXtendXpandProject; import org.eclipse.xtend.shared.ui.core.IXtendXpandResource; -import org.eclipse.xtend.shared.ui.internal.XtendLog; import org.eclipse.xtend.ui.XtendEditorPlugin; import org.eclipse.xtend.ui.editor.XtendEditor; @@ -60,6 +62,7 @@ import org.eclipse.xtend.ui.editor.XtendEditor; * The IPluginAdapter implementation for Expressions. * * @author Clemens Kadura (zAJKa) + * @author Aykut Kilic (itemis) - Bug#465802 */ public class ExpressionPluginAdapter implements PluginAdapter { @@ -93,10 +96,7 @@ public class ExpressionPluginAdapter implements PluginAdapter { } public boolean isToggleBpEnabled(IResource resource, int start, int end, int line) { - final List<ISyntaxElement> candidates = getAllElementsForExtensionAtOffset(resource, start); - if (candidates.isEmpty()) - return false; - ISyntaxElement element = findLastValidElementBeforeOffset(candidates, start); + ISyntaxElement element = findElementForPosition(resource, start, line); if (element == null) return false; @@ -104,115 +104,220 @@ public class ExpressionPluginAdapter implements PluginAdapter { } public MWEBreakpoint createBreakpoint(IResource resource, int start, int end, int line) throws CoreException { - ISyntaxElement element = findElementForPosition(resource, start, end, line); - if (element == null) + ISyntaxElement element = findElementForPosition(resource, start, line); + if (element == null || !(element instanceof OperationCall)) // TODO: CK: Message that no BP could be created return null; - return new MWEBreakpoint(resource, element.getNameString(null), element.getLine(), pres.getStart(element), pres - .getStartingEndPosition(element)); + return new MWEBreakpoint(resource, element.getNameString(null), element.getLine(), element.getStart(), element.getEnd()); } public IBreakpoint checkBreakpoints(IBreakpoint[] bps, IResource resource, int start, int end, int line) throws CoreException { - ISyntaxElement element = findElementForPosition(resource, start, end, line); - if (element == null) - return null; + ISyntaxElement element = findElementForPosition(resource, start, line); for (IBreakpoint bp1 : bps) { MWEBreakpoint bp = (MWEBreakpoint) bp1; if (bp.getResource().equals(resource.getFullPath().toString()) - && bp.getLine() == element.getLine() - ) + && bp.getLine() == element.getLine()) return bp; } return null; } - private ISyntaxElement findElementForPosition(IResource resource, int start, int end, int line) { - final List<ISyntaxElement> candidates = getAllElementsForExtensionAtOffset(resource, start); + /** + * @since 2.2 + */ + protected ISyntaxElement findElementForPosition(final IResource resource, final int position, final int line) { + ISyntaxElement rootElem = getContainingRootElement(resource, position); + if (rootElem == null) + return null; - ISyntaxElement element = null; + ISyntaxElement body = getBodyOfRootElement(rootElem); - if (end == start) - element = findLastValidElementBeforeOffset(candidates, start); - else - element = findFirstValidElementInLine(candidates, start, end); - if (element == null) - element = findLastValidElementBeforeOffset(candidates, start); + if (body instanceof ChainExpression) { + return getContainingElementOfChainExpression( + (ChainExpression) body, position); + } else if (body instanceof LetExpression) { + return getContainingElementOfLetExpression((LetExpression) body, + position); + } else + return body; + } - if (element != null && element.getLine() != line) - element = null; - return element; + private boolean contains(final ISyntaxElement elem, final int position) { + return elem.getStart() <= position && elem.getEnd() >= position; } - private List<ISyntaxElement> getAllElementsForExtensionAtOffset(IResource resource, int offset) { - final IXtendXpandProject project = Activator.getExtXptModelManager().findProject(resource.getProject().getFullPath()); - if (project != null) { - for (IXtendXpandResource res : project.getAllRegisteredResources()) { - if (!resource.equals(res.getUnderlyingStorage())) - continue; - List<ISyntaxElement> candidates = collectFirstLevelElements(res); - if (candidates.isEmpty()) - return Collections.emptyList(); - ISyntaxElement topElement = candidates.get(0); - for (ISyntaxElement next : candidates) { - int start = next.getStart(); - // workaround for a Antlr3 bug: some elements don't have a correct location (start is 0) - if (start == 0) { - System.out.println("Start is 0 for " + next.getClass().getSimpleName()); - List<ISyntaxElement> bodyElements = getBody(next); - if (!bodyElements.isEmpty()) - start = pres.getStart(bodyElements.get(0)); - } - if (start > offset) - break; - topElement = next; - } - return getAllContainingElements(topElement); + private ISyntaxElement getContainingElement(final SyntaxElement se, final int position) { + if (se instanceof ChainExpression) + return getContainingElementOfChainExpression((ChainExpression) se, position); + else if (se instanceof LetExpression) { + return getContainingElementOfLetExpression((LetExpression) se, position); + } else if (se instanceof SwitchExpression) { + return getContainingElementOfSwitchExpression((SwitchExpression) se, position); + } else if (se instanceof ListLiteral) { + return getContainingElementOfListLiteral((ListLiteral) se, position); + } else if (se instanceof IfExpression) { + return getContainingElementOfIfExpression((IfExpression) se, position); + } + + if (contains(se, position)) + return se; + + return null; + } + + private ISyntaxElement getContainingElementOfLetExpression(final LetExpression le, int position) { + ISyntaxElement result = null; + + // if bp is in "let varname = "varexpr ... we have to shift start and + // end. + position = shiftPositionIfInside(position, le, le.getVarExpression()); + + result = getContainingElement(le.getVarExpression(), position); + if (result != null) + return result; + + result = getContainingElement(le.getTargetExpression(), position); + if (result != null) + return result; + + return null; + } + + private ISyntaxElement getContainingElementOfIfExpression(final IfExpression ie, int position) { + ISyntaxElement result = null; + + // if bp is in "if( expr ) "... we have to shift start and end. + position = shiftPositionIfInside(position, ie, ie.getCondition()); + + result = getContainingElement(ie.getCondition(), position); + if (result != null) + return result; + + result = getContainingElement(ie.getThenPart(), position); + if (result != null) + return result; + + if (ie.getElsePart() != null) { + result = getContainingElement(ie.getElsePart(), position); + if (result != null) + return result; + } + + return null; + } + + private int shiftPositionIfInside(final int currentPosition, + final SyntaxElement lowerBound, final SyntaxElement upperBound) { + return lowerBound.getLine() == upperBound.getLine() + && currentPosition >= lowerBound.getStart() + && currentPosition <= upperBound.getStart() ? upperBound + .getStart() : currentPosition; + } + + private ISyntaxElement getContainingElementOfListLiteral(final ListLiteral ll, int position) { + + List<Expression> list = ll.getElementsAsList(); + + // if bp is in "{ "... we have to shift start and end. + if (list.size() > 0) { + Expression firstElem = list.get(0); + if (ll.getStart() <= position && firstElem.getStart() > position) { + position = firstElem.getStart(); } - } else { - XtendLog.logInfo("Couldn't create ExtXpt Project for project " + resource.getProject().getName()); } - return Collections.emptyList(); + + for (Expression item : list) { + ISyntaxElement result = getContainingElement(item, position); + if (result != null) + return result; + } + + return null; } - private List<ISyntaxElement> getAllContainingElements(ISyntaxElement parent) { - List<ISyntaxElement> result = new ArrayList<ISyntaxElement>(); - if (parent instanceof EvaluatedElementWrapper) - result.add(((EvaluatedElementWrapper) parent).getElement()); - else { - List<ISyntaxElement> bodyElements = getBody(parent); - for (ISyntaxElement element : bodyElements) - result.addAll(getAllContainingElements(element)); + private ISyntaxElement getContainingElementOfSwitchExpression(final SwitchExpression se, int position) { + ISyntaxElement result = null; + + Expression firstCaseExpression; + // if bp is in "switch(expr) { case expr: "... we have to shift start + // and end. + if (se.getCases().size() > 0) + firstCaseExpression = se.getCases().get(0).getThenPart(); + else + firstCaseExpression = se.getDefaultExpr(); + + position = shiftPositionIfInside(position, se, firstCaseExpression); + + for (Case caze : se.getCases()) { + result = getContainingElement(caze.getThenPart(), position); + if (result != null) + return result; } - return result; + result = getContainingElement(se.getDefaultExpr(), position); + if (result != null) + return result; + + return null; } - private ISyntaxElement findLastValidElementBeforeOffset(List<ISyntaxElement> candidates, int offset) { - ISyntaxElement previousValid = null; - ISyntaxElement candidate = null; - for (ISyntaxElement next : candidates) { - if (isValidReturnElement(next)) - previousValid = next; - if (pres.getStart(next) > offset) { - if (isValidReturnElement(candidate)) - return candidate; + private ISyntaxElement getContainingElementOfChainExpression(final ChainExpression ce, final int position) { + + ISyntaxElement result = null; + result = getRootOperationCall(getContainingElement(ce.getFirst(), position)); + if (result != null) + return result; + + result = getRootOperationCall(getContainingElement(ce.getNext(), position)); + if (result != null) + return result; + + return null; + } + + /** + * returns the first operationcall of a call chain ie: for fn3 of + * a.b.fn1().fn2().fn3() this will return fn1(). + */ + private ISyntaxElement getRootOperationCall(final ISyntaxElement element) { + ISyntaxElement result = element; + + if (element instanceof OperationCall) { + Expression target = ((OperationCall) element).getTarget(); + while (target != null && target instanceof OperationCall) { + result = target; + target = ((OperationCall) target).getTarget(); } - candidate = next; } - if (isValidReturnElement(candidate)) - return candidate; - return previousValid; + + return result; + } + + /** + * @since 2.2 + */ + protected ISyntaxElement getContainingRootElement(final IResource resource, + final int position) { + IXtendXpandResource file = getXtendXpandResource(resource); + List<ISyntaxElement> elems = collectFirstLevelElements(file); + for (ISyntaxElement elem : elems) + if (contains(elem, position)) + return elem; + + return null; } - private ISyntaxElement findFirstValidElementInLine(List<ISyntaxElement> candidates, int start, int end) { - for (ISyntaxElement next : candidates) { - if (pres.getStart(next) > start) - if (isValidReturnElement(next)) - return next; - if (pres.getStart(next) > end) - break; + private IXtendXpandResource getXtendXpandResource(final IResource resource) { + final IXtendXpandProject project = Activator.getExtXptModelManager().findProject(resource.getProject().getFullPath()); + if (project != null) { + for (IXtendXpandResource res : project.getAllRegisteredResources()) { + if (!resource.equals(res.getUnderlyingStorage())) + continue; + return res; + } } + return null; } @@ -220,30 +325,46 @@ public class ExpressionPluginAdapter implements PluginAdapter { // Expression specific methods protected List<ISyntaxElement> collectFirstLevelElements(IXtendXpandResource res) { - List<ISyntaxElement> exts = new ArrayList<ISyntaxElement>(); - exts.addAll(((ExtensionFile) res.getExtXptResource()).getExtensions()); - exts.addAll(((ExtensionFile) res.getExtXptResource()).getArounds()); - List<ISyntaxElement> expressions = new ArrayList<ISyntaxElement>(); - for (ISyntaxElement ext : exts) + ExtensionFile file = (ExtensionFile) res.getExtXptResource(); + List<ISyntaxElement> result = new ArrayList<ISyntaxElement>(); + + result.addAll(file.getArounds()); + result.addAll(file.getChecks()); + + for (ISyntaxElement ext : file.getExtensions()) { // Hint: we don't create BP internal of Java extension statements // Java Debugger to be used instead - if (ext instanceof ExpressionExtensionStatement) - expressions.add(ext); - else if (ext instanceof CreateExtensionStatement) - expressions.add(ext); - else if (ext instanceof Around) - expressions.add(ext); - return expressions; + if (ext instanceof JavaExtensionStatement) + continue; + + result.add(ext); + } + + return result; + } + + + private ISyntaxElement getBodyOfRootElement(final ISyntaxElement elem) { + if (elem instanceof ExpressionExtensionStatement) + return ((ExpressionExtensionStatement) elem).getExpression(); + else if (elem instanceof CreateExtensionStatement) + return ((CreateExtensionStatement) elem).getExpression(); + else if (elem instanceof Around) + return ((Around) elem).getExpression(); + + return null; } protected List<ISyntaxElement> getBody(ISyntaxElement exp) { - // Hint: we accept all kinds of body elements here, because their children could be OperationCalls + // Hint: we accept all kinds of body elements here, because their + // children could be OperationCalls ISyntaxElement[] body = new ISyntaxElement[0]; if (exp instanceof IfExpression) { IfExpression op = (IfExpression) exp; body = new ISyntaxElement[] { op.getCondition(), op.getThenPart(), op.getElsePart() }; } else if (exp instanceof OperationCall) { - // Note: Check first for OperationCall because it extends FeatureCall + // Note: Check first for OperationCall because it extends + // FeatureCall OperationCall op = (OperationCall) exp; List<ISyntaxElement> kids = new ArrayList<ISyntaxElement>(); kids.add(op.getTarget()); @@ -281,9 +402,8 @@ public class ExpressionPluginAdapter implements PluginAdapter { return result; } - protected boolean isValidReturnElement(ISyntaxElement se) { - - return (se instanceof Expression); + protected boolean isValidReturnElement(final ISyntaxElement se) { + return (se instanceof OperationCall || se instanceof ChainExpression); } // ------------------------------------------------------------------------- diff --git a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/debug/ExpressionElementAdapter.java b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/debug/ExpressionElementAdapter.java index 5f37f23a..dbb8763e 100644 --- a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/debug/ExpressionElementAdapter.java +++ b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/debug/ExpressionElementAdapter.java @@ -43,6 +43,7 @@ import org.eclipse.xtend.typesystem.Type; * * @author Bernd Kolb * @author Clemens Kadura (zAJKa) + * @author Aykut Kilic (itemis) - Bug#465802 */ public class ExpressionElementAdapter implements ElementAdapter { @@ -78,8 +79,9 @@ public class ExpressionElementAdapter implements ElementAdapter { // ------------------------------------------------------------------------- public boolean canHandle(final Object element) { - if (element instanceof Expression) + if (element instanceof org.eclipse.internal.xtend.expression.ast.SyntaxElement) { return true; + } if (element instanceof SyntaxElement) { final SyntaxElement se = (SyntaxElement) element; return se.resource.endsWith(".ext"); @@ -88,7 +90,8 @@ public class ExpressionElementAdapter implements ElementAdapter { } public boolean shallHandle(final Object element) { - return element instanceof OperationCall && ((OperationCall) element).getName().toString().length() > 2; + // shallHandle is only processed by the CommandRuntimeHandler + return element instanceof org.eclipse.internal.xtend.expression.ast.SyntaxElement; } public boolean shallSuspend(final Object element, final int flag) { @@ -96,6 +99,11 @@ public class ExpressionElementAdapter implements ElementAdapter { for (final BaseSpecialTreatment special : specials) { result &= !special.shallNotSuspend(element, flag, context); } + if (element instanceof OperationCall) { + String fileName = ((OperationCall) element).getFileName(); + result &= (fileName != null) && !fileName.equals("nofile"); + } + return result; } diff --git a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/debug/NoResourceSpecial.java b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/debug/NoResourceSpecial.java index f3bc707e..25803a5c 100644 --- a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/debug/NoResourceSpecial.java +++ b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/debug/NoResourceSpecial.java @@ -18,6 +18,7 @@ import org.eclipse.xtend.expression.ExecutionContext; * Adapter to handle statements that don't have an associated resource. (mainly the initial one) * * @author Clemens Kadura (zAJKa) + * @author Aykut Kilic (itemis) - Bug#465802 */ public class NoResourceSpecial extends BaseSpecialTreatment { @@ -47,7 +48,8 @@ public class NoResourceSpecial extends BaseSpecialTreatment { // ------------------------------------------------------------------------- private boolean hasResource(final Object element) { - return getClass().getResource("/" + ((org.eclipse.internal.xtend.expression.ast.SyntaxElement) element).getFileName()) != null; + // return getClass().getResource("/" + ((org.eclipse.internal.xtend.expression.ast.SyntaxElement) element).getFileName()) != null; + return true; } } diff --git a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/xtend/ast/AbstractExtension.java b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/xtend/ast/AbstractExtension.java index 7d97e437..55d52974 100644 --- a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/xtend/ast/AbstractExtension.java +++ b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/xtend/ast/AbstractExtension.java @@ -36,6 +36,7 @@ import org.eclipse.xtend.typesystem.Type; * @author Darius Jockel * @author Sebastian Zarnekow * @author Karsten Thoms + * @author Aykut Kilic (itemis) - Bug#465802 */ public abstract class AbstractExtension extends SyntaxElement implements Extension { private static final List<DeclaredParameter> EMPTY_DECLARED_PARAMETERS = Collections.<DeclaredParameter> emptyList(); @@ -168,7 +169,9 @@ public abstract class AbstractExtension extends SyntaxElement implements Extensi throw new IllegalStateException("No containing file!"); } _ctx = _ctx.cloneWithResource(getExtensionFile()); + ctx.preTask(this); final Object result = evaluateInternal(parameters, _ctx); + ctx.postTask(this); if (cached) { cache.put(Arrays.asList(parameters), result); } |