本文整理汇总了Java中com.intellij.find.FindModel.setStringToFind方法的典型用法代码示例。如果您正苦于以下问题:Java FindModel.setStringToFind方法的具体用法?Java FindModel.setStringToFind怎么用?Java FindModel.setStringToFind使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.intellij.find.FindModel
的用法示例。
在下文中一共展示了FindModel.setStringToFind方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testFindInPathInLibraryDirActuallySearchesInTheirSourcesToo
import com.intellij.find.FindModel; //导入方法依赖的package包/类
public void testFindInPathInLibraryDirActuallySearchesInTheirSourcesToo() throws Exception {
FindModel model = new FindModel();
final PsiClass aClass = myJavaFacade.findClass("LibraryClass1");
assertNotNull(aClass);
model.setDirectoryName(aClass.getContainingFile().getContainingDirectory().getVirtualFile().getPath());
model.setCaseSensitive(true);
model.setCustomScope(false);
model.setStringToFind("LibraryClass1");
model.setProjectScope(false);
List<UsageInfo> usages = new ArrayList<>();
FindInProjectUtil.findUsages(model, getProject(),
new CommonProcessors.CollectProcessor<>(
usages), FindInProjectUtil
.setupProcessPresentation(getProject(), false, FindInProjectUtil.setupViewPresentation(false, model)));
assertEquals(2, usages.size());
}
示例2: testFindInPathInLibrarySourceDirShouldSearchJustInThisDirectoryOnly
import com.intellij.find.FindModel; //导入方法依赖的package包/类
public void testFindInPathInLibrarySourceDirShouldSearchJustInThisDirectoryOnly() throws Exception {
FindModel model = new FindModel();
final PsiClass aClass = myJavaFacade.findClass("x.X");
assertNotNull(aClass);
String classDirPath = aClass.getContainingFile().getContainingDirectory().getVirtualFile().getPath();
String sourceDirPath = ((PsiFile)aClass.getContainingFile().getNavigationElement()).getContainingDirectory().getVirtualFile().getPath();
assertFalse(classDirPath.equals(sourceDirPath));
model.setDirectoryName(sourceDirPath);
model.setCaseSensitive(true);
model.setCustomScope(false);
model.setStringToFind("xxx");
model.setProjectScope(false);
List<UsageInfo> usages = new ArrayList<>();
FindInProjectUtil.findUsages(model, getProject(),
new CommonProcessors.CollectProcessor<>(
usages), FindInProjectUtil
.setupProcessPresentation(getProject(), false, FindInProjectUtil.setupViewPresentation(false, model)));
UsageInfo info = assertOneElement(usages);
assertEquals("X.java", info.getFile().getName());
}
示例3: actionPerformed
import com.intellij.find.FindModel; //导入方法依赖的package包/类
@Override
public void actionPerformed(final AnActionEvent e) {
Editor editor = e.getRequiredData(CommonDataKeys.EDITOR_EVEN_IF_INACTIVE);
Project project = e.getRequiredData(CommonDataKeys.PROJECT);
EditorSearchSession search = e.getRequiredData(EditorSearchSession.SESSION_KEY);
if (project.isDisposed()) return;
FindModel oldModel = FindManager.getInstance(project).getFindInFileModel();
FindModel newModel = oldModel.clone();
String text = search.getTextInField();
if (StringUtil.isEmpty(text)) return;
newModel.setStringToFind(text);
FindUtil.findAllAndShow(project, editor, newModel);
}
示例4: findExpressionOccurrences
import com.intellij.find.FindModel; //导入方法依赖的package包/类
public PsiExpression[] findExpressionOccurrences() {
if (myMainOccurence instanceof PsiLiteralExpression && !myMainOccurence.isPhysical()) {
final FindManager findManager = FindManager.getInstance(getScope().getProject());
final FindModel findModel = (FindModel)findManager.getFindInFileModel().clone();
findModel.setCaseSensitive(true);
findModel.setRegularExpressions(false);
String value = StringUtil.stripQuotesAroundValue(myMainOccurence.getText());
if (value.length() > 0) {
findModel.setStringToFind(value);
final List<PsiExpression> results = new ArrayList<PsiExpression>();
final PsiFile file = getScope().getContainingFile();
final String text = getScope().getText();
final int offset = getScope().getTextRange().getStartOffset();
FindResult result = findManager.findString(text, 0, findModel);
final Set<PsiLiteralExpression> literals = new HashSet<PsiLiteralExpression>();
while (result.isStringFound()) {
final int startOffset = offset + result.getStartOffset();
final int endOffset = result.getEndOffset();
final PsiLiteralExpression literalExpression =
PsiTreeUtil.getParentOfType(file.findElementAt(startOffset), PsiLiteralExpression.class);
if (literalExpression != null && !literals.contains(literalExpression)) { //enum. occurrences inside string literals
final PsiExpression expression =
IntroduceVariableBase.getSelectedExpression(file.getProject(), file, startOffset, offset + endOffset);
if (expression != null && IntroduceVariableBase.getErrorMessage(expression) == null) {
results.add(expression);
literals.add(literalExpression);
}
}
result = findManager.findString(text, endOffset, findModel);
}
return results.toArray(new PsiExpression[results.size()]);
}
}
return CodeInsightUtil.findExpressionOccurrences(myScope, myMainOccurence);
}
示例5: getFindModel
import com.intellij.find.FindModel; //导入方法依赖的package包/类
protected static FindModel getFindModel(String text, boolean wholeWords) {
FindModel model = new FindModel();
model.setStringToFind(text);
model.setCaseSensitive(true);
model.setWholeWordsOnly(wholeWords);
return model;
}
示例6: execute
import com.intellij.find.FindModel; //导入方法依赖的package包/类
@Override
protected void execute(@NotNull final Project project) {
FindManager findManager = FindManager.getInstance(project);
UsageViewManager usageViewManager = UsageViewManager.getInstance(project);
FindModel findModel = (FindModel)findManager.getFindInProjectModel().clone();
findModel.setStringToFind(myTextToFind);
findModel.setReplaceState(false);
findModel.setOpenInNewTabVisible(true);
findModel.setOpenInNewTabEnabled(true);
findModel.setOpenInNewTab(true);
findModel.setFileFilter(SdkConstants.FN_BUILD_GRADLE);
findManager.getFindInProjectModel().copyFrom(findModel);
final FindModel findModelCopy = (FindModel)findModel.clone();
UsageViewPresentation presentation = FindInProjectUtil.setupViewPresentation(findModel.isOpenInNewTabEnabled(), findModelCopy);
boolean showPanelIfOnlyOneUsage = !FindSettings.getInstance().isSkipResultsWithOneUsage();
final FindUsagesProcessPresentation processPresentation =
FindInProjectUtil.setupProcessPresentation(project, showPanelIfOnlyOneUsage, presentation);
UsageTarget usageTarget = new FindInProjectUtil.StringUsageTarget(project, findModel);
usageViewManager.searchAndShowUsages(new UsageTarget[]{usageTarget}, new Factory<UsageSearcher>() {
@Override
public UsageSearcher create() {
return new UsageSearcher() {
@Override
public void generate(@NotNull final Processor<Usage> processor) {
AdapterProcessor<UsageInfo, Usage> consumer =
new AdapterProcessor<UsageInfo, Usage>(processor, UsageInfo2UsageAdapter.CONVERTER);
//noinspection ConstantConditions
FindInProjectUtil.findUsages(findModelCopy, project, consumer, processPresentation);
}
};
}
}, processPresentation, presentation, null);
}
示例7: createFindModel
import com.intellij.find.FindModel; //导入方法依赖的package包/类
private static FindModel createFindModel(FindManager findManager, String selectedString, String replaceWith) {
FindModel findModel = (FindModel)findManager.getFindInProjectModel().clone();
findModel.setStringToFind(selectedString);
findModel.setStringToReplace(replaceWith);
findModel.setReplaceState(true);
findModel.setPromptOnReplace(true);
findModel.setCaseSensitive(true);
findModel.setRegularExpressions(false);
return findModel;
}
示例8: actionPerformed
import com.intellij.find.FindModel; //导入方法依赖的package包/类
@Override
public void actionPerformed(final AnActionEvent e) {
Editor editor = getEditorSearchComponent().getEditor();
Project project = editor.getProject();
if (project != null && !project.isDisposed()) {
final FindModel model = FindManager.getInstance(project).getFindInFileModel();
final FindModel realModel = (FindModel)model.clone();
String text = getEditorSearchComponent().getTextInField();
if (StringUtil.isEmpty(text)) return;
realModel.setStringToFind(text);
FindUtil.findAllAndShow(project, editor, realModel);
}
}
示例9: doExecute
import com.intellij.find.FindModel; //导入方法依赖的package包/类
@Override
public void doExecute(Editor editor, @Nullable Caret c, DataContext dataContext) {
Caret caret = c == null ? editor.getCaretModel().getPrimaryCaret() : c;
if (!caret.hasSelection()) {
TextRange wordSelectionRange = getSelectionRange(editor, caret);
if (wordSelectionRange != null) {
setSelection(editor, caret, wordSelectionRange);
}
}
String selectedText = caret.getSelectedText();
Project project = editor.getProject();
if (project == null || selectedText == null) {
return;
}
int caretShiftFromSelectionStart = caret.getOffset() - caret.getSelectionStart();
FindManager findManager = FindManager.getInstance(project);
FindModel model = new FindModel();
model.setStringToFind(selectedText);
model.setCaseSensitive(true);
model.setWholeWordsOnly(true);
int searchStartOffset = 0;
FindResult findResult = findManager.findString(editor.getDocument().getCharsSequence(), searchStartOffset, model);
while (findResult.isStringFound()) {
int newCaretOffset = caretShiftFromSelectionStart + findResult.getStartOffset();
EditorActionUtil.makePositionVisible(editor, newCaretOffset);
Caret newCaret = editor.getCaretModel().addCaret(editor.offsetToVisualPosition(newCaretOffset));
if (newCaret != null) {
setSelection(editor, newCaret, findResult);
}
findResult = findManager.findString(editor.getDocument().getCharsSequence(), findResult.getEndOffset(), model);
}
editor.getScrollingModel().scrollToCaret(ScrollType.RELATIVE);
}
示例10: createFindModel
import com.intellij.find.FindModel; //导入方法依赖的package包/类
FindModel createFindModel(FindManager findManager) {
FindModel clone = (FindModel) findManager.getFindInFileModel().clone();
clone.setFindAll(true);
clone.setFromCursor(true);
clone.setForward(true);
clone.setWholeWordsOnly(false);
clone.setCaseSensitive(true);
clone.setRegularExpressions(true);
clone.setWholeWordsOnly(true);
clone.setStringToFind(FIND_REGEXP);
return clone;
}
示例11: applyTo
import com.intellij.find.FindModel; //导入方法依赖的package包/类
private void applyTo(@NotNull FindModel model, boolean findAll) {
model.setCaseSensitive(myCbCaseSensitive.isSelected());
if (model.isReplaceState()) {
model.setPreserveCase(myCbPreserveCase.isSelected());
}
model.setWholeWordsOnly(myCbWholeWordsOnly.isSelected());
String selectedSearchContextInUi = (String)mySearchContext.getSelectedItem();
FindModel.SearchContext searchContext = FindModel.SearchContext.ANY;
if (FindBundle.message("find.context.in.literals.scope.label").equals(selectedSearchContextInUi)) {
searchContext = FindModel.SearchContext.IN_STRING_LITERALS;
}
else if (FindBundle.message("find.context.in.comments.scope.label").equals(selectedSearchContextInUi)) {
searchContext = FindModel.SearchContext.IN_COMMENTS;
}
else if (FindBundle.message("find.context.except.comments.scope.label").equals(selectedSearchContextInUi)) {
searchContext = FindModel.SearchContext.EXCEPT_COMMENTS;
}
else if (FindBundle.message("find.context.except.literals.scope.label").equals(selectedSearchContextInUi)) {
searchContext = FindModel.SearchContext.EXCEPT_STRING_LITERALS;
} else if (FindBundle.message("find.context.except.comments.and.literals.scope.label").equals(selectedSearchContextInUi)) {
searchContext = FindModel.SearchContext.EXCEPT_COMMENTS_AND_STRING_LITERALS;
}
model.setSearchContext(searchContext);
model.setRegularExpressions(myCbRegularExpressions.isSelected());
String stringToFind = getStringToFind();
model.setStringToFind(stringToFind);
if (model.isReplaceState()){
model.setPromptOnReplace(true);
model.setReplaceAll(false);
String stringToReplace = getStringToReplace();
model.setStringToReplace(StringUtil.convertLineSeparators(stringToReplace));
}
if (!model.isMultipleFiles()){
model.setForward(myRbForward.isSelected());
model.setFromCursor(myRbFromCursor.isSelected());
model.setGlobal(myRbGlobal.isSelected());
}
else{
if (myCbToOpenInNewTab != null){
model.setOpenInNewTab(myCbToOpenInNewTab.isSelected());
}
model.setProjectScope(myRbProject.isSelected());
model.setDirectoryName(null);
model.setModuleName(null);
model.setCustomScopeName(null);
model.setCustomScope(null);
model.setCustomScope(false);
if (myRbDirectory.isSelected()) {
String directory = getDirectory();
model.setDirectoryName(directory == null ? "" : directory);
model.setWithSubdirectories(myCbWithSubdirectories.isSelected());
}
else if (myRbModule.isSelected()) {
model.setModuleName((String)myModuleComboBox.getSelectedItem());
}
else if (myRbCustomScope.isSelected()) {
SearchScope selectedScope = myScopeCombo.getSelectedScope();
String customScopeName = selectedScope == null ? null : selectedScope.getDisplayName();
model.setCustomScopeName(customScopeName);
model.setCustomScope(selectedScope == null ? null : selectedScope);
model.setCustomScope(true);
}
}
model.setFindAll(findAll);
String mask = getFileTypeMask();
model.setFileFilter(mask);
}
示例12: execute
import com.intellij.find.FindModel; //导入方法依赖的package包/类
@Override
public boolean execute(@NotNull ReferencesSearch.SearchParameters queryParameters, @NotNull final Processor<PsiReference> consumer) {
final PsiElement file = queryParameters.getElementToSearch();
if (file instanceof PsiBinaryFile) {
final Module module = ApplicationManager.getApplication().runReadAction(new Computable<Module>() {
@Override
public Module compute() {
return ModuleUtilCore.findModuleForPsiElement(file);
}
});
final VirtualFile image = ((PsiBinaryFile)file).getVirtualFile();
if (isImage(image) && isIconsModule(module)) {
final Project project = file.getProject();
final FindModel model = new FindModel();
final String path = getPathToImage(image, module);
if (path == null) return true;
model.setStringToFind(path);
model.setCaseSensitive(true);
model.setFindAll(true);
model.setWholeWordsOnly(true);
FindInProjectUtil.findUsages(model, project, new Processor<UsageInfo>() {
@Override
public boolean process(final UsageInfo usage) {
ApplicationManager.getApplication().runReadAction(new Runnable() {
public void run() {
final PsiElement element = usage.getElement();
final ProperTextRange textRange = usage.getRangeInElement();
if (element != null && textRange != null) {
final PsiElement start = element.findElementAt(textRange.getStartOffset());
final PsiElement end = element.findElementAt(textRange.getEndOffset());
if (start != null && end != null) {
PsiElement value = PsiTreeUtil.findCommonParent(start, end);
if (value instanceof PsiJavaToken) {
value = value.getParent();
}
if (value != null) {
final PsiFileReference reference = FileReferenceUtil.findFileReference(value);
if (reference != null) {
consumer.process(reference);
}
}
}
}
}
});
return true;
}
}, new FindUsagesProcessPresentation(new UsageViewPresentation()));
}
}
return true;
}
示例13: applyTo
import com.intellij.find.FindModel; //导入方法依赖的package包/类
private void applyTo(@NotNull FindModel model, boolean findAll) {
model.setCaseSensitive(myCbCaseSensitive.isSelected());
if (model.isReplaceState()) {
model.setPreserveCase(myCbPreserveCase.isSelected());
}
model.setWholeWordsOnly(myCbWholeWordsOnly.isSelected());
model.setInStringLiteralsOnly(myCbInStringLiteralsOnly.isSelected());
model.setInCommentsOnly(myCbInCommentsOnly.isSelected());
model.setRegularExpressions(myCbRegularExpressions.isSelected());
String stringToFind = getStringToFind();
model.setStringToFind(stringToFind);
if (model.isReplaceState()){
model.setPromptOnReplace(true);
model.setReplaceAll(false);
String stringToReplace = getStringToReplace();
model.setStringToReplace(StringUtil.convertLineSeparators(stringToReplace));
}
if (!model.isMultipleFiles()){
model.setForward(myRbForward.isSelected());
model.setFromCursor(myRbFromCursor.isSelected());
model.setGlobal(myRbGlobal.isSelected());
}
else{
if (myCbToOpenInNewTab != null){
model.setOpenInNewTab(myCbToOpenInNewTab.isSelected());
}
model.setProjectScope(myRbProject.isSelected());
model.setDirectoryName(null);
model.setModuleName(null);
model.setCustomScopeName(null);
model.setCustomScope(null);
model.setCustomScope(false);
if (myRbDirectory.isSelected()) {
String directory = getDirectory();
model.setDirectoryName(directory == null ? "" : directory);
model.setWithSubdirectories(myCbWithSubdirectories.isSelected());
}
else if (myRbModule.isSelected()) {
model.setModuleName((String)myModuleComboBox.getSelectedItem());
}
else if (myRbCustomScope.isSelected()) {
SearchScope selectedScope = myScopeCombo.getSelectedScope();
String customScopeName = selectedScope == null ? null : selectedScope.getDisplayName();
model.setCustomScopeName(customScopeName);
model.setCustomScope(selectedScope == null ? null : selectedScope);
model.setCustomScope(true);
}
}
model.setFindAll(findAll);
String mask = getFileTypeMask();
model.setFileFilter(mask);
}
示例14: execute
import com.intellij.find.FindModel; //导入方法依赖的package包/类
@Override
public boolean execute(@NotNull ReferencesSearch.SearchParameters queryParameters, @NotNull final Processor<PsiReference> consumer) {
final PsiElement file = queryParameters.getElementToSearch();
if (file instanceof PsiBinaryFile) {
final Module module = ApplicationManager.getApplication().runReadAction(new Computable<Module>() {
@Override
public Module compute() {
return ModuleUtilCore.findModuleForPsiElement(file);
}
});
final VirtualFile image = ((PsiBinaryFile)file).getVirtualFile();
if (isImage(image) && isIconsModule(module)) {
final Project project = file.getProject();
final FindModel model = new FindModel();
final String path = getPathToImage(image, module);
if (path == null) return true;
model.setStringToFind(path);
model.setCaseSensitive(true);
model.setFindAll(true);
model.setWholeWordsOnly(true);
FindInProjectUtil.findUsages(model, FindInProjectUtil.getPsiDirectory(model, project), project, false, new Processor<UsageInfo>() {
@Override
public boolean process(final UsageInfo usage) {
ApplicationManager.getApplication().runReadAction(new Runnable() {
public void run() {
final PsiElement element = usage.getElement();
final ProperTextRange textRange = usage.getRangeInElement();
if (element != null && textRange != null) {
final PsiElement start = element.findElementAt(textRange.getStartOffset());
final PsiElement end = element.findElementAt(textRange.getEndOffset());
if (start != null && end != null) {
PsiElement value = PsiTreeUtil.findCommonParent(start, end);
if (value instanceof PsiJavaToken) {
value = value.getParent();
}
if (value != null) {
final PsiFileReference reference = FileReferenceUtil.findFileReference(value);
if (reference != null) {
consumer.process(reference);
}
}
}
}
}
});
return true;
}
}, new FindUsagesProcessPresentation());
}
}
return true;
}
示例15: findReplaceEmberClass
import com.intellij.find.FindModel; //导入方法依赖的package包/类
private FindModel findReplaceEmberClass(FindModel findModel, String thing) {
findModel.setStringToFind(findEmberClass(thing));
findModel.setStringToReplace("$1");
return findModel;
}