1 11 package org.eclipse.jdt.internal.core; 12 13 import org.eclipse.core.runtime.IPath; 14 import org.eclipse.core.runtime.Path; 15 import org.eclipse.jdt.core.IAccessRule; 16 import org.eclipse.jdt.core.compiler.IProblem; 17 import org.eclipse.jdt.internal.compiler.env.AccessRule; 18 19 public class ClasspathAccessRule extends AccessRule implements IAccessRule { 20 21 public ClasspathAccessRule(IPath pattern, int kind) { 22 this(pattern.toString().toCharArray(), toProblemId(kind)); 23 } 24 25 public ClasspathAccessRule(char[] pattern, int problemId) { 26 super(pattern, problemId); 27 } 28 29 private static int toProblemId(int kind) { 30 boolean ignoreIfBetter = (kind & IAccessRule.IGNORE_IF_BETTER) != 0; 31 switch (kind & ~IAccessRule.IGNORE_IF_BETTER) { 32 case K_NON_ACCESSIBLE: 33 return ignoreIfBetter ? IProblem.ForbiddenReference | AccessRule.IgnoreIfBetter : IProblem.ForbiddenReference; 34 case K_DISCOURAGED: 35 return ignoreIfBetter ? IProblem.DiscouragedReference | AccessRule.IgnoreIfBetter : IProblem.DiscouragedReference; 36 default: 37 return ignoreIfBetter ? AccessRule.IgnoreIfBetter : 0; 38 } 39 } 40 41 public IPath getPattern() { 42 return new Path(new String (this.pattern)); 43 } 44 45 public int getKind() { 46 switch (getProblemId()) { 47 case IProblem.ForbiddenReference: 48 return K_NON_ACCESSIBLE; 49 case IProblem.DiscouragedReference: 50 return K_DISCOURAGED; 51 default: 52 return K_ACCESSIBLE; 53 } 54 } 55 56 } 57 | Popular Tags |