com.intellij.openapi.project.DumbAware Java Examples

The following examples show how to use com.intellij.openapi.project.DumbAware. 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: SelectInManager.java    From consulo with Apache License 2.0 5 votes vote down vote up
public SelectInTarget[] getTargets() {
  checkLoadExtensions();
  SelectInTarget[] targets = myTargets.toArray(new SelectInTarget[myTargets.size()]);
  Arrays.sort(targets, new SelectInTargetComparator());

  if (DumbService.getInstance(myProject).isDumb()) {
    final List<SelectInTarget> awareList = (List)ContainerUtil.findAll(targets, DumbAware.class);
    return awareList.toArray(new SelectInTarget[awareList.size()]);
  }

  return targets;
}
 
Example #2
Source File: DisposeAwareRunnable.java    From consulo with Apache License 2.0 5 votes vote down vote up
private static Runnable create(@Nonnull Runnable delegate, @Nullable Object disposable) {
  if (disposable == null) {
    return delegate;
  }

  if (delegate instanceof DumbAware) {
    return new DumbAwareRunnable(delegate, disposable);
  }

  if (delegate instanceof PossiblyDumbAware) {
    return new PossiblyDumbAwareRunnable(delegate, disposable);
  }

  return new DisposeAwareRunnable(delegate, disposable);
}
 
Example #3
Source File: CompletionContributorForTextField.java    From consulo with Apache License 2.0 5 votes vote down vote up
@RequiredReadAction
@Override
public void fillCompletionVariants(CompletionParameters parameters, CompletionResultSet result) {
  PsiFile file = parameters.getOriginalFile();
  if (!(file instanceof PsiPlainTextFile)) return;

  TextFieldCompletionProvider field = file.getUserData(TextFieldCompletionProvider.COMPLETING_TEXT_FIELD_KEY);
  if (field == null) return;

  if (!(field instanceof DumbAware) && DumbService.isDumb(file.getProject())) return;
  
  String text = file.getText();
  int offset = Math.min(text.length(), parameters.getOffset());

  String prefix = field.getPrefix(text.substring(0, offset));

  CompletionResultSet activeResult;

  if (!result.getPrefixMatcher().getPrefix().equals(prefix)) {
    activeResult = result.withPrefixMatcher(prefix);
  }
  else {
    activeResult = result;
  }

  if (field.isCaseInsensitivity()) {
    activeResult = activeResult.caseInsensitive();
  }

  field.addCompletionVariants(text, offset, prefix, activeResult);
}
 
Example #4
Source File: NonProblemFilterWrapper.java    From intellij with Apache License 2.0 4 votes vote down vote up
@Override
public boolean isDumbAware() {
  return delegate instanceof DumbAware;
}
 
Example #5
Source File: AnAction.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Override
public boolean isDumbAware() {
  return this instanceof DumbAware;
}
 
Example #6
Source File: GutterIconRenderer.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Override
public boolean isDumbAware() {
  return this instanceof DumbAware;
}