Exemplo n.º 1
0
 public static String prepareValueText(String text, Project project) {
   text = StringUtil.unquoteString(text);
   text = StringUtil.unescapeStringCharacters(text);
   int tabSize = CodeStyleSettingsManager.getSettings(project).getTabSize(StdFileTypes.JAVA);
   if (tabSize < 0) {
     tabSize = 0;
   }
   return text.replace("\t", StringUtil.repeat(" ", tabSize));
 }
    @Override
    public void parse(String start, ListIterator<String> iterator) {
      if (myIgnoreMode) {
        return;
      }

      if (!iterator.hasNext()) {
        mySyntaxException =
            new PatchSyntaxException(iterator.previousIndex(), "Empty additional info header");
        return;
      }
      while (true) {
        final String header = iterator.next();
        final int idxHead = header.indexOf(UnifiedDiffWriter.ADD_INFO_HEADER);
        if (idxHead == -1) {
          if (myAddMap.isEmpty()) {
            mySyntaxException =
                new PatchSyntaxException(iterator.previousIndex(), "Empty additional info header");
          }
          iterator.previous();
          return;
        }

        final String subsystem =
            header.substring(idxHead + UnifiedDiffWriter.ADD_INFO_HEADER.length()).trim();
        if (!iterator.hasNext()) {
          mySyntaxException =
              new PatchSyntaxException(
                  iterator.previousIndex(), "Empty '" + subsystem + "' data section");
          return;
        }

        final StringBuilder sb = new StringBuilder();
        myAddMap.put(subsystem, sb);
        while (iterator.hasNext()) {
          final String line = iterator.next();
          if (!line.startsWith(UnifiedDiffWriter.ADD_INFO_LINE_START)) {
            iterator.previous();
            break;
          }
          if (sb.length() > 0) {
            sb.append("\n");
          }
          sb.append(
              StringUtil.unescapeStringCharacters(
                  line.substring(UnifiedDiffWriter.ADD_INFO_LINE_START.length())));
        }
      }
    }
Exemplo n.º 3
0
 @NotNull
 static String getKotlinSignature(@NotNull PsiAnnotation kotlinSignatureAnnotation) {
   PsiNameValuePair pair = kotlinSignatureAnnotation.getParameterList().getAttributes()[0];
   PsiAnnotationMemberValue value = pair.getValue();
   if (value == null) {
     return "null";
   } else if (value instanceof PsiLiteralExpression) {
     Object valueObject = ((PsiLiteralExpression) value).getValue();
     return valueObject == null
         ? "null"
         : StringUtil.unescapeStringCharacters(valueObject.toString());
   } else {
     return value.getText();
   }
 }
  public boolean satisfiedBy(PsiElement element) {
    if (!(element instanceof PsiLiteralExpression)) {
      return false;
    }
    final PsiLiteralExpression expression = (PsiLiteralExpression) element;
    final PsiType type = expression.getType();
    if (!PsiType.CHAR.equals(type)) {
      return false;
    }
    final String charLiteral = element.getText();
    if (charLiteral.length() < 2)
      return false; // Incomplete char literal probably without closing amp

    final String charText = charLiteral.substring(1, charLiteral.length() - 1);
    if (StringUtil.unescapeStringCharacters(charText).length() != 1) {
      // not satisfied with character literals of more than one character
      return false;
    }
    return isInConcatenationContext(expression);
  }
Exemplo n.º 5
0
 @Override
 protected void initialize() {
   signature =
       StringUtil.unescapeStringCharacters(
           getStringAttribute(JvmStdlibNames.KOTLIN_SIGNATURE_VALUE_METHOD, ""));
 }