Пример #1
0
 public static boolean isAllUppercaseName(String name) {
   int uppercaseChars = 0;
   for (int i = 0; i < name.length(); i++) {
     if (Character.isLowerCase(name.charAt(i))) {
       return false;
     }
     if (Character.isUpperCase(name.charAt(i))) {
       uppercaseChars++;
     }
   }
   return uppercaseChars >= 3;
 }
  private boolean findClassOrPackageAtFirst() {
    final String name = getReferenceName();
    if (StringUtil.isEmpty(name) || hasAt()) return false;

    return Character.isUpperCase(name.charAt(0)) && !isMethodCallRef()
        || getParent() instanceof GrReferenceExpressionImpl
            && ((GrReferenceExpressionImpl) getParent()).findClassOrPackageAtFirst();
  }
Пример #3
0
 /**
  * Convinient conversion of testSomeTest -> someTest | SomeTest where testSomeTest is the name of
  * current test.
  *
  * @param lowercaseFirstLetter - whether first letter after test should be lowercased.
  */
 protected String getTestName(boolean lowercaseFirstLetter) {
   String name = getName();
   assertTrue("Test name should start with 'test'", name.startsWith("test"));
   name = name.substring("test".length());
   if (lowercaseFirstLetter && !UsefulTestCase.isAllUppercaseName(name)) {
     name = Character.toLowerCase(name.charAt(0)) + name.substring(1);
   }
   return name;
 }
 private static int getNewIndent(final PsiFile psiFile, final int firstWhitespace) {
   final Document document = psiFile.getViewProvider().getDocument();
   final int startOffset = document.getLineStartOffset(document.getLineNumber(firstWhitespace));
   int endOffset = startOffset;
   final CharSequence charsSequence = document.getCharsSequence();
   while (Character.isWhitespace(charsSequence.charAt(endOffset++))) ;
   final String newIndentStr = charsSequence.subSequence(startOffset, endOffset - 1).toString();
   return IndentHelperImpl.getIndent(
       psiFile.getProject(), psiFile.getFileType(), newIndentStr, true);
 }
 public static RangeMarker insertTemporary(
     final int endOffset, final Document document, final String temporary) {
   final CharSequence chars = document.getCharsSequence();
   final int length = chars.length();
   final RangeMarker toDelete;
   if (endOffset < length && Character.isJavaIdentifierPart(chars.charAt(endOffset))) {
     document.insertString(endOffset, temporary);
     toDelete = document.createRangeMarker(endOffset, endOffset + 1);
   } else if (endOffset >= length) {
     toDelete = document.createRangeMarker(length, length);
   } else {
     toDelete = document.createRangeMarker(endOffset, endOffset);
   }
   toDelete.setGreedyToLeft(true);
   toDelete.setGreedyToRight(true);
   return toDelete;
 }
Пример #6
0
 public static String lowercaseFirstLetter(String name, boolean lowercaseFirstLetter) {
   if (lowercaseFirstLetter && !isAllUppercaseName(name)) {
     name = Character.toLowerCase(name.charAt(0)) + name.substring(1);
   }
   return name;
 }