本文整理匯總了Java中org.eclipse.jdt.core.dom.Modifier.isNative方法的典型用法代碼示例。如果您正苦於以下問題:Java Modifier.isNative方法的具體用法?Java Modifier.isNative怎麽用?Java Modifier.isNative使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.eclipse.jdt.core.dom.Modifier
的用法示例。
在下文中一共展示了Modifier.isNative方法的11個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: endVisit
import org.eclipse.jdt.core.dom.Modifier; //導入方法依賴的package包/類
@Override
public void endVisit(MethodDeclaration node) {
int modifiers = node.getModifiers();
if (Modifier.isNative(modifiers)) {
String nativeCode = extractNativeCode(node);
if (nativeCode != null) {
Block body = new Block();
body.getStatements().add(new NativeStatement(nativeCode));
node.setBody(body);
node.removeModifiers(Modifier.NATIVE);
}
}
if (Modifier.isSynchronized(modifiers)) {
ITypeBinding declaringClass = node.getMethodBinding().getDeclaringClass();
SynchronizedStatement syncStmt = new SynchronizedStatement(
Modifier.isStatic(modifiers) ? new TypeLiteral(declaringClass)
: new ThisExpression(declaringClass));
syncStmt.setBody(TreeUtil.remove(node.getBody()));
Block newBody = new Block();
newBody.getStatements().add(syncStmt);
node.setBody(newBody);
node.removeModifiers(Modifier.SYNCHRONIZED);
}
}
示例2: removeDeadMethods
import org.eclipse.jdt.core.dom.Modifier; //導入方法依賴的package包/類
/**
* Remove dead methods from a type's body declarations.
*/
private void removeDeadMethods(String clazz, List<BodyDeclaration> declarations) {
Iterator<BodyDeclaration> declarationsIter = declarations.iterator();
while (declarationsIter.hasNext()) {
BodyDeclaration declaration = declarationsIter.next();
if (declaration instanceof MethodDeclaration) {
MethodDeclaration method = (MethodDeclaration) declaration;
// Need to keep native methods because otherwise the OCNI content will
// be emitted without a surrounding method.
// TODO(kstanger): Remove the method and its OCNI comment.
if (Modifier.isNative(method.getModifiers())) {
continue;
}
IMethodBinding binding = method.getMethodBinding();
String name = getProGuardName(binding);
String signature = BindingUtil.getSignature(binding);
if (deadCodeMap.isDeadMethod(clazz, name, signature)) {
declarationsIter.remove();
}
}
}
}
示例3: getAdornmentFlags
import org.eclipse.jdt.core.dom.Modifier; //導入方法依賴的package包/類
private static int getAdornmentFlags(IBinding binding) {
int adornments = 0;
final int modifiers = binding.getModifiers();
if (Modifier.isAbstract(modifiers)) adornments |= JavaElementImageDescriptor.ABSTRACT;
if (Modifier.isFinal(modifiers)) adornments |= JavaElementImageDescriptor.FINAL;
if (Modifier.isStatic(modifiers)) adornments |= JavaElementImageDescriptor.STATIC;
if (binding.isDeprecated()) adornments |= JavaElementImageDescriptor.DEPRECATED;
if (binding instanceof IMethodBinding) {
if (((IMethodBinding) binding).isConstructor())
adornments |= JavaElementImageDescriptor.CONSTRUCTOR;
if (Modifier.isSynchronized(modifiers)) adornments |= JavaElementImageDescriptor.SYNCHRONIZED;
if (Modifier.isNative(modifiers)) adornments |= JavaElementImageDescriptor.NATIVE;
ITypeBinding type = ((IMethodBinding) binding).getDeclaringClass();
if (type.isInterface() && !Modifier.isAbstract(modifiers) && !Modifier.isStatic(modifiers))
adornments |= JavaElementImageDescriptor.DEFAULT_METHOD;
if (((IMethodBinding) binding).getDefaultValue() != null)
adornments |= JavaElementImageDescriptor.ANNOTATION_DEFAULT;
}
if (binding instanceof IVariableBinding && ((IVariableBinding) binding).isField()) {
if (Modifier.isTransient(modifiers)) adornments |= JavaElementImageDescriptor.TRANSIENT;
if (Modifier.isVolatile(modifiers)) adornments |= JavaElementImageDescriptor.VOLATILE;
}
return adornments;
}
示例4: printModifiers
import org.eclipse.jdt.core.dom.Modifier; //導入方法依賴的package包/類
private void printModifiers(int modifiers) {
if (Modifier.isPublic(modifiers)) {
sb.print("public ");
}
if (Modifier.isProtected(modifiers)) {
sb.print("protected ");
}
if (Modifier.isPrivate(modifiers)) {
sb.print("private ");
}
if (Modifier.isStatic(modifiers)) {
sb.print("static ");
}
if (Modifier.isAbstract(modifiers)) {
sb.print("abstract ");
}
if (Modifier.isFinal(modifiers)) {
sb.print("final ");
}
if (Modifier.isSynchronized(modifiers)) {
sb.print("synchronized ");
}
if (Modifier.isVolatile(modifiers)) {
sb.print("volatile ");
}
if (Modifier.isNative(modifiers)) {
sb.print("native ");
}
if (Modifier.isStrictfp(modifiers)) {
sb.print("strictfp ");
}
if (Modifier.isTransient(modifiers)) {
sb.print("transient ");
}
if ((modifiers & BindingUtil.ACC_SYNTHETIC) > 0) {
sb.print("synthetic ");
}
}
示例5: printFunctionDeclaration
import org.eclipse.jdt.core.dom.Modifier; //導入方法依賴的package包/類
@Override
protected void printFunctionDeclaration(FunctionDeclaration function) {
newline();
// We expect native functions to be defined externally.
if (!Modifier.isNative(function.getModifiers())) {
print("__attribute__((unused)) static ");
}
print(getFunctionSignature(function));
if (function.returnsRetained()) {
print(" NS_RETURNS_RETAINED");
}
println(";");
}
示例6: printFunctionDeclaration
import org.eclipse.jdt.core.dom.Modifier; //導入方法依賴的package包/類
@Override
protected void printFunctionDeclaration(FunctionDeclaration function) {
if (Modifier.isNative(function.getModifiers())) {
return;
}
String functionBody = generateStatement(function.getBody(), /* isFunction */ true);
newline();
println(getFunctionSignature(function) + " " + reindent(functionBody));
}
示例7: endVisit
import org.eclipse.jdt.core.dom.Modifier; //導入方法依賴的package包/類
@Override
public void endVisit(MethodDeclaration method) {
if (Modifier.isNative(method.getModifiers())) {
JavaValidationResult methodResult = JsniParser.parse(method);
// Collect all Java references we found in this method
result.addAllJavaRefs(methodResult.getJavaRefs());
// Report problems, unless we're suppressing them
if (!JavaASTUtils.hasSuppressWarnings(method, "jsni")) {
result.addAllProblems(methodResult.getProblems());
}
}
}
示例8: extractBasicModifiersFromBinding
import org.eclipse.jdt.core.dom.Modifier; //導入方法依賴的package包/類
private void extractBasicModifiersFromBinding(int modifiers, NamedEntity entity) {
Boolean publicModifier = Modifier.isPublic(modifiers);
Boolean protectedModifier = Modifier.isProtected(modifiers);
Boolean privateModifier = Modifier.isPrivate(modifiers);
if (publicModifier )
entity.addModifiers("public");
if (protectedModifier)
entity.addModifiers("protected");
if (privateModifier)
entity.addModifiers("private");
if (!(publicModifier || protectedModifier || privateModifier))
entity.addModifiers("package");
if (Modifier.isFinal(modifiers))
entity.addModifiers("final");
if (Modifier.isAbstract(modifiers))
entity.addModifiers("abstract");
if (Modifier.isNative(modifiers))
entity.addModifiers("native");
if (Modifier.isSynchronized(modifiers))
entity.addModifiers("synchronized");
if (Modifier.isTransient(modifiers))
entity.addModifiers("transient");
if (Modifier.isVolatile(modifiers))
entity.addModifiers("volatile");
/* We do not extract the static modifier here because we want to set the hasClassScope property
and we do that specifically only for attributes and methods */
}
示例9: endVisit
import org.eclipse.jdt.core.dom.Modifier; //導入方法依賴的package包/類
@Override
public void endVisit(MethodDeclaration node) {
IMethodBinding binding = node.getMethodBinding();
if (BindingUtil.isMappedToNative(binding)
|| isConstructorOfMappedClass(binding)) {
// mapped method should not be functionized. they will not
// be called anyways
if (binding.isConstructor()) {
node.getBody()
.getStatements()
.add(new ReturnStatement(new ThisExpression(binding.getDeclaringClass())));
}
return;
}
FunctionDeclaration function = null;
List<BodyDeclaration> declarationList = TreeUtil.asDeclarationSublist(node);
List<String> extraSelectors = NameTable.getExtraSelectors(binding);
if (BindingUtil.isStatic(binding) || binding.isConstructor()
|| Modifier.isNative(node.getModifiers()) || functionizableMethods.contains(binding)
|| !extraSelectors.isEmpty()) {
ITypeBinding declaringClass = binding.getDeclaringClass();
function = makeFunction(node);
for (String selector : extraSelectors) {
declarationList.add(makeExtraMethodDeclaration(node, selector, function));
}
declarationList.add(function);
if (binding.isConstructor() && !BindingUtil.isAbstract(declaringClass)) {
declarationList.add(makeAllocatingConstructor(node));
}
boolean keepMethod = !BindingUtil.isStatic(binding) || !Options.removeClassMethods();
if (keepMethod || TranslationUtil.needsReflection(declaringClass)) {
setFunctionCaller(node, function);
if (!keepMethod) {
// We're only keeping the method for reflection, so we can keep it out
// of the declaration.
node.addModifiers(BindingUtil.ACC_SYNTHETIC);
}
if (binding.isConstructor()) {
node.getBody()
.getStatements()
.add(new ReturnStatement(new ThisExpression(binding.getDeclaringClass())));
}
} else {
node.remove();
}
ErrorUtil.functionizedMethod();
}
}
示例10: makeFunction
import org.eclipse.jdt.core.dom.Modifier; //導入方法依賴的package包/類
/**
* Create an equivalent function declaration for a given method.
*/
private FunctionDeclaration makeFunction(MethodDeclaration method) {
IMethodBinding m = method.getMethodBinding();
ITypeBinding declaringClass = m.getDeclaringClass();
boolean isInstanceMethod = !BindingUtil.isStatic(m) && !m.isConstructor();
FunctionDeclaration function = new FunctionDeclaration(
NameTable.getFullFunctionName(m), m.getReturnType());
if (!BindingUtil.isStatic(m)) {
GeneratedVariableBinding var = new GeneratedVariableBinding(NameTable.SELF_NAME, 0,
declaringClass, false, true, declaringClass, null);
function.getParameters().add(new SingleVariableDeclaration(var));
}
TreeUtil.copyList(method.getParameters(), function.getParameters());
function.setModifiers(
BindingUtil.isPrivate(m) || isInstanceMethod ? Modifier.PRIVATE : Modifier.PUBLIC);
if (Modifier.isNative(method.getModifiers())) {
function.addModifiers(Modifier.NATIVE);
return function;
}
function.setBody(TreeUtil.remove(method.getBody()));
if (BindingUtil.isStatic(m)) {
// Add class initialization invocation, since this may be the first use of this class.
if (!BindingUtil.isMappedToNative(declaringClass)) {
// Note, if the class is mapped to a native class, such initialization is not needed
String initName = String.format("%s_initialize", NameTable.getFullName(declaringClass));
ITypeBinding voidType = Types.resolveJavaType("void");
FunctionInvocation initCall =
new FunctionInvocation(initName, voidType, voidType, declaringClass);
function.getBody().getStatements().add(0, new ExpressionStatement(initCall));
}
}
if (!BindingUtil.isStatic(m)) {
FunctionConverter.convert(function);
}
return function;
}
示例11: isNative
import org.eclipse.jdt.core.dom.Modifier; //導入方法依賴的package包/類
public static boolean isNative(IBinding binding) {
return Modifier.isNative(binding.getModifiers());
}