Java Code Examples for com.intellij.util.BitUtil

The following are top voted examples for showing how to use com.intellij.util.BitUtil. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: MultiHighlight   File: ColorChooserPanel.java   Source Code and License 6 votes vote down vote up
@Override
public void reset(@NotNull TextAttributes ta) {
    myCbBold.setEnabled(true);
    myCbItalic.setEnabled(true);

    int fontType = ta.getFontType();
    myCbBold.setSelected(BitUtil.isSet(fontType, Font.BOLD));
    myCbItalic.setSelected(BitUtil.isSet(fontType, Font.ITALIC));

    resetColorChooser(myCbForeground, myForegroundChooser, ta.getForegroundColor());
    resetColorChooser(myCbBackground, myBackgroundChooser, ta.getBackgroundColor());
    resetColorChooser(myCbErrorStripe, myErrorStripeColorChooser, ta.getErrorStripeColor());

    Color effectColor = ta.getEffectColor();
    resetColorChooser(myCbEffects, myEffectsColorChooser, effectColor);

    if (effectColor == null) {
        myEffectsCombo.setEnabled(false);
    } else {
        myEffectsCombo.setEnabled(true);
        myEffectsModel.setSelectedItem(
                ContainerUtil.reverseMap(myEffectsMap).get(ta.getEffectType()));
    }
}
 
Example 2
Project: intellij-ce-playground   File: ToolkitBugsProcessor.java   Source Code and License 6 votes vote down vote up
public ToolkitBugsProcessor() {
  Class<?>[] classes = getClass().getDeclaredClasses();
  for (Class<?> each : classes) {
    if (!BitUtil.isSet(each.getModifiers(), Modifier.ABSTRACT) && Handler.class.isAssignableFrom(each)) {
      try {
        Handler eachHandler = (Handler)each.newInstance();
        if (eachHandler.isActual()) {
          myHandlers.add(eachHandler);
        }
      }
      catch (Throwable e) {
        LOG.error(e);
      }
    }
  }
}
 
Example 3
Project: tools-idea   File: ToolkitBugsProcessor.java   Source Code and License 6 votes vote down vote up
public ToolkitBugsProcessor() {
  Class<?>[] classes = getClass().getDeclaredClasses();
  for (Class<?> each : classes) {
    if (!BitUtil.isSet(each.getModifiers(), Modifier.ABSTRACT) && Handler.class.isAssignableFrom(each)) {
      try {
        Handler eachHandler = (Handler)each.newInstance();
        if (eachHandler.isActual()) {
          myHandlers.add(eachHandler);
        }
      }
      catch (Throwable e) {
        LOG.error(e);
      }
    }
  }
}
 
Example 4
Project: consulo-ikvm   File: JavaMethodStubBuilder.java   Source Code and License 6 votes vote down vote up
@Override
public void buildToBytecode(ClassWriter parent)
{
	int access = 0;
	access = BitUtil.set(access, Opcodes.ACC_STATIC, myModifiers.contains(PsiModifier.STATIC));
	access = BitUtil.set(access, Opcodes.ACC_PUBLIC, myModifiers.contains(PsiModifier.PUBLIC));

	StringBuilder descBuilder = new StringBuilder();
	descBuilder.append("(");
	for(JavaParameterStubBuilder parameter : myParameters)
	{
		appendType(parameter.getType(), descBuilder);
	}
	descBuilder.append(")");
	appendType(myReturnType, descBuilder);

	try
	{
		parent.visitMethod(access, myName, descBuilder.toString(), null, null).visitEnd();
	}
	catch(Exception e)
	{
		e.printStackTrace();
	}
}
 
Example 5
Project: consulo-csharp   File: SharedParsingHelpers.java   Source Code and License 6 votes vote down vote up
protected static Pair<PsiBuilder.Marker, ModifierSet> parseModifierList(CSharpBuilderWrapper builder, int flags)
{
	PsiBuilder.Marker marker = builder.mark();

	Set<IElementType> set = new THashSet<>();
	while(!builder.eof())
	{
		if(MODIFIERS.contains(builder.getTokenType()))
		{
			set.add(builder.getTokenType());

			builder.advanceLexer();
		}
		else
		{
			break;
		}
	}
	marker.done(BitUtil.isSet(flags, STUB_SUPPORT) ? CSharpStubElements.MODIFIER_LIST : CSharpElements.MODIFIER_LIST);
	return Pair.create(marker, ModifierSet.create(set));
}
 
Example 6
Project: consulo-csharp   File: ExpressionParsing.java   Source Code and License 6 votes vote down vote up
@Nullable
private static PsiBuilder.Marker parseReferenceTypeArgumentList(@NotNull 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 7
Project: consulo-csharp   File: CSharpElementCompareUtil.java   Source Code and License 6 votes vote down vote up
@RequiredReadAction
private static boolean compareVirtualImpl(@NotNull PsiElement o1, @NotNull PsiElement o2, int flags, @NotNull PsiElement scope)
{
	if(!BitUtil.isSet(flags, CHECK_VIRTUAL_IMPL_TYPE))
	{
		return true;
	}
	DotNetType type1 = ((DotNetVirtualImplementOwner) o1).getTypeForImplement();
	DotNetType type2 = ((DotNetVirtualImplementOwner) o2).getTypeForImplement();

	if(type1 == null && type2 == null)
	{
		return true;
	}

	if(type1 == null || type2 == null)
	{
		return false;
	}
	// we need call getTypeRefForImplement() due light element have ref for original DotNetType but getTypeRefForImplement() ill return another
	return CSharpTypeUtil.isTypeEqual(((DotNetVirtualImplementOwner) o1).getTypeRefForImplement(), ((DotNetVirtualImplementOwner) o2).getTypeRefForImplement(), scope);
}
 
Example 8
Project: consulo-csharp   File: CSharpTypeStubElementType.java   Source Code and License 6 votes vote down vote up
@Override
@RequiredReadAction
public void indexStub(@NotNull CSharpTypeDeclStub stub, @NotNull 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_QNAME_INDEX, getNameWithNamespaceForIndexing(parentQName, name));

		indexSink.occurrence(CSharpIndexKeys.TYPE_BY_VMQNAME_INDEX, stub.getVmQName());
	}
}
 
Example 9
Project: consulo-csharp   File: CSharpElementTreeNode.java   Source Code and License 6 votes vote down vote up
@Nullable
@Override
@RequiredDispatchThread
protected Collection<AbstractTreeNode> getChildrenImpl()
{
	final ViewSettings settings = getSettings();
	if(!settings.isShowMembers() && !BitUtil.isSet(myFlags, FORCE_EXPAND))
	{
		return Collections.emptyList();
	}

	DotNetNamedElement[] members = filterNamespaces(getValue());
	if(members.length == 0)
	{
		return Collections.emptyList();
	}

	List<AbstractTreeNode> list = new ArrayList<>(members.length);
	for(DotNetNamedElement dotNetElement : members)
	{
		list.add(new CSharpElementTreeNode(dotNetElement, settings, 0));
	}
	return list;
}
 
Example 10
Project: consulo-csharp   File: CSharpElementTreeNode.java   Source Code and License 6 votes vote down vote up
@Override
@RequiredDispatchThread
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 11
Project: consulo-dotnet   File: DotNetTypeRefCacheUtil.java   Source Code and License 6 votes vote down vote up
@Exported
@NotNull
@RequiredReadAction
private static <E extends PsiElement> DotNetTypeRef getResultCacheResultImpl(@NotNull Key<CachedValue<DotNetTypeRef>> cachedValueKey,
		@NotNull E element,
		@NotNull Key dropKey,
		@NotNull final NotNullFunction<E, DotNetTypeRef> resolver)
{
	Class<? extends NotNullFunction> aClass = resolver.getClass();
	if(!BitUtil.isSet(aClass.getModifiers(), Modifier.STATIC))
	{
		throw new IllegalArgumentException("Accepted only static resolver");
	}

	CachedValue<DotNetTypeRef> cachedValue = element.getUserData(cachedValueKey);
	if(cachedValue == null)
	{
		DotNetTypeRefCachedValueProvider<E> provider = new DotNetTypeRefCachedValueProvider<>(dropKey, element, resolver);

		cachedValue = ((UserDataHolderEx) element).putUserDataIfAbsent(cachedValueKey, CachedValuesManager.getManager(element.getProject()).createCachedValue(provider, false));

		return cachedValue.getValue();
	}
	return cachedValue.getValue();
}
 
Example 12
Project: consulo-dotnet   File: DotNetElementPresentationUtil.java   Source Code and License 6 votes vote down vote up
@NotNull
@Deprecated
public static String formatMethod(@NotNull DotNetLikeMethodDeclaration methodDeclaration, int flags)
{
	StringBuilder builder = new StringBuilder();

	if(BitUtil.isSet(flags, METHOD_WITH_RETURN_TYPE) && !BitUtil.isSet(flags, METHOD_SCALA_FORMAT))
	{
		if(!(methodDeclaration instanceof DotNetConstructorDeclaration))
		{
			builder.append(methodDeclaration.getReturnTypeRef().getPresentableText()).append(" ");
		}
	}

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

	builder.append(methodDeclaration.getName());
	formatTypeGenericParameters(methodDeclaration.getGenericParameters(), builder);
	formatParameters(methodDeclaration, builder, flags);
	return builder.toString();
}
 
Example 13
Project: consulo   File: GwtTransportServiceImpl.java   Source Code and License 6 votes vote down vote up
@Nonnull
public static GwtTextAttributes createTextAttributes(TextAttributes textAttributes) {
  GwtColor foreground = null;
  GwtColor background = null;

  Color foregroundColor = textAttributes.getForegroundColor();
  if (foregroundColor != null) {
    foreground = createColor(foregroundColor);
  }

  Color backgroundColor = textAttributes.getBackgroundColor();
  if (backgroundColor != null) {
    background = createColor(backgroundColor);
  }

  int flags = 0;
  flags = BitUtil.set(flags, GwtTextAttributes.BOLD, (textAttributes.getFontType() & Font.BOLD) != 0);
  flags = BitUtil.set(flags, GwtTextAttributes.ITALIC, (textAttributes.getFontType() & Font.ITALIC) != 0);
  flags = BitUtil.set(flags, GwtTextAttributes.UNDERLINE, textAttributes.getEffectType() == EffectType.LINE_UNDERSCORE);
  flags = BitUtil.set(flags, GwtTextAttributes.LINE_THROUGH, textAttributes.getEffectType() == EffectType.STRIKEOUT);

  return new GwtTextAttributes(foreground, background, flags);
}
 
Example 14
Project: consulo   File: MouseShortcut.java   Source Code and License 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 15
Project: consulo   File: RequestFocusHttpRequestHandler.java   Source Code and License 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 16
Project: consulo   File: EditorTabbedContainer.java   Source Code and License 6 votes vote down vote up
@RequiredDispatchThread
@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 17
Project: consulo   File: ReopenProjectAction.java   Source Code and License 6 votes vote down vote up
@RequiredDispatchThread
@Override
public void actionPerformed(@Nonnull AnActionEvent e) {
  //Force move focus to IdeFrame
  IdeEventQueue.getInstance().getPopupManager().closeAllPopups();

  final int modifiers = e.getModifiers();
  final boolean forceOpenInNewFrame = BitUtil.isSet(modifiers, InputEvent.CTRL_MASK) || BitUtil.isSet(modifiers, InputEvent.SHIFT_MASK) || e.getPlace() == ActionPlaces.WELCOME_SCREEN;

  Project project = e.getData(CommonDataKeys.PROJECT);
  if (!new File(myProjectPath).exists()) {
    if (Messages.showDialog(project, "The path " +
                                     FileUtil.toSystemDependentName(myProjectPath) +
                                     " does not exist.\n" +
                                     "If it is on a removable or network drive, please make sure that the drive is connected.", "Reopen Project", new String[]{"OK", "&Remove From List"}, 0,
                            Messages.getErrorIcon()) == 1) {
      RecentProjectsManager.getInstance().removePath(myProjectPath);
    }
    return;
  }

  Platform.hacky(() -> ProjectUtil.open(myProjectPath, project, forceOpenInNewFrame), () -> ProjectUtil.openAsync(myProjectPath, null, forceOpenInNewFrame, UIAccess.get()));
}
 
Example 18
Project: consulo   File: ToolkitBugsProcessor.java   Source Code and License 6 votes vote down vote up
public ToolkitBugsProcessor() {
  Class<?>[] classes = getClass().getDeclaredClasses();
  for (Class<?> each : classes) {
    if (!BitUtil.isSet(each.getModifiers(), Modifier.ABSTRACT) && Handler.class.isAssignableFrom(each)) {
      try {
        Handler eachHandler = (Handler)each.newInstance();
        if (eachHandler.isActual()) {
          myHandlers.add(eachHandler);
        }
      }
      catch (Throwable e) {
        LOG.error(e);
      }
    }
  }
}
 
Example 19
Project: consulo   File: DesktopToolWindowHeader.java   Source Code and License 6 votes vote down vote up
@Override
@RequiredDispatchThread
public void actionPerformed(final ActionEvent e) {
  AnAction action =
          myAlternativeAction != null && BitUtil.isSet(e.getModifiers(), InputEvent.ALT_MASK) ? myAlternativeAction : myAction;
  final DataContext dataContext = DataManager.getInstance().getDataContext(this);
  final ActionManagerEx actionManager = ActionManagerEx.getInstanceEx();
  InputEvent inputEvent = e.getSource() instanceof InputEvent ? (InputEvent) e.getSource() : null;
  final AnActionEvent event =
          new AnActionEvent(inputEvent, dataContext, ActionPlaces.TOOLWINDOW_TITLE, action.getTemplatePresentation(),
                            ActionManager.getInstance(),
                            0);
  actionManager.fireBeforeActionPerformed(action, dataContext, event);
  final Component component = dataContext.getData(PlatformDataKeys.CONTEXT_COMPONENT);
  if (component != null && !component.isShowing()) {
    return;
  }

  action.actionPerformed(event);
}
 
Example 20
Project: consulo-java   File: ExceptionUtil.java   Source Code and License 6 votes vote down vote up
private static boolean blockCompletesAbruptly(@NotNull final PsiCodeBlock finallyBlock)
{
	try
	{
		ControlFlow flow = ControlFlowFactory.getInstance(finallyBlock.getProject()).getControlFlow(finallyBlock, LocalsOrMyInstanceFieldsControlFlowPolicy.getInstance(), false);
		int completionReasons = ControlFlowUtil.getCompletionReasons(flow, 0, flow.getSize());
		if(!BitUtil.isSet(completionReasons, ControlFlowUtil.NORMAL_COMPLETION_REASON))
		{
			return true;
		}
	}
	catch(AnalysisCanceledException e)
	{
		return true;
	}
	return false;
}
 
Example 21
Project: consulo-java   File: PsiModifierListImpl.java   Source Code and License 6 votes vote down vote up
private Set<String> calcExplicitModifiers()
{
	Set<String> explicitModifiers = ContainerUtil.newHashSet();
	PsiModifierListStub stub = getGreenStub();
	if(stub != null)
	{
		int mask = stub.getModifiersMask();
		for(int i = 0; i < 31; i++)
		{
			int flag = 1 << i;
			if(BitUtil.isSet(mask, flag))
			{
				ContainerUtil.addIfNotNull(explicitModifiers, ModifierFlags.MODIFIER_FLAG_TO_NAME_MAP.get(flag));
			}
		}
	}
	else
	{
		for(ASTNode child : getNode().getChildren(null))
		{
			ContainerUtil.addIfNotNull(explicitModifiers, KEYWORD_TYPE_TO_NAME_MAP.get(child.getElementType()));
		}
	}

	return explicitModifiers;
}
 
Example 22
Project: intellij-ce-playground   File: ToolWindowHeader.java   Source Code and License 5 votes vote down vote up
public void actionPerformed(final ActionEvent e) {
  AnAction action =
    myAlternativeAction != null && BitUtil.isSet(e.getModifiers(), InputEvent.ALT_MASK) ? myAlternativeAction : myAction;
  final DataContext dataContext = DataManager.getInstance().getDataContext(this);
  final ActionManagerEx actionManager = ActionManagerEx.getInstanceEx();
  InputEvent inputEvent = e.getSource() instanceof InputEvent ? (InputEvent) e.getSource() : null;
  final AnActionEvent event = AnActionEvent.createFromAnAction(action, inputEvent, ActionPlaces.TOOLWINDOW_TITLE, dataContext);
  actionManager.fireBeforeActionPerformed(action, dataContext, event);
  final Component component = PlatformDataKeys.CONTEXT_COMPONENT.getData(dataContext);
  if (component != null && !component.isShowing()) {
    return;
  }

  action.actionPerformed(event);
}
 
Example 23
Project: intellij-ce-playground   File: ProjectWindowAction.java   Source Code and License 5 votes vote down vote up
@Override
public void setSelected(@Nullable AnActionEvent e, boolean selected) {

  if (e == null) return;
  boolean macMainMenu = SystemInfo.isMac && ActionPlaces.isMainMenuOrActionSearch(e.getPlace());

  if (!selected && !macMainMenu) {
    return;
  }

  final Project project = findProject();
  if (project == null) {
    return;
  }
  final JFrame projectFrame = WindowManager.getInstance().getFrame(project);
  final int frameState = projectFrame.getExtendedState();

  if (macMainMenu && !(e.getInputEvent().getSource() instanceof ActionMenuItem) && (projectFrame.getExtendedState() & Frame.ICONIFIED) != 0) {
    // On Mac minimized window should not be restored this way
    return;
  }

  if (BitUtil.isSet(frameState, Frame.ICONIFIED)) {
    // restore the frame if it is minimized
    projectFrame.setExtendedState(frameState ^ Frame.ICONIFIED);
  }
  projectFrame.toFront();
  projectFrame.requestFocus();
  //ProjectUtil.focusProjectWindow(project, true);
}
 
Example 24
Project: intellij-ce-playground   File: IntToIntBtree.java   Source Code and License 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 25
Project: intellij-ce-playground   File: BreadcrumbsXmlWrapper.java   Source Code and License 5 votes vote down vote up
@Override
public void itemSelected(@NotNull final BreadcrumbsPsiItem item, final int modifiers) {
  final PsiElement psiElement = item.getPsiElement();
  moveEditorCaretTo(psiElement);

  if (BitUtil.isSet(modifiers, Event.SHIFT_MASK) || BitUtil.isSet(modifiers, Event.META_MASK)) {
    final TextRange range = psiElement.getTextRange();
    myEditor.getSelectionModel().setSelection(range.getStartOffset(), range.getEndOffset());
  }
}
 
Example 26
Project: consulo-csharp   File: SharedParsingHelpers.java   Source Code and License 5 votes vote down vote up
private static PsiBuilder.Marker parseAttribute(CSharpBuilderWrapper builder, ModifierSet set, int flags)
{
	PsiBuilder.Marker mark = builder.mark();
	if(ExpressionParsing.parseQualifiedReference(builder, null, flags, TokenSet.EMPTY) == null)
	{
		mark.drop();
		return null;
	}

	ExpressionParsing.parseArgumentList(builder, true, set);

	mark.done(BitUtil.isSet(flags, STUB_SUPPORT) ? CSharpStubElements.ATTRIBUTE : CSharpElements.ATTRIBUTE);
	return mark;
}
 
Example 27
Project: consulo-csharp   File: SharedParsingHelpers.java   Source Code and License 5 votes vote down vote up
protected static Pair<PsiBuilder.Marker, ModifierSet> parseModifierListWithAttributes(CSharpBuilderWrapper builder, int flags)
{
	if(MODIFIERS.contains(builder.getTokenType()))
	{
		return parseModifierList(builder, flags);
	}
	else
	{
		Set<IElementType> set = new THashSet<>();
		PsiBuilder.Marker marker = builder.mark();
		if(!parseAttributeList(builder, ModifierSet.EMPTY, flags))
		{
			// FIXME [VISTALL] dummy
			set.add(BitUtil.isSet(flags, STUB_SUPPORT) ? CSharpStubElements.ATTRIBUTE : CSharpElements.ATTRIBUTE);
		}
		while(!builder.eof())
		{
			if(MODIFIERS.contains(builder.getTokenType()))
			{
				set.add(builder.getTokenType());

				builder.advanceLexer();
			}
			else
			{
				break;
			}
		}
		marker.done(BitUtil.isSet(flags, STUB_SUPPORT) ? CSharpStubElements.MODIFIER_LIST : CSharpElements.MODIFIER_LIST);
		return Pair.create(marker, ModifierSet.create(set));
	}
}
 
Example 28
Project: consulo-csharp   File: SharedParsingHelpers.java   Source Code and License 5 votes vote down vote up
public static void reportIdentifier(PsiBuilder builder, int flags)
{
	PsiBuilder.Marker mark = builder.mark();
	builder.error("Expected identifier");
	mark.done(BitUtil.isSet(flags, STUB_SUPPORT) ? CSharpStubElements.IDENTIFIER : CSharpElements.IDENTIFIER);
	mark.setCustomEdgeTokenBinders(WhitespacesBinders.GREEDY_LEFT_BINDER, null);
}
 
Example 29
Project: consulo-csharp   File: MethodParsing.java   Source Code and License 5 votes vote down vote up
public static void parseParameterList(CSharpBuilderWrapper builder, int flags, IElementType end, ModifierSet set)
{
	PsiBuilder.Marker mark = builder.mark();

	builder.advanceLexer();

	if(builder.getTokenType() != end)
	{
		while(!builder.eof())
		{
			parseParameter(builder, end, flags, set);

			if(builder.getTokenType() == COMMA)
			{
				builder.advanceLexer();
			}
			else if(builder.getTokenType() == end)
			{
				break;
			}
			else
			{
				PsiBuilder.Marker errorMarker = builder.mark();
				builder.advanceLexer();
				errorMarker.error("Expected comma");
			}
		}
	}

	expect(builder, end, "')' expected");
	mark.done(BitUtil.isSet(flags, STUB_SUPPORT) ? CSharpStubElements.PARAMETER_LIST : CSharpElements.PARAMETER_LIST);
}
 
Example 30
Project: consulo-csharp   File: MethodParsing.java   Source Code and License 5 votes vote down vote up
private static void parseParameter(CSharpBuilderWrapper builder, IElementType end, int flags, ModifierSet set)
{
	PsiBuilder.Marker mark = builder.mark();

	Pair<PsiBuilder.Marker, ModifierSet> modifierPair = parseModifierListWithAttributes(builder, flags);

	TypeInfo typeInfo = parseType(builder, flags);
	if(typeInfo == null)
	{
		if(modifierPair.getSecond().isEmpty())
		{
			// if no modifiers but we failed parse type - need go advance, due ill infinity loop inside parseParameterList,
			// but dont eat close brace
			if(builder.getTokenType() != end)
			{
				builder.advanceLexer();
			}
		}
		mark.error("Type expected");
	}
	else
	{
		if(typeInfo.nativeElementType != CSharpTokens.__ARGLIST_KEYWORD)
		{
			expectOrReportIdentifier(builder, flags);

			if(expect(builder, EQ, null))
			{
				if(ExpressionParsing.parse(builder, set) == null)
				{
					builder.error("Expression expected.");
				}
			}
		}
		mark.done(BitUtil.isSet(flags, STUB_SUPPORT) ? CSharpStubElements.PARAMETER : CSharpElements.PARAMETER);
	}
}
 
Example 31
Project: consulo-csharp   File: CSharpElementCompareUtil.java   Source Code and License 5 votes vote down vote up
@RequiredReadAction
private static boolean compareReturnTypeRef(@NotNull PsiElement o1, @NotNull PsiElement o2, int flags, @NotNull PsiElement scope)
{
	if(!BitUtil.isSet(flags, CHECK_RETURN_TYPE))
	{
		return true;
	}
	DotNetTypeRef returnTypeRef1 = ((DotNetLikeMethodDeclaration) o1).getReturnTypeRef();
	DotNetTypeRef returnTypeRef2 = ((DotNetLikeMethodDeclaration) o2).getReturnTypeRef();
	return CSharpTypeUtil.isTypeEqual(returnTypeRef1, returnTypeRef2, scope);
}
 
Example 32
Project: consulo-csharp   File: CSharpMethodDeclarationImpl.java   Source Code and License 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 33
Project: consulo-csharp   File: CSharpMethodDeclarationImpl.java   Source Code and License 5 votes vote down vote up
@Override
public boolean isExtension()
{
	CSharpMethodDeclStub stub = getGreenStub();
	if(stub != null)
	{
		return BitUtil.isSet(stub.getOtherModifierMask(), CSharpMethodDeclStub.EXTENSION_MASK);
	}
	return CSharpMethodImplUtil.isExtensionMethod(this);
}
 
Example 34
Project: consulo-csharp   File: CSharpConstructorDeclarationImpl.java   Source Code and License 5 votes vote down vote up
@Override
public boolean isDeConstructor()
{
	CSharpMethodDeclStub stub = getGreenStub();
	if(stub != null)
	{
		return BitUtil.isSet(stub.getOtherModifierMask(), CSharpMethodDeclStub.DE_CONSTRUCTOR_MASK);
	}

	return findChildByType(CSharpTokens.TILDE) != null;
}
 
Example 35
Project: consulo-csharp   File: CSharpMethodStubElementType.java   Source Code and License 5 votes vote down vote up
@Override
@RequiredReadAction
public void indexStub(@NotNull CSharpMethodDeclStub stub, @NotNull IndexSink indexSink)
{
	String name = getName(stub);
	if(!StringUtil.isEmpty(name))
	{
		indexSink.occurrence(CSharpIndexKeys.METHOD_INDEX, name);

		if(!stub.isNested())
		{
			if(BitUtil.isSet(stub.getOtherModifierMask(), CSharpMethodDeclStub.DELEGATE_MASK))
			{
				String parentQName = stub.getParentQName();

				DotNetNamespaceStubUtil.indexStub(indexSink, CSharpIndexKeys.MEMBER_BY_NAMESPACE_QNAME_INDEX, CSharpIndexKeys.MEMBER_BY_ALL_NAMESPACE_QNAME_INDEX, parentQName, name);
			}
		}

		if(BitUtil.isSet(stub.getOtherModifierMask(), CSharpMethodDeclStub.EXTENSION_MASK))
		{
			indexSink.occurrence(CSharpIndexKeys.EXTENSION_METHOD_BY_NAME_INDEX, name);
		}

		if(BitUtil.isSet(stub.getOtherModifierMask(), CSharpMethodDeclStub.DELEGATE_MASK))
		{
			indexSink.occurrence(CSharpIndexKeys.DELEGATE_METHOD_BY_NAME_INDEX, name);
		}
	}
}
 
Example 36
Project: consulo-csharp   File: CSharpVariableDeclStub.java   Source Code and License 5 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);
	}
	return i;
}
 
Example 37
Project: consulo-csharp   File: CSharpElementPresentationUtil.java   Source Code and License 5 votes vote down vote up
@NotNull
@RequiredReadAction
public static String formatProperty(@NotNull DotNetPropertyDeclaration propertyDeclaration, int flags)
{
	StringBuilder builder = new StringBuilder();

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

	if(BitUtil.isSet(flags, SCALA_FORMAT))
	{
		builder.append(propertyDeclaration.getName());
		builder.append(":");
		CSharpTypeRefPresentationUtil.appendTypeRef(propertyDeclaration, builder, propertyDeclaration.toTypeRef(true), typeRefMask(flags));

	}
	else
	{
		CSharpTypeRefPresentationUtil.appendTypeRef(propertyDeclaration, builder, propertyDeclaration.toTypeRef(true), typeRefMask(flags));

		builder.append(" ");
		builder.append(propertyDeclaration.getName());
	}
	return builder.toString();
}
 
Example 38
Project: consulo-csharp   File: CSharpElementPresentationUtil.java   Source Code and License 5 votes vote down vote up
private static int typeRefMask(int flags)
{
	if(BitUtil.isSet(flags, NON_QUALIFIED_TYPE))
	{
		return CSharpTypeRefPresentationUtil.TYPE_KEYWORD;
	}
	return CSharpTypeRefPresentationUtil.QUALIFIED_NAME_WITH_KEYWORD;
}
 
Example 39
Project: consulo-dotnet   File: MsilModifierListStub.java   Source Code and License 5 votes vote down vote up
public MsilModifierListStub(StubElement parent, IStubElementType elementType, MsilModifierList modifiers)
{
	super(parent, elementType);

	int mod = 0;
	for(DotNetModifier dotNetModifier : modifiers.getModifiers())
	{
		mod |= BitUtil.set(mod, getMask((MsilModifierElementType) dotNetModifier), true);
	}
	myModifiers = mod;
}
 
Example 40
Project: consulo-dotnet   File: MsilGenericParameterStub.java   Source Code and License 5 votes vote down vote up
public static int toModifiers(MsilGenericParameter parameter)
{
	int i = 0;
	i = BitUtil.set(i, COVARIANT, parameter.hasModifier(DotNetModifier.COVARIANT));
	i = BitUtil.set(i, CONTRAVARIANT, parameter.hasModifier(DotNetModifier.CONTRAVARIANT));
	i = BitUtil.set(i, HAS_DEFAULT_CONSTRUCTOR, parameter.hasDefaultConstructor());
	return i;
}
 
Example 41
Project: consulo-dotnet   File: MsilGenericParameterStub.java   Source Code and License 5 votes vote down vote up
public boolean hasModifier(DotNetModifier modifier)
{
	if(modifier == DotNetModifier.COVARIANT)
	{
		return BitUtil.isSet(myModifierMask, COVARIANT);
	}
	else if(modifier == DotNetModifier.CONTRAVARIANT)
	{
		return BitUtil.isSet(myModifierMask, CONTRAVARIANT);
	}
	return false;
}
 
Example 42
Project: consulo-dotnet   File: MsilIconDescriptorUpdater.java   Source Code and License 5 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(MsilTokens.PRIVATE_KEYWORD))
		{
			iconDescriptor.setRightIcon(AllIcons.Nodes.C_private);
		}
		else if(owner.hasModifier(MsilTokens.PUBLIC_KEYWORD))
		{
			iconDescriptor.setRightIcon(AllIcons.Nodes.C_public);
		}
		else if(owner.hasModifier(MsilTokens.PROTECTED_KEYWORD))
		{
			iconDescriptor.setRightIcon(AllIcons.Nodes.C_protected);
		}
		else
		{
			iconDescriptor.setRightIcon(AllIcons.Nodes.C_plocal);
		}
	}

	if(owner.hasModifier(MsilTokens.SEALED_KEYWORD))
	{
		iconDescriptor.addLayerIcon(AllIcons.Nodes.FinalMark);
	}
}
 
Example 43
Project: consulo   File: VfsIconUtil.java   Source Code and License 5 votes vote down vote up
@Override
@RequiredReadAction
public Icon fun(final AnyIconKey<VirtualFile> key) {
  final VirtualFile file = key.getObject();
  final int flags = key.getFlags();
  Project project = key.getProject();

  if (!file.isValid() || project != null && (project.isDisposed() || !wasEverInitialized(project))) return null;

  boolean processedDescriptors = false;
  // disable on webservice native icon
  IconDescriptor iconDescriptor = new IconDescriptor(VirtualFilePresentation.getIcon(file));

  if (project != null) {
    PsiManager manager = PsiManager.getInstance(project);
    final PsiElement element = file.isDirectory() ? manager.findDirectory(file) : manager.findFile(file);
    if (element != null) {
      IconDescriptorUpdaters.processExistingDescriptor(iconDescriptor, element, flags);
      processedDescriptors = true;
    }
  }

  // if descriptors not processed - we need add layer icon obviously
  if (!processedDescriptors && file.is(VFileProperty.SYMLINK)) {
    iconDescriptor.addLayerIcon(AllIcons.Nodes.Symlink);
  }

  if (BitUtil.isSet(flags, Iconable.ICON_FLAG_READ_STATUS)) {
    final boolean isLocked = !file.isWritable() || !WritingAccessProvider.isPotentiallyWritable(file, project);
    if (isLocked) {
      iconDescriptor.addLayerIcon(AllIcons.Nodes.Locked);
    }
  }

  Icon icon = iconDescriptor.toIcon();
  Iconable.LastComputedIcon.put(file, icon, flags);
  return icon;
}
 
Example 44
Project: consulo   File: MouseEnterHandler.java   Source Code and License 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 45
Project: consulo   File: LockedIconDescriptorUpdater.java   Source Code and License 5 votes vote down vote up
@RequiredReadAction
@Override
public void updateIcon(@Nonnull IconDescriptor iconDescriptor, @Nonnull PsiElement element, int flags) {
  if (BitUtil.isSet(flags, Iconable.ICON_FLAG_READ_STATUS)) {

    VirtualFile file = PsiUtilCore.getVirtualFile(element);
    final boolean isLocked = !element.isWritable() || !WritingAccessProvider.isPotentiallyWritable(file, element.getProject());

    if (isLocked) {
      iconDescriptor.addLayerIcon(AllIcons.Nodes.Locked);
    }
  }
}
 
Example 46
Project: consulo   File: FSRecords.java   Source Code and License 5 votes vote down vote up
private static void scanFreeRecords() {
  final int filelength = (int)myRecords.length();
  LOG.assertTrue(filelength % RECORD_SIZE == 0, "invalid file size: " + filelength);

  int count = filelength / RECORD_SIZE;
  for (int n = 2; n < count; n++) {
    if (BitUtil.isSet(getFlags(n), FREE_RECORD_FLAG)) {
      myFreeRecords.add(n);
    }
  }
}
 
Example 47
Project: consulo   File: IntToIntBtree.java   Source Code and License 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 48
Project: consulo-java   File: PsiParameterStubImpl.java   Source Code and License 5 votes vote down vote up
private static byte packFlags(boolean isEllipsis, boolean generatedName)
{
	byte flags = 0;
	flags = BitUtil.set(flags, ELLIPSIS, isEllipsis);
	flags = BitUtil.set(flags, GENERATED_NAME, generatedName);
	return flags;
}
 
Example 49
Project: consulo-java   File: PsiModifierListImpl.java   Source Code and License 5 votes vote down vote up
@Override
public boolean hasExplicitModifier(@NotNull String name)
{
	PsiModifierListStub stub = getGreenStub();
	if(stub != null)
	{
		return BitUtil.isSet(stub.getModifiersMask(), ModifierFlags.NAME_TO_MODIFIER_FLAG_MAP.get(name));
	}

	final CompositeElement tree = (CompositeElement) getNode();
	final IElementType type = NAME_TO_KEYWORD_TYPE_MAP.get(name);
	return tree.findChildByType(type) != null;
}
 
Example 50
Project: intellij-ce-playground   File: PsiMethodStubImpl.java   Source Code and License 4 votes vote down vote up
@Override
public boolean isConstructor() {
  return BitUtil.isSet(myFlags, CONSTRUCTOR);
}
 
Example 51
Project: intellij-ce-playground   File: PsiMethodStubImpl.java   Source Code and License 4 votes vote down vote up
@Override
public boolean isVarArgs() {
  return BitUtil.isSet(myFlags, VARARGS);
}
 
Example 52
Project: intellij-ce-playground   File: PsiMethodStubImpl.java   Source Code and License 4 votes vote down vote up
public boolean isParsedViaGenericSignature() {
  return BitUtil.isSet(myFlags, PARSED_VIA_GENERIC_SIGNATURE);
}
 
Example 53
Project: intellij-ce-playground   File: ObjectPropertyImpl.java   Source Code and License 4 votes vote down vote up
@Override
public final boolean isWritable() {
  return BitUtil.isSet(flags, WRITABLE);
}
 
Example 54
Project: intellij-ce-playground   File: ObjectPropertyImpl.java   Source Code and License 4 votes vote down vote up
@Override
public final boolean isConfigurable() {
  return BitUtil.isSet(flags, CONFIGURABLE);
}
 
Example 55
Project: intellij-ce-playground   File: ObjectPropertyImpl.java   Source Code and License 4 votes vote down vote up
@Override
public final boolean isEnumerable() {
  return BitUtil.isSet(flags, ENUMERABLE);
}
 
Example 56
Project: intellij-ce-playground   File: RangeHighlighterImpl.java   Source Code and License 4 votes vote down vote up
private boolean isFlagSet(@FlagConstant byte mask) {
  return BitUtil.isSet(myFlags, mask);
}
 
Example 57
Project: intellij-ce-playground   File: RangeHighlighterImpl.java   Source Code and License 4 votes vote down vote up
private void setFlag(@FlagConstant byte mask, boolean value) {
  myFlags = BitUtil.set(myFlags, mask, value);
}
 
Example 58
Project: intellij-ce-playground   File: Node.java   Source Code and License 4 votes vote down vote up
private boolean isFlagSet(@FlagConstant byte mask) {
  return BitUtil.isSet(myCachedFlags, mask);
}
 
Example 59
Project: intellij-ce-playground   File: Node.java   Source Code and License 4 votes vote down vote up
private void setFlag(@FlagConstant byte mask, boolean value) {
  myCachedFlags = BitUtil.set(myCachedFlags, mask, value);
}
 
Example 60
Project: intellij-ce-playground   File: RefEntityImpl.java   Source Code and License 4 votes vote down vote up
public boolean checkFlag(long mask) {
  return BitUtil.isSet(myFlags, mask);
}