com.intellij.util.BitUtil Java Examples

The following examples show how to use com.intellij.util.BitUtil. 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: 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 #2
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 #3
Source File: SharedParsingHelpers.java    From consulo-csharp with Apache License 2.0 6 votes vote down vote up
@Nonnull
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 #4
Source File: OpenAndroidModule.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
@Override
public void actionPerformed(AnActionEvent e) {
  final VirtualFile projectFile = findProjectFile(e);
  if (projectFile == null) {
    FlutterMessages.showError("Error Opening Android Studio", "Project not found.");
    return;
  }
  final int modifiers = e.getModifiers();
  // From ReopenProjectAction.
  final boolean forceOpenInNewFrame = BitUtil.isSet(modifiers, InputEvent.CTRL_MASK)
                                      || BitUtil.isSet(modifiers, InputEvent.SHIFT_MASK)
                                      || e.getPlace() == ActionPlaces.WELCOME_SCREEN;

  VirtualFile sourceFile = e.getData(CommonDataKeys.VIRTUAL_FILE);
  // Using:
  //ProjectUtil.openOrImport(projectFile.getPath(), e.getProject(), forceOpenInNewFrame);
  // presents the user with a really imposing Gradle project import dialog.
  openOrImportProject(projectFile, e.getProject(), sourceFile, forceOpenInNewFrame);
}
 
Example #5
Source File: OpenAndroidModule.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
@Override
public void actionPerformed(AnActionEvent e) {
  final VirtualFile projectFile = findProjectFile(e);
  if (projectFile == null) {
    FlutterMessages.showError("Error Opening Android Studio", "Project not found.");
    return;
  }
  final int modifiers = e.getModifiers();
  // From ReopenProjectAction.
  final boolean forceOpenInNewFrame = BitUtil.isSet(modifiers, InputEvent.CTRL_MASK)
                                      || BitUtil.isSet(modifiers, InputEvent.SHIFT_MASK)
                                      || e.getPlace() == ActionPlaces.WELCOME_SCREEN;

  VirtualFile sourceFile = e.getData(CommonDataKeys.VIRTUAL_FILE);
  // Using:
  //ProjectUtil.openOrImport(projectFile.getPath(), e.getProject(), forceOpenInNewFrame);
  // presents the user with a really imposing Gradle project import dialog.
  openOrImportProject(projectFile, e.getProject(), sourceFile, forceOpenInNewFrame);
}
 
Example #6
Source File: CSharpElementCompareUtil.java    From consulo-csharp with Apache License 2.0 6 votes vote down vote up
@RequiredReadAction
private static boolean compareVirtualImpl(@Nonnull PsiElement o1, @Nonnull PsiElement o2, int flags, @Nonnull 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 #7
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 #8
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 #9
Source File: CSharpElementTreeNode.java    From consulo-csharp with Apache License 2.0 6 votes vote down vote up
@Nullable
@Override
@RequiredUIAccess
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
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 #11
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 #12
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 #13
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 #14
Source File: ReopenProjectAction.java    From consulo with Apache License 2.0 6 votes vote down vote up
@RequiredUIAccess
@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) {
      myIsRemoved = true;
      RecentProjectsManager.getInstance().removePath(myProjectPath);
    }
    return;
  }

  ProjectUtil.openAsync(myProjectPath, project, forceOpenInNewFrame, UIAccess.current());
}
 
Example #15
Source File: ToolkitBugsProcessor.java    From consulo with Apache License 2.0 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 #16
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 #17
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 #18
Source File: SharedParsingHelpers.java    From consulo-csharp with Apache License 2.0 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, 0);

	mark.done(BitUtil.isSet(flags, STUB_SUPPORT) ? CSharpStubElements.ATTRIBUTE : CSharpElements.ATTRIBUTE);
	return mark;
}
 
Example #19
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 #20
Source File: ScopeChooserCombo.java    From consulo with Apache License 2.0 5 votes vote down vote up
public static boolean processScopes(@Nonnull Project project,
                                    @Nonnull DataContext dataContext,
                                    @MagicConstant(flagsFromClass = ScopeChooserCombo.class) int options,
                                    @Nonnull Processor<? super ScopeDescriptor> processor) {
  List<SearchScope> predefinedScopes = PredefinedSearchScopeProvider.getInstance()
          .getPredefinedScopes(project, dataContext, BitUtil.isSet(options, OPT_LIBRARIES), BitUtil.isSet(options, OPT_SEARCH_RESULTS), BitUtil.isSet(options, OPT_FROM_SELECTION),
                               BitUtil.isSet(options, OPT_USAGE_VIEW), BitUtil.isSet(options, OPT_EMPTY_SCOPES));
  for (SearchScope searchScope : predefinedScopes) {
    if (!processor.process(new ScopeDescriptor(searchScope))) return false;
  }
  for (ScopeDescriptorProvider provider : ScopeDescriptorProvider.EP_NAME.getExtensionList()) {
    for (ScopeDescriptor descriptor : provider.getScopeDescriptors(project)) {
      if (!processor.process(descriptor)) return false;
    }
  }
  Comparator<SearchScope> comparator = (o1, o2) -> {
    int w1 = o1 instanceof WeighedItem ? ((WeighedItem)o1).getWeight() : Integer.MAX_VALUE;
    int w2 = o2 instanceof WeighedItem ? ((WeighedItem)o2).getWeight() : Integer.MAX_VALUE;
    if (w1 == w2) return StringUtil.naturalCompare(o1.getDisplayName(), o2.getDisplayName());
    return w1 - w2;
  };
  for (SearchScopeProvider each : SearchScopeProvider.EP_NAME.getExtensionList()) {
    if (StringUtil.isEmpty(each.getDisplayName())) continue;
    List<SearchScope> scopes = each.getSearchScopes(project);
    if (scopes.isEmpty()) continue;
    if (!processor.process(new ScopeSeparator(each.getDisplayName()))) return false;
    for (SearchScope scope : ContainerUtil.sorted(scopes, comparator)) {
      if (!processor.process(new ScopeDescriptor(scope))) return false;
    }
  }
  return true;
}
 
Example #21
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 #22
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 #23
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 #24
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 #25
Source File: LockedIconDescriptorUpdater.java    From consulo with Apache License 2.0 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 #26
Source File: SharedParsingHelpers.java    From consulo-csharp with Apache License 2.0 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 #27
Source File: SharedParsingHelpers.java    From consulo-csharp with Apache License 2.0 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 #28
Source File: CSharpElementPresentationUtil.java    From consulo-csharp with Apache License 2.0 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 #29
Source File: CSharpElementPresentationUtil.java    From consulo-csharp with Apache License 2.0 5 votes vote down vote up
@Nonnull
@RequiredReadAction
public static String formatProperty(@Nonnull 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 #30
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;
}