Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(379)

Unified Diff: editor/util/plugins/com.google.dart.java2dart/src/com/google/dart/java2dart/util/JavaUtils.java

Issue 189803004: Translate private Java members to private Dart members. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Tweaks Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: editor/util/plugins/com.google.dart.java2dart/src/com/google/dart/java2dart/util/JavaUtils.java
diff --git a/editor/util/plugins/com.google.dart.java2dart/src/com/google/dart/java2dart/util/JavaUtils.java b/editor/util/plugins/com.google.dart.java2dart/src/com/google/dart/java2dart/util/JavaUtils.java
index 05c11dff92e629e62713469ec80848380512a2ba..542dda0d19a2e5f80de971eace2d1eb7fd2e51b3 100644
--- a/editor/util/plugins/com.google.dart.java2dart/src/com/google/dart/java2dart/util/JavaUtils.java
+++ b/editor/util/plugins/com.google.dart.java2dart/src/com/google/dart/java2dart/util/JavaUtils.java
@@ -16,12 +16,14 @@ package com.google.dart.java2dart.util;
import org.apache.commons.lang3.StringUtils;
import org.eclipse.core.runtime.Assert;
+import org.eclipse.jdt.core.dom.BodyDeclaration;
import org.eclipse.jdt.core.dom.IBinding;
import org.eclipse.jdt.core.dom.IMethodBinding;
import org.eclipse.jdt.core.dom.IPackageBinding;
import org.eclipse.jdt.core.dom.ITypeBinding;
import org.eclipse.jdt.core.dom.IVariableBinding;
import org.eclipse.jdt.core.dom.Modifier;
+import org.eclipse.jdt.core.dom.TypeDeclaration;
/**
* Helper for JDT integration.
@@ -313,6 +315,42 @@ public class JavaUtils {
return false;
}
+ /**
+ * Checks if the given {@link BodyDeclaration} is declared as "package private".
+ */
+ public static boolean isPackagePrivate(BodyDeclaration node) {
+ return !isPublic(node) && !isProtected(node) && !isPrivate(node);
+ }
+
+ /**
+ * Checks if the given {@link BodyDeclaration} is declared as "private".
+ */
+ public static boolean isPrivate(BodyDeclaration node) {
+ return Modifier.isPrivate(node.getModifiers());
+ }
+
+ /**
+ * Checks if the given {@link BodyDeclaration} is declared as "protected".
+ */
+ public static boolean isProtected(BodyDeclaration node) {
+ return Modifier.isProtected(node.getModifiers());
+ }
+
+ /**
+ * Checks if the given {@link BodyDeclaration} is declared as "public" or is implicitly public
+ * because if declared in an interface.
+ */
+ public static boolean isPublic(BodyDeclaration node) {
+ if (Modifier.isPublic(node.getModifiers())) {
+ return true;
+ }
+ if (node.getParent() instanceof TypeDeclaration) {
+ TypeDeclaration typeDeclaration = (TypeDeclaration) node.getParent();
+ return typeDeclaration.isInterface();
+ }
+ return false;
+ }
+
public static boolean isStaticFieldBinding(Object binding) {
if (binding instanceof IVariableBinding) {
IVariableBinding fieldBinding = (IVariableBinding) binding;

Powered by Google App Engine
This is Rietveld 408576698