public void apply(IDocument document) {
   if (this.getRepValue().getType() != NewReplaceValue.TYPE_PAR) {
     String prefix = this.getPrefix();
     String replaceString = prefix + this.getItem();
     if (getItem().getType() == ReferenceUtilities.REF_ENUMVAR
         || this.getRepValue().getType() == NewReplaceValue.TYPE_NONE) {
       // Not Sure why this was toString()
       // replaceString = this.item.toString();
       replaceString = this.getItem().getname();
     }
     if (getItem().getType() == ReferenceUtilities.REF_MODINSTANCE_CONNECT) {
       ModInstanceConnect connect = (ModInstanceConnect) getItem().getObject();
       String name = connect.getname();
       if (prefix.length() == 1) replaceString = name;
       else replaceString = prefix + name;
     }
     if (ReferenceUtilities.checkType(getItem().getType(), ReferenceUtilities.REF_PORT_TOP) == 0) {
       if (!prefix.equalsIgnoreCase("(")) {
         replaceString = prefix + getItem().getname();
       } else {
         replaceString = getItem().getname();
       }
     }
     if (replaceString.startsWith(".")) {
       replaceString = replaceString.substring(1);
     }
     /*if (item.getType() == ReferenceUtilities.REF_COMPONENT) {
         replaceString = "";
     }
     if (item.getType() == ReferenceUtilities.REF_INSTANCE_MODULE) {
         replaceString = "";
     }*/
     try {
       replaceString = replaceString.trim();
       if (this.getRepValue().getLength() == 0) {
         String ustr = document.get(this.getRepValue().getSpos() - 1, 1);
         document.replace(
             this.getRepValue().getSpos() - 1,
             this.getRepValue().getLength() + 1,
             ustr + replaceString);
       } else {
         document.replace(
             this.getRepValue().getSpos(), this.getRepValue().getLength(), replaceString);
       }
     } catch (BadLocationException e) {
       HardwareLog.logError(e);
     }
   } else {
     String prefix = this.getPrefix();
     String replaceString = prefix + this.getItem();
     replaceString = replaceString.trim();
     try {
       document.replace(
           this.getRepValue().getSpos(), this.getRepValue().getLength(), replaceString);
     } catch (BadLocationException e) {
       HardwareLog.logError(e);
     }
   }
 }
 private void handleKeyword(IDocument d, String key, int sp, int ep) {
   String k = key.toUpperCase();
   if (!k.equals(key)) {
     try {
       d.replace(sp, ep - sp + 1, k);
     } catch (BadLocationException e) {
       HardwareLog.logError(e);
     }
   }
 }
  /** Needs Binary Search over keywords */
  private void checkForKeywords(IDocument d, DocumentCommand c) {
    int off = c.offset - 1;

    char u;
    try {
      if (this.isCommentLine(d, c.offset)) return;
      int ep = off;
      u = d.getChar(off);
      String key = "";
      while (Character.isJavaIdentifierPart(u)) {
        key = u + key;
        off = off - 1;
        u = d.getChar(off);
      }
      int sp = off + 1;
      for (String ukey : VhdlScanner.keywords) {
        if (ukey.equalsIgnoreCase(key)) {
          this.handleKeyword(d, key, sp, ep);
        }
      }
    } catch (BadLocationException e) {
      HardwareLog.logError(e);
    }
  }