本文整理汇总了Java中org.eclipse.jdt.core.Flags.AccPublic方法的典型用法代码示例。如果您正苦于以下问题:Java Flags.AccPublic方法的具体用法?Java Flags.AccPublic怎么用?Java Flags.AccPublic使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.jdt.core.Flags
的用法示例。
在下文中一共展示了Flags.AccPublic方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: updateReplacementString
import org.eclipse.jdt.core.Flags; //导入方法依赖的package包/类
/**
* @param document
* @param offset
* @param importRewrite
* @param completionSnippetsSupported
* @return
* @throws CoreException
* @throws BadLocationException
*/
public String updateReplacementString(IDocument document, int offset, ImportRewrite importRewrite, boolean completionSnippetsSupported) throws CoreException, BadLocationException {
int flags= Flags.AccPublic | (fField.getFlags() & Flags.AccStatic);
String stub;
if (fIsGetter) {
String getterName= GetterSetterUtil.getGetterName(fField, null);
stub = GetterSetterUtil.getGetterStub(fField, getterName, true, flags);
} else {
String setterName= GetterSetterUtil.getSetterName(fField, null);
stub = GetterSetterUtil.getSetterStub(fField, setterName, true, flags);
}
// use the code formatter
String lineDelim= TextUtilities.getDefaultLineDelimiter(document);
String replacement = CodeFormatterUtil.format(CodeFormatter.K_CLASS_BODY_DECLARATIONS, stub, 0, lineDelim, fField.getJavaProject());
if (replacement.endsWith(lineDelim)) {
replacement = replacement.substring(0, replacement.length() - lineDelim.length());
}
return replacement;
}
示例2: getConsistentVisibility
import org.eclipse.jdt.core.Flags; //导入方法依赖的package包/类
public static int getConsistentVisibility(Collection col)
throws JavaModelException {
if (col.isEmpty())
return -1;
// They should already be consistent.
final IMember firstElem = (IMember) col.iterator().next();
if (Flags.isPublic(firstElem.getFlags()))
return Flags.AccPublic;
else if (Flags.isPackageDefault(firstElem.getFlags()))
return Flags.AccDefault;
else if (Flags.isPrivate(firstElem.getFlags()))
return Flags.AccPrivate;
else if (Flags.isProtected(firstElem.getFlags()))
return Flags.AccProtected;
else
throw new IllegalArgumentException(
Messages.Util_InvalidMemberVisibility);
}
示例3: checkInitialConditions
import org.eclipse.jdt.core.Flags; //导入方法依赖的package包/类
@Override
public RefactoringStatus checkInitialConditions(IProgressMonitor pm) throws CoreException {
if (fVisibility < 0)
fVisibility = (fField.getFlags() & (Flags.AccPublic | Flags.AccProtected | Flags.AccPrivate));
RefactoringStatus result = new RefactoringStatus();
result.merge(Checks.checkAvailability(fField));
if (result.hasFatalError()) return result;
fRoot =
new RefactoringASTParser(ASTProvider.SHARED_AST_LEVEL)
.parse(fField.getCompilationUnit(), true, pm);
ISourceRange sourceRange = fField.getNameRange();
ASTNode node = NodeFinder.perform(fRoot, sourceRange.getOffset(), sourceRange.getLength());
if (node == null) {
return mappingErrorFound(result, node);
}
fFieldDeclaration =
(VariableDeclarationFragment) ASTNodes.getParent(node, VariableDeclarationFragment.class);
if (fFieldDeclaration == null) {
return mappingErrorFound(result, node);
}
if (fFieldDeclaration.resolveBinding() == null) {
if (!processCompilerError(result, node))
result.addFatalError(RefactoringCoreMessages.SelfEncapsulateField_type_not_resolveable);
return result;
}
computeUsedNames();
return result;
}
示例4: getFlags
import org.eclipse.jdt.core.Flags; //导入方法依赖的package包/类
private int getFlags() {
int flags = Flags.AccPublic;
try {
flags = Flags.AccPublic | (fField.getFlags() & Flags.AccStatic);
} catch (CoreException e) {
JavaLanguageServerPlugin.logException("Get flags for getter/setter ", e);
}
return flags;
}
示例5: keywordToVisibility
import org.eclipse.jdt.core.Flags; //导入方法依赖的package包/类
/**
* Converts a given modifier keyword into a visibility flag.
*
* @param keyword the keyword to convert
* @return the visibility flag
*/
private static int keywordToVisibility(final ModifierKeyword keyword) {
int visibility = 0;
if (keyword == ModifierKeyword.PUBLIC_KEYWORD) visibility = Flags.AccPublic;
else if (keyword == ModifierKeyword.PRIVATE_KEYWORD) visibility = Flags.AccPrivate;
else if (keyword == ModifierKeyword.PROTECTED_KEYWORD) visibility = Flags.AccProtected;
return visibility;
}
示例6: updateReplacementString
import org.eclipse.jdt.core.Flags; //导入方法依赖的package包/类
@Override
protected boolean updateReplacementString(
IDocument document, char trigger, int offset, ImportRewrite impRewrite)
throws CoreException, BadLocationException {
CodeGenerationSettings settings =
JavaPreferencesSettings.getCodeGenerationSettings(fField.getJavaProject());
boolean addComments = settings.createComments;
int flags = Flags.AccPublic | (fField.getFlags() & Flags.AccStatic);
String stub;
if (fIsGetter) {
String getterName = GetterSetterUtil.getGetterName(fField, null);
stub = GetterSetterUtil.getGetterStub(fField, getterName, addComments, flags);
} else {
String setterName = GetterSetterUtil.getSetterName(fField, null);
stub = GetterSetterUtil.getSetterStub(fField, setterName, addComments, flags);
}
// use the code formatter
String lineDelim = TextUtilities.getDefaultLineDelimiter(document);
IRegion region = document.getLineInformationOfOffset(getReplacementOffset());
int lineStart = region.getOffset();
int indent =
Strings.computeIndentUnits(
document.get(lineStart, getReplacementOffset() - lineStart),
settings.tabWidth,
settings.indentWidth);
String replacement =
CodeFormatterUtil.format(
CodeFormatter.K_CLASS_BODY_DECLARATIONS,
stub,
indent,
lineDelim,
fField.getJavaProject());
if (replacement.endsWith(lineDelim)) {
replacement = replacement.substring(0, replacement.length() - lineDelim.length());
}
setReplacementString(Strings.trimLeadingTabsAndSpaces(replacement));
return true;
}