Java Code Examples for org.eclipse.xtext.ide.editor.contentassist.ContentAssistContext#getPreviousModel()
The following examples show how to use
org.eclipse.xtext.ide.editor.contentassist.ContentAssistContext#getPreviousModel() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: N4JSIdeContentProposalProvider.java From n4js with Eclipse Public License 1.0 | 6 votes |
@Override protected void _createProposals(Keyword keyword, ContentAssistContext context, IIdeContentProposalAcceptor acceptor) { EObject currentModel = context.getCurrentModel(); EObject previousModel = context.getPreviousModel(); if (currentModel instanceof ParameterizedPropertyAccessExpression || previousModel instanceof ParameterizedPropertyAccessExpression) return; // filter out all keywords if we are in the context of a property access if (currentModel instanceof JSXElement || previousModel instanceof JSXElement) return; // filter out all keywords if we are in the context of a JSX element if (!Character.isAlphabetic(keyword.getValue().charAt(0))) return; // filter out operators if (keyword.getValue().length() < 5) return; // filter out short keywords super._createProposals(keyword, context, acceptor); }
Example 2
Source File: XbaseIdeContentProposalProvider.java From xtext-extras with Eclipse Public License 2.0 | 6 votes |
@Override public boolean filterKeyword(final Keyword keyword, final ContentAssistContext context) { final String value = keyword.getValue(); if (((value.length() > 1) && Character.isLetter(value.charAt(0)))) { if ((Objects.equal(value, "as") || Objects.equal(value, "instanceof"))) { final EObject previousModel = context.getPreviousModel(); if ((previousModel instanceof XExpression)) { if (((context.getPrefix().length() == 0) && (NodeModelUtils.getNode(previousModel).getEndOffset() > context.getOffset()))) { return false; } final LightweightTypeReference type = this.typeResolver.resolveTypes(previousModel).getActualType(((XExpression)previousModel)); if (((type == null) || type.isPrimitiveVoid())) { return false; } } } return true; } return false; }
Example 3
Source File: XbaseIdeContentProposalProvider.java From xtext-extras with Eclipse Public License 2.0 | 5 votes |
protected void completeBinaryOperation(final EObject model, final Assignment assignment, final ContentAssistContext context, final IIdeContentProposalAcceptor acceptor) { if ((model instanceof XBinaryOperation)) { int _length = context.getPrefix().length(); boolean _tripleEquals = (_length == 0); if (_tripleEquals) { final INode currentNode = context.getCurrentNode(); final int offset = currentNode.getOffset(); final int endOffset = currentNode.getEndOffset(); if ((((offset < context.getOffset()) && (endOffset >= context.getOffset())) && (currentNode.getGrammarElement() instanceof CrossReference))) { return; } } int _endOffset = NodeModelUtils.findActualNodeFor(model).getEndOffset(); int _offset = context.getOffset(); boolean _lessEqualsThan = (_endOffset <= _offset); if (_lessEqualsThan) { AbstractElement _terminal = assignment.getTerminal(); this.createReceiverProposals(((XExpression) model), ((CrossReference) _terminal), context, acceptor); } else { AbstractElement _terminal_1 = assignment.getTerminal(); this.createReceiverProposals(((XBinaryOperation)model).getLeftOperand(), ((CrossReference) _terminal_1), context, acceptor); } } else { final EObject previousModel = context.getPreviousModel(); if ((previousModel instanceof XExpression)) { if (((context.getPrefix().length() == 0) && (NodeModelUtils.getNode(previousModel).getEndOffset() > context.getOffset()))) { return; } AbstractElement _terminal_2 = assignment.getTerminal(); this.createReceiverProposals(((XExpression)previousModel), ((CrossReference) _terminal_2), context, acceptor); } } }