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

The following examples show how to use com.intellij.util.BitUtil#isSet() . 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: CSharpTypeStubElementType.java    From consulo-csharp with Apache License 2.0 6 votes vote down vote up
@Override
@RequiredReadAction
public void indexStub(@Nonnull CSharpTypeDeclStub stub, @Nonnull IndexSink indexSink)
{
	String name = getName(stub);
	if(!StringUtil.isEmpty(name))
	{
		indexSink.occurrence(CSharpIndexKeys.TYPE_INDEX, name);

		String parentQName = stub.getParentQName();
		if(!stub.isNested())
		{
			DotNetNamespaceStubUtil.indexStub(indexSink, CSharpIndexKeys.MEMBER_BY_NAMESPACE_QNAME_INDEX, CSharpIndexKeys.MEMBER_BY_ALL_NAMESPACE_QNAME_INDEX, parentQName, name);

			if(BitUtil.isSet(stub.getOtherModifierMask(), CSharpTypeDeclStub.HAVE_EXTENSIONS))
			{
				indexSink.occurrence(CSharpIndexKeys.TYPE_WITH_EXTENSION_METHODS_INDEX, DotNetNamespaceStubUtil.getIndexableNamespace(parentQName));
			}
		}

		indexSink.occurrence(CSharpIndexKeys.TYPE_BY_VMQNAME_INDEX, stub.getVmQName().hashCode());
	}
}
 
Example 2
Source File: MouseShortcut.java    From consulo with Apache License 2.0 6 votes vote down vote up
@JdkConstants.InputEventMask
private static int mapOldModifiers(@JdkConstants.InputEventMask int modifiers) {
  if (BitUtil.isSet(modifiers, InputEvent.SHIFT_MASK)) {
    modifiers |= InputEvent.SHIFT_DOWN_MASK;
  }
  if (BitUtil.isSet(modifiers, InputEvent.ALT_MASK)) {
    modifiers |= InputEvent.ALT_DOWN_MASK;
  }
  if (BitUtil.isSet(modifiers, InputEvent.ALT_GRAPH_MASK)) {
    modifiers |= InputEvent.ALT_GRAPH_DOWN_MASK;
  }
  if (BitUtil.isSet(modifiers, InputEvent.CTRL_MASK)) {
    modifiers |= InputEvent.CTRL_DOWN_MASK;
  }
  if (BitUtil.isSet(modifiers, InputEvent.META_MASK)) {
    modifiers |= InputEvent.META_DOWN_MASK;
  }

  modifiers &= InputEvent.SHIFT_DOWN_MASK
               | InputEvent.ALT_DOWN_MASK
               | InputEvent.ALT_GRAPH_DOWN_MASK
               | InputEvent.CTRL_DOWN_MASK
               | InputEvent.META_DOWN_MASK;

  return modifiers;
}
 
Example 3
Source File: CSharpElementTreeNode.java    From consulo-csharp with Apache License 2.0 6 votes vote down vote up
@Override
@RequiredUIAccess
protected void updateImpl(PresentationData presentationData)
{
	DotNetNamedElement value = getValue();

	presentationData.setPresentableText(getPresentableText(value));

	if(BitUtil.isSet(myFlags, ALLOW_GRAY_FILE_NAME))
	{
		PsiFile containingFile = value.getContainingFile();
		if(containingFile != null)
		{
			if(!Comparing.equal(FileUtil.getNameWithoutExtension(containingFile.getName()), value.getName()))
			{
				presentationData.setLocationString(containingFile.getName());
			}
		}
	}
}
 
Example 4
Source File: ExpressionParsing.java    From consulo-csharp with Apache License 2.0 6 votes vote down vote up
@Nullable
private static PsiBuilder.Marker parseReferenceTypeArgumentList(@Nonnull CSharpBuilderWrapper builder, int flags)
{
	IElementType startElementType = BitUtil.isSet(flags, INSIDE_DOC) ? LBRACE : LT;

	if(builder.getTokenType() != startElementType)
	{
		return null;
	}

	if(BitUtil.isSet(flags, ALLOW_EMPTY_TYPE_ARGUMENTS))
	{
		if(BitUtil.isSet(flags, STUB_SUPPORT))
		{
			throw new IllegalArgumentException("Empty type arguments is not allowed inside stub tree");
		}
		PsiBuilder.Marker marker = parseReferenceEmptyTypeArgumentListImpl(builder);
		if(marker != null)
		{
			return marker;
		}
	}
	return parseReferenceTypeArgumentListImpl(builder, flags);
}
 
Example 5
Source File: EditorTabbedContainer.java    From consulo with Apache License 2.0 6 votes vote down vote up
@RequiredUIAccess
@Override
public void actionPerformed(final AnActionEvent e) {
  final FileEditorManagerEx mgr = FileEditorManagerEx.getInstanceEx(myProject);
  consulo.fileEditor.impl.EditorWindow window;
  final VirtualFile file = (VirtualFile)myTabInfo.getObject();
  if (ActionPlaces.EDITOR_TAB.equals(e.getPlace())) {
    window = myWindow;
  }
  else {
    window = mgr.getCurrentWindow();
  }

  if (window != null) {
    if (BitUtil.isSet(e.getModifiers(), InputEvent.ALT_MASK)) {
      window.closeAllExcept(file);
    }
    else {
      if (window.findFileComposite(file) != null) {
        mgr.closeFile(file, window);
      }
    }
  }
}
 
Example 6
Source File: IntToIntBtree.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
protected void doInitFlags(int flags) {
  super.doInitFlags(flags);
  flags = (flags >> FLAGS_SHIFT) & 0xFF;
  isHashedLeaf = BitUtil.isSet(flags, HASHED_LEAF_MASK);
  isIndexLeaf = BitUtil.isSet(flags, INDEX_LEAF_MASK);
}
 
Example 7
Source File: StubUpdatingIndex.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Nullable
static IndexingStampInfo getIndexingStampInfo(@Nonnull VirtualFile file) {
  try (DataInputStream stream = INDEXED_STAMP.readAttribute(file)) {
    if (stream == null) {
      return null;
    }
    long stamp = DataInputOutputUtil.readTIME(stream);
    long byteLength = DataInputOutputUtil.readLONG(stream);

    byte flags = stream.readByte();
    boolean isBinary = BitUtil.isSet(flags, IS_BINARY_MASK);
    boolean readOnlyOneLength = BitUtil.isSet(flags, BYTE_AND_CHAR_LENGTHS_ARE_THE_SAME_MASK);

    int charLength;
    if (isBinary) {
      charLength = -1;
    }
    else if (readOnlyOneLength) {
      charLength = (int)byteLength;
    }
    else {
      charLength = DataInputOutputUtil.readINT(stream);
    }
    return new IndexingStampInfo(stamp, byteLength, charLength);
  }
  catch (IOException e) {
    LOG.error(e);
    return null;
  }
}
 
Example 8
Source File: HintManagerImpl.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
public boolean hasShownHintsThatWillHideByOtherHint(boolean willShowTooltip) {
  LOG.assertTrue(SwingUtilities.isEventDispatchThread());
  for (HintInfo hintInfo : getHintsStackArray()) {
    if (hintInfo.hint.isVisible() && BitUtil.isSet(hintInfo.flags, HIDE_BY_OTHER_HINT)) return true;
    if (willShowTooltip && hintInfo.hint.isAwtTooltip()) {
      // only one AWT tooltip can be visible, so this hint will hide even though it's not marked with HIDE_BY_OTHER_HINT
      return true;
    }
  }
  return false;
}
 
Example 9
Source File: CSharpMethodDeclarationImpl.java    From consulo-csharp with Apache License 2.0 5 votes vote down vote up
@Override
public boolean isDelegate()
{
	CSharpMethodDeclStub stub = getGreenStub();
	if(stub != null)
	{
		return BitUtil.isSet(stub.getOtherModifierMask(), CSharpMethodDeclStub.DELEGATE_MASK);
	}
	return findChildByType(CSharpTokens.DELEGATE_KEYWORD) != null;
}
 
Example 10
Source File: HintManagerImpl.java    From consulo with Apache License 2.0 5 votes vote down vote up
private void updateScrollableHints(VisibleAreaEvent e) {
  LOG.assertTrue(SwingUtilities.isEventDispatchThread());
  for (HintInfo info : getHintsStackArray()) {
    if (info.hint != null && BitUtil.isSet(info.flags, UPDATE_BY_SCROLLING)) {
      updateScrollableHintPosition(e, info.hint, BitUtil.isSet(info.flags, HIDE_IF_OUT_OF_EDITOR));
    }
  }
}
 
Example 11
Source File: MouseEnterHandler.java    From consulo with Apache License 2.0 4 votes vote down vote up
public boolean isMousePressed() {
  return BitUtil.isSet(myFlags, PRESSED);
}
 
Example 12
Source File: CSharpElementPresentationUtil.java    From consulo-csharp with Apache License 2.0 4 votes vote down vote up
@Nonnull
@RequiredReadAction
public static String formatMethod(@Nonnull DotNetLikeMethodDeclaration methodDeclaration, int flags)
{
	StringBuilder builder = new StringBuilder();

	if(BitUtil.isSet(flags, METHOD_WITH_RETURN_TYPE) && !BitUtil.isSet(flags, SCALA_FORMAT))
	{
		if(!(methodDeclaration instanceof DotNetConstructorDeclaration))
		{
			CSharpTypeRefPresentationUtil.appendTypeRef(methodDeclaration, builder, methodDeclaration.getReturnTypeRef(), typeRefMask(flags));
			builder.append(" ");
		}
	}

	if(methodDeclaration instanceof DotNetConstructorDeclaration && ((DotNetConstructorDeclaration) methodDeclaration).isDeConstructor())
	{
		builder.append("~");
	}

	if(BitUtil.isSet(flags, WITH_VIRTUAL_IMPL_TYPE))
	{
		if(methodDeclaration instanceof DotNetVirtualImplementOwner)
		{
			DotNetTypeRef typeRefForImplement = ((DotNetVirtualImplementOwner) methodDeclaration).getTypeRefForImplement();
			if(typeRefForImplement != DotNetTypeRef.ERROR_TYPE)
			{
				CSharpTypeRefPresentationUtil.appendTypeRef(methodDeclaration, builder, typeRefForImplement, typeRefMask(flags));
				builder.append(".");
			}
		}
	}

	if(methodDeclaration instanceof CSharpIndexMethodDeclaration)
	{
		builder.append("this");
	}
	else
	{
		builder.append(methodDeclaration.getName());
	}
	formatTypeGenericParameters(methodDeclaration.getGenericParameters(), builder);
	formatParameters(methodDeclaration, builder, flags);
	return builder.toString();
}
 
Example 13
Source File: Node.java    From consulo with Apache License 2.0 4 votes vote down vote up
private boolean isFlagSet(@FlagConstant byte mask) {
  return BitUtil.isSet(myCachedFlags, mask);
}
 
Example 14
Source File: LineSet.java    From consulo with Apache License 2.0 4 votes vote down vote up
final boolean isModified(int index) {
  checkLineIndex(index);
  return !isLastEmptyLine(index) && BitUtil.isSet(myFlags[index], MODIFIED_MASK);
}
 
Example 15
Source File: CSharpIconDescriptorUpdater.java    From consulo-csharp with Apache License 2.0 4 votes vote down vote up
@RequiredReadAction
private static void processModifierListOwner(PsiElement element, IconDescriptor iconDescriptor, int flags)
{
	DotNetModifierListOwner owner = (DotNetModifierListOwner) element;
	if(BitUtil.isSet(flags, Iconable.ICON_FLAG_VISIBILITY))
	{
		if(owner.hasModifier(CSharpModifier.PRIVATE))
		{
			iconDescriptor.setRightIcon(AllIcons.Nodes.C_private);
		}
		else if(owner.hasModifier(CSharpModifier.PUBLIC))
		{
			iconDescriptor.setRightIcon(AllIcons.Nodes.C_public);
		}
		else if(owner.hasModifier(CSharpModifier.PROTECTED))
		{
			iconDescriptor.setRightIcon(AllIcons.Nodes.C_protected);
		}
		else
		{
			iconDescriptor.setRightIcon(AllIcons.Nodes.C_plocal);
		}
	}

	if(owner.hasModifier(CSharpModifier.STATIC) && !(owner instanceof CSharpTypeDeclaration))
	{
		iconDescriptor.addLayerIcon(AllIcons.Nodes.StaticMark);
	}

	if(owner.hasModifier(CSharpModifier.SEALED) ||
			owner.hasModifier(CSharpModifier.READONLY) ||
			element instanceof DotNetVariable && ((DotNetVariable) element).isConstant() ||
			element instanceof CSharpPropertyDeclaration && ((CSharpPropertyDeclaration) element).isAutoGet())
	{
		iconDescriptor.addLayerIcon(AllIcons.Nodes.FinalMark);
	}

	// dont check it for msil wrappers
	if(!(element instanceof MsilElementWrapper))
	{
		if(element instanceof DotNetTypeDeclaration && DotNetRunUtil.hasEntryPoint((DotNetTypeDeclaration) element) || element instanceof DotNetMethodDeclaration && DotNetRunUtil.isEntryPoint(
				(DotNetMethodDeclaration) element))

		{
			iconDescriptor.addLayerIcon(AllIcons.Nodes.RunnableMark);
		}
	}
}
 
Example 16
Source File: ExpressionParsing.java    From consulo-csharp with Apache License 2.0 4 votes vote down vote up
public static ReferenceInfo parseQualifiedReference(@Nonnull CSharpBuilderWrapper builder, @Nullable final PsiBuilder.Marker prevMarker, int flags, @Nonnull TokenSet nameStopperSet)
{
	if(prevMarker != null)
	{
		builder.advanceLexer(); // skip dot or coloncolon
	}

	PsiBuilder.Marker marker = prevMarker == null ? builder.mark() : prevMarker;

	ReferenceInfo referenceInfo = new ReferenceInfo(false, marker);

	if(prevMarker == null)
	{
		builder.enableSoftKeyword(CSharpSoftTokens.GLOBAL_KEYWORD);
		IElementType tokenType = builder.getTokenType();
		builder.disableSoftKeyword(CSharpSoftTokens.GLOBAL_KEYWORD);

		if(tokenType == CSharpSoftTokens.GLOBAL_KEYWORD && builder.lookAhead(1) == CSharpTokens.COLONCOLON)
		{
			builder.advanceLexer(); // global

			marker.done(referenceExpression(flags));

			return parseQualifiedReference(builder, marker.precede(), flags, nameStopperSet);
		}
		else
		{
			builder.remapBackIfSoft();
		}
	}

	if(expect(builder, CSharpTokens.IDENTIFIER, "Identifier expected"))
	{
		referenceInfo.isParameterized = parseReferenceTypeArgumentList(builder, flags) != null;

		marker.done(referenceExpression(flags));

		// inside doc - PLUS used for nested type reference
		if(builder.getTokenType() == DOT || BitUtil.isSet(flags, INSIDE_DOC) && builder.getTokenType() == PLUS)
		{
			// if after dot we found stoppers, name expected - but we done
			if(nameStopperSet.contains(builder.lookAhead(1)) || nameStopperSet.contains(builder.lookAhead(2)))
			{
				return referenceInfo;
			}
			referenceInfo = parseQualifiedReference(builder, marker.precede(), flags, nameStopperSet);
		}
	}
	else
	{
		marker.drop();
		return null;
	}

	return referenceInfo;
}
 
Example 17
Source File: HighlightInfo.java    From consulo with Apache License 2.0 4 votes vote down vote up
private boolean isFlagSet(@FlagConstant byte mask) {
  return BitUtil.isSet(myFlags, mask);
}
 
Example 18
Source File: CSharpVariableDeclStub.java    From consulo-csharp with Apache License 2.0 4 votes vote down vote up
public boolean isMultipleDeclaration()
{
	return BitUtil.isSet(getOtherModifierMask(), MULTIPLE_DECLARATION_MASK);
}
 
Example 19
Source File: CSharpTypeDeclStub.java    From consulo-csharp with Apache License 2.0 4 votes vote down vote up
public boolean isEnum()
{
	return BitUtil.isSet(getOtherModifierMask(), ENUM);
}
 
Example 20
Source File: RefEntityImpl.java    From consulo with Apache License 2.0 4 votes vote down vote up
public synchronized boolean checkFlag(long mask) {
  return BitUtil.isSet(myFlags, mask);
}