Java Code Examples for com.intellij.util.ThreeState#NO

The following examples show how to use com.intellij.util.ThreeState#NO . 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: 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 2
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 3
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 4
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 5
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 6
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 7
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 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: 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 10
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 11
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 12
Source File: SkipDefaultsSerializationFilter.java    From consulo with Apache License 2.0 4 votes vote down vote up
boolean equal(@Nullable Binding binding, @Nullable Object currentValue, @Nullable Object defaultValue) {
  if (defaultValue instanceof Element && currentValue instanceof Element) {
    return JDOMUtil.areElementsEqual((Element)currentValue, (Element)defaultValue);
  }
  else {
    if (currentValue == defaultValue) {
      return true;
    }
    if (currentValue == null || defaultValue == null) {
      return false;
    }

    if (binding instanceof BasePrimitiveBinding) {
      Binding referencedBinding = ((BasePrimitiveBinding)binding).myBinding;
      if (referencedBinding instanceof BeanBinding) {
        BeanBinding classBinding = (BeanBinding)referencedBinding;
        ThreeState compareByFields = classBinding.hasEqualMethod;
        if (compareByFields == ThreeState.UNSURE) {
          try {
            classBinding.myBeanClass.getDeclaredMethod("equals", Object.class);
            compareByFields = ThreeState.NO;
          }
          catch (NoSuchMethodException ignored) {
            compareByFields = ThreeState.YES;
          }
          catch (Exception e) {
            Binding.LOG.warn(e);
          }

          classBinding.hasEqualMethod = compareByFields;
        }

        if (compareByFields == ThreeState.YES) {
          return classBinding.equalByFields(currentValue, defaultValue, this);
        }
      }
    }

    return Comparing.equal(currentValue, defaultValue);
  }
}
 
Example 13
Source File: CppCompletionConfidence.java    From CppTools with Apache License 2.0 4 votes vote down vote up
@NotNull
@Override
public ThreeState shouldFocusLookup(@NotNull CompletionParameters completionParameters) {
  return ThreeState.NO;
}
 
Example 14
Source File: VcsFileStatusProvider.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Nonnull
@Override
public ThreeState getNotChangedDirectoryParentingStatus(@Nonnull VirtualFile virtualFile) {
  return myConfiguration.SHOW_DIRTY_RECURSIVELY ? myChangeListManager.haveChangesUnder(virtualFile) : ThreeState.NO;
}
 
Example 15
Source File: WatchNodeImpl.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Override
@Nonnull
public ThreeState computeInlineDebuggerData(@Nonnull XInlineDebuggerDataCallback callback) {
  return ThreeState.NO;
}
 
Example 16
Source File: Invoker.java    From consulo with Apache License 2.0 4 votes vote down vote up
/**
 * Returns {@code true} if the current thread allows to process a task.
 *
 * @return {@code true} if the current thread is valid, or {@code false} otherwise
 */
public boolean isValidThread() {
  if (useReadAction != ThreeState.NO) return true;
  Application application = getApplication();
  return application == null || !application.isReadAccessAllowed();
}
 
Example 17
Source File: PhpAnnotationCompletionConfidence.java    From idea-php-annotation-plugin with MIT License 4 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) {

        // foo="<|>"
        if(PhpPatterns.psiElement(PhpDocElementTypes.phpDocString).accepts(context)) {
            return ThreeState.NO;
        }

    } else if(context instanceof PhpDocComment) {

        // * <|>
        if(PhpPatterns.psiElement().afterLeafSkipping(
            PhpPatterns.psiElement(PsiWhiteSpace.class),
            PhpPatterns.psiElement(PhpDocTokenTypes.DOC_LEADING_ASTERISK)
        ).accepts(contextElement)) {
            return ThreeState.NO;
        }

    } else if(context instanceof PhpPsiElementImpl) {

        // @Foo(<|>)
        if(PhpPatterns.psiElement(PhpDocElementTypes.phpDocAttributeList).accepts(context)) {
            return ThreeState.NO;
        }

        // @<|>
        if(PhpPatterns.psiElement(PhpDocElementTypes.phpDocTag).accepts(context)) {
            return ThreeState.NO;
        }

    }

    return ThreeState.UNSURE;
}
 
Example 18
Source File: PhpParameterStringCompletionConfidence.java    From idea-php-laravel-plugin with MIT License 4 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;
    }

    Project project = contextElement.getProject();
    if(!LaravelProjectComponent.isEnabled(project) || !LaravelSettings.getInstance(project).useAutoPopup) {
        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 19
Source File: IdeaFrameFixture.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
public boolean isGradleSyncNotNeeded() {
  return GradleSyncState.getInstance(getProject()).isSyncNeeded() == ThreeState.NO;
}