use of com.intellij.lang.javascript.psi.JSProperty in project intellij-plugins by JetBrains.
the class AngularUiRouterTest method emptyViewNavigatesToFilesDefaultView.
private void emptyViewNavigatesToFilesDefaultView(PsiFile file, String str) {
final PsiElement inObj = getElement(file, str);
Assert.assertTrue(inObj.getParent() instanceof JSLiteralExpression);
Assert.assertTrue(inObj.getParent().getParent() instanceof JSProperty);
final JSProperty templateUrl = (JSProperty) inObj.getParent().getParent();
Assert.assertEquals("templateUrl", templateUrl.getName());
final PsiElement parentProperty = templateUrl.getParent().getParent();
Assert.assertTrue(parentProperty instanceof JSProperty);
final PsiReference reference = parentProperty.getReference();
Assert.assertNotNull(reference);
Assert.assertEquals("", reference.getCanonicalText());
final PsiElement resolve = reference.resolve();
Assert.assertNotNull(resolve);
Assert.assertEquals(StringUtil.unquoteString(str), resolve.getContainingFile().getName());
Assert.assertEquals("", ((JSPsiNamedElementBase) resolve).getName());
final PsiElement element = ((JSOffsetBasedImplicitElement) resolve).getElementAtOffset();
Assert.assertEquals("ui-view", element.getText());
}
use of com.intellij.lang.javascript.psi.JSProperty in project oxy-template-support-plugin by mutant-industries.
the class MacroParamDocumentationProvider method getCustomDocumentationElement.
@Nullable
@Override
public PsiElement getCustomDocumentationElement(@NotNull Editor editor, @NotNull PsiFile file, @Nullable PsiElement contextElement) {
PsiElement element;
PsiReference reference;
if (contextElement != null) {
if (contextElement.getNode().getElementType() == OxyTemplateTypes.T_MACRO_PARAM_NAME) {
return contextElement;
} else if ((contextElement.getNode().getElementType() == JSTokenTypes.IDENTIFIER || contextElement.getNode().getElementType() == JSTokenTypes.COLON) && (((element = PsiTreeUtil.getParentOfType(contextElement, JSReferenceExpression.class)) != null && (element = ((JSReferenceExpression) element).resolve()) != null) || (element = contextElement.getParent()) instanceof JSProperty) && element instanceof JSProperty && OxyTemplateIndexUtil.isMacro(element)) {
return new FakeDocumentationPsiElement((JSProperty) element);
} else if (contextElement.getNode().getElementType() == OxyTemplateTypes.T_MACRO_NAME && (element = PsiTreeUtil.getParentOfType(contextElement, MacroName.class)) != null && (reference = element.getReference()) != null && (element = reference.resolve()) != null && element instanceof JSProperty && OxyTemplateIndexUtil.isMacro(element)) {
return new FakeDocumentationPsiElement((JSProperty) element);
}
}
return null;
}
use of com.intellij.lang.javascript.psi.JSProperty in project oxy-template-support-plugin by mutant-industries.
the class InnerJsTypeEvaluator method checkMacroFirstParameter.
/**
* @param parameter
* @return macro, if parameter is its first parameter, null otherwise
*/
@Nullable
private static JSProperty checkMacroFirstParameter(@Nullable JSParameter parameter) {
JSProperty macro;
JSFunctionExpression functionExpression;
if ((macro = PsiTreeUtil.getParentOfType(parameter, JSProperty.class)) != null && OxyTemplateIndexUtil.isMacro(macro) && macro.getLastChild() instanceof JSFunctionExpression) {
functionExpression = (JSFunctionExpression) macro.getLastChild();
if (functionExpression.getParameters().length > 0 && functionExpression.getParameters()[0].isEquivalentTo(parameter)) {
return macro;
}
}
return null;
}
use of com.intellij.lang.javascript.psi.JSProperty in project intellij-plugins by JetBrains.
the class JstdStructureTest method matchTest.
private static void matchTest(@NotNull MarkedTestStructure markedTestStructure, @NotNull JstdTestStructure testStructure) {
Assert.assertEquals("Build test name is not equal to the marked one", markedTestStructure.getName(), testStructure.getName());
String testName = testStructure.getName();
JSProperty markedJsProperty = markedTestStructure.getPropertyPsiElement();
if (markedJsProperty != null) {
matchPsiElement(testName, "property", markedJsProperty, testStructure.getJsProperty());
} else {
matchPsiElement(testName, "declaration", markedTestStructure.getDeclarationPsiElement(), testStructure.getTestMethodNameDeclaration());
matchPsiElement(testName, "body", markedTestStructure.getBodyPsiElement(), testStructure.getTestMethodBody());
}
}
use of com.intellij.lang.javascript.psi.JSProperty in project intellij-plugins by JetBrains.
the class AngularJSDirectiveRenameProcessor method renameElement.
@Override
public void renameElement(PsiElement element, String newName, UsageInfo[] usages, @Nullable RefactoringElementListener listener) throws IncorrectOperationException {
final boolean isAngular2 = DirectiveUtil.isAngular2Directive(element);
final PsiNamedElement directive = (PsiNamedElement) element;
final String attributeName = isAngular2 ? newName : DirectiveUtil.getAttributeName(newName);
for (UsageInfo usage : usages) {
RenameUtil.rename(usage, attributeName);
}
if (isAngular2) {
final JSProperty selector = AngularJS2IndexingHandler.getSelector(element.getParent());
final JSExpression value = selector != null ? selector.getValue() : null;
if (value != null) {
if (value.getText().contains("["))
newName = "[" + newName + "]";
ElementManipulators.getManipulator(value).handleContentChange(value, newName);
}
} else {
directive.setName(DirectiveUtil.attributeToDirective(element, newName));
}
if (listener != null) {
listener.elementRenamed(element);
}
}
Aggregations