当前位置: 首页>>代码示例>>Java>>正文


Java PsiModifier.PACKAGE_LOCAL属性代码示例

本文整理汇总了Java中com.intellij.psi.PsiModifier.PACKAGE_LOCAL属性的典型用法代码示例。如果您正苦于以下问题:Java PsiModifier.PACKAGE_LOCAL属性的具体用法?Java PsiModifier.PACKAGE_LOCAL怎么用?Java PsiModifier.PACKAGE_LOCAL使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在com.intellij.psi.PsiModifier的用法示例。


在下文中一共展示了PsiModifier.PACKAGE_LOCAL属性的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getVisibility

@Nullable
public String getVisibility() {
  if (myRbPublic.isSelected()) {
    return PsiModifier.PUBLIC;
  }
  if (myRbPackageLocal.isSelected()) {
    return PsiModifier.PACKAGE_LOCAL;
  }
  if (myRbProtected.isSelected()) {
    return PsiModifier.PROTECTED;
  }
  if (myRbPrivate.isSelected()) {
    return PsiModifier.PRIVATE;
  }
  if (myRbEscalate != null && myRbEscalate.isSelected()) {
    return VisibilityUtil.ESCALATE_VISIBILITY;
  }

  return null;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:20,代码来源:JavaVisibilityPanel.java

示例2: perform

/**
 * to be performed in write action
 */
public void perform(final PsiVariable variable) {
  ApplicationManager.getApplication().assertWriteAccessAllowed();

  final Document document = myEditor.getDocument();
  LOG.assertTrue(variable != null);
  final PsiModifierList modifierList = variable.getModifierList();
  LOG.assertTrue(modifierList != null);
  int textOffset = modifierList.getTextOffset();
  final String modifierListText = modifierList.getText();

  int length = PsiModifier.PUBLIC.length();
  int idx = modifierListText.indexOf(PsiModifier.PUBLIC);

  if (idx == -1) {
    idx = modifierListText.indexOf(PsiModifier.PROTECTED);
    length = PsiModifier.PROTECTED.length();
  }

  if (idx == -1) {
    idx = modifierListText.indexOf(PsiModifier.PRIVATE);
    length = PsiModifier.PRIVATE.length();
  }

  String visibility = getVisibility();
  if (visibility == PsiModifier.PACKAGE_LOCAL) {
    visibility = "";
  }

  final boolean wasPackageLocal = idx == -1;
  final boolean isPackageLocal = visibility.isEmpty();

  final int startOffset = textOffset + (wasPackageLocal ? 0 : idx);
  final int endOffset;
  if (wasPackageLocal) {
    endOffset = startOffset;
  }
  else {
    endOffset = textOffset + length + (isPackageLocal ? 1 : 0);
  }

  final String finalVisibility = visibility + (wasPackageLocal ? " " : "");

  Runnable runnable = new Runnable() {
    @Override
    public void run() {
      document.replaceString(startOffset, endOffset, finalVisibility);
    }
  };

  final LookupImpl lookup = (LookupImpl)LookupManager.getActiveLookup(myEditor);
  if (lookup != null) {
    lookup.performGuardedChange(runnable);
  } else {
    runnable.run();
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:59,代码来源:VisibilityListener.java

示例3: getDialog

@NotNull
@Override
protected GrIntroduceDialog<GrIntroduceFieldSettings> getDialog(@NotNull GrIntroduceContext context) {
  return new GrIntroduceDialog<GrIntroduceFieldSettings>() {
    @Override
    public GrIntroduceFieldSettings getSettings() {
      return new GrIntroduceFieldSettings() {
        @Override
        public boolean declareFinal() {
          return myDeclareFinal;
        }

        @Override
        public Init initializeIn() {
          return myInitializeIn;
        }

        @Override
        public String getVisibilityModifier() {
          return PsiModifier.PACKAGE_LOCAL;
        }

        @Override
        public boolean isStatic() {
          return myIsStatic;
        }

        @Override
        public boolean removeLocalVar() {
          return myRemoveLocal;
        }

        @Override
        public String getName() {
          return "f";
        }

        @Override
        public boolean replaceAllOccurrences() {
          return replaceAll;
        }

        @Override
        public PsiType getSelectedType() {
          return mySelectedType;
        }
      };
    }

    @Override
    public void show() {
    }

    @Override
    public boolean isOK() {
      return true;
    }

    @NotNull
    @Override
    public LinkedHashSet<String> suggestNames() {
      LinkedHashSet<String> strings = new LinkedHashSet<String>();
      strings.add("f");
      return strings;
    }
  };
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:67,代码来源:IntroduceFieldTestHandler.java

示例4: getModifier

@Override
protected String getModifier() {
  return PsiModifier.PACKAGE_LOCAL;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:4,代码来源:MakePackagePrivateIntention.java


注:本文中的com.intellij.psi.PsiModifier.PACKAGE_LOCAL属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。