Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/Visibility.java')
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/Visibility.java92
1 files changed, 92 insertions, 0 deletions
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/Visibility.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/Visibility.java
new file mode 100644
index 00000000000..1093192d386
--- /dev/null
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/Visibility.java
@@ -0,0 +1,92 @@
+/*******************************************************************************
+ * Copyright (c) 2008 Institute for Software, HSR Hochschule fuer Technik
+ * Rapperswil, University of applied sciences and others
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Institute for Software - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.refactoring;
+
+import org.eclipse.cdt.core.dom.ast.DOMException;
+import org.eclipse.cdt.core.dom.ast.IASTName;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTVisiblityLabel;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPMember;
+
+public class Visibility {
+
+ /**
+ * The visibility public.
+ */
+ public static final Visibility PUBLIC = new Visibility(){
+ @Override
+ public String stringValue(){
+ return "public"; //$NON-NLS-1$
+ }
+ };
+
+ /**
+ * The visibility protected.
+ */
+ public static final Visibility PROTECTED = new Visibility(){
+ @Override
+ public String stringValue(){
+ return "protected"; //$NON-NLS-1$
+ }
+ };
+
+ /**
+ * The visibility private.
+ */
+ public static final Visibility PRIVATE = new Visibility(){
+ @Override
+ public String stringValue(){
+ return "private"; //$NON-NLS-1$
+ }
+ };
+
+ /**
+ * The visibility unknown, cause of parsing error.
+ */
+ public static final Visibility UNKNOWN = new Visibility(){ };
+
+
+
+ private Visibility(){ }
+
+ public static Visibility getVisibility(IASTName name){
+ try {
+ ICPPMember member = ((ICPPMember)name.resolveBinding());
+
+ switch (member.getVisibility()){
+ case ICPPASTVisiblityLabel.v_public:
+ return PUBLIC;
+ case ICPPASTVisiblityLabel.v_protected:
+ return PROTECTED;
+ case ICPPASTVisiblityLabel.v_private:
+ return PRIVATE;
+ default:
+ return UNKNOWN;
+ }
+
+ } catch (DOMException e) {
+ return UNKNOWN;
+ } catch (RuntimeException e){
+ return UNKNOWN;
+ }
+ }
+
+ public String stringValue(){
+ return ""; //$NON-NLS-1$
+ }
+
+ @Override
+ public String toString() {
+ return stringValue();
+ }
+
+
+}

Back to the top