com.intellij.util.ThreeState Java Examples

The following examples show how to use com.intellij.util.ThreeState. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: SmartSerializer.java    From consulo with Apache License 2.0 6 votes vote down vote up
public SmartSerializer(boolean trackSerializedNames, boolean useSkipEmptySerializationFilter) {
  mySerializedAccessorNameTracker = trackSerializedNames ? new LinkedHashSet<String>() : null;

  mySerializationFilter = useSkipEmptySerializationFilter ?
                          new SkipEmptySerializationFilter() {
                            @Override
                            protected ThreeState accepts(@Nonnull String name, @Nonnull Object beanValue) {
                              return mySerializedAccessorNameTracker != null && mySerializedAccessorNameTracker.contains(name) ? ThreeState.YES : ThreeState.UNSURE;
                            }
                          } :
                          new SkipDefaultValuesSerializationFilters() {
                            @Override
                            public boolean accepts(@Nonnull Accessor accessor, @Nonnull Object bean) {
                              if (mySerializedAccessorNameTracker != null && mySerializedAccessorNameTracker.contains(accessor.getName())) {
                                return true;
                              }
                              return super.accepts(accessor, bean);
                            }
                          };
}
 
Example #2
Source File: MyDeviceChooser.java    From ADB-Duang with MIT License 6 votes vote down vote up
@Override
protected void customizeCellRenderer(JTable table, Object value, boolean selected, boolean hasFocus, int row, int column) {
  if (!(value instanceof LaunchCompatibility)) {
    return;
  }

  LaunchCompatibility compatibility = (LaunchCompatibility)value;
  ThreeState compatible = compatibility.isCompatible();
  if (compatible == ThreeState.YES) {
    append("Yes");
  } else {
    if (compatible == ThreeState.NO) {
      append("No", SimpleTextAttributes.ERROR_ATTRIBUTES);
    } else {
      append("Maybe");
    }
    String reason = compatibility.getReason();
    if (reason != null) {
      append(", ");
      append(reason);
    }
  }
}
 
Example #3
Source File: CachedIntentions.java    From consulo with Apache License 2.0 6 votes vote down vote up
private int getWeight(@Nonnull IntentionActionWithTextCaching action) {
  IntentionAction a = action.getAction();
  int group = getGroup(action).getPriority();
  while (a instanceof IntentionActionDelegate) {
    a = ((IntentionActionDelegate)a).getDelegate();
  }
  if (a instanceof PriorityAction) {
    return group + getPriorityWeight(((PriorityAction)a).getPriority());
  }
  if (a instanceof SuppressIntentionActionFromFix) {
    if (((SuppressIntentionActionFromFix)a).isShouldBeAppliedToInjectionHost() == ThreeState.NO) {
      return group - 1;
    }
  }
  return group;
}
 
Example #4
Source File: CompletionPhase.java    From consulo with Apache License 2.0 6 votes vote down vote up
private static boolean shouldSkipAutoPopup(Editor editor, PsiFile psiFile) {
  int offset = editor.getCaretModel().getOffset();
  int psiOffset = Math.max(0, offset - 1);

  PsiElement elementAt = psiFile.findElementAt(psiOffset);
  if (elementAt == null) return true;

  Language language = PsiUtilCore.findLanguageFromElement(elementAt);

  for (CompletionConfidence confidence : CompletionConfidenceEP.forLanguage(language)) {
    final ThreeState result = confidence.shouldSkipAutopopup(elementAt, psiFile, offset);
    if (result != ThreeState.UNSURE) {
      LOG.debug(confidence + " has returned shouldSkipAutopopup=" + result);
      return result == ThreeState.YES;
    }
  }
  return false;
}
 
Example #5
Source File: MyDeviceChooser.java    From ADBWIFI with Apache License 2.0 6 votes vote down vote up
@Override
protected void customizeCellRenderer(JTable table, Object value, boolean selected, boolean hasFocus, int row, int column) {
  if (!(value instanceof LaunchCompatibility)) {
    return;
  }

  LaunchCompatibility compatibility = (LaunchCompatibility)value;
  ThreeState compatible = compatibility.isCompatible();
  if (compatible == ThreeState.YES) {
    append("Yes");
  } else {
    if (compatible == ThreeState.NO) {
      append("No", SimpleTextAttributes.ERROR_ATTRIBUTES);
    } else {
      append("Maybe");
    }
    String reason = compatibility.getReason();
    if (reason != null) {
      append(", ");
      append(reason);
    }
  }
}
 
Example #6
Source File: ContentAnnotationCacheImpl.java    From consulo with Apache License 2.0 6 votes vote down vote up
@Override
@Nullable
public ThreeState isRecent(final VirtualFile vf,
                           final VcsKey vcsKey,
                           final VcsRevisionNumber number,
                           final TextRange range,
                           final long boundTime) {
  TreeMap<Integer, Long> treeMap;
  synchronized (myLock) {
    treeMap = myCache.get(new HistoryCacheWithRevisionKey(VcsContextFactory.SERVICE.getInstance().createFilePathOn(vf), vcsKey, number));
  }
  if (treeMap != null) {
    Map.Entry<Integer, Long> last = treeMap.floorEntry(range.getEndOffset());
    if (last == null || last.getKey() < range.getStartOffset()) return ThreeState.NO;
    Map.Entry<Integer, Long> first = treeMap.ceilingEntry(range.getStartOffset());
    assert first != null;
    final SortedMap<Integer,Long> interval = treeMap.subMap(first.getKey(), last.getKey());
    for (Map.Entry<Integer, Long> entry : interval.entrySet()) {
      if (entry.getValue() >= boundTime) return ThreeState.YES;
    }
    return ThreeState.NO;
  }
  return ThreeState.UNSURE;
}
 
Example #7
Source File: PantsPythonTestRunConfigurationProducer.java    From intellij-pants-plugin with Apache License 2.0 6 votes vote down vote up
private boolean isOrContainsPyTests(PsiElement element) {
  if (new PyTestFinder().isTest(element)) {
    return true;
  }

  if (element instanceof PyFile) {
    PyFile pyFile = (PyFile) element;

    for (PyClass pyClass : pyFile.getTopLevelClasses()) {
      if (PythonUnitTestUtil.isTestClass(pyClass, ThreeState.YES, null)) {
        return true;
      }
    }
  }
  else if (element instanceof PsiDirectory) {
    PsiDirectory directory = (PsiDirectory) element;
    for (PsiFile file : directory.getFiles()) {
      if (isOrContainsPyTests(file)) {
        return true;
      }
    }
  }

  return false;
}
 
Example #8
Source File: ChangeListWorker.java    From consulo with Apache License 2.0 5 votes vote down vote up
public ThreeState haveChangesUnder(@Nonnull VirtualFile virtualFile) {
  FilePath dir = VcsUtil.getFilePath(virtualFile);
  FilePath changeCandidate = myIdx.getAffectedPaths().ceiling(dir);
  if (changeCandidate == null) {
    return ThreeState.NO;
  }
  return FileUtil.isAncestorThreeState(dir.getPath(), changeCandidate.getPath(), false);
}
 
Example #9
Source File: StartedActivated.java    From consulo with Apache License 2.0 5 votes vote down vote up
public void stop(final List<ThrowableRunnable<VcsException>> callList) {
  if (myDependent != null) {
    myDependent.stop(callList);
  }
  if (ThreeState.YES.equals(myState)) {
    myState = ThreeState.NO;
    callList.add(myStop);
  }
}
 
Example #10
Source File: RollbackAction.java    From consulo with Apache License 2.0 5 votes vote down vote up
private static boolean hasReversibleFiles(@Nonnull AnActionEvent e) {
  ChangeListManager manager = ChangeListManager.getInstance(e.getRequiredData(CommonDataKeys.PROJECT));
  Set<VirtualFile> modifiedWithoutEditing = ContainerUtil.newHashSet(manager.getModifiedWithoutEditing());

  return notNullize(e.getData(VcsDataKeys.VIRTUAL_FILE_STREAM)).anyMatch(
          file -> manager.haveChangesUnder(file) != ThreeState.NO || manager.isFileAffected(file) || modifiedWithoutEditing.contains(file));
}
 
Example #11
Source File: BuildFileCompletionConfidence.java    From intellij with Apache License 2.0 5 votes vote down vote up
@Override
public ThreeState shouldSkipAutopopup(PsiElement contextElement, PsiFile psiFile, int offset) {
  if (contextElement.getParent() instanceof IntegerLiteral) {
    return ThreeState.YES;
  }
  return super.shouldSkipAutopopup(contextElement, psiFile, offset);
}
 
Example #12
Source File: ShowIntentionActionsHandler.java    From consulo with Apache License 2.0 5 votes vote down vote up
public static boolean availableFor(@Nonnull PsiFile psiFile, @Nonnull Editor editor, @Nonnull IntentionAction action) {
  if (!psiFile.isValid()) return false;

  try {
    Project project = psiFile.getProject();
    action = IntentionActionDelegate.unwrap(action);
    if (action instanceof SuppressIntentionActionFromFix) {
      final ThreeState shouldBeAppliedToInjectionHost = ((SuppressIntentionActionFromFix)action).isShouldBeAppliedToInjectionHost();
      if (editor instanceof EditorWindow && shouldBeAppliedToInjectionHost == ThreeState.YES) {
        return false;
      }
      if (!(editor instanceof EditorWindow) && shouldBeAppliedToInjectionHost == ThreeState.NO) {
        return false;
      }
    }

    if (action instanceof PsiElementBaseIntentionAction) {
      PsiElementBaseIntentionAction psiAction = (PsiElementBaseIntentionAction)action;
      if (!psiAction.checkFile(psiFile)) {
        return false;
      }
      PsiElement leaf = psiFile.findElementAt(editor.getCaretModel().getOffset());
      if (leaf == null || !psiAction.isAvailable(project, editor, leaf)) {
        return false;
      }
    }
    else if (!action.isAvailable(project, editor, psiFile)) {
      return false;
    }
  }
  catch (IndexNotReadyException e) {
    return false;
  }
  return true;
}
 
Example #13
Source File: OSSPantsPythonRunConfigurationIntegrationTest.java    From intellij-pants-plugin with Apache License 2.0 5 votes vote down vote up
public void testPyTestRunConfiguration() throws Throwable {
  doImport("examples/tests/python/example_test/hello");

  PyClass pyClass = PyClassNameIndex.find("GreetTest", myProject, true).iterator().next();
  PyClass truClass = new PyTestClass(pyClass);
  assertFalse(PythonUnitTestUtil.isTestClass(pyClass, ThreeState.YES, null));

  PsiFile file = new PyTestFile(truClass.getContainingFile(), truClass);
  ExternalSystemRunConfiguration esc = getExternalSystemRunConfiguration(file);
  List<String> items = PantsUtil.parseCmdParameters(esc.getSettings().getScriptParameters());

  assertNotContainsSubstring(items, PantsConstants.PANTS_CLI_OPTION_JUNIT_TEST);
  assertContainsSubstring(items, PantsConstants.PANTS_CLI_OPTION_PYTEST);
}
 
Example #14
Source File: P4Vcs.java    From p4ic4idea with Apache License 2.0 5 votes vote down vote up
/**
 * Invoked when a changelist is deleted explicitly by user or implicitly (e.g. after default changelist switch
 * when the previous one was empty).
 * @param list change list that's about to be removed
 * @param explicitly whether it's a result of explicit Delete action, or just after switching the active changelist.
 * @return UNSURE if the VCS has nothing to say about this changelist.
 * YES or NO if the changelist has to be removed or not, and no further confirmations are needed about this changelist
 * (in particular, the VCS can show a confirmation to the user by itself)
 */
@Override
// @CalledInAwt
@NotNull
public ThreeState mayRemoveChangeList(@NotNull LocalChangeList list, boolean explicitly) {
    if (!explicitly || ChangeListUtil.isDefaultChangelist(list)) {
        return ThreeState.NO;
    }
    return ThreeState.YES;
}
 
Example #15
Source File: UnityPlayerService.java    From consulo-unity3d with Apache License 2.0 5 votes vote down vote up
@RequiredUIAccess
public void bindAndRun(@Nonnull Project project, @Nonnull Runnable runnable)
{
	switch(myBindState)
	{
		case YES:
			runnable.run();
			break;
		case UNSURE:
			// nothing
			break;
		default:
			myBindState = ThreeState.UNSURE;

			new Task.Backgroundable(project, "Preparing network listeners...")
			{
				@Override
				public void run(@Nonnull ProgressIndicator progressIndicator)
				{
					bind(progressIndicator);
				}

				@RequiredUIAccess
				@Override
				public void onFinished()
				{
					myBindState = ThreeState.YES;

					runUpdateTask();

					runnable.run();
				}
			}.queue();
			break;
	}
}
 
Example #16
Source File: PhpParameterStringCompletionConfidence.java    From idea-php-symfony2-plugin with MIT License 5 votes vote down vote up
@NotNull
@Override
public ThreeState shouldSkipAutopopup(@NotNull PsiElement contextElement, @NotNull PsiFile psiFile, int offset) {
    if (!Symfony2ProjectComponent.isEnabled(contextElement)) {
        return ThreeState.UNSURE;
    }

    if(!(psiFile instanceof PhpFile)) {
        return ThreeState.UNSURE;
    }

    PsiElement context = contextElement.getContext();
    if(!(context instanceof StringLiteralExpression)) {
        return ThreeState.UNSURE;
    }

    // $test == "";
    if(context.getParent() instanceof BinaryExpression) {
        return ThreeState.NO;
    }

    // $this->container->get("");
    PsiElement stringContext = context.getContext();
    if(stringContext instanceof ParameterList) {
        return ThreeState.NO;
    }

    // $this->method(... array('foo'); array('bar' => 'foo') ...);
    ArrayCreationExpression arrayCreationExpression = PhpElementsUtil.getCompletableArrayCreationElement(context);
    if(arrayCreationExpression != null && arrayCreationExpression.getContext() instanceof ParameterList) {
        return ThreeState.NO;
    }

    // $array['value']
    if(PlatformPatterns.psiElement().withSuperParent(2, ArrayIndex.class).accepts(contextElement)) {
        return ThreeState.NO;
    }

    return ThreeState.UNSURE;
}
 
Example #17
Source File: PhpParameterStringCompletionConfidence.java    From idea-php-advanced-autocomplete with MIT License 5 votes vote down vote up
@NotNull
    @Override
    public ThreeState shouldSkipAutopopup(@NotNull PsiElement contextElement, @NotNull PsiFile psiFile, int offset) {

        if (!(psiFile instanceof PhpFile)) {
            return ThreeState.UNSURE;
        }

        PsiElement context = contextElement.getContext();
        if (!(context instanceof StringLiteralExpression)) {
            return ThreeState.UNSURE;
        }

//        // $test == "";
//        if(context.getParent() instanceof BinaryExpression) {
//            return ThreeState.NO;
//        }

        // $object->method("");
        PsiElement stringContext = context.getContext();
        if (stringContext instanceof ParameterList) {
            return ThreeState.NO;
        }

//        // $object->method(... array('foo'); array('bar' => 'foo') ...);
//        ArrayCreationExpression arrayCreationExpression = PhpElementsUtil.getCompletableArrayCreationElement(context);
//        if(arrayCreationExpression != null && arrayCreationExpression.getContext() instanceof ParameterList) {
//            return ThreeState.NO;
//        }

//        // $array['value']
//        if(PlatformPatterns.psiElement().withSuperParent(2, ArrayIndex.class).accepts(contextElement)) {
//            return ThreeState.NO;
//        }

        return ThreeState.UNSURE;
    }
 
Example #18
Source File: GradleDslSimpleExpression.java    From ok-gradle with Apache License 2.0 5 votes vote down vote up
/**
 * Works out whether or not this GradleDslSimpleExpression has a cycle.
 */
public boolean hasCycle() {
  if (myHasCycle != ThreeState.UNSURE) {
    return myHasCycle == ThreeState.YES;
  }
  return hasCycle(this, new HashSet<>(), new HashSet<>());
}
 
Example #19
Source File: XValueNodeImpl.java    From consulo with Apache License 2.0 5 votes vote down vote up
public void updateInlineDebuggerData() {
  try {
    XDebugSession session = XDebugView.getSession(getTree());
    final XSourcePosition debuggerPosition = session == null ? null : session.getCurrentPosition();
    if (debuggerPosition == null) {
      return;
    }

    final XInlineDebuggerDataCallback callback = new XInlineDebuggerDataCallback() {
      @Override
      public void computed(XSourcePosition position) {
        if (isObsolete() || position == null) return;
        VirtualFile file = position.getFile();
        // filter out values from other files
        if (!Comparing.equal(debuggerPosition.getFile(), file)) {
          return;
        }
        final Document document = FileDocumentManager.getInstance().getDocument(file);
        if (document == null) return;

        XVariablesView.InlineVariablesInfo data = myTree.getProject().getUserData(XVariablesView.DEBUG_VARIABLES);
        if (data == null) {
          return;
        }

        if (!showAsInlay(file, position, debuggerPosition)) {
          data.put(file, position, XValueNodeImpl.this, document.getModificationStamp());

          myTree.updateEditor();
        }
      }
    };

    if (getValueContainer().computeInlineDebuggerData(callback) == ThreeState.UNSURE) {
      getValueContainer().computeSourcePosition(callback::computed);
    }
  }
  catch (Exception ignore) {
  }
}
 
Example #20
Source File: FileStatusManagerImpl.java    From consulo with Apache License 2.0 5 votes vote down vote up
private void cacheChangedFileStatus(final VirtualFile virtualFile, final FileStatus fs) {
  myCachedStatuses.put(virtualFile, fs);
  if (FileStatus.NOT_CHANGED.equals(fs)) {
    final ThreeState parentingStatus = myFileStatusProvider.getNotChangedDirectoryParentingStatus(virtualFile);
    if (ThreeState.YES.equals(parentingStatus)) {
      myWhetherExactlyParentToChanged.put(virtualFile, true);
    }
    else if (ThreeState.UNSURE.equals(parentingStatus)) {
      myWhetherExactlyParentToChanged.put(virtualFile, false);
    }
  }
  else {
    myWhetherExactlyParentToChanged.remove(virtualFile);
  }
}
 
Example #21
Source File: Invoker.java    From consulo with Apache License 2.0 5 votes vote down vote up
private Invoker(@Nonnull String prefix, @Nonnull Disposable parent, @Nonnull ThreeState useReadAction) {
  StringBuilder sb = new StringBuilder().append(UID.getAndIncrement()).append(".Invoker.").append(prefix);
  if (useReadAction != ThreeState.UNSURE) {
    sb.append(".ReadAction=").append(useReadAction);
  }
  description = sb.append(": ").append(parent).toString();
  this.useReadAction = useReadAction;
  register(parent, this);
}
 
Example #22
Source File: GradleDslSimpleExpression.java    From ok-gradle with Apache License 2.0 5 votes vote down vote up
protected GradleDslSimpleExpression(@Nullable me.scana.okgradle.internal.dsl.parser.elements.GradleDslElement parent,
                                    @Nullable PsiElement psiElement,
                                    @NotNull me.scana.okgradle.internal.dsl.parser.elements.GradleNameElement name,
                                    @Nullable PsiElement expression) {
  super(parent, psiElement, name);
  myExpression = expression;
  myHasCycle = ThreeState.UNSURE;
  resolve();
  // Resolved values must be created after resolve() is called. If the debugger calls toString to trigger
  // any of the producers they will be stuck with the wrong value as dependencies have not been computed.
  myResolvedCachedValue = new CachedValue<>(this, GradleDslSimpleExpression::produceValue);
  myUnresolvedCachedValue = new CachedValue<>(this, GradleDslSimpleExpression::produceUnresolvedValue);
  myRawCachedValue = new CachedValue<>(this, GradleDslSimpleExpression::produceRawValue);
}
 
Example #23
Source File: StartedActivated.java    From consulo with Apache License 2.0 5 votes vote down vote up
public void start(final List<ThrowableRunnable<VcsException>> callList) {
  if (myMaster != null) {
    myMaster.start(callList);
  }
  if (! ThreeState.YES.equals(myState)) {
    myState = ThreeState.YES;
    callList.add(myStart);
  }
}
 
Example #24
Source File: ASTShallowComparator.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
public boolean hashCodesEqual(@Nonnull final ASTNode n1, @Nonnull final ASTNode n2) {
  if (n1 instanceof LeafElement && n2 instanceof LeafElement) {
    return textMatches(n1, n2) == ThreeState.YES;
  }

  if (n1 instanceof PsiErrorElement && n2 instanceof PsiErrorElement) {
    final PsiErrorElement e1 = (PsiErrorElement)n1;
    final PsiErrorElement e2 = (PsiErrorElement)n2;
    if (!Comparing.equal(e1.getErrorDescription(), e2.getErrorDescription())) return false;
  }

  return ((TreeElement)n1).hc() == ((TreeElement)n2).hc();
}
 
Example #25
Source File: ASTShallowComparator.java    From consulo with Apache License 2.0 5 votes vote down vote up
private ThreeState textMatches(ASTNode oldNode, ASTNode newNode) {
  myIndicator.checkCanceled();
  String oldText = TreeUtil.isCollapsedChameleon(oldNode) ? oldNode.getText() : null;
  String newText = TreeUtil.isCollapsedChameleon(newNode) ? newNode.getText() : null;
  if (oldText != null && newText != null) return oldText.equals(newText) ? ThreeState.YES : ThreeState.UNSURE;

  if (oldText != null) {
    return compareTreeToText((TreeElement)newNode, oldText) ? ThreeState.YES : ThreeState.UNSURE;
  }
  if (newText != null) {
    return compareTreeToText((TreeElement)oldNode, newText) ? ThreeState.YES : ThreeState.UNSURE;
  }

  if (oldNode instanceof ForeignLeafPsiElement) {
    return newNode instanceof ForeignLeafPsiElement && oldNode.getText().equals(newNode.getText()) ? ThreeState.YES : ThreeState.NO;
  }

  if (newNode instanceof ForeignLeafPsiElement) return ThreeState.NO;

  if (oldNode instanceof LeafElement) {
    return ((LeafElement)oldNode).textMatches(newNode.getText()) ? ThreeState.YES : ThreeState.NO;
  }
  if (newNode instanceof LeafElement) {
    return ((LeafElement)newNode).textMatches(oldNode.getText()) ? ThreeState.YES : ThreeState.NO;
  }

  if (oldNode instanceof PsiErrorElement && newNode instanceof PsiErrorElement) {
    final PsiErrorElement e1 = (PsiErrorElement)oldNode;
    final PsiErrorElement e2 = (PsiErrorElement)newNode;
    if (!Comparing.equal(e1.getErrorDescription(), e2.getErrorDescription())) return ThreeState.NO;
  }

  return ThreeState.UNSURE;
}
 
Example #26
Source File: URLUtil.java    From consulo with Apache License 2.0 5 votes vote down vote up
/**
 * Checks whether local resource specified by {@code url} exists. Returns {@link ThreeState#UNSURE} if {@code url} point to a remote resource.
 */
@Nonnull
public static ThreeState resourceExists(@Nonnull URL url) {
  if (url.getProtocol().equals(FILE_PROTOCOL)) {
    return ThreeState.fromBoolean(urlToFile(url).exists());
  }
  if (url.getProtocol().equals(JAR_PROTOCOL)) {
    Pair<String, String> paths = splitJarUrl(url.getFile());
    if (paths == null) {
      return ThreeState.NO;
    }
    if (!new File(paths.first).isFile()) {
      return ThreeState.NO;
    }
    try {
      ZipFile file = new ZipFile(paths.first);
      try {
        return ThreeState.fromBoolean(file.getEntry(paths.second) != null);
      }
      finally {
        file.close();
      }
    }
    catch (IOException e) {
      return ThreeState.NO;
    }
  }
  return ThreeState.UNSURE;
}
 
Example #27
Source File: SkipAutopopupInComments.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Nonnull
@Override
public ThreeState shouldSkipAutopopup(@Nonnull PsiElement contextElement, @Nonnull PsiFile psiFile, int offset) {
  if (PsiTreeUtil.getNonStrictParentOfType(contextElement, PsiComment.class) != null) {
    return ThreeState.YES;
  }

  return ThreeState.UNSURE;
}
 
Example #28
Source File: SkipAutopopupInStrings.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Nonnull
@Override
public ThreeState shouldSkipAutopopup(@Nonnull PsiElement contextElement, @Nonnull PsiFile psiFile, int offset) {
  if (isInStringLiteral(contextElement)) {
    return ThreeState.YES;
  }

  return ThreeState.UNSURE;
}
 
Example #29
Source File: DiffTree.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Nonnull
private CompareResult looksEqual(@Nonnull ShallowNodeComparator<OT, NT> comparator, OT oldChild1, NT newChild1) {
  if (oldChild1 == null || newChild1 == null) {
    return oldChild1 == newChild1 ? CompareResult.EQUAL : CompareResult.NOT_EQUAL;
  }
  if (!comparator.typesEqual(oldChild1, newChild1)) return CompareResult.NOT_EQUAL;
  ThreeState ret = comparator.deepEqual(oldChild1, newChild1);
  if (ret == ThreeState.YES) return CompareResult.EQUAL;
  if (ret == ThreeState.UNSURE) return CompareResult.DRILL_DOWN_NEEDED;
  return CompareResult.TYPE_ONLY;
}
 
Example #30
Source File: ASTShallowComparator.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Nonnull
@Override
public ThreeState deepEqual(@Nonnull final ASTNode oldNode, @Nonnull final ASTNode newNode) {
  return textMatches(oldNode, newNode);
}