use of org.eclipse.wst.sse.ui.internal.contentassist.CustomCompletionProposal in project webtools.sourceediting by eclipse.
the class AbstractXMLModelQueryCompletionProposalComputer method addAttributeNameProposals.
protected void addAttributeNameProposals(ContentAssistRequest contentAssistRequest, CompletionProposalInvocationContext context) {
IDOMNode node = (IDOMNode) contentAssistRequest.getNode();
IStructuredDocumentRegion sdRegion = contentAssistRequest.getDocumentRegion();
// retrieve the list of attributes
CMElementDeclaration elementDecl = getCMElementDeclaration(node);
if (elementDecl != null) {
CMNamedNodeMapImpl attributes = new CMNamedNodeMapImpl(elementDecl.getAttributes());
addModelQueryAttributeDeclarations(node, elementDecl, attributes);
String matchString = contentAssistRequest.getMatchString();
int cursorOffset = context.getInvocationOffset();
// check whether an attribute really exists for the replacement
// offsets AND if it possesses a value
boolean attrAtLocationHasValue = false;
boolean proposalNeedsSpace = false;
NamedNodeMap attrs = node.getAttributes();
for (int i = 0; i < attrs.getLength(); i++) {
AttrImpl existingAttr = (AttrImpl) attrs.item(i);
ITextRegion name = existingAttr.getNameRegion();
if (name != null && (sdRegion.getStartOffset(name) <= contentAssistRequest.getReplacementBeginPosition()) && (sdRegion.getStartOffset(name) + name.getLength() >= contentAssistRequest.getReplacementBeginPosition() + contentAssistRequest.getReplacementLength()) && (existingAttr.getValueRegion() != null)) {
// selected region is attribute name
if (cursorOffset >= sdRegion.getStartOffset(name) && contentAssistRequest.getReplacementLength() != 0)
attrAtLocationHasValue = true;
else // propose new attribute, cursor is at the start of another attribute name
if (cursorOffset == sdRegion.getStartOffset(name))
proposalNeedsSpace = true;
break;
}
}
// only add proposals for the attributes whose names begin with the matchstring
if (attributes != null) {
for (int i = 0; i < attributes.getLength(); i++) {
CMAttributeDeclaration attrDecl = (CMAttributeDeclaration) attributes.item(i);
if (validModelQueryNode(attrDecl)) {
int isRequired = 0;
if (attrDecl.getUsage() == CMAttributeDeclaration.REQUIRED) {
isRequired = XMLRelevanceConstants.R_REQUIRED;
}
boolean showAttribute = true;
showAttribute = showAttribute && beginsWith(getRequiredName(node, attrDecl), matchString.trim());
AttrImpl attr = (AttrImpl) node.getAttributes().getNamedItem(getRequiredName(node, attrDecl));
ITextRegion nameRegion = attr != null ? attr.getNameRegion() : null;
// nameRegion.getEndOffset() + 1 is required to allow for
// matches against the full name of an existing Attr
showAttribute = showAttribute && ((attr == null) || nameRegion == null || ((nameRegion != null) && (sdRegion.getStartOffset(nameRegion) < contentAssistRequest.getReplacementBeginPosition()) && (sdRegion.getStartOffset(nameRegion) + nameRegion.getLength() >= (contentAssistRequest.getReplacementBeginPosition() + contentAssistRequest.getReplacementLength()))));
if (showAttribute) {
// get the proposal image
Image attrImage = CMImageUtil.getImage(attrDecl);
if (attrImage == null) {
if (isRequired > 0) {
attrImage = this.getRequiredAttributeImage();
} else {
attrImage = this.getNotRequiredAttributeImage();
}
}
String proposedText = null;
String proposedInfo = getAdditionalInfo(elementDecl, attrDecl);
CustomCompletionProposal proposal = null;
// attribute is at this location and already exists
if (attrAtLocationHasValue) {
// only propose the name
proposedText = getRequiredName(node, attrDecl);
proposal = new MarkupCompletionProposal(proposedText, contentAssistRequest.getReplacementBeginPosition(), contentAssistRequest.getReplacementLength(), proposedText.length(), attrImage, proposedText, null, proposedInfo, XMLRelevanceConstants.R_XML_ATTRIBUTE_NAME + isRequired, true);
} else // no attribute exists or is elsewhere, generate
// minimally
{
Attr existingAttrNode = (Attr) node.getAttributes().getNamedItem(getRequiredName(node, attrDecl));
String value = null;
if (existingAttrNode != null && existingAttrNode.getSpecified()) {
value = existingAttrNode.getNodeValue();
}
int cursorPosition = 0;
if ((value != null) && (value.length() > 0)) {
proposedText = getRequiredName(node, attrDecl);
cursorPosition = proposedText.length() + 2;
} else {
proposedText = getRequiredText(node, attrDecl);
// skip the cursor past a fixed value
if (attrDecl.getAttrType() != null && attrDecl.getAttrType().getImpliedValueKind() == CMDataType.IMPLIED_VALUE_FIXED)
cursorPosition = proposedText.length();
else
cursorPosition = getRequiredName(node, attrDecl).length() + 2;
}
if (proposalNeedsSpace)
// $NON-NLS-1$
proposedText += " ";
proposal = new MarkupCompletionProposal(proposedText, contentAssistRequest.getReplacementBeginPosition(), contentAssistRequest.getReplacementLength(), cursorPosition, attrImage, // and there is no single quote that may be encasing a double quote
((proposedText.lastIndexOf('\"') - proposedText.indexOf('\"') == 1 && proposedText.indexOf('\'') == -1)) ? getRequiredName(node, attrDecl) : proposedText, null, proposedInfo, XMLRelevanceConstants.R_XML_ATTRIBUTE_NAME + isRequired);
}
contentAssistRequest.addProposal(proposal);
}
}
}
}
} else {
setErrorMessage(NLS.bind(XMLUIMessages.Element__is_unknown, (new Object[] { node.getNodeName() })));
}
}
use of org.eclipse.wst.sse.ui.internal.contentassist.CustomCompletionProposal in project webtools.sourceediting by eclipse.
the class AbstractXMLModelQueryCompletionProposalComputer method addTagCloseProposals.
/**
* Close an unclosed start tag
*/
protected void addTagCloseProposals(ContentAssistRequest contentAssistRequest, CompletionProposalInvocationContext context) {
IDOMNode node = (IDOMNode) contentAssistRequest.getParent();
if (node.getNodeType() == Node.ELEMENT_NODE) {
CMElementDeclaration elementDecl = getCMElementDeclaration(node);
String proposedInfo = (elementDecl != null) ? getAdditionalInfo(null, elementDecl) : null;
int contentType = (elementDecl != null) ? elementDecl.getContentType() : CMElementDeclaration.ANY;
// if it's XML and content doesn't HAVE to be element, add "/>" proposal.
boolean endWithSlashBracket = (isXMLNode(node) && (contentType != CMElementDeclaration.ELEMENT));
// get the image
Image image = CMImageUtil.getImage(elementDecl);
if (image == null) {
image = this.getGenericTagImage();
}
// is the start tag ended properly?
if ((contentAssistRequest.getDocumentRegion() == node.getFirstStructuredDocumentRegion()) && !(node.getFirstStructuredDocumentRegion()).isEnded()) {
setErrorMessage(null);
// tell, we assume it's not.
if ((elementDecl != null) && (elementDecl.getContentType() == CMElementDeclaration.EMPTY)) {
// prompt with a self-closing end character if needed
// this is one of the few times to ignore the length -- always insert
// contentAssistRequest.getReplacementLength()
CustomCompletionProposal proposal = new MarkupCompletionProposal(getContentGenerator().getStartTagClose(node, elementDecl), contentAssistRequest.getReplacementBeginPosition(), 0, getContentGenerator().getStartTagClose(node, elementDecl).length(), image, NLS.bind(XMLUIMessages.Close_with___, (new Object[] { getContentGenerator().getStartTagClose(node, elementDecl) })), null, proposedInfo, XMLRelevanceConstants.R_CLOSE_TAG);
contentAssistRequest.addProposal(proposal);
} else {
// prompt with a close for the start tag
CustomCompletionProposal proposal = new // $NON-NLS-1$
MarkupCompletionProposal(// $NON-NLS-1$
">", contentAssistRequest.getReplacementBeginPosition(), // $NON-NLS-1$
0, // $NON-NLS-1$
1, // $NON-NLS-1$
image, // $NON-NLS-1$
NLS.bind(XMLUIMessages.Close_with__, (new Object[] { " '>'" })), null, proposedInfo, XMLRelevanceConstants.R_CLOSE_TAG);
contentAssistRequest.addProposal(proposal);
// prompt with the closer for the start tag and an end tag if one is not present
if (node.getEndStructuredDocumentRegion() == null) {
// make sure tag name is actually what it thinks it
// is...(eg. <%@ vs. <jsp:directive)
IStructuredDocumentRegion sdr = contentAssistRequest.getDocumentRegion();
// $NON-NLS-1$
String openingTagText = (sdr != null) ? sdr.getFullText() : "";
if ((openingTagText != null) && (openingTagText.indexOf(node.getNodeName()) != -1)) {
proposal = new // $NON-NLS-2$//$NON-NLS-1$
MarkupCompletionProposal(// $NON-NLS-2$//$NON-NLS-1$
"></" + node.getNodeName() + ">", contentAssistRequest.getReplacementBeginPosition(), // contentAssistRequest.getReplacementLength(),
0, 1, image, NLS.bind(XMLUIMessages.Close_with____, (new Object[] { node.getNodeName() })), null, proposedInfo, XMLRelevanceConstants.R_CLOSE_TAG);
contentAssistRequest.addProposal(proposal);
}
}
// prompt with slash bracket "/>" incase if it's a self ending tag
if (endWithSlashBracket) {
proposal = new // $NON-NLS-1$
MarkupCompletionProposal(// $NON-NLS-1$
"/>", contentAssistRequest.getReplacementBeginPosition(), // $NON-NLS-1$
0, // $NON-NLS-1$
2, // $NON-NLS-1$
image, // $NON-NLS-1$
NLS.bind(XMLUIMessages.Close_with__, (new Object[] { " \"/>\"" })), null, proposedInfo, // +1
XMLRelevanceConstants.R_CLOSE_TAG + 1);
// to bring to top of list
contentAssistRequest.addProposal(proposal);
}
}
} else if ((contentAssistRequest.getDocumentRegion() == node.getLastStructuredDocumentRegion()) && !node.getLastStructuredDocumentRegion().isEnded()) {
setErrorMessage(null);
// prompt with a closing end character for the end tag
CustomCompletionProposal proposal = new // $NON-NLS-1$
MarkupCompletionProposal(// $NON-NLS-1$
">", contentAssistRequest.getReplacementBeginPosition(), // $NON-NLS-1$
0, // $NON-NLS-1$
1, // $NON-NLS-1$
image, // $NON-NLS-1$
NLS.bind(XMLUIMessages.Close_with__, (new Object[] { " '>'" })), null, proposedInfo, XMLRelevanceConstants.R_CLOSE_TAG);
contentAssistRequest.addProposal(proposal);
}
} else if (node.getNodeType() == Node.DOCUMENT_NODE) {
setErrorMessage(XMLUIMessages.Content_Assist_not_availab_UI_);
}
}
use of org.eclipse.wst.sse.ui.internal.contentassist.CustomCompletionProposal in project webtools.sourceediting by eclipse.
the class AbstractXMLModelQueryCompletionProposalComputer method addEndTagNameProposals.
/**
* Add the proposals for the name in an end tag
*/
protected void addEndTagNameProposals(ContentAssistRequest contentAssistRequest, CompletionProposalInvocationContext context) {
if (contentAssistRequest.getStartOffset() + contentAssistRequest.getRegion().getTextLength() < contentAssistRequest.getReplacementBeginPosition()) {
CustomCompletionProposal proposal = new // $NON-NLS-1$
MarkupCompletionProposal(// $NON-NLS-1$
">", // $NON-NLS-1$
contentAssistRequest.getReplacementBeginPosition(), // $NON-NLS-1$
contentAssistRequest.getReplacementLength(), // $NON-NLS-1$
1, // $NON-NLS-1$
XMLEditorPluginImageHelper.getInstance().getImage(XMLEditorPluginImages.IMG_OBJ_TAG_GENERIC), // $NON-NLS-1$
NLS.bind(XMLUIMessages.Close_with__, (new Object[] { " '>'" })), null, null, XMLRelevanceConstants.R_END_TAG_NAME);
contentAssistRequest.addProposal(proposal);
} else {
Node aNode = contentAssistRequest.getNode();
String matchString = contentAssistRequest.getMatchString();
if (matchString.startsWith("</")) {
// $NON-NLS-1$
matchString = matchString.substring(2);
}
while (aNode != null) {
if (aNode.getNodeType() == Node.ELEMENT_NODE) {
if (aNode.getNodeName().startsWith(matchString)) {
IDOMNode aXMLNode = (IDOMNode) aNode;
CMElementDeclaration ed = getCMElementDeclaration(aNode);
// declaration must be valid for this computer to make proposal
if ((aXMLNode.getEndStructuredDocumentRegion() == null) && (ed == null || (validModelQueryNode(ed) && ed.getContentType() != CMElementDeclaration.EMPTY))) {
String replacementText = aNode.getNodeName();
String displayText = replacementText;
String proposedInfo = (ed != null) ? getAdditionalInfo(null, ed) : null;
if (!contentAssistRequest.getDocumentRegion().isEnded()) {
// $NON-NLS-1$
replacementText += ">";
}
CustomCompletionProposal proposal = null;
// double check to see if the region acted upon is
// a tag name; replace it if so
Image image = CMImageUtil.getImage(ed);
if (image == null) {
image = this.getGenericTagImage();
}
if (contentAssistRequest.getRegion().getType() == DOMRegionContext.XML_TAG_NAME) {
proposal = new MarkupCompletionProposal(replacementText, contentAssistRequest.getStartOffset(), contentAssistRequest.getRegion().getTextLength(), replacementText.length(), image, displayText, null, proposedInfo, XMLRelevanceConstants.R_END_TAG_NAME);
} else {
proposal = new MarkupCompletionProposal(replacementText, contentAssistRequest.getReplacementBeginPosition(), contentAssistRequest.getReplacementLength(), replacementText.length(), image, NLS.bind(XMLUIMessages.Close_with__, // $NON-NLS-1$ //$NON-NLS-2$
(new Object[] { "'" + displayText + "'" })), null, proposedInfo, XMLRelevanceConstants.R_END_TAG_NAME);
}
contentAssistRequest.addProposal(proposal);
}
}
}
aNode = aNode.getParentNode();
}
}
}
use of org.eclipse.wst.sse.ui.internal.contentassist.CustomCompletionProposal in project webtools.sourceediting by eclipse.
the class XMLContentAssistUtilities method computeJSPEndTagProposal.
/**
* A convenience method for getting the closing proposal given the
* contents (IndexedRegion) of a tag that is started, but possibly not
* ended
*
* @param viewer
* the text viewer
* @param documentPosition
* the cursor position in the viewer
* @param indexedNode
* the contents of the tag that is started but possibly not
* ended
* @param parentTagName
* the tag on which you are checkin for an ending tag
* @param imagePath
* content assist image relative path
* @return ICompletionProposal
*/
public static ICompletionProposal computeJSPEndTagProposal(ITextViewer viewer, int documentPosition, IndexedRegion indexedNode, String parentTagName, String imagePath) {
ICompletionProposal p = null;
// check if tag is closed
boolean hasEndTag = true;
boolean isJSPTag = false;
IDOMNode xnode = null;
// $NON-NLS-1$
String tagName = "";
if (indexedNode instanceof IDOMNode) {
xnode = ((IDOMNode) indexedNode);
// it's ended already...
if (xnode.getEndStructuredDocumentRegion() != null) {
return null;
}
IDOMNode openNode = null;
if (!xnode.getNodeName().equalsIgnoreCase(parentTagName)) {
openNode = (IDOMNode) xnode.getParentNode();
}
if (openNode != null) {
if (openNode instanceof IDOMElement) {
isJSPTag = ((IDOMElement) openNode).isJSPTag();
}
tagName = openNode.getNodeName();
hasEndTag = (openNode.getEndStructuredDocumentRegion() != null);
}
}
// it's closed, don't add close tag proposal
if (!hasEndTag && !isJSPTag) {
// create appropriate close tag text
// $NON-NLS-1$
String proposedText = "</" + tagName;
String viewerText = viewer.getTextWidget().getText();
if ((viewerText.length() >= documentPosition) && (viewerText.length() >= 2) && (documentPosition >= 2)) {
String last2chars = viewerText.substring(documentPosition - 2, documentPosition);
if (last2chars.endsWith("</")) {
proposedText = tagName;
} else if (last2chars.endsWith("<")) {
// $NON-NLS-1$
proposedText = "/" + tagName;
}
}
// create proposal
p = new // $NON-NLS-1$
CustomCompletionProposal(// $NON-NLS-1$
proposedText + ">", documentPosition, 0, proposedText.length() + 1, XMLEditorPluginImageHelper.getInstance().getImage(imagePath), NLS.bind(XMLUIMessages.End_with_, (new Object[] { proposedText })), null, null, XMLRelevanceConstants.R_END_TAG);
} else if (!hasEndTag && isJSPTag) {
// create appropriate close tag text
// $NON-NLS-1$
String proposedText = "%";
String viewerText = viewer.getTextWidget().getText();
// already there...
if ((viewerText.length() >= documentPosition) && (viewerText.length() >= 2)) {
String last2chars = viewerText.substring(documentPosition - 2, documentPosition);
String lastchar = viewerText.substring(documentPosition - 1, documentPosition);
if (// $NON-NLS-1$
lastchar.equals("%")) {
if (last2chars.endsWith("<%")) {
// $NON-NLS-1$
proposedText = "%";
} else {
// $NON-NLS-1$
proposedText = "";
}
}
}
// create proposal
p = new // $NON-NLS-1$
CustomCompletionProposal(// $NON-NLS-1$
proposedText + ">", documentPosition, 0, proposedText.length() + 1, XMLEditorPluginImageHelper.getInstance().getImage(imagePath), NLS.bind(XMLUIMessages.End_with_, (new Object[] { proposedText })), null, null, XMLRelevanceConstants.R_END_TAG);
}
return p;
}
use of org.eclipse.wst.sse.ui.internal.contentassist.CustomCompletionProposal in project webtools.sourceediting by eclipse.
the class JSPCompletionProposalComputer method computeCompletionProposals.
/**
* @see org.eclipse.wst.xml.ui.internal.contentassist.AbstractXMLCompletionProposalComputer#computeCompletionProposals(java.lang.String, org.eclipse.wst.sse.core.internal.provisional.text.ITextRegion, org.eclipse.wst.xml.core.internal.provisional.document.IDOMNode, org.eclipse.wst.xml.core.internal.provisional.document.IDOMNode, org.eclipse.wst.sse.ui.contentassist.CompletionProposalInvocationContext)
*/
protected ContentAssistRequest computeCompletionProposals(String matchString, ITextRegion completionRegion, IDOMNode treeNode, IDOMNode xmlnode, CompletionProposalInvocationContext context) {
// be sure to get the super proposals
ContentAssistRequest request = super.computeCompletionProposals(matchString, completionRegion, treeNode, xmlnode, context);
// calculate JSP specific proposals
int documentPosition = context.getInvocationOffset();
IStructuredDocumentRegion sdRegion = ContentAssistUtils.getStructuredDocumentRegion(context.getViewer(), documentPosition);
Document doc = null;
if (xmlnode != null) {
if (xmlnode.getNodeType() == Node.DOCUMENT_NODE) {
doc = (Document) xmlnode;
} else {
doc = xmlnode.getOwnerDocument();
}
}
// $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
String[] directiveNames = { "page", "include", "taglib" };
ITextRegion prevTextRegion = null;
try {
int offset = sdRegion.getStartOffset(completionRegion);
if (offset > 0) {
offset--;
}
ITypedRegion prevRegion = context.getDocument().getPartition(offset);
prevTextRegion = sdRegion.getRegionAtCharacterOffset(prevRegion.getOffset());
} catch (BadLocationException e) {
// this should never happen
Logger.logException(e);
}
// suggest JSP Expression inside of XML comments
if (completionRegion.getType() == DOMRegionContext.XML_COMMENT_TEXT && !isXMLFormat(doc)) {
if (request == null) {
request = new ContentAssistRequest(treeNode, xmlnode, sdRegion, completionRegion, documentPosition, 0, // $NON-NLS-1$
"");
}
request.addProposal(new // $NON-NLS-1$
CustomCompletionProposal(// $NON-NLS-1$
"<%= %>", documentPosition, 0, 4, JSPEditorPluginImageHelper.getInstance().getImage(JSPEditorPluginImages.IMG_OBJ_TAG_JSP), "jsp:expression", null, "<%= %>", // $NON-NLS-1$ //$NON-NLS-2$
XMLRelevanceConstants.R_JSP));
} else /* handle proposals in and around JSP_DIRECTIVE_OPEN,
* JSP_DIRECTIVE_CLOSE (preceded by OPEN) and JSP_DIRECTIVE_NAME
*/
if ((completionRegion.getType() == DOMJSPRegionContexts.JSP_DIRECTIVE_OPEN && documentPosition >= sdRegion.getTextEndOffset(completionRegion)) || (completionRegion.getType() == DOMJSPRegionContexts.JSP_DIRECTIVE_NAME && documentPosition <= sdRegion.getTextEndOffset(completionRegion)) || (completionRegion.getType() == DOMJSPRegionContexts.JSP_DIRECTIVE_CLOSE && prevTextRegion != null && prevTextRegion.getType() == DOMJSPRegionContexts.JSP_DIRECTIVE_OPEN && documentPosition <= sdRegion.getTextEndOffset(completionRegion))) {
if (completionRegion.getType() == DOMJSPRegionContexts.JSP_DIRECTIVE_OPEN || completionRegion.getType() == DOMJSPRegionContexts.JSP_DIRECTIVE_CLOSE) {
if (request == null) {
request = new ContentAssistRequest(xmlnode, xmlnode, sdRegion, completionRegion, documentPosition, 0, matchString);
}
// determine if there is any part of a directive name already existing
Iterator regions = sdRegion.getRegions().iterator();
String nameString = null;
int begin = request.getReplacementBeginPosition();
int length = request.getReplacementLength();
while (regions.hasNext()) {
ITextRegion region = (ITextRegion) regions.next();
if (region.getType() == DOMJSPRegionContexts.JSP_DIRECTIVE_NAME) {
nameString = sdRegion.getText(region);
begin = sdRegion.getStartOffset(region);
length = region.getTextLength();
break;
}
}
if (nameString == null) {
// $NON-NLS-1$
nameString = "";
}
/* Suggest the directive names that have been determined to be
* appropriate based on existing content
*/
for (int i = 0; i < directiveNames.length; i++) {
if (directiveNames[i].startsWith(nameString) || documentPosition <= begin) {
request.addProposal(new CustomCompletionProposal(directiveNames[i], begin, length, directiveNames[i].length(), JSPEditorPluginImageHelper.getInstance().getImage(JSPEditorPluginImages.IMG_OBJ_TAG_JSP), directiveNames[i], null, null, XMLRelevanceConstants.R_JSP));
}
}
} else // by default, JSP_DIRECTIVE_NAME
{
if (request == null) {
request = new ContentAssistRequest(xmlnode, xmlnode, sdRegion, completionRegion, sdRegion.getStartOffset(completionRegion), completionRegion.getTextLength(), matchString);
}
// add each of the directive names as a proposal
for (int i = 0; i < directiveNames.length; i++) {
if (directiveNames[i].startsWith(matchString)) {
request.addProposal(new CustomCompletionProposal(directiveNames[i], request.getReplacementBeginPosition(), request.getReplacementLength(), directiveNames[i].length(), JSPEditorPluginImageHelper.getInstance().getImage(JSPEditorPluginImages.IMG_OBJ_TAG_JSP), directiveNames[i], null, null, XMLRelevanceConstants.R_JSP));
}
}
}
} else if ((completionRegion.getType() == DOMJSPRegionContexts.JSP_DIRECTIVE_NAME && documentPosition > sdRegion.getTextEndOffset(completionRegion)) || (completionRegion.getType() == DOMJSPRegionContexts.JSP_DIRECTIVE_CLOSE && documentPosition <= sdRegion.getStartOffset(completionRegion))) {
if (request == null) {
request = computeAttributeProposals(matchString, completionRegion, treeNode, xmlnode, context);
}
} else // no name?: <%@ %>
if (completionRegion.getType() == DOMJSPRegionContexts.JSP_DIRECTIVE_CLOSE && documentPosition <= sdRegion.getStartOffset(completionRegion)) {
if (request != null) {
request = computeAttributeProposals(matchString, completionRegion, treeNode, xmlnode, context);
}
Iterator regions = sdRegion.getRegions().iterator();
String nameString = null;
while (regions.hasNext()) {
ITextRegion region = (ITextRegion) regions.next();
if (region.getType() == DOMJSPRegionContexts.JSP_DIRECTIVE_NAME) {
nameString = sdRegion.getText(region);
break;
}
}
if (nameString == null) {
for (int i = 0; i < directiveNames.length; i++) {
request.addProposal(new CustomCompletionProposal(directiveNames[i], request.getReplacementBeginPosition(), request.getReplacementLength(), directiveNames[i].length(), JSPEditorPluginImageHelper.getInstance().getImage(JSPEditorPluginImages.IMG_OBJ_TAG_JSP), directiveNames[i], null, null, XMLRelevanceConstants.R_JSP));
}
}
}
return request;
}
Aggregations