Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
Copyright (c) 2009 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.xtext.ui.editor.contentassist;
 
import  org.eclipse.jface.text.Region;

Abstract base implementation of the IProposalConflictHelper that deals with the node model to extract the previous sibling of the input source.

Implementors have to provide the semantics of existsConflict(String, String, ContentAssistContext). They should consider to extend the AntlrProposalConflictHelper.

Author(s):
Sebastian Zarnekow - Initial contribution and API
public abstract class ProposalConflictHelper implements IProposalConflictHelper {
	public boolean existsConflict(String proposalContentAssistContext context) {
		// hidden node between lastCompleteNode and currentNode?
		INode lastCompleteNode = context.getLastCompleteNode();
		Region replaceRegion = context.getReplaceRegion();
		int nodeEnd = lastCompleteNode.getEndOffset();
		if (nodeEnd < replaceRegion.getOffset())
			return false;
		return existsConflict(lastCompleteNodereplaceRegion.getOffset(), proposalcontext);
	}

Returns false if the proposal would corrupt the previous input.

Parameters:
lastCompleteText the previous sibling in the input source. Is never null but may be empty. However, the implementation of existsConflict(INode, int, String, ContentAssistContext) will not pass empty strings by default but return false instead.
proposal a possible proposal string. Is never null.
context the current content assist context. Is never null.
Returns:
false if the proposal would corrupt the current input.
	public abstract boolean existsConflict(String lastCompleteTextString proposalContentAssistContext context);
	public boolean existsConflict(INode lastCompleteNodeint offsetString proposalContentAssistContext context) {
		String lastCompleteText = lastCompleteNode.getText();
		lastCompleteText = lastCompleteText.substring(0, offset - lastCompleteNode.getTotalOffset());
		if (Strings.isEmpty(lastCompleteText))
			return false;
		return existsConflict(lastCompleteTextproposalcontext);
	}
New to GrepCode? Check out our FAQ X