本文整理匯總了Java中com.intellij.openapi.util.Comparing類的典型用法代碼示例。如果您正苦於以下問題:Java Comparing類的具體用法?Java Comparing怎麽用?Java Comparing使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
Comparing類屬於com.intellij.openapi.util包,在下文中一共展示了Comparing類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: rootsChanged
import com.intellij.openapi.util.Comparing; //導入依賴的package包/類
@Override
public void rootsChanged(ModuleRootEvent event) {
final ToolWindow window = ToolWindowManager.getInstance(myProject).getToolWindow(TOOL_WINDOW_ID);
if (window == null) {
return;
}
if (window.isDisposed() || !window.isVisible()) {
return;
}
AndroidPlatform newPlatform = getPlatform();
if (!Comparing.equal(myPrevPlatform, newPlatform)) {
myPrevPlatform = newPlatform;
ApplicationManager.getApplication().invokeLater(new Runnable() {
@Override
public void run() {
if (!window.isDisposed() && window.isVisible()) {
myView.activate();
}
}
});
}
}
示例2: drawEditorLineBackgroundRect
import com.intellij.openapi.util.Comparing; //導入依賴的package包/類
private void drawEditorLineBackgroundRect(Graphics g,
TextAttributes attributes,
int visualLine,
Color defaultBackgroundColor,
Color defaultForegroundColor,
int startX,
int startY) {
Color color = myEditor.getBackgroundColor(attributes);
if (!Comparing.equal(color, defaultBackgroundColor)) {
Color fgColor = attributes.getForegroundColor();
if (!Comparing.equal(fgColor, defaultForegroundColor)) {
myTextFgColors.put(visualLine, fgColor);
}
g.setColor(color);
g.fillRect(startX, startY, getWidth() - startX, myEditor.getLineHeight());
}
}
示例3: moveContentToStackTop
import com.intellij.openapi.util.Comparing; //導入依賴的package包/類
private void moveContentToStackTop(Transferable t, boolean notifyOthers) {
Transferable current = myData.isEmpty() ? null : myData.get(0);
if (!Comparing.equal(t, current)) {
myData.remove(t);
myData.add(0, t);
if (notifyOthers) {
setSystemClipboardContent(t);
fireContentChanged(current, t);
}
}
else {
if (notifyOthers) {
setSystemClipboardContent(t);
}
}
}
示例4: visitPyCallExpression
import com.intellij.openapi.util.Comparing; //導入依賴的package包/類
@Override
public void visitPyCallExpression(PyCallExpression node) {
if (node.isCalleeText("pop", "get", "getattr")) {
PyReferenceExpression child = PsiTreeUtil.getChildOfType(node.getCallee(), PyReferenceExpression.class);
if (child != null) {
String operandName = child.getName();
if (node.getArguments().length > 0) {
PyExpression argument = node.getArguments()[0];
processGet(operandName, argument);
}
}
}
else if (node.isCalleeText("__init__")) {
kwArgsTransit = false;
for (PyExpression e : node.getArguments()) {
if (e instanceof PyStarArgument) {
PyStarArgument kw = (PyStarArgument)e;
if (Comparing.equal(myKwArgs.getName(), kw.getFirstChild().getNextSibling().getText())) {
kwArgsTransit = true;
break;
}
}
}
}
super.visitPyCallExpression(node);
}
示例5: handleElementRename
import com.intellij.openapi.util.Comparing; //導入依賴的package包/類
@Override
public PsiElement handleElementRename(String newElementName) throws IncorrectOperationException {
PsiElement oldIdentifier = findChildByRoleAsPsiElement(ChildRole.REFERENCE_NAME);
if (oldIdentifier == null) {
oldIdentifier = findChildByRoleAsPsiElement(ChildRole.CLASS_REFERENCE);
}
if (oldIdentifier == null) {
throw new IncorrectOperationException();
}
final String oldRefName = oldIdentifier.getText();
if (PsiKeyword.THIS.equals(oldRefName) ||
PsiKeyword.SUPER.equals(oldRefName) ||
PsiKeyword.NEW.equals(oldRefName) ||
Comparing.strEqual(oldRefName, newElementName)) {
return this;
}
PsiIdentifier identifier = JavaPsiFacade.getInstance(getProject()).getElementFactory().createIdentifier(newElementName);
oldIdentifier.replace(identifier);
return this;
}
示例6: compareMembers
import com.intellij.openapi.util.Comparing; //導入依賴的package包/類
private static int compareMembers(PsiMember m1, PsiMember m2, PsiExpression context) {
ProgressManager.checkCanceled();
int result = JavaStatisticsManager.createInfo(null, m2).getUseCount() - JavaStatisticsManager.createInfo(null, m1).getUseCount();
if (result != 0) return result;
final PsiClass aClass = m1.getContainingClass();
final PsiClass bClass = m2.getContainingClass();
if (aClass != null && bClass != null) {
result = JavaStatisticsManager.createInfo(null, bClass).getUseCount() - JavaStatisticsManager.createInfo(null, aClass).getUseCount();
if (result != 0) return result;
}
WeighingComparable<PsiElement,ProximityLocation> proximity1 = PsiProximityComparator.getProximity(m1, context);
WeighingComparable<PsiElement,ProximityLocation> proximity2 = PsiProximityComparator.getProximity(m2, context);
if (proximity1 != null && proximity2 != null) {
result = proximity2.compareTo(proximity1);
if (result != 0) return result;
}
String name1 = PsiUtil.getMemberQualifiedName(m1);
String name2 = PsiUtil.getMemberQualifiedName(m2);
return Comparing.compare(name1, name2);
}
示例7: findParametersUsage
import com.intellij.openapi.util.Comparing; //導入依賴的package包/類
private void findParametersUsage(final PsiMethod method, ArrayList<UsageInfo> result, PsiMethod[] overriders) {
if (JavaLanguage.INSTANCE.equals(myChangeInfo.getLanguage())) {
PsiParameter[] parameters = method.getParameterList().getParameters();
for (ParameterInfo info : myChangeInfo.getNewParameters()) {
if (info.getOldIndex() >= 0) {
PsiParameter parameter = parameters[info.getOldIndex()];
if (!info.getName().equals(parameter.getName())) {
addParameterUsages(parameter, result, info);
for (PsiMethod overrider : overriders) {
PsiParameter parameter1 = overrider.getParameterList().getParameters()[info.getOldIndex()];
if (parameter1 != null && Comparing.strEqual(parameter.getName(), parameter1.getName())) {
addParameterUsages(parameter1, result, info);
}
}
}
}
}
}
}
示例8: applySettings
import com.intellij.openapi.util.Comparing; //導入依賴的package包/類
private void applySettings(VirtualFile file) {
if (file == null) return;
if (!Utils.isEnabled(CodeStyleSettingsManager.getInstance(myProject).getCurrentSettings())) return;
// Prevent "setEncoding" calling "saveAll" from causing an endless loop
isApplyingSettings = true;
try {
final String filePath = Utils.getFilePath(myProject, file);
final List<OutPair> outPairs = SettingsProviderComponent.getInstance().getOutPairs(myProject, filePath);
final EncodingProjectManager encodingProjectManager = EncodingProjectManager.getInstance(myProject);
final String charset = Utils.configValueForKey(outPairs, charsetKey);
if (!charset.isEmpty()) {
final Charset newCharset = encodingMap.get(charset);
if (newCharset != null) {
if (Comparing.equal(newCharset, file.getCharset())) return;
encodingProjectManager.setEncoding(file, newCharset);
} else {
Utils.invalidConfigMessage(myProject, charset, charsetKey, filePath);
}
}
} finally {
isApplyingSettings = false;
}
}
示例9: isSimplePropertySetter
import com.intellij.openapi.util.Comparing; //導入依賴的package包/類
@SuppressWarnings("HardCodedStringLiteral")
public static boolean isSimplePropertySetter(@Nullable PsiMethod method) {
if (method == null) return false;
if (method.isConstructor()) return false;
String methodName = method.getName();
if (!(methodName.startsWith("set") && methodName.length() > "set".length())) return false;
if (Character.isLowerCase(methodName.charAt("set".length()))
&& (methodName.length() == "set".length() + 1 || Character.isLowerCase(methodName.charAt("set".length() + 1)))) {
return false;
}
if (method.getParameterList().getParametersCount() != 1) {
return false;
}
final PsiType returnType = method.getReturnType();
if (returnType == null || PsiType.VOID.equals(returnType)) {
return true;
}
return Comparing.equal(PsiUtil.resolveClassInType(TypeConversionUtil.erasure(returnType)), method.getContainingClass());
}
示例10: findArtifacts
import com.intellij.openapi.util.Comparing; //導入依賴的package包/類
@NotNull
public List<MavenArtifact> findArtifacts(@Nullable String groupId, @Nullable String artifactId, @Nullable String version) {
Map<String, List<MavenArtifact>> groupMap = myData.get(groupId);
if (groupMap == null) return Collections.emptyList();
List<MavenArtifact> artifacts = groupMap.get(artifactId);
if (artifacts == null) return Collections.emptyList();
List<MavenArtifact> res = new SmartList<MavenArtifact>();
for (MavenArtifact artifact : artifacts) {
if (Comparing.equal(version, artifact.getVersion())) {
res.add(artifact);
}
}
return res;
}
示例11: unify
import com.intellij.openapi.util.Comparing; //導入依賴的package包/類
@Nullable
private static PsiSubstitutor unify(@NotNull PsiSubstitutor substitutor, @NotNull PsiSubstitutor parentSubstitutor, @NotNull Project project) {
Map<PsiTypeParameter,PsiType> newMap = new THashMap<PsiTypeParameter, PsiType>(substitutor.getSubstitutionMap());
for (Map.Entry<PsiTypeParameter, PsiType> entry : substitutor.getSubstitutionMap().entrySet()) {
PsiTypeParameter typeParameter = entry.getKey();
PsiType type = entry.getValue();
PsiClass resolved = PsiUtil.resolveClassInType(type);
if (!parentSubstitutor.getSubstitutionMap().containsKey(typeParameter)) continue;
PsiType parentType = parentSubstitutor.substitute(parentSubstitutor.substitute(typeParameter));
if (resolved instanceof PsiTypeParameter) {
PsiTypeParameter res = (PsiTypeParameter)resolved;
newMap.put(res, parentType);
}
else if (!Comparing.equal(type, parentType)) {
return null; // cannot unify
}
}
return JavaPsiFacade.getElementFactory(project).createSubstitutor(newMap);
}
示例12: copy
import com.intellij.openapi.util.Comparing; //導入依賴的package包/類
private void copy(Task issue) {
mySummary = issue.getSummary();
myDescription = issue.getDescription();
myComments = issue.getComments();
myClosed = issue.isClosed();
myCreated = issue.getCreated();
if (Comparing.compare(myUpdated, issue.getUpdated()) < 0) {
myUpdated = issue.getUpdated();
}
myType = issue.getType();
myPresentableName = issue.getPresentableName();
myCustomIcon = issue.getCustomIcon();
myIssueUrl = issue.getIssueUrl();
myRepository = issue.getRepository();
myProject = issue.getProject();
myNumber = issue.getNumber();
}
示例13: getPackageDirs
import com.intellij.openapi.util.Comparing; //導入依賴的package包/類
private static String getPackageDirs(DataContext dataContext) {
final Module module = LangDataKeys.MODULE.getData(dataContext);
if (module != null) {
final VirtualFile[] sourceRoots = ModuleRootManager.getInstance(module).getSourceRoots();
if (sourceRoots.length > 0) {
for (VirtualFile sourceRoot : sourceRoots) {
// TODO notify if we have multiple source roots and can't build mapping automatically
final VirtualFile contentRoot = ProjectFileIndex.SERVICE.getInstance(module.getProject()).getContentRootForFile(sourceRoot);
if (contentRoot != null && !Comparing.equal(contentRoot, sourceRoot)) {
final String relativePath = VfsUtilCore.getRelativePath(sourceRoot, contentRoot, '/');
return "\n package_dir={'': '" + relativePath + "'},";
}
}
}
}
return "";
}
示例14: isChanged
import com.intellij.openapi.util.Comparing; //導入依賴的package包/類
@Override
public boolean isChanged() {
if (myOrderRootPointerContainers.size() != mySource.myOrderRootPointerContainers.size()) return true;
for (final OrderRootType type : myOrderRootPointerContainers.keySet()) {
final VirtualFilePointerContainer container = myOrderRootPointerContainers.get(type);
final VirtualFilePointerContainer otherContainer = mySource.myOrderRootPointerContainers.get(type);
if (container == null || otherContainer == null) {
if (container != otherContainer) return true;
}
else {
final String[] urls = container.getUrls();
final String[] otherUrls = otherContainer.getUrls();
if (urls.length != otherUrls.length) return true;
for (int i = 0; i < urls.length; i++) {
if (!Comparing.strEqual(urls[i], otherUrls[i])) return true;
}
}
}
return false;
}
示例15: getSubstituted
import com.intellij.openapi.util.Comparing; //導入依賴的package包/類
@Nullable
public PsiElement getSubstituted() {
if (mySubstituted != null && mySubstituted.isValid()){
if (mySubstituted instanceof PsiNameIdentifierOwner) {
if (Comparing.strEqual(myOldName, ((PsiNameIdentifierOwner)mySubstituted).getName())) return mySubstituted;
final RangeMarker rangeMarker = mySubstitutedRange != null ? mySubstitutedRange : myRenameOffset;
if (rangeMarker != null)
return PsiTreeUtil.findElementOfClassAtRange(mySubstituted.getContainingFile(), rangeMarker.getStartOffset(), rangeMarker.getEndOffset(), PsiNameIdentifierOwner.class);
}
return mySubstituted;
}
if (mySubstitutedRange != null) {
final PsiFile psiFile = PsiDocumentManager.getInstance(myProject).getPsiFile(myEditor.getDocument());
if (psiFile != null) {
return PsiTreeUtil.findElementOfClassAtRange(psiFile, mySubstitutedRange.getStartOffset(), mySubstitutedRange.getEndOffset(), PsiNameIdentifierOwner.class);
}
}
return getVariable();
}