本文整理汇总了Java中org.eclipse.jdt.core.Flags类的典型用法代码示例。如果您正苦于以下问题:Java Flags类的具体用法?Java Flags怎么用?Java Flags使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Flags类属于org.eclipse.jdt.core包,在下文中一共展示了Flags类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: visit
import org.eclipse.jdt.core.Flags; //导入依赖的package包/类
@Override
public boolean visit(MethodInvocation node) {
// check for calls to particular java.lang.Object
// methods #144.
IMethodBinding methodBinding = node.resolveMethodBinding();
if (methodBinding != null && methodBinding.getDeclaringClass().getQualifiedName().equals("java.lang.Object")) {
IMethod calledObjectMethod = (IMethod) methodBinding.getJavaElement();
try {
if (Flags.isProtected(calledObjectMethod.getFlags())) {
this.methodContainsCallToProtectedObjectMethod = true;
this.calledProtectedObjectMethodSet.add(calledObjectMethod);
}
} catch (JavaModelException e) {
throw new RuntimeException(e);
}
}
return super.visit(node);
}
开发者ID:ponder-lab,项目名称:Migrate-Skeletal-Implementation-to-Interface-Refactoring,代码行数:21,代码来源:SourceMethodBodyAnalysisVisitor.java
示例2: handleType
import org.eclipse.jdt.core.Flags; //导入依赖的package包/类
private void handleType(IType type, IFile file, List<ServiceImplementation> serviceImplementations) throws JavaModelException {
/* Parcourt les méthodes. */
for (IMethod method : type.getMethods()) {
/* Filtre pour ne garder que les méthodes publiques d'instance */
if (method.isConstructor() || Flags.isStatic(method.getFlags()) || Flags.isPrivate(method.getFlags())) {
continue;
}
/* Créé le ServiceImplementation. */
String javaName = method.getElementName();
ISourceRange nameRange = method.getNameRange();
FileRegion fileRegion = new FileRegion(file, nameRange.getOffset(), nameRange.getLength());
ServiceImplementation serviceImplementation = new ServiceImplementation(fileRegion, javaName);
serviceImplementations.add(serviceImplementation);
}
}
示例3: handleType
import org.eclipse.jdt.core.Flags; //导入依赖的package包/类
private void handleType(IType type, IFile file, List<DaoImplementation> daoImplementations) throws JavaModelException {
/* Parcourt les méthodes. */
for (IMethod method : type.getMethods()) {
/* Filtre pour ne garder que les méthodes publiques d'instance */
if (method.isConstructor() || Flags.isStatic(method.getFlags()) || Flags.isPrivate(method.getFlags())) {
continue;
}
/* Créé le DaoImplementation. */
String javaName = method.getElementName();
ISourceRange nameRange = method.getNameRange();
FileRegion fileRegion = new FileRegion(file, nameRange.getOffset(), nameRange.getLength());
DaoImplementation daoImplementation = new DaoImplementation(fileRegion, javaName);
daoImplementations.add(daoImplementation);
}
}
示例4: parseVertigoDtoField
import org.eclipse.jdt.core.Flags; //导入依赖的package包/类
private static void parseVertigoDtoField(IMethod method, List<DtoField> fields) {
try {
if (method.isConstructor() || !Flags.isPublic(method.getFlags())) {
return;
}
IAnnotation fieldAnnotation = JdtUtils.getAnnotation(method, FIELD_ANNOTATION_NAME);
if (fieldAnnotation == null) {
return;
}
String domain = (String) JdtUtils.getMemberValue(fieldAnnotation, DOMAIN_FIELD_NAME);
/* Cas d'un champ de composition DTO/DTC : on filtre. */
if (domain == null || domain.startsWith(DTO_DOMAIN_PREFIX)) {
return;
}
String constantCaseName = StringUtils.toConstantCase(KspStringUtils.getFieldNameFromGetter(method.getElementName()));
String label = (String) JdtUtils.getMemberValue(fieldAnnotation, LABEL_FIELD_NAME);
Boolean persistent = (Boolean) JdtUtils.getMemberValue(fieldAnnotation, PERSISTENT_FIELD_NAME);
DtoField field = new DtoField(constantCaseName, label, domain, persistent);
fields.add(field);
} catch (JavaModelException e) {
ErrorUtils.handle(e);
}
}
示例5: isKasper3DtoType
import org.eclipse.jdt.core.Flags; //导入依赖的package包/类
/**
* Indique si le type donné est un DtObject Kasper 3.
*
* @param type Type JDT.
* @return <code>true</code> si le type est un DtObject.
*/
public static boolean isKasper3DtoType(IType type) {
try {
/* Vérifie que c'est une classe publique. */
if (!type.isClass() || !Flags.isPublic(type.getFlags())) {
return false;
}
/* Vérifie que la classe hérite de SuperDtObject */
if (type.getSuperclassName() == null) {
return false;
}
return "SuperDtObject".equals(type.getSuperclassName()) || "kasper.model.SuperDtObject".equals(type.getSuperclassName());
} catch (JavaModelException e) {
ErrorUtils.handle(e);
}
return false;
}
示例6: isKasper345DtoType
import org.eclipse.jdt.core.Flags; //导入依赖的package包/类
/**
* Indique si le type donné est un DtObject Kasper 4 ou 5.
*
* @param type Type JDT.
* @return <code>true</code> si le type est un DtObject.
*/
public static boolean isKasper345DtoType(IType type) {
try {
/* Vérifie que c'est une classe publique. */
if (!type.isClass() || !Flags.isPublic(type.getFlags())) {
return false;
}
/* Vérifie que la classe hérite d'un abstract de même nom préfixé ou suffixé par Abstract */
String superclassName = type.getSuperclassName();
if (superclassName == null) {
return false;
}
String prefixedName = "Abstract" + type.getElementName();
String suffixedName = type.getElementName() + "Abstract";
return superclassName.equals(prefixedName) || superclassName.equals(suffixedName);
} catch (JavaModelException e) {
ErrorUtils.handle(e);
}
return false;
}
示例7: isSubclass
import org.eclipse.jdt.core.Flags; //导入依赖的package包/类
/**
* Indique si le type donné est une sous-classe direct d'un type parmi une liste.
*
* @param type Type JDT.
* @param parentClasses Liste des classes parentes candidates.
* @return <code>true</code> si le type est une sous-classe.
*/
public static boolean isSubclass(IType type, List<String> parentClasses) {
if (parentClasses == null || parentClasses.isEmpty()) {
return false;
}
try {
/* Vérifie que c'est une classe publique. */
if (!type.isClass() || !Flags.isPublic(type.getFlags())) {
return false;
}
/* Vérifie que la classe hérite d'une classe (autre que Object) */
String superclassName = type.getSuperclassName();
if (superclassName == null) {
return false;
}
/* Vérifie que la classe parente est parmi les candidates. */
return parentClasses.contains(superclassName);
} catch (JavaModelException e) {
ErrorUtils.handle(e);
}
return false;
}
示例8: getInstanceMethods
import org.eclipse.jdt.core.Flags; //导入依赖的package包/类
public List<IMethod> getInstanceMethods() {
if(jType == null)
return Collections.emptyList();
try {
List<IMethod> list = new ArrayList<>();
IMethod[] methods = jType.getMethods();
for(IMethod m : methods)
if(!m.isConstructor() && !Flags.isStatic(m.getFlags()) && isMethodVisible(m))
list.add(m);
return list;
} catch (JavaModelException e) {
e.printStackTrace();
return Collections.emptyList();
}
// return info.getMethods(EnumSet.of(VisibilityInfo.PUBLIC));
}
示例9: addRefCombovalues
import org.eclipse.jdt.core.Flags; //导入依赖的package包/类
private void addRefCombovalues(Combo combo, String paramType) {
if(!PrimitiveType.isPrimitiveSig(paramType)) {
combo.add("null");
IType owner = (IType) method.getParent();
try {
IField[] fields = owner.getFields();
for(IField f : fields)
if(Flags.isStatic(f.getFlags()) && f.getTypeSignature().equals(paramType))
combo.add(f.getElementName());
} catch (JavaModelException e1) {
e1.printStackTrace();
}
}
}
示例10: addCombovalues
import org.eclipse.jdt.core.Flags; //导入依赖的package包/类
private void addCombovalues(Combo combo, String paramType) {
if(!PrimitiveType.isPrimitiveSig(paramType)) {
String sel = combo.getText();
combo.removeAll();
combo.add("null");
IType owner = (IType) method.getParent();
try {
IField[] fields = owner.getFields();
for(IField f : fields)
if(Flags.isStatic(f.getFlags()) && f.getTypeSignature().equals(paramType))
combo.add(f.getElementName());
} catch (JavaModelException e1) {
e1.printStackTrace();
}
if(sel.isEmpty())
combo.select(0);
else
combo.setText(sel);
}
}
示例11: appendUnboundedParameterList
import org.eclipse.jdt.core.Flags; //导入依赖的package包/类
/**
* Appends the parameter list to <code>buffer</code>.
*
* @param buffer the buffer to append to
* @param methodProposal the method proposal
* @return the modified <code>buffer</code>
*/
private StringBuilder appendUnboundedParameterList(StringBuilder buffer, CompletionProposal methodProposal) {
// TODO remove once https://bugs.eclipse.org/bugs/show_bug.cgi?id=85293
// gets fixed.
char[] signature= SignatureUtil.fix83600(methodProposal.getSignature());
char[][] parameterNames= methodProposal.findParameterNames(null);
char[][] parameterTypes= Signature.getParameterTypes(signature);
for (int i= 0; i < parameterTypes.length; i++) {
parameterTypes[i]= createTypeDisplayName(SignatureUtil.getLowerBound(parameterTypes[i]));
}
if (Flags.isVarargs(methodProposal.getFlags())) {
int index= parameterTypes.length - 1;
parameterTypes[index]= convertToVararg(parameterTypes[index]);
}
return appendParameterSignature(buffer, parameterTypes, parameterNames);
}
示例12: 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;
}
示例13: isVisible
import org.eclipse.jdt.core.Flags; //导入依赖的package包/类
private boolean isVisible(TypeNameMatch curr) {
int flags= curr.getModifiers();
if (Flags.isPrivate(flags)) {
return false;
}
boolean isPublic;
try {
isPublic= JdtFlags.isPublic(curr.getType());
} catch (JavaModelException e) {
isPublic= Flags.isPublic(flags);
}
if (isPublic || Flags.isProtected(flags)) {
return true;
}
return curr.getPackageName().equals(fCurrPackage.getElementName());
}
示例14: checkDestinationInterfaceTargetMethods
import org.eclipse.jdt.core.Flags; //导入依赖的package包/类
private RefactoringStatus checkDestinationInterfaceTargetMethods(IMethod sourceMethod) throws JavaModelException {
RefactoringStatus status = new RefactoringStatus();
logInfo("Checking destination interface target methods...");
// Ensure that target methods are not already default methods.
// For each method to move, add a warning if the associated target
// method is already default.
IMethod targetMethod = getTargetMethod(sourceMethod, Optional.empty());
if (targetMethod != null) {
int targetMethodFlags = targetMethod.getFlags();
if (Flags.isDefaultMethod(targetMethodFlags)) {
RefactoringStatusEntry entry = addError(status, sourceMethod,
PreconditionFailure.TargetMethodIsAlreadyDefault, targetMethod);
addUnmigratableMethod(sourceMethod, entry);
}
}
return status;
}
开发者ID:ponder-lab,项目名称:Migrate-Skeletal-Implementation-to-Interface-Refactoring,代码行数:22,代码来源:MigrateSkeletalImplementationToInterfaceRefactoringProcessor.java
示例15: getMethodModifier
import org.eclipse.jdt.core.Flags; //导入依赖的package包/类
/**
* Returns the method modifier as String.
*
* @param method
* @return method modifier
* @throws JavaModelException
*/
public static String getMethodModifier(IMethod method)
throws JavaModelException {
int methodFlags = method.getFlags();
if (Flags.isPublic(methodFlags)) {
return MOD_PUBLIC;
} else if (Flags.isProtected(methodFlags)) {
return MOD_PROTECTED;
} else if (Flags.isPrivate(methodFlags)) {
return MOD_PRIVATE;
} else if (Flags.isPackageDefault(methodFlags)) {
return MOD_PACKAGE;
}
return ""; //$NON-NLS-1$
}