use of com.intellij.structuralsearch.MatchOptions in project intellij-community by JetBrains.
the class TypeConversionDescriptor method replaceExpression.
@NotNull
public static PsiExpression replaceExpression(@NotNull PsiExpression expression, String stringToReplace, String replaceByString) {
Project project = expression.getProject();
final ReplaceOptions options = new ReplaceOptions();
final MatchOptions matchOptions = options.getMatchOptions();
matchOptions.setFileType(StdFileTypes.JAVA);
final Replacer replacer = new Replacer(project, null);
final String replacement = replacer.testReplace(expression.getText(), stringToReplace, replaceByString, options);
return (PsiExpression) JavaCodeStyleManager.getInstance(project).shortenClassReferences(expression.replace(JavaPsiFacade.getInstance(project).getElementFactory().createExpressionFromText(replacement, expression)));
}
use of com.intellij.structuralsearch.MatchOptions in project intellij-community by JetBrains.
the class FindInFilesOptimizingSearchHelper method doAddSearchWordInText.
protected void doAddSearchWordInText(final String refname) {
final MatchOptions options = context.getOptions();
CacheManager.SERVICE.getInstance(myProject).processFilesWithWord(myFileProcessor, refname, UsageSearchContext.IN_PLAIN_TEXT, (GlobalSearchScope) options.getScope(), options.isCaseSensitiveMatch());
}
use of com.intellij.structuralsearch.MatchOptions in project intellij-community by JetBrains.
the class FindInFilesOptimizingSearchHelper method doAddSearchWordInCode.
protected void doAddSearchWordInCode(final String refname) {
final MatchOptions options = context.getOptions();
CacheManager.SERVICE.getInstance(myProject).processFilesWithWord(myFileProcessor, refname, UsageSearchContext.IN_CODE, (GlobalSearchScope) options.getScope(), options.isCaseSensitiveMatch());
}
use of com.intellij.structuralsearch.MatchOptions in project intellij-community by JetBrains.
the class SelectTemplateDialog method showPatternPreviewFromConfiguration.
private void showPatternPreviewFromConfiguration(@Nullable final Configuration configuration) {
if (configuration == null) {
myCardLayout.show(myPreviewPanel, SELECT_TEMPLATE_CARD);
return;
} else {
myCardLayout.show(myPreviewPanel, PREVIEW_CARD);
}
final MatchOptions matchOptions = configuration.getMatchOptions();
UIUtil.setContent(searchPatternEditor, matchOptions.getSearchPattern(), 0, searchPatternEditor.getDocument().getTextLength(), project);
searchPatternEditor.putUserData(SubstitutionShortInfoHandler.CURRENT_CONFIGURATION_KEY, configuration);
if (replace) {
String replacement;
if (configuration instanceof ReplaceConfiguration) {
replacement = ((ReplaceConfiguration) configuration).getOptions().getReplacement();
} else {
replacement = configuration.getMatchOptions().getSearchPattern();
}
UIUtil.setContent(replacePatternEditor, replacement, 0, replacePatternEditor.getDocument().getTextLength(), project);
replacePatternEditor.putUserData(SubstitutionShortInfoHandler.CURRENT_CONFIGURATION_KEY, configuration);
}
}
use of com.intellij.structuralsearch.MatchOptions in project intellij-community by JetBrains.
the class StructuralSearchUsageTarget method getLongDescriptiveName.
@NotNull
@Override
public String getLongDescriptiveName() {
final MatchOptions matchOptions = myConfiguration.getMatchOptions();
final String pattern = matchOptions.getSearchPattern();
final String scope = matchOptions.getScope().getDisplayName();
final String result;
if (myConfiguration instanceof ReplaceConfiguration) {
final ReplaceConfiguration replaceConfiguration = (ReplaceConfiguration) myConfiguration;
final String replacement = replaceConfiguration.getOptions().getReplacement();
result = SSRBundle.message("replace.occurrences.of.0.with.1.in.2", pattern, replacement, scope);
} else {
result = SSRBundle.message("occurrences.of.0.in.1", pattern, scope);
}
return StringUtil.shortenTextWithEllipsis(result, 150, 0, true);
}
Aggregations