private void replaceIteratorNext(
     PsiElement element,
     String contentVariableName,
     String iteratorName,
     PsiElement childToSkip,
     StringBuilder out,
     PsiType contentType) {
   if (isIteratorNext(element, iteratorName, contentType)) {
     out.append(contentVariableName);
   } else {
     final PsiElement[] children = element.getChildren();
     if (children.length == 0) {
       final String text = element.getText();
       if (PsiKeyword.INSTANCEOF.equals(text) && out.charAt(out.length() - 1) != ' ') {
         out.append(' ');
       }
       out.append(text);
     } else {
       boolean skippingWhiteSpace = false;
       for (final PsiElement child : children) {
         if (child.equals(childToSkip)) {
           skippingWhiteSpace = true;
         } else if (child instanceof PsiWhiteSpace && skippingWhiteSpace) {
           // don't do anything
         } else {
           skippingWhiteSpace = false;
           replaceIteratorNext(
               child, contentVariableName, iteratorName, childToSkip, out, contentType);
         }
       }
     }
   }
 }
 private void replaceCollectionGetAccess(
     PsiElement element,
     String contentVariableName,
     PsiVariable listVariable,
     String indexName,
     PsiElement childToSkip,
     StringBuilder out) {
   if (isListGetLookup(element, indexName, listVariable)) {
     out.append(contentVariableName);
   } else {
     final PsiElement[] children = element.getChildren();
     if (children.length == 0) {
       final String text = element.getText();
       if (PsiKeyword.INSTANCEOF.equals(text) && out.charAt(out.length() - 1) != ' ') {
         out.append(' ');
       }
       out.append(text);
     } else {
       boolean skippingWhiteSpace = false;
       for (final PsiElement child : children) {
         if (child.equals(childToSkip)) {
           skippingWhiteSpace = true;
         } else if (child instanceof PsiWhiteSpace && skippingWhiteSpace) {
           // don't do anything
         } else {
           skippingWhiteSpace = false;
           replaceCollectionGetAccess(
               child, contentVariableName, listVariable, indexName, childToSkip, out);
         }
       }
     }
   }
 }
예제 #3
1
 public PropertyAction(RADProperty<?> aProperty) {
   super();
   property = (RADProperty<Object>) aProperty;
   String name = (String) aProperty.getValue("actionName"); // NOI18N
   if (name == null) {
     StringBuilder sb = new StringBuilder(aProperty.getName());
     sb.setCharAt(0, Character.toUpperCase(sb.charAt(0)));
     name = sb.toString();
   }
   putValue(Action.NAME, name);
 }
예제 #4
1
 /**
  * @param source Source string
  * @param chars  Symbols to be trimmed
  * @return string without all specified chars at the end. For example,
  *         <code>chopTrailingChars("c:\\my_directory\\//\\",new char[]{'\\'}) is <code>"c:\\my_directory\\//"</code>,
  *         <code>chopTrailingChars("c:\\my_directory\\//\\",new char[]{'\\','/'}) is <code>"c:\my_directory"</code>.
  *         Actually this method can be used to normalize file names to chop trailing separator chars.
  */
 public static String chopTrailingChars(String source, char[] chars) {
   StringBuilder sb = new StringBuilder(source);
   while (true) {
     boolean atLeastOneCharWasChopped = false;
     for (int i = 0; i < chars.length && sb.length() > 0; i++) {
       if (sb.charAt(sb.length() - 1) == chars[i]) {
         sb.deleteCharAt(sb.length() - 1);
         atLeastOneCharWasChopped = true;
       }
     }
     if (!atLeastOneCharWasChopped) {
       break;
     }
   }
   return sb.toString();
 }