Index: batch/org/eclipse/jdt/internal/compiler/batch/Main.java =================================================================== RCS file: /home/eclipse/org.eclipse.jdt.core/batch/org/eclipse/jdt/internal/compiler/batch/Main.java,v retrieving revision 1.199 diff -u -r1.199 Main.java --- batch/org/eclipse/jdt/internal/compiler/batch/Main.java 8 Jun 2005 20:30:40 -0000 1.199 +++ batch/org/eclipse/jdt/internal/compiler/batch/Main.java 9 Jun 2005 14:34:58 -0000 @@ -2437,8 +2437,8 @@ } } if (rulesOK) { - AccessRuleSet accessRuleSet = new AccessRuleSet( - accessRules, "{0}"); //$NON-NLS-1$ + AccessRuleSet accessRuleSet = new AccessRuleSet(accessRules); + // TODO Maxime double check access rules diagnostics in batch compiler FileSystem.Classpath currentClasspath = FileSystem .getClasspath(currentClasspathName, customEncoding, 0, accessRuleSet); Index: compiler/org/eclipse/jdt/internal/compiler/ast/ASTNode.java =================================================================== RCS file: /home/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ASTNode.java,v retrieving revision 1.46 diff -u -r1.46 ASTNode.java --- compiler/org/eclipse/jdt/internal/compiler/ast/ASTNode.java 6 Jun 2005 18:24:56 -0000 1.46 +++ compiler/org/eclipse/jdt/internal/compiler/ast/ASTNode.java 9 Jun 2005 14:34:58 -0000 @@ -269,6 +269,15 @@ // ignore cases where field is used from within inside itself field.modifiers |= AccLocallyUsed; } + +// if (field.hasRestrictedAccess()) { + if ((field.modifiers & AccRestrictedAccess) != 0) { + AccessRestriction restriction = scope.environment().getAccessRestriction(field.declaringClass); + if (restriction != null) { + scope.problemReporter().forbiddenReference(field, this, + restriction.getFieldAccessMessageTemplate(), restriction.getProblemId()); + } + } if (!field.isViewedAsDeprecated()) return false; @@ -288,20 +297,37 @@ /* Answer true if the method use is considered deprecated. * An access in the same compilation unit is allowed. */ - public final boolean isMethodUseDeprecated(MethodBinding method, Scope scope) { + public final boolean isMethodUseDeprecated(MethodBinding method, Scope scope, boolean isExplicitUse) { if ((method.isPrivate() || method.declaringClass.isLocalType()) && !scope.isDefinedInMethod(method)) { // ignore cases where method is used from within inside itself (e.g. direct recursions) method.original().modifiers |= AccLocallyUsed; } + if (isExplicitUse && (method.modifiers & AccRestrictedAccess) != 0) { + // note: explicit constructors calls warnings are kept despite the 'new C1()' case (two + // warnings, one on type, the other on constructor), because of the 'super()' case. + AccessRestriction restriction = scope.environment().getAccessRestriction(method.declaringClass); + if (restriction != null) + if (method.isConstructor()) + scope.problemReporter().forbiddenReference(method, this, + restriction.getConstructorAccessMessageTemplate(), restriction.getProblemId()); + else + scope.problemReporter().forbiddenReference(method, this, + restriction.getMethodAccessMessageTemplate(), restriction.getProblemId()); + } + if (!method.isViewedAsDeprecated()) return false; // inside same unit - no report if (scope.isDefinedInSameUnit(method.declaringClass)) return false; + + // if non explicit use, but explicitly deprecated still warn + if (!isExplicitUse && (method.modifiers & AccDeprecated) == 0) return false; // if context is deprecated, may avoid reporting if (!scope.compilerOptions().reportDeprecationInsideDeprecatedCode && scope.isInsideDeprecatedCode()) return false; + return true; } @@ -338,6 +364,9 @@ scope.problemReporter().forbiddenReference(type, this, restriction.getMessageTemplate(), restriction.getProblemId()); } } + if (refType instanceof SourceTypeBinding) + ((SourceTypeBinding) refType).checkDeprecatedAnnotation(); + // WORK look force annotations resolution before deciding whether the type may be deprecated if (!refType.isViewedAsDeprecated()) return false; // inside same unit - no report Index: compiler/org/eclipse/jdt/internal/compiler/ast/AllocationExpression.java =================================================================== RCS file: /home/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/AllocationExpression.java,v retrieving revision 1.48 diff -u -r1.48 AllocationExpression.java --- compiler/org/eclipse/jdt/internal/compiler/ast/AllocationExpression.java 4 May 2005 11:31:09 -0000 1.48 +++ compiler/org/eclipse/jdt/internal/compiler/ast/AllocationExpression.java 9 Jun 2005 14:34:58 -0000 @@ -310,7 +310,7 @@ scope.problemReporter().invalidConstructor(this, binding); return this.resolvedType; } - if (isMethodUseDeprecated(binding, scope)) + if (isMethodUseDeprecated(binding, scope, true)) scope.problemReporter().deprecatedMethod(binding, this); checkInvocationArguments(scope, null, allocationType, this.binding, this.arguments, argumentTypes, argsContainCast, this); Index: compiler/org/eclipse/jdt/internal/compiler/ast/ExplicitConstructorCall.java =================================================================== RCS file: /home/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ExplicitConstructorCall.java,v retrieving revision 1.43 diff -u -r1.43 ExplicitConstructorCall.java --- compiler/org/eclipse/jdt/internal/compiler/ast/ExplicitConstructorCall.java 30 May 2005 15:53:25 -0000 1.43 +++ compiler/org/eclipse/jdt/internal/compiler/ast/ExplicitConstructorCall.java 9 Jun 2005 14:34:58 -0000 @@ -325,7 +325,7 @@ argumentTypes = new TypeBinding[] { scope.getJavaLangString(), BaseTypes.IntBinding }; } if ((binding = scope.getConstructor(receiverType, argumentTypes, this)).isValidBinding()) { - if (isMethodUseDeprecated(binding, scope)) + if (isMethodUseDeprecated(this.binding, scope, this.accessMode != ImplicitSuper)) scope.problemReporter().deprecatedMethod(binding, this); checkInvocationArguments(scope, null, receiverType, binding, this.arguments, argumentTypes, argsContainCast, this); if (binding.isPrivate() || receiverType.isLocalType()) { Index: compiler/org/eclipse/jdt/internal/compiler/ast/JavadocAllocationExpression.java =================================================================== RCS file: /home/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/JavadocAllocationExpression.java,v retrieving revision 1.22 diff -u -r1.22 JavadocAllocationExpression.java --- compiler/org/eclipse/jdt/internal/compiler/ast/JavadocAllocationExpression.java 2 Jun 2005 21:09:43 -0000 1.22 +++ compiler/org/eclipse/jdt/internal/compiler/ast/JavadocAllocationExpression.java 9 Jun 2005 14:34:58 -0000 @@ -120,7 +120,7 @@ } } } - if (isMethodUseDeprecated(this.binding, scope)) { + if (isMethodUseDeprecated(this.binding, scope, true)) { scope.problemReporter().javadocDeprecatedMethod(this.binding, this, scope.getDeclarationModifiers()); } return allocationType; Index: compiler/org/eclipse/jdt/internal/compiler/ast/JavadocMessageSend.java =================================================================== RCS file: /home/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/JavadocMessageSend.java,v retrieving revision 1.22 diff -u -r1.22 JavadocMessageSend.java --- compiler/org/eclipse/jdt/internal/compiler/ast/JavadocMessageSend.java 2 Jun 2005 21:09:43 -0000 1.22 +++ compiler/org/eclipse/jdt/internal/compiler/ast/JavadocMessageSend.java 9 Jun 2005 14:34:59 -0000 @@ -164,7 +164,7 @@ } } } - if (isMethodUseDeprecated(this.binding, scope)) { + if (isMethodUseDeprecated(this.binding, scope, true)) { scope.problemReporter().javadocDeprecatedMethod(this.binding, this, scope.getDeclarationModifiers()); } Index: compiler/org/eclipse/jdt/internal/compiler/ast/MessageSend.java =================================================================== RCS file: /home/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/MessageSend.java,v retrieving revision 1.93 diff -u -r1.93 MessageSend.java --- compiler/org/eclipse/jdt/internal/compiler/ast/MessageSend.java 2 Jun 2005 19:43:33 -0000 1.93 +++ compiler/org/eclipse/jdt/internal/compiler/ast/MessageSend.java 9 Jun 2005 14:34:59 -0000 @@ -381,7 +381,7 @@ } // abstract private methods cannot occur nor abstract static............ } - if (isMethodUseDeprecated(binding, scope)) + if (isMethodUseDeprecated(binding, scope, true)) scope.problemReporter().deprecatedMethod(binding, this); // from 1.5 compliance on, array#clone() returns the array type (but binding still shows Object) Index: compiler/org/eclipse/jdt/internal/compiler/ast/QualifiedAllocationExpression.java =================================================================== RCS file: /home/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/QualifiedAllocationExpression.java,v retrieving revision 1.67 diff -u -r1.67 QualifiedAllocationExpression.java --- compiler/org/eclipse/jdt/internal/compiler/ast/QualifiedAllocationExpression.java 1 Jun 2005 15:16:53 -0000 1.67 +++ compiler/org/eclipse/jdt/internal/compiler/ast/QualifiedAllocationExpression.java 9 Jun 2005 14:34:59 -0000 @@ -296,7 +296,7 @@ return this.resolvedType = receiverType; } if ((this.binding = scope.getConstructor(allocationType, argumentTypes, this)).isValidBinding()) { - if (isMethodUseDeprecated(binding, scope)) { + if (isMethodUseDeprecated(binding, scope, true)) { scope.problemReporter().deprecatedMethod(this.binding, this); } checkInvocationArguments(scope, null, allocationType, binding, this.arguments, argumentTypes, argsContainCast, this); Index: compiler/org/eclipse/jdt/internal/compiler/env/AccessRestriction.java =================================================================== RCS file: /home/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/env/AccessRestriction.java,v retrieving revision 1.11 diff -u -r1.11 AccessRestriction.java --- compiler/org/eclipse/jdt/internal/compiler/env/AccessRestriction.java 20 Apr 2005 16:47:02 -0000 1.11 +++ compiler/org/eclipse/jdt/internal/compiler/env/AccessRestriction.java 9 Jun 2005 14:34:59 -0000 @@ -13,10 +13,10 @@ public class AccessRestriction { private AccessRule accessRule; - private String messageTemplate; - public AccessRestriction(AccessRule accessRule, String messageTemplate) { + private String[] messageTemplates; + public AccessRestriction(AccessRule accessRule, String [] messageTemplates) { this.accessRule = accessRule; - this.messageTemplate = messageTemplate; + this.messageTemplates = messageTemplates; } /** @@ -25,9 +25,21 @@ * e.g. "{0} has restricted access" */ public String getMessageTemplate() { - return this.messageTemplate; + return this.messageTemplates[0]; } + public String getConstructorAccessMessageTemplate() { + return this.messageTemplates[1]; + } + + public String getMethodAccessMessageTemplate() { + return this.messageTemplates[2]; + } + + public String getFieldAccessMessageTemplate() { + return this.messageTemplates[3]; + } + public int getProblemId() { return this.accessRule.problemId; } Index: compiler/org/eclipse/jdt/internal/compiler/env/AccessRuleSet.java =================================================================== RCS file: /home/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/env/AccessRuleSet.java,v retrieving revision 1.6 diff -u -r1.6 AccessRuleSet.java --- compiler/org/eclipse/jdt/internal/compiler/env/AccessRuleSet.java 1 Jun 2005 09:06:28 -0000 1.6 +++ compiler/org/eclipse/jdt/internal/compiler/env/AccessRuleSet.java 9 Jun 2005 14:34:59 -0000 @@ -19,16 +19,31 @@ public class AccessRuleSet { private AccessRule[] accessRules; - public String messageTemplate; + public String[] messageTemplates; + public static final int MESSAGE_TEMPLATES_LENGTH = 4; public AccessRuleSet(AccessRule[] accessRules) { - this.accessRules = accessRules; + this(accessRules, null); } - public AccessRuleSet(AccessRule[] accessRules, String messageTemplate) { + + /** + * Make a new set of access rules. + * @param accessRules the access rules to be contained by the new set + * @param messageTemplates a Sting[4] array specifying the messages for type, + * constructor, method and field access violation; each should contain as many + * placeholders as expected by the respective access violation message (that is, + * one for type and constructor, two for method and field). + */ + // TODO Maxime move to better support + public AccessRuleSet(AccessRule[] accessRules, String[] messageTemplates) { this.accessRules = accessRules; - this.messageTemplate = messageTemplate; + if (messageTemplates != null && messageTemplates.length == MESSAGE_TEMPLATES_LENGTH) + this.messageTemplates = messageTemplates; + else + this.messageTemplates = new String[] {"{0}", "{0}", "{0} {1}", "{0} {1}"}; //$NON-NLS-1$ //$NON-NLS-2$//$NON-NLS-3$ //$NON-NLS-4$ } + /** * @see java.lang.Object#equals(java.lang.Object) */ @@ -38,8 +53,13 @@ if (!(object instanceof AccessRuleSet)) return false; AccessRuleSet otherRuleSet = (AccessRuleSet) object; - if (!this.messageTemplate.equals(otherRuleSet.messageTemplate)) - return false; + if (this.messageTemplates.length != MESSAGE_TEMPLATES_LENGTH || + otherRuleSet.messageTemplates.length != MESSAGE_TEMPLATES_LENGTH) + return false; // guard + for (int i = 0; i < MESSAGE_TEMPLATES_LENGTH; i++) + if (!this.messageTemplates[i].equals(otherRuleSet.messageTemplates[i])) + return false; + // WORK look clarify internal contracting policy with Philippe int rulesLength = this.accessRules.length; if (rulesLength != otherRuleSet.accessRules.length) return false; for (int i = 0; i < rulesLength; i++) @@ -64,7 +84,7 @@ switch (accessRule.problemId) { case IProblem.ForbiddenReference: case IProblem.DiscouragedReference: - return new AccessRestriction(accessRule, this.messageTemplate); + return new AccessRestriction(accessRule, this.messageTemplates); default: return null; } @@ -92,10 +112,10 @@ else if (i < length-1) buffer.append(", "); //$NON-NLS-1$ } - buffer - .append("} [template:\"") //$NON-NLS-1$ - .append(this.messageTemplate) - .append("\"]"); //$NON-NLS-1$ + buffer.append("} [templates:\""); //$NON-NLS-1$ + for (int i = 0; i < messageTemplates.length; i++) + buffer.append(this.messageTemplates[i]); + buffer.append("\"]"); //$NON-NLS-1$ return buffer.toString(); } } Index: compiler/org/eclipse/jdt/internal/compiler/lookup/BinaryTypeBinding.java =================================================================== RCS file: /home/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/BinaryTypeBinding.java,v retrieving revision 1.78 diff -u -r1.78 BinaryTypeBinding.java --- compiler/org/eclipse/jdt/internal/compiler/lookup/BinaryTypeBinding.java 4 Jun 2005 13:03:22 -0000 1.78 +++ compiler/org/eclipse/jdt/internal/compiler/lookup/BinaryTypeBinding.java 9 Jun 2005 14:34:59 -0000 @@ -274,6 +274,7 @@ this.fields = new FieldBinding[size]; boolean use15specifics = sourceLevel >= ClassFileConstants.JDK1_5; boolean isViewedAsDeprecated = isViewedAsDeprecated(); + boolean hasRestrictedAccess = hasRestrictedAccess(); for (int i = 0; i < size; i++) { IBinaryField binaryField = iFields[i]; char[] fieldSignature = use15specifics ? binaryField.getGenericSignature() : null; @@ -292,6 +293,8 @@ field.tagBits |= binaryField.getTagBits(); if (isViewedAsDeprecated && !field.isDeprecated()) field.modifiers |= AccDeprecatedImplicitly; + if (hasRestrictedAccess) + field.modifiers |= AccRestrictedAccess; if (fieldSignature != null) field.modifiers |= AccGenericSignature; this.fields[i] = field; @@ -446,12 +449,15 @@ } boolean isViewedAsDeprecated = isViewedAsDeprecated(); + boolean hasRestrictedAccess = hasRestrictedAccess(); this.methods = new MethodBinding[total]; if (total == initialTotal) { for (int i = 0; i < initialTotal; i++) { MethodBinding method = createMethod(iMethods[i], sourceLevel); if (isViewedAsDeprecated && !method.isDeprecated()) method.modifiers |= AccDeprecatedImplicitly; + if (hasRestrictedAccess) + method.modifiers |= AccRestrictedAccess; this.methods[i] = method; } } else { Index: compiler/org/eclipse/jdt/internal/compiler/lookup/SourceTypeBinding.java =================================================================== RCS file: /home/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/SourceTypeBinding.java,v retrieving revision 1.107 diff -u -r1.107 SourceTypeBinding.java --- compiler/org/eclipse/jdt/internal/compiler/lookup/SourceTypeBinding.java 3 Jun 2005 03:16:24 -0000 1.107 +++ compiler/org/eclipse/jdt/internal/compiler/lookup/SourceTypeBinding.java 9 Jun 2005 14:34:59 -0000 @@ -603,6 +603,10 @@ } return uniqueKey; } +public void checkDeprecatedAnnotation () { + if ((this.getAnnotationTagBits() & AnnotationDeprecated) != 0) // TODO Maxime inline bypass test on annotations loading + this.modifiers |= AccDeprecated; +} void faultInTypesForFieldsAndMethods() { // check @Deprecated annotation if ((this.getAnnotationTagBits() & AnnotationDeprecated) != 0) { @@ -1147,6 +1151,8 @@ } if (isViewedAsDeprecated() && !field.isDeprecated()) field.modifiers |= AccDeprecatedImplicitly; + if (hasRestrictedAccess()) + field.modifiers |= AccRestrictedAccess; FieldDeclaration[] fieldDecls = scope.referenceContext.fields; for (int f = 0, length = fieldDecls.length; f < length; f++) { if (fieldDecls[f].binding != field) @@ -1202,6 +1208,8 @@ } if (isViewedAsDeprecated() && !method.isDeprecated()) method.modifiers |= AccDeprecatedImplicitly; + if (hasRestrictedAccess()) + method.modifiers |= AccRestrictedAccess; AbstractMethodDeclaration methodDecl = method.sourceMethod(); if (methodDecl == null) return null; // method could not be resolved in previous iteration Index: compiler/org/eclipse/jdt/internal/compiler/problem/ProblemReporter.java =================================================================== RCS file: /home/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/problem/ProblemReporter.java,v retrieving revision 1.252 diff -u -r1.252 ProblemReporter.java --- compiler/org/eclipse/jdt/internal/compiler/problem/ProblemReporter.java 6 Jun 2005 18:24:56 -0000 1.252 +++ compiler/org/eclipse/jdt/internal/compiler/problem/ProblemReporter.java 9 Jun 2005 14:35:00 -0000 @@ -614,10 +614,19 @@ case IProblem.JavadocUsingDeprecatedConstructor: case IProblem.JavadocUsingDeprecatedMethod: case IProblem.JavadocUsingDeprecatedType: - if (!(this.options.reportInvalidJavadocTags && this.options.reportInvalidJavadocTagsDeprecatedRef)) { - return ProblemSeverities.Ignore; - } - break; + if (!(this.options.reportInvalidJavadocTags && + this.options.reportInvalidJavadocTagsDeprecatedRef && + this.options.docCommentSupport)) + return Ignore; + else if (this.options.getSeverity(CompilerOptions.InvalidJavadoc) != Error) + return Warning; + else if (this.options.getSeverity(CompilerOptions.UsingDeprecatedAPI) != Error) + return this.options.getSeverity(CompilerOptions.UsingDeprecatedAPI); + // could even be Ignore + else + return Error; + // WORK look review + /* * Javadoc invalid tags due to non-visible references */ @@ -1184,6 +1193,42 @@ location.sourceStart, location.sourceEnd); } +public void forbiddenReference(MethodBinding method, ASTNode location, + String messageTemplate, int problemId) { + if (method.isConstructor()) + this.handle( + problemId, + new String[] { new String(method.readableName()) }, // distinct from msg arg for quickfix purpose + new String[] { + MessageFormat.format(messageTemplate, + new String[]{new String(method.shortReadableName())})}, + location.sourceStart, + location.sourceEnd); + else + this.handle( + problemId, + new String[] { new String(method.readableName()) }, // distinct from msg arg for quickfix purpose + new String[] { + MessageFormat.format(messageTemplate, + new String[]{ + new String(method.shortReadableName()), + new String(method.declaringClass.shortReadableName())})}, + location.sourceStart, + location.sourceEnd); +} +public void forbiddenReference(FieldBinding field, ASTNode location, + String messageTemplate, int problemId) { + this.handle( + problemId, + new String[] { new String(field.readableName()) }, // distinct from msg arg for quickfix purpose + new String[] { + MessageFormat.format(messageTemplate, + new String[]{ + new String(field.shortReadableName()), + new String(field.declaringClass.shortReadableName())})}, + location.sourceStart, + location.sourceEnd); +} public void forwardReference(Reference reference, int indexInQualification, TypeBinding type) { this.handle( IProblem.ReferenceToForwardField, Index: eval/org/eclipse/jdt/internal/eval/CodeSnippetAllocationExpression.java =================================================================== RCS file: /home/eclipse/org.eclipse.jdt.core/eval/org/eclipse/jdt/internal/eval/CodeSnippetAllocationExpression.java,v retrieving revision 1.28 diff -u -r1.28 CodeSnippetAllocationExpression.java --- eval/org/eclipse/jdt/internal/eval/CodeSnippetAllocationExpression.java 23 Feb 2005 02:47:29 -0000 1.28 +++ eval/org/eclipse/jdt/internal/eval/CodeSnippetAllocationExpression.java 9 Jun 2005 14:35:00 -0000 @@ -190,7 +190,7 @@ return this.resolvedType; } } - if (isMethodUseDeprecated(this.binding, scope)) { + if (isMethodUseDeprecated(this.binding, scope, true)) { scope.problemReporter().deprecatedMethod(this.binding, this); } if (arguments != null) { Index: eval/org/eclipse/jdt/internal/eval/CodeSnippetMessageSend.java =================================================================== RCS file: /home/eclipse/org.eclipse.jdt.core/eval/org/eclipse/jdt/internal/eval/CodeSnippetMessageSend.java,v retrieving revision 1.42 diff -u -r1.42 CodeSnippetMessageSend.java --- eval/org/eclipse/jdt/internal/eval/CodeSnippetMessageSend.java 2 Jun 2005 19:43:33 -0000 1.42 +++ eval/org/eclipse/jdt/internal/eval/CodeSnippetMessageSend.java 9 Jun 2005 14:35:00 -0000 @@ -334,7 +334,7 @@ } // abstract private methods cannot occur nor abstract static............ } - if (isMethodUseDeprecated(binding, scope)) + if (isMethodUseDeprecated(binding, scope, true)) scope.problemReporter().deprecatedMethod(binding, this); // from 1.5 compliance on, array#clone() returns the array type (but binding still shows Object) Index: model/org/eclipse/jdt/internal/core/ClasspathEntry.java =================================================================== RCS file: /home/eclipse/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/ClasspathEntry.java,v retrieving revision 1.81 diff -u -r1.81 ClasspathEntry.java --- model/org/eclipse/jdt/internal/core/ClasspathEntry.java 1 Jun 2005 18:56:14 -0000 1.81 +++ model/org/eclipse/jdt/internal/core/ClasspathEntry.java 9 Jun 2005 14:35:01 -0000 @@ -207,7 +207,7 @@ AccessRuleSet ruleSet = createAccessRuleSet(accessRules); if (ruleSet != null) { // compute message template - ruleSet.messageTemplate = getMessageTemplate(); + ruleSet.messageTemplates = getMessageTemplates(); } this.accessRuleSet = ruleSet; @@ -781,11 +781,21 @@ return this.extraAttributes; } - private String getMessageTemplate() { + private String[] getMessageTemplates() { + String [] result = new String[AccessRuleSet.MESSAGE_TEMPLATES_LENGTH]; if (this.entryKind == CPE_PROJECT || this.entryKind == CPE_SOURCE) { // can be remote source entry when reconciling - return Messages.bind( + result[0] = Messages.bind( org.eclipse.jdt.internal.core.util.Messages.restrictedAccess_project, new String[] {"{0}", getPath().segment(0)}); //$NON-NLS-1$ + result[1] = Messages.bind( + org.eclipse.jdt.internal.core.util.Messages.restrictedAccess_constructor_project, + new String[] {"{0}", getPath().segment(0)}); //$NON-NLS-1$ + result[2] = Messages.bind( + org.eclipse.jdt.internal.core.util.Messages.restrictedAccess_method_project, + new String[] {"{0}", "{1}", getPath().segment(0)}); //$NON-NLS-1$ //$NON-NLS-2$ + result[3] = Messages.bind( + org.eclipse.jdt.internal.core.util.Messages.restrictedAccess_field_project, + new String[] {"{0}", "{1}", getPath().segment(0)}); //$NON-NLS-1$ //$NON-NLS-2$ } else { IPath libPath = getPath(); Object target = JavaModel.getTarget(ResourcesPlugin.getWorkspace().getRoot(), libPath, false); @@ -794,10 +804,20 @@ pathString = libPath.toOSString(); else pathString = libPath.makeRelative().toString(); - return Messages.bind( + result[0] = Messages.bind( org.eclipse.jdt.internal.core.util.Messages.restrictedAccess_library, new String[] {"{0}", pathString}); //$NON-NLS-1$ + result[1] = Messages.bind( + org.eclipse.jdt.internal.core.util.Messages.restrictedAccess_constructor_library, + new String[] {"{0}", pathString}); //$NON-NLS-1$ + result[2] = Messages.bind( + org.eclipse.jdt.internal.core.util.Messages.restrictedAccess_method_library, + new String[] {"{0}", "{1}", pathString}); //$NON-NLS-1$ //$NON-NLS-2$ + result[3] = Messages.bind( + org.eclipse.jdt.internal.core.util.Messages.restrictedAccess_field_library, + new String[] {"{0}", "{1}", pathString}); //$NON-NLS-1$ //$NON-NLS-2$ } + return result; } /** Index: model/org/eclipse/jdt/internal/core/builder/State.java =================================================================== RCS file: /home/eclipse/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/State.java,v retrieving revision 1.49 diff -u -r1.49 State.java --- model/org/eclipse/jdt/internal/core/builder/State.java 8 Jun 2005 21:18:57 -0000 1.49 +++ model/org/eclipse/jdt/internal/core/builder/State.java 9 Jun 2005 14:35:01 -0000 @@ -330,9 +330,12 @@ int problemId = in.readInt(); accessRules[i] = new ClasspathAccessRule(pattern, problemId); } - String messageTemplate = in.readUTF(); + String[] messageTemplates = new String[AccessRuleSet.MESSAGE_TEMPLATES_LENGTH]; + for (int i = 0; i < 3; i++) { + messageTemplates[i] = in.readUTF(); + } AccessRuleSet accessRuleSet = new AccessRuleSet(accessRules); - accessRuleSet.messageTemplate = messageTemplate; + accessRuleSet.messageTemplates = messageTemplates; return accessRuleSet; } @@ -601,7 +604,8 @@ writeName(accessRule.pattern, out); out.writeInt(accessRule.problemId); } - out.writeUTF(accessRuleSet.messageTemplate); + for (int i = 0; i < accessRuleSet.messageTemplates.length; i++) + out.writeUTF(accessRuleSet.messageTemplates[i]); } } } Index: model/org/eclipse/jdt/internal/core/util/Messages.java =================================================================== RCS file: /home/eclipse/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/Messages.java,v retrieving revision 1.4 diff -u -r1.4 Messages.java --- model/org/eclipse/jdt/internal/core/util/Messages.java 31 May 2005 15:34:07 -0000 1.4 +++ model/org/eclipse/jdt/internal/core/util/Messages.java 9 Jun 2005 14:35:01 -0000 @@ -166,8 +166,15 @@ public static String cache_invalidLoadFactor; public static String savedState_jobName; public static String javamodel_initialization; - public static String restrictedAccess_project; + public static String restrictedAccess_project; + // WORK look ask Philippe if we could rename this to restrictedAccess_type_project or add it public static String restrictedAccess_library; + public static String restrictedAccess_constructor_project; + public static String restrictedAccess_constructor_library; + public static String restrictedAccess_field_project; + public static String restrictedAccess_field_library; + public static String restrictedAccess_method_project; + public static String restrictedAccess_method_library; public static String convention_unit_nullName; public static String convention_unit_notJavaName; public static String convention_classFile_nullName; Index: model/org/eclipse/jdt/internal/core/util/messages.properties =================================================================== RCS file: /home/eclipse/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/messages.properties,v retrieving revision 1.44 diff -u -r1.44 messages.properties --- model/org/eclipse/jdt/internal/core/util/messages.properties 31 May 2005 15:34:07 -0000 1.44 +++ model/org/eclipse/jdt/internal/core/util/messages.properties 9 Jun 2005 14:35:01 -0000 @@ -178,6 +178,12 @@ ### access restrictions restrictedAccess_project = The type {0} is not accessible due to restriction on required project {1} restrictedAccess_library = The type {0} is not accessible due to restriction on required library {1} +restrictedAccess_constructor_project = The constructor {0} is not accessible due to restriction on required project {1} +restrictedAccess_constructor_library = The constructor {0} is not accessible due to restriction on required library {1} +restrictedAccess_field_project = The field {0} from the type {1} is not accessible due to restriction on required project {2} +restrictedAccess_field_library = The field {0} from the type {1} is not accessible due to restriction on required library {2} +restrictedAccess_method_project = The method {0} from the type {1} is not accessible due to restriction on required project {2} +restrictedAccess_method_library = The method {0} from the type {1} is not accessible due to restriction on required library {2} ### java conventions convention_unit_nullName = Compilation unit name must not be null