Java Code Examples for com.intellij.util.BitUtil#set()

The following examples show how to use com.intellij.util.BitUtil#set() . 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: CSharpVariableDeclStub.java    From consulo-csharp with Apache License 2.0 6 votes vote down vote up
@RequiredReadAction
public static int getOtherModifierMask(DotNetVariable variable)
{
	int i = 0;
	i = BitUtil.set(i, CONSTANT_MASK, variable.isConstant());
	if(variable instanceof CSharpStubVariableImpl)
	{
		i = BitUtil.set(i, MULTIPLE_DECLARATION_MASK, CSharpStubVariableImplUtil.isMultipleDeclaration((CSharpStubVariableImpl<?>) variable));
	}
	if(variable instanceof CSharpStubParameterImpl)
	{
		i = BitUtil.set(i, OPTIONAL, variable.getInitializer() != null);
	}
	if(variable instanceof CSharpPropertyDeclaration)
	{
		i = BitUtil.set(i, AUTO_GET, ((CSharpPropertyDeclaration) variable).isAutoGet());
	}
	return i;
}
 
Example 2
Source File: RequestFocusHttpRequestHandler.java    From consulo with Apache License 2.0 6 votes vote down vote up
public static boolean activateFrame(@Nullable final Frame frame) {
  if (frame != null) {
    Runnable runnable = new Runnable() {
      @Override
      public void run() {
        int extendedState = frame.getExtendedState();
        if (BitUtil.isSet(extendedState, Frame.ICONIFIED)) {
          extendedState = BitUtil.set(extendedState, Frame.ICONIFIED, false);
          frame.setExtendedState(extendedState);
        }

        // fixme [vistall] dirty hack - show frame on top
        frame.setAlwaysOnTop(true);
        frame.setAlwaysOnTop(false);
        IdeFocusManager.getGlobalInstance().doForceFocusWhenFocusSettlesDown(frame);
      }
    };
    //noinspection SSBasedInspection
    SwingUtilities.invokeLater(runnable);
    return true;
  }
  return false;
}
 
Example 3
Source File: ScopeChooserCombo.java    From consulo with Apache License 2.0 6 votes vote down vote up
public void init(final Project project, final boolean suggestSearchInLibs, final boolean prevSearchWholeFiles, final Object selection, @Nullable Condition<? super ScopeDescriptor> scopeFilter) {
  if (myProject != null) {
    throw new IllegalStateException("scope chooser combo already initialized");
  }
  myOptions = BitUtil.set(myOptions, OPT_LIBRARIES, suggestSearchInLibs);
  myOptions = BitUtil.set(myOptions, OPT_SEARCH_RESULTS, prevSearchWholeFiles);
  myProject = project;

  NamedScopesHolder.ScopeListener scopeListener = () -> {
    SearchScope selectedScope = getSelectedScope();
    rebuildModelAndSelectScopeOnSuccess(selectedScope);
  };
  myScopeFilter = scopeFilter;
  NamedScopeManager.getInstance(project).addScopeListener(scopeListener, this);
  DependencyValidationManager.getInstance(project).addScopeListener(scopeListener, this);
  addActionListener(this::handleScopeChooserAction);

  ComboBox<ScopeDescriptor> combo = getComboBox();
  combo.setMinimumAndPreferredWidth(JBUIScale.scale(300));
  combo.setRenderer(createDefaultRenderer());
  combo.setSwingPopup(false);

  rebuildModelAndSelectScopeOnSuccess(selection);
}
 
Example 4
Source File: StubUpdatingIndex.java    From consulo with Apache License 2.0 6 votes vote down vote up
private static void rememberIndexingStamp(@Nonnull VirtualFile file, boolean isBinary, long contentByteLength, int contentCharLength) {
  try (DataOutputStream stream = INDEXED_STAMP.writeAttribute(file)) {
    DataInputOutputUtil.writeTIME(stream, file.getTimeStamp());
    DataInputOutputUtil.writeLONG(stream, contentByteLength);

    boolean lengthsAreTheSame = contentByteLength == contentCharLength;
    byte flags = 0;
    flags = BitUtil.set(flags, IS_BINARY_MASK, isBinary);
    flags = BitUtil.set(flags, BYTE_AND_CHAR_LENGTHS_ARE_THE_SAME_MASK, lengthsAreTheSame);
    stream.writeByte(flags);

    if (!lengthsAreTheSame && !isBinary) {
      DataInputOutputUtil.writeINT(stream, contentCharLength);
    }
  }
  catch (IOException e) {
    LOG.error(e);
  }
}
 
Example 5
Source File: AWTKeyAdapterAsKeyListener.java    From consulo with Apache License 2.0 5 votes vote down vote up
private static int getUIModifiers(KeyEvent e) {
  int value = 0;

  value = BitUtil.set(value, consulo.ui.event.KeyEvent.M_ALT, e.isAltDown());
  value = BitUtil.set(value, consulo.ui.event.KeyEvent.M_CTRL, e.isControlDown());
  value = BitUtil.set(value, consulo.ui.event.KeyEvent.M_SHIFT, e.isShiftDown());
  return value;
}
 
Example 6
Source File: TargetAWTFacadeImpl.java    From consulo with Apache License 2.0 5 votes vote down vote up
public static SimpleTextAttributes from(@Nonnull TextAttribute textAttribute) {
  int mask = 0;

  mask = BitUtil.set(mask, SimpleTextAttributes.STYLE_PLAIN, BitUtil.isSet(textAttribute.getStyle(), TextAttribute.STYLE_PLAIN));
  mask = BitUtil.set(mask, SimpleTextAttributes.STYLE_BOLD, BitUtil.isSet(textAttribute.getStyle(), TextAttribute.STYLE_BOLD));
  mask = BitUtil.set(mask, SimpleTextAttributes.STYLE_ITALIC, BitUtil.isSet(textAttribute.getStyle(), TextAttribute.STYLE_ITALIC));

  ColorValue backgroundColor = textAttribute.getBackgroundColor();
  ColorValue foregroundColor = textAttribute.getForegroundColor();
  return new SimpleTextAttributes(mask, TargetAWT.to(foregroundColor), TargetAWT.to(backgroundColor));
}
 
Example 7
Source File: MouseEnterHandler.java    From consulo with Apache License 2.0 5 votes vote down vote up
public MouseEnterHandler(final Component component) {
  myMouseAdapter = new MouseAdapter() {
    @Override
    public void mouseEntered(MouseEvent e) {
      if (!component.isEnabled()) {
        return;
      }
      myFlags = BitUtil.set(myFlags, ENTERED, true);
      component.repaint();
    }

    @Override
    public void mouseExited(MouseEvent e) {
      myFlags = BitUtil.set(myFlags, ENTERED, false);
      component.repaint();
    }

    @Override
    public void mousePressed(MouseEvent e) {
      if (!component.isEnabled()) {
        return;
      }
      myFlags = BitUtil.set(myFlags, PRESSED, true);
      component.repaint();
    }

    @Override
    public void mouseReleased(MouseEvent e) {
      myFlags = BitUtil.set(myFlags, PRESSED, false);
      component.repaint();
    }
  };
}
 
Example 8
Source File: RedBlackTree.java    From consulo with Apache License 2.0 4 votes vote down vote up
void setFlag(byte mask, boolean value) {
  myFlags = BitUtil.set(myFlags, mask, value);
}
 
Example 9
Source File: FoldingDescriptor.java    From consulo with Apache License 2.0 4 votes vote down vote up
private void setFlag(byte mask, boolean value) {
  myFlags = BitUtil.set(myFlags, mask, value);
}
 
Example 10
Source File: HighlightInfo.java    From consulo with Apache License 2.0 4 votes vote down vote up
private void setFlag(@FlagConstant byte mask, boolean value) {
  myFlags = BitUtil.set(myFlags, mask, value);
}
 
Example 11
Source File: ScopeChooserCombo.java    From consulo with Apache License 2.0 4 votes vote down vote up
public void setCurrentSelection(boolean currentSelection) {
  myOptions = BitUtil.set(myOptions, OPT_FROM_SELECTION, currentSelection);
}
 
Example 12
Source File: ScopeChooserCombo.java    From consulo with Apache License 2.0 4 votes vote down vote up
public void setUsageView(boolean usageView) {
  myOptions = BitUtil.set(myOptions, OPT_USAGE_VIEW, usageView);
}
 
Example 13
Source File: ScopeChooserCombo.java    From consulo with Apache License 2.0 4 votes vote down vote up
public void setShowEmptyScopes(boolean showEmptyScopes) {
  myOptions = BitUtil.set(myOptions, OPT_EMPTY_SCOPES, showEmptyScopes);
}
 
Example 14
Source File: WhiteSpace.java    From consulo with Apache License 2.0 4 votes vote down vote up
private void setFlag(final int mask, final boolean value) {
  myFlags = BitUtil.set(myFlags, mask, value);
}
 
Example 15
Source File: RefEntityImpl.java    From consulo with Apache License 2.0 4 votes vote down vote up
public synchronized void setFlag(final boolean value, final long mask) {
  myFlags = BitUtil.set(myFlags, mask, value);
}
 
Example 16
Source File: Node.java    From consulo with Apache License 2.0 4 votes vote down vote up
private void setFlag(@FlagConstant byte mask, boolean value) {
  myCachedFlags = BitUtil.set(myCachedFlags, mask, value);
}
 
Example 17
Source File: RangeHighlighterImpl.java    From consulo with Apache License 2.0 4 votes vote down vote up
private void setFlag(@FlagConstant byte mask, boolean value) {
  myFlags = BitUtil.set(myFlags, mask, value);
}