private void addImportant(List candidates) {
   ICSSNode targetNode = fContext.getTargetNode();
   while (targetNode instanceof ICSSPrimitiveValue) {
     targetNode = targetNode.getParentNode();
   }
   if (!(targetNode instanceof ICSSStyleDeclItem)) {
     return;
   }
   // 1. has no priority region
   // 2. cursor position is after of last child
   // 3. normal isMatch method
   String priority = ((ICSSStyleDeclItem) targetNode).getPriority();
   if (priority == null || priority.length() == 0) {
     ICSSNode lastChild = targetNode.getLastChild();
     if (lastChild instanceof IndexedRegion) {
       int startOffset = ((IndexedRegion) lastChild).getStartOffset();
       //	int endOffset = ((IndexedRegion)lastChild).getEndOffset();
       if (startOffset < fContext.getCursorPos() && isMatch(IMPORTANT)) {
         CSSCACandidate item = new CSSCACandidate();
         item.setReplacementString(IMPORTANT);
         item.setCursorPosition(IMPORTANT.length());
         item.setDisplayString(IMPORTANT);
         item.setImageType(CSSImageType.VALUE_STRING);
         appendSemiColon(item);
         candidates.add(item);
       }
     }
   }
 }
コード例 #2
0
 /**
  * @return java.lang.StringBuffer
  * @param node org.eclipse.wst.css.core.model.interfaces.ICSSNode
  * @param region org.eclipse.jface.text.IRegion
  */
 protected final StringBuffer formatProc(ICSSNode node, IRegion region) {
   StringBuffer source = new StringBuffer();
   int curStart = ((IndexedRegion) node).getStartOffset();
   int curEnd = ((IndexedRegion) node).getEndOffset();
   if (node.getChildNodes().getLength() > 0) {
     curEnd = ((IndexedRegion) node.getFirstChild()).getStartOffset();
     if (overlaps(region, curStart, curEnd)) {
       if (includes(region, curStart, curEnd)) formatPre(node, source);
       else formatPre(node, overlappedRegion(region, curStart, curEnd), source);
     }
     curStart = curEnd;
     curEnd = ((IndexedRegion) node.getLastChild()).getEndOffset();
     if (overlaps(region, curStart, curEnd)) {
       if (includes(region, curStart, curEnd)) formatChildren(node, source);
       else formatChildren(node, overlappedRegion(region, curStart, curEnd), source);
     }
     curStart = curEnd;
     curEnd = ((IndexedRegion) node).getEndOffset();
     if (overlaps(region, curStart, curEnd)) {
       if (includes(region, curStart, curEnd)) formatPost(node, source);
       else formatPost(node, overlappedRegion(region, curStart, curEnd), source);
     }
   } else {
     curEnd = getChildInsertPos(node);
     if (overlaps(region, curStart, curEnd)) {
       if (includes(region, curStart, curEnd)) formatPre(node, source);
       else formatPre(node, overlappedRegion(region, curStart, curEnd), source);
     }
     curStart = curEnd;
     curEnd = ((IndexedRegion) node).getEndOffset();
     if (overlaps(region, curStart, curEnd)) {
       if (includes(region, curStart, curEnd)) formatPost(node, source);
       else formatPost(node, overlappedRegion(region, curStart, curEnd), source);
     }
   }
   return source;
 }