use of org.intellij.lang.xpath.psi.XPathExpression in project intellij-community by JetBrains.
the class RemoveExplicitConversionFix method invokeImpl.
public void invokeImpl(Project project, PsiFile file) throws IncorrectOperationException {
PsiElement myElement = getStartElement();
final XPathExpression arg0 = ((XPathFunctionCall) myElement).getArgumentList()[0];
final XPathExpression outer = PsiTreeUtil.getParentOfType(myElement, XPathExpression.class);
if (arg0 instanceof XPathBinaryExpression && outer instanceof XPathBinaryExpression) {
// TODO make this smarter by determining operator precedence
replace("(" + arg0.getText() + ")");
} else {
replace(arg0.getText());
}
}
use of org.intellij.lang.xpath.psi.XPathExpression in project intellij-community by JetBrains.
the class Xslt2RefactoringTest method doExtractFunction.
private void doExtractFunction() throws Throwable {
myFixture.configureByFile(getTestFileName() + ".xsl");
final Editor editor = myFixture.getEditor();
assertTrue("Selection required", editor.getSelectionModel().hasSelection());
editor.getCaretModel().moveToOffset(editor.getSelectionModel().getSelectionStart());
final XsltExtractFunctionAction action = new XsltExtractFunctionAction() {
@Override
protected RefactoringOptions getSettings(XPathExpression expression, Set<XPathExpression> matchingExpressions) {
return new RefactoringOptions() {
@Override
public boolean isCanceled() {
return false;
}
@Override
public String getName() {
return "f:foo";
}
};
}
};
final PsiFile file = InjectedLanguageUtil.findInjectedPsiNoCommit(myFixture.getFile(), editor.getCaretModel().getOffset());
final Editor editorWindow = InjectedLanguageUtil.getInjectedEditorForInjectedFile(editor, file);
assertTrue(editorWindow instanceof EditorWindow);
action.invoke(myFixture.getProject(), editorWindow, file, null);
myFixture.checkResultByFile(getTestFileName() + "_after.xsl");
}
use of org.intellij.lang.xpath.psi.XPathExpression in project intellij-community by JetBrains.
the class IntroduceParameterProcessor method findUsages.
@NotNull
protected UsageInfo[] findUsages() {
int usageCount = myOtherExpressions.size() + 1;
final List<PsiElement> callsToUpdate;
if (!mySettings.isCreateDefault()) {
assert myTemplate != null;
final Collection<PsiReference> references = ReferencesSearch.search(myTemplate, myTemplate.getUseScope(), false).findAll();
callsToUpdate = new ArrayList<>(references.size());
for (PsiReference reference : references) {
final PsiElement e = reference.getElement();
final XmlTag tag = PsiTreeUtil.getContextOfType(e, XmlTag.class, true);
if (tag != null && XsltSupport.isTemplateCall(tag)) {
callsToUpdate.add(tag);
}
}
usageCount += callsToUpdate.size();
} else {
//noinspection unchecked
callsToUpdate = Collections.emptyList();
}
final UsageInfo[] usageInfos = new UsageInfo[usageCount];
usageInfos[0] = XPathUsageInfo.create(myExpression);
int i = 1;
for (XPathExpression expression : myOtherExpressions) {
usageInfos[i++] = XPathUsageInfo.create(expression);
}
for (PsiElement o : callsToUpdate) {
usageInfos[i++] = new UsageInfo(o, false);
}
return usageInfos;
}
Aggregations