@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())); } }
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); } } } }
@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(); } }
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)); }
@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); }
@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); }
@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()); } }
@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; }
@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()); } } } }
@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(); }
@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(); }
@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); }
@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; }
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; }
@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); } } } }
@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())); }
@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); }
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; }
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; }
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); }
@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); }
@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); }
@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()); } }
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; }
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)); } }
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); }
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); }
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); } }
@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); }
@Override public boolean isDelegate() { CSharpMethodDeclStub stub = getGreenStub(); if(stub != null) { return BitUtil.isSet(stub.getOtherModifierMask(), CSharpMethodDeclStub.DELEGATE_MASK); } return findChildByType(CSharpTokens.DELEGATE_KEYWORD) != null; }
@Override public boolean isExtension() { CSharpMethodDeclStub stub = getGreenStub(); if(stub != null) { return BitUtil.isSet(stub.getOtherModifierMask(), CSharpMethodDeclStub.EXTENSION_MASK); } return CSharpMethodImplUtil.isExtensionMethod(this); }
@Override public boolean isDeConstructor() { CSharpMethodDeclStub stub = getGreenStub(); if(stub != null) { return BitUtil.isSet(stub.getOtherModifierMask(), CSharpMethodDeclStub.DE_CONSTRUCTOR_MASK); } return findChildByType(CSharpTokens.TILDE) != null; }
@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); } } }
@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; }
@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(); }
private static int typeRefMask(int flags) { if(BitUtil.isSet(flags, NON_QUALIFIED_TYPE)) { return CSharpTypeRefPresentationUtil.TYPE_KEYWORD; } return CSharpTypeRefPresentationUtil.QUALIFIED_NAME_WITH_KEYWORD; }
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; }
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; }