本文整理汇总了Java中com.intellij.util.ArrayUtil.find方法的典型用法代码示例。如果您正苦于以下问题:Java ArrayUtil.find方法的具体用法?Java ArrayUtil.find怎么用?Java ArrayUtil.find使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.intellij.util.ArrayUtil
的用法示例。
在下文中一共展示了ArrayUtil.find方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: isEscapesCut
import com.intellij.util.ArrayUtil; //导入方法依赖的package包/类
private static boolean isEscapesCut(GrLiteral literal, int startOffset, int endOffset) {
String rawContent = GrStringUtil.removeQuotes(literal.getText());
int[] offsets = new int[rawContent.length() + 1];
if (GrStringUtil.isSingleQuoteString(literal) || GrStringUtil.isDoubleQuoteString(literal)) {
GrStringUtil.parseStringCharacters(rawContent, new StringBuilder(), offsets);
}
else if (GrStringUtil.isSlashyString(literal)) {
GrStringUtil.parseRegexCharacters(rawContent, new StringBuilder(), offsets, true);
}
else if (GrStringUtil.isDollarSlashyString(literal)) {
GrStringUtil.parseRegexCharacters(rawContent, new StringBuilder(), offsets, false);
}
int contentStart = literal.getTextRange().getStartOffset() + GrStringUtil.getStartQuote(literal.getText()).length();
int relativeStart = startOffset - contentStart;
int relativeEnd = endOffset - contentStart;
return ArrayUtil.find(offsets, relativeStart) < 0 ||
ArrayUtil.find(offsets, relativeEnd) < 0;
}
示例2: checkResolveAfterRemoveCast
import com.intellij.util.ArrayUtil; //导入方法依赖的package包/类
private static boolean checkResolveAfterRemoveCast(PsiElement parent) {
PsiElement grandPa = parent.getParent();
if (grandPa instanceof PsiExpressionList) {
PsiExpression[] expressions = ((PsiExpressionList)grandPa).getExpressions();
int idx = ArrayUtil.find(expressions, parent);
PsiElement grandGrandPa = grandPa.getParent();
if (grandGrandPa instanceof PsiCall) {
PsiElement resolve = ((PsiCall)grandGrandPa).resolveMethod();
if (resolve instanceof PsiMethod) {
PsiCall expression = (PsiCall)grandGrandPa.copy();
PsiExpressionList argumentList = expression.getArgumentList();
LOG.assertTrue(argumentList != null);
PsiExpression toReplace = argumentList.getExpressions()[idx];
if (toReplace instanceof PsiConditionalExpression) {
PsiExpression thenExpression = ((PsiConditionalExpression)toReplace).getThenExpression();
PsiExpression elseExpression = ((PsiConditionalExpression)toReplace).getElseExpression();
if (thenExpression instanceof PsiTypeCastExpression) {
final PsiExpression thenOperand = ((PsiTypeCastExpression)thenExpression).getOperand();
if (thenOperand != null) {
thenExpression.replace(thenOperand);
}
} else if (elseExpression instanceof PsiTypeCastExpression) {
final PsiExpression elseOperand = ((PsiTypeCastExpression)elseExpression).getOperand();
if (elseOperand != null) {
elseExpression.replace(elseOperand);
}
}
}
if (expression.resolveMethod() != resolve) {
return false;
}
}
}
}
return true;
}
示例3: composeReceiverQualifierText
import com.intellij.util.ArrayUtil; //导入方法依赖的package包/类
@Nullable
private static String composeReceiverQualifierText(PsiParameter[] parameters,
PsiMethod psiMethod,
PsiClass containingClass,
@NotNull PsiExpression qualifierExpression) {
if (psiMethod.hasModifierProperty(PsiModifier.STATIC)) {
return null;
}
final PsiMethod nonAmbiguousMethod = getNonAmbiguousReceiver(parameters, psiMethod);
if (nonAmbiguousMethod == null) {
return null;
}
final PsiClass nonAmbiguousContainingClass = nonAmbiguousMethod.getContainingClass();
if (!containingClass.equals(nonAmbiguousContainingClass)) {
return getClassReferenceName(nonAmbiguousContainingClass);
}
if (containingClass.isPhysical() && qualifierExpression instanceof PsiReferenceExpression) {
final PsiElement resolve = ((PsiReferenceExpression)qualifierExpression).resolve();
final boolean parameterWithoutFormalType = resolve instanceof PsiParameter && ((PsiParameter)resolve).getTypeElement() == null;
if (parameterWithoutFormalType && ArrayUtil.find(parameters, resolve) > -1) {
return getClassReferenceName(containingClass);
}
}
final PsiType qualifierExpressionType = qualifierExpression.getType();
if (qualifierExpressionType != null && !TypeConversionUtil.containsWildcards(qualifierExpressionType)) {
try {
final String canonicalText = qualifierExpressionType.getCanonicalText();
JavaPsiFacade.getElementFactory(containingClass.getProject()).createExpressionFromText(canonicalText + "::foo", qualifierExpression);
return canonicalText;
}
catch (IncorrectOperationException ignore){}
}
return getClassReferenceName(containingClass);
}
示例4: removeFromElementText
import com.intellij.util.ArrayUtil; //导入方法依赖的package包/类
@Nullable
private String removeFromElementText(final PsiElement... elements) {
String text = "";
for (PsiElement element : elements) {
text += StringUtil.trimStart(element.getText(), "//").trim();
}
text = StringUtil.trimStart(text, "@").trim();
text = StringUtil.trimStart(text, SuppressionUtilCore.SUPPRESS_INSPECTIONS_TAG_NAME).trim();
List<String> ids = StringUtil.split(text, ",");
int i = ArrayUtil.find(ids.toArray(), myID);
if (i==-1) return null;
ids.remove(i);
return StringUtil.join(ids, ",");
}
示例5: compare
import com.intellij.util.ArrayUtil; //导入方法依赖的package包/类
@Override
public int compare(@NotNull VcsRef ref1, @NotNull VcsRef ref2) {
int power1 = ArrayUtil.find(getOrderedTypes(), getType(ref1));
int power2 = ArrayUtil.find(getOrderedTypes(), getType(ref2));
if (power1 != power2) {
return power1 - power2;
}
int namesComparison = ref1.getName().compareTo(ref2.getName());
if (namesComparison != 0) {
return namesComparison;
}
return VcsLogUtil.compareRoots(ref1.getRoot(), ref2.getRoot());
}
示例6: annotateWithParameter
import com.intellij.util.ArrayUtil; //导入方法依赖的package包/类
public void annotateWithParameter(PsiJavaCodeReferenceElement reference) {
for (VariableData data : myInputVariables) {
final PsiElement element = reference.resolve();
if (data.variable.equals(element)) {
PsiType type = data.variable.getType();
final PsiMethodCallExpression methodCallExpression = PsiTreeUtil.getParentOfType(reference, PsiMethodCallExpression.class);
if (methodCallExpression != null) {
int idx = ArrayUtil.find(methodCallExpression.getArgumentList().getExpressions(), reference);
if (idx > -1) {
final PsiMethod psiMethod = methodCallExpression.resolveMethod();
if (psiMethod != null) {
final PsiParameter[] parameters = psiMethod.getParameterList().getParameters();
if (idx >= parameters.length) { //vararg parameter
idx = parameters.length - 1;
if (idx >= 0) { //incomplete code
type = parameters[idx].getType();
}
}
if (type instanceof PsiEllipsisType) {
type = ((PsiEllipsisType)type).getComponentType();
}
}
}
}
if (!myFoldingAvailable || !myFolding.annotateWithParameter(data, reference)) {
reference.putUserData(DuplicatesFinder.PARAMETER, Pair.create(data.variable, type));
}
}
}
}
示例7: isMyFile
import com.intellij.util.ArrayUtil; //导入方法依赖的package包/类
@Override
public boolean isMyFile(@NotNull XmlFile file, @Nullable Module module) {
if (!super.isMyFile(file, module)) {
return false;
}
final XmlTag rootTag = file.getRootTag();
if (rootTag == null) {
return false;
}
return ArrayUtil.find(ROOT_TAGS, rootTag.getName()) >= 0;
}
示例8: containsInCurrentFile
import com.intellij.util.ArrayUtil; //导入方法依赖的package包/类
private static boolean containsInCurrentFile(@NotNull PsiJavaFile file, PsiClass curRefClass) {
if (curRefClass != null) {
final String curRefClassQualifiedName = curRefClass.getQualifiedName();
if (curRefClassQualifiedName != null &&
ArrayUtil.find(file.getImplicitlyImportedPackages(), StringUtil.getPackageName(curRefClassQualifiedName)) < 0) {
return true;
}
}
return false;
}
示例9: isMyFile
import com.intellij.util.ArrayUtil; //导入方法依赖的package包/类
@Override
public boolean isMyFile(@NotNull XmlFile file, @Nullable Module module) {
if (!super.isMyFile(file, module)) {
return false;
}
final XmlTag rootTag = file.getRootTag();
if (rootTag == null) {
return false;
}
return ArrayUtil.find(POSSIBLE_ROOT_TAGS, rootTag.getName()) >= 0;
}
示例10: doNavigate
import com.intellij.util.ArrayUtil; //导入方法依赖的package包/类
private void doNavigate(DataContext dataContext, Project project) {
final FileEditorManagerEx editorManager = FileEditorManagerEx.getInstanceEx(project);
EditorWindow currentWindow = EditorWindow.DATA_KEY.getData(dataContext);
if (currentWindow == null){
currentWindow = editorManager.getCurrentWindow ();
}
VirtualFile selectedFile = currentWindow.getSelectedFile();
if (selectedFile == null) {
selectedFile = CommonDataKeys.VIRTUAL_FILE.getData(dataContext);
}
final VirtualFile[] files = currentWindow.getFiles();
int index = ArrayUtil.find(files, selectedFile);
LOG.assertTrue(index != -1);
editorManager.openFile(files[(index + files.length + myDir) % files.length], true);
}
示例11: getByArgument
import com.intellij.util.ArrayUtil; //导入方法依赖的package包/类
@Nullable
public static PyGlobalStatement getByArgument(final PsiElement element){
final PsiElement parent = element.getParent();
if (parent instanceof PyGlobalStatement){
final PyGlobalStatement statement = (PyGlobalStatement)parent;
return ArrayUtil.find(statement.getGlobals(), element) != -1 ? statement : null;
}
return null;
}
示例12: currentStateAsHistoryEntry
import com.intellij.util.ArrayUtil; //导入方法依赖的package包/类
@NotNull
public HistoryEntry currentStateAsHistoryEntry() {
final FileEditor[] editors = getEditors();
final FileEditorState[] states = new FileEditorState[editors.length];
for (int j = 0; j < states.length; j++) {
states[j] = editors[j].getState(FileEditorStateLevel.FULL);
LOG.assertTrue(states[j] != null);
}
final int selectedProviderIndex = ArrayUtil.find(editors, getSelectedEditor());
LOG.assertTrue(selectedProviderIndex != -1);
final FileEditorProvider[] providers = getProviders();
return new HistoryEntry(getFile(), providers, states, providers[selectedProviderIndex]);
}
示例13: getStyleableNameByTagName
import com.intellij.util.ArrayUtil; //导入方法依赖的package包/类
public static String getStyleableNameByTagName(@NotNull String tagName) {
if (tagName.equals("set")) {
return "AnimationSet";
}
String capitalizedTagName = StringUtil.capitalize(tagName);
String suffix = "Animation";
if (ArrayUtil.find(TAG_NAMES, tagName) >= 0 && !tagName.endsWith(suffix)) {
return capitalizedTagName + suffix;
}
return capitalizedTagName;
}
示例14: importExternalAndroidLibDependencies
import com.intellij.util.ArrayUtil; //导入方法依赖的package包/类
private static void importExternalAndroidLibDependencies(Project project,
MavenRootModelAdapter rootModelAdapter,
IdeModifiableModelsProvider modelsProvider,
MavenProjectsTree mavenTree,
MavenProject mavenProject,
Map<MavenProject, String> mavenProject2ModuleName,
List<MavenProjectsProcessorTask> tasks) {
final ModifiableRootModel rootModel = rootModelAdapter.getRootModel();
removeUselessDependencies(rootModel, modelsProvider, mavenProject);
for (MavenArtifact depArtifact : mavenProject.getDependencies()) {
if (mavenTree.findProject(depArtifact) != null) {
continue;
}
final String type = depArtifact.getType();
if (AndroidMavenUtil.APKLIB_DEPENDENCY_AND_PACKAGING_TYPE.equals(type)) {
final AndroidExternalApklibDependenciesManager.MavenDependencyInfo depInfo =
AndroidExternalApklibDependenciesManager.MavenDependencyInfo.create(depArtifact);
final String apklibModuleName = doImportExternalApklibDependency(
project, modelsProvider, mavenTree, mavenProject,
mavenProject2ModuleName, tasks, depInfo);
if (ArrayUtil.find(rootModel.getDependencyModuleNames(), apklibModuleName) < 0) {
final DependencyScope scope = getApklibModuleDependencyScope(depArtifact);
if (scope != null) {
addModuleDependency(modelsProvider, rootModel, apklibModuleName, scope);
}
}
}
else if (AndroidMavenUtil.AAR_DEPENDENCY_AND_PACKAGING_TYPE.equals(type) &&
MavenConstants.SCOPE_COMPILE.equals(depArtifact.getScope())) {
importExternalAarDependency(depArtifact, mavenProject, mavenTree, rootModelAdapter, modelsProvider, project, tasks);
}
}
}
示例15: doImportDependencies
import com.intellij.util.ArrayUtil; //导入方法依赖的package包/类
private static void doImportDependencies(@Nullable Module module,
@Nullable Module allowedDepModule,
@NotNull List<ImportDependenciesTask> tasks,
@NotNull List<MyUnresolvedDependency> unresolvedDependencies,
@NotNull Project project,
@NotNull ModuleProvider moduleProvider,
@NotNull Pair<Properties, VirtualFile> defaultProperties) {
for (VirtualFile libDir : getLibDirs(defaultProperties)) {
final Module depModule = ModuleUtil.findModuleForFile(libDir, project);
if (depModule != null) {
if ((allowedDepModule == null || allowedDepModule == depModule) &&
ArrayUtil.find(ModuleRootManager.getInstance(depModule).getContentRoots(), libDir) >= 0 &&
!(module != null && ModuleRootManager.getInstance(module).isDependsOn(depModule))) {
tasks.add(new AddModuleDependencyTask(moduleProvider, ModuleProvider.create(depModule)));
}
}
else {
final VirtualFile libModuleFile = findModuleFileChild(libDir);
final ModuleProvidingTask task = libModuleFile != null && new File(libModuleFile.getPath()).exists()
? new ImportModuleTask(project, libModuleFile.getPath(), libDir)
: new CreateNewModuleTask(project, libDir);
if (!tasks.contains(task)) {
tasks.add(task);
final ModuleProvider newModuleProvider = ModuleProvider.create(task);
tasks.add(new AddModuleDependencyTask(moduleProvider, newModuleProvider));
importDependenciesForNewModule(project, newModuleProvider, libDir, tasks, unresolvedDependencies);
}
else {
unresolvedDependencies.add(new MyUnresolvedDependency(moduleProvider, libDir));
}
}
}
}