AttributeInfo attrInfo = tagInfo.getAttributeInfo(attr);
if(attrInfo!=null){
AssistInfo[] keywords = getAttributeValues(last,dim[0].substring(1),attrInfo);
for(int i=0;i<keywords.length;i++){
if(keywords[i].getReplaceString().toLowerCase().startsWith(value.toLowerCase())){
list.add(new CompletionProposal(
keywords[i].getReplaceString(),
documentOffset - value.length(), value.length(),
keywords[i].getReplaceString().length(),
keywords[i].getImage()==null ? valueImage : keywords[i].getImage(),
keywords[i].getDisplayString(), null, null));
}
}
}
}
// tag
} else if(word.startsWith("<") && !word.equals("</")) {
if(supportTagRelation()){
TagInfo parent = getTagInfo(last);
tagList = new ArrayList();
if(parent!=null){
String[] childNames = parent.getChildTagNames();
for(int i=0;i<childNames.length;i++){
tagList.add(getTagInfo(childNames[i]));
}
}
}
for(int i=0;i<tagList.size();i++){
TagInfo tagInfo = (TagInfo)tagList.get(i);
if(tagInfo instanceof TextInfo){
TextInfo textInfo = (TextInfo)tagInfo;
if ((textInfo.getText().toLowerCase()).indexOf(word) == 0) {
list.add(new CompletionProposal(
textInfo.getText(), documentOffset - word.length(),
word.length(), textInfo.getPosition(), tagImage,
textInfo.getDisplayString(), null, tagInfo.getDescription()));
}
continue;
}
String tagName = tagInfo.getTagName();
if (("<" + tagInfo.getTagName().toLowerCase()).indexOf(word) == 0) {
String assistKeyword = tagName;
int position = 0;
// required attributes
AttributeInfo[] requierAttrs = tagInfo.getRequiredAttributeInfo();
for(int j=0;j<requierAttrs.length;j++){
assistKeyword = assistKeyword + " " + requierAttrs[j].getAttributeName();
if(requierAttrs[j].hasValue()){
assistKeyword = assistKeyword + "=\"\"";
if(j==0){
position = tagName.length() + requierAttrs[j].getAttributeName().length() + 3;
}
}
}
if(tagInfo.hasBody()){
assistKeyword = assistKeyword + ">";
if(assistCloseTag){
if(position==0){
position = assistKeyword.length();
}
assistKeyword = assistKeyword + "</" + tagName + ">";
}
} else {
if(tagInfo.isEmptyTag() && xhtmlMode == false){
assistKeyword = assistKeyword + ">";
} else {
assistKeyword = assistKeyword + "/>";
}
}
if(position==0){
position = assistKeyword.length();
}
try {
list.add(new CompletionProposal(
assistKeyword, documentOffset - word.length() + 1,
word.length() - 1, position, tagImage, tagName, null, tagInfo.getDescription()));
} catch(Exception ex){
}
}
}
// custom elements
for(int i=0;i<customElems.size();i++){
CustomElement element = (CustomElement)customElems.get(i);
if ((element.getAssistString().toLowerCase()).indexOf(word) == 0) {
int position = element.getAssistString().indexOf('"');
if(position==-1){
position = element.getAssistString().indexOf("><");
}
if(position==-1){
position = element.getAssistString().length();
}
list.add(new CompletionProposal(
element.getAssistString(), documentOffset - word.length(),
word.length(), position + 1, tagImage, element.getDisplayName(),
null, null));
}
}
// attribute
} else if(!prev.equals("")){
String tagName = prev;
TagInfo tagInfo = getTagInfo(tagName);
if(tagInfo!=null){
AttributeInfo[] attrList = tagInfo.getAttributeInfo();
for(int j=0;j<attrList.length;j++){
if (attrList[j].getAttributeName().toLowerCase().indexOf(word) == 0) {
String assistKeyword = null;
int position = 0;
if(attrList[j].hasValue()){
assistKeyword = attrList[j].getAttributeName() + "=\"\"";
position = 2;
} else {
assistKeyword = attrList[j].getAttributeName();
position = 0;
}
list.add(new CompletionProposal(
assistKeyword, documentOffset - word.length(), word.length(),
attrList[j].getAttributeName().length() + position,
attrImage, attrList[j].getAttributeName(), null, attrList[j].getDescription()));
}
}
}
// custom attributes
for(int i=0;i<customAttrs.size();i++){
CustomAttribute attrInfo = (CustomAttribute)customAttrs.get(i);
if(attrInfo.getTargetTag().equals("*") || attrInfo.getTargetTag().equals(tagName)){
if(tagName.indexOf(":")<0 || customElemNames.contains(tagName)){
list.add(new CompletionProposal(
attrInfo.getAttributeName() + "=\"\"",
documentOffset - word.length(), word.length(),
attrInfo.getAttributeName().length() + 2,
attrImage, attrInfo.getAttributeName(), null, null));
}
}
}
// close tag
} else if(!last.equals("")){
TagInfo info = getTagInfo(last);
if(info==null || xhtmlMode==true || info.hasBody() || !info.isEmptyTag()){
String assistKeyword = "</" + last + ">";
int length = 0;
if(word.equals("</")){
length = 2;
}
list.add(new CompletionProposal(
assistKeyword, documentOffset - length, length,
assistKeyword.length(), tagImage, assistKeyword, null, null));
}
}