コード例 #1
0
  @Nullable
  public static String getArrayHashValue(
      ArrayCreationExpression arrayCreationExpression, String keyName) {
    ArrayHashElement translationArrayHashElement =
        PsiElementUtils.getChildrenOfType(
            arrayCreationExpression,
            PlatformPatterns.psiElement(ArrayHashElement.class)
                .withFirstChild(
                    PlatformPatterns.psiElement(PhpElementTypes.ARRAY_KEY)
                        .withText(
                            PlatformPatterns.string()
                                .oneOf("'" + keyName + "'", "\"" + keyName + "\""))));

    if (translationArrayHashElement == null) {
      return null;
    }

    if (!(translationArrayHashElement.getValue() instanceof StringLiteralExpression)) {
      return null;
    }

    StringLiteralExpression valueString =
        (StringLiteralExpression) translationArrayHashElement.getValue();
    if (valueString == null) {
      return null;
    }

    return valueString.getContents();
  }
コード例 #2
0
  public static String getMethodParameter(PsiElement parameter) {

    if (!(parameter instanceof StringLiteralExpression)) {
      return null;
    }

    StringLiteralExpression stringLiteralExpression = (StringLiteralExpression) parameter;

    String stringValue = stringLiteralExpression.getText();
    String value =
        stringValue.substring(
            stringLiteralExpression.getValueRange().getStartOffset(),
            stringLiteralExpression.getValueRange().getEndOffset());

    return removeIdeaRuleHack(value);
  }
コード例 #3
0
 public RouteParameterReference(@NotNull StringLiteralExpression element, String routeName) {
   super(element);
   this.routeName = routeName;
   this.parameterName = element.getContents();
 }