@Override public PsiElement setName(@NotNull String name) throws IncorrectOperationException { if (name.isEmpty()) { throw new IncorrectOperationException("You can't set an empty method name"); } PsiElement nameIdentifier = getNameIdentifier(); if (nameIdentifier instanceof LeafPsiElement) { ((LeafPsiElement) nameIdentifier).replaceWithText(name); } return this; }
private static void addPrototypeTest( @NotNull JstdTestCaseStructure testCaseStructure, @Nullable JSExpression rightAssignmentOperand, @NotNull JSDefinitionExpression wholeLeftDefExpr) { JSReferenceExpression wholeLeftRefExpr = ObjectUtils.tryCast(wholeLeftDefExpr.getExpression(), JSReferenceExpression.class); LeafPsiElement testMethodLeafPsiElement = null; if (wholeLeftRefExpr != null) { testMethodLeafPsiElement = ObjectUtils.tryCast(wholeLeftRefExpr.getReferenceNameElement(), LeafPsiElement.class); } if (testMethodLeafPsiElement != null && testMethodLeafPsiElement.getElementType() == JSTokenTypes.IDENTIFIER) { JSFunctionExpression jsFunctionExpression = JsPsiUtils.extractFunctionExpression(rightAssignmentOperand); JstdTestStructure jstdTestStructure = JstdTestStructure.newPrototypeBasedTestStructure( wholeLeftDefExpr, testMethodLeafPsiElement, jsFunctionExpression); if (jstdTestStructure != null) { testCaseStructure.addTestStructure(jstdTestStructure); } } }
@Override public void clearCaches() { super.clearCaches(); createMyReferences(); }
@Override public void accept(@NotNull PsiElementVisitor visitor) { if (visitor instanceof PerlVisitor) ((PerlVisitor) visitor).visitStringContentElement(this); else super.accept(visitor); }