1 72 package org.eclipse.jdt.core; 73 74 import java.io.File ; 75 import java.util.ArrayList ; 76 import java.util.HashMap ; 77 import java.util.Hashtable ; 78 import java.util.Map ; 79 80 import org.eclipse.core.resources.IContainer; 81 import org.eclipse.core.resources.IFile; 82 import org.eclipse.core.resources.IFolder; 83 import org.eclipse.core.resources.IMarker; 84 import org.eclipse.core.resources.IMarkerDelta; 85 import org.eclipse.core.resources.IProject; 86 import org.eclipse.core.resources.IResource; 87 import org.eclipse.core.resources.IResourceChangeEvent; 88 import org.eclipse.core.resources.IResourceChangeListener; 89 import org.eclipse.core.resources.IWorkspace; 90 import org.eclipse.core.resources.IWorkspaceRoot; 91 import org.eclipse.core.resources.IWorkspaceRunnable; 92 import org.eclipse.core.resources.ResourcesPlugin; 93 import org.eclipse.core.runtime.Assert; 94 import org.eclipse.core.runtime.CoreException; 95 import org.eclipse.core.runtime.IConfigurationElement; 96 import org.eclipse.core.runtime.IExtension; 97 import org.eclipse.core.runtime.IExtensionPoint; 98 import org.eclipse.core.runtime.IPath; 99 import org.eclipse.core.runtime.IProgressMonitor; 100 import org.eclipse.core.runtime.OperationCanceledException; 101 import org.eclipse.core.runtime.Platform; 102 import org.eclipse.core.runtime.Plugin; 103 import org.eclipse.core.runtime.QualifiedName; 104 import org.eclipse.core.runtime.SubProgressMonitor; 105 import org.eclipse.core.runtime.jobs.ISchedulingRule; 106 import org.eclipse.jdt.core.compiler.CharOperation; 107 import org.eclipse.jdt.core.search.IJavaSearchConstants; 108 import org.eclipse.jdt.core.search.IJavaSearchScope; 109 import org.eclipse.jdt.core.search.SearchEngine; 110 import org.eclipse.jdt.core.search.SearchPattern; 111 import org.eclipse.jdt.core.search.TypeNameRequestor; 112 import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants; 113 import org.eclipse.jdt.internal.compiler.impl.CompilerOptions; 114 import org.eclipse.jdt.internal.compiler.util.SuffixConstants; 115 import org.eclipse.jdt.internal.core.*; 116 import org.eclipse.jdt.internal.core.builder.JavaBuilder; 117 import org.eclipse.jdt.internal.core.builder.State; 118 import org.eclipse.jdt.internal.core.util.MementoTokenizer; 119 import org.eclipse.jdt.internal.core.util.Messages; 120 import org.eclipse.jdt.internal.core.util.Util; 121 import org.osgi.framework.BundleContext; 122 123 139 public final class JavaCore extends Plugin { 140 141 private static final IResource[] NO_GENERATED_RESOURCES = new IResource[0]; 142 143 private static Plugin JAVA_CORE_PLUGIN = null; 144 148 public static final String PLUGIN_ID = "org.eclipse.jdt.core" ; 150 154 public static final String BUILDER_ID = PLUGIN_ID + ".javabuilder" ; 156 160 public static final String MODEL_ID = PLUGIN_ID + ".javamodel" ; 162 170 public static final String NATURE_ID = PLUGIN_ID + ".javanature" ; 172 175 protected static final String ATT_HANDLE_ID = 176 "org.eclipse.jdt.internal.core.JavaModelManager.handleId" ; 178 182 public static final String USER_LIBRARY_CONTAINER_ID= "org.eclipse.jdt.USER_LIBRARY"; 184 186 190 public static final String COMPILER_LOCAL_VARIABLE_ATTR = PLUGIN_ID + ".compiler.debug.localVariable"; 195 public static final String COMPILER_LINE_NUMBER_ATTR = PLUGIN_ID + ".compiler.debug.lineNumber"; 200 public static final String COMPILER_SOURCE_FILE_ATTR = PLUGIN_ID + ".compiler.debug.sourceFile"; 205 public static final String COMPILER_CODEGEN_UNUSED_LOCAL = PLUGIN_ID + ".compiler.codegen.unusedLocal"; 210 public static final String COMPILER_CODEGEN_TARGET_PLATFORM = PLUGIN_ID + ".compiler.codegen.targetPlatform"; 216 public static final String COMPILER_CODEGEN_INLINE_JSR_BYTECODE = PLUGIN_ID + ".compiler.codegen.inlineJsrBytecode"; 222 public static final String COMPILER_DOC_COMMENT_SUPPORT = PLUGIN_ID + ".compiler.doc.comment.support"; 228 public static final String COMPILER_PB_UNREACHABLE_CODE = PLUGIN_ID + ".compiler.problem.unreachableCode"; 234 public static final String COMPILER_PB_INVALID_IMPORT = PLUGIN_ID + ".compiler.problem.invalidImport"; 239 public static final String COMPILER_PB_OVERRIDING_PACKAGE_DEFAULT_METHOD = PLUGIN_ID + ".compiler.problem.overridingPackageDefaultMethod"; 244 public static final String COMPILER_PB_METHOD_WITH_CONSTRUCTOR_NAME = PLUGIN_ID + ".compiler.problem.methodWithConstructorName"; 249 public static final String COMPILER_PB_DEPRECATION = PLUGIN_ID + ".compiler.problem.deprecation"; 255 public static final String COMPILER_PB_DEPRECATION_IN_DEPRECATED_CODE = PLUGIN_ID + ".compiler.problem.deprecationInDeprecatedCode"; 261 public static final String COMPILER_PB_DEPRECATION_WHEN_OVERRIDING_DEPRECATED_METHOD = "org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod"; 266 public static final String COMPILER_PB_HIDDEN_CATCH_BLOCK = PLUGIN_ID + ".compiler.problem.hiddenCatchBlock"; 271 public static final String COMPILER_PB_UNUSED_LOCAL = PLUGIN_ID + ".compiler.problem.unusedLocal"; 276 public static final String COMPILER_PB_UNUSED_PARAMETER = PLUGIN_ID + ".compiler.problem.unusedParameter"; 282 public static final String COMPILER_PB_UNUSED_PARAMETER_WHEN_IMPLEMENTING_ABSTRACT = PLUGIN_ID + ".compiler.problem.unusedParameterWhenImplementingAbstract"; 288 public static final String COMPILER_PB_UNUSED_PARAMETER_WHEN_OVERRIDING_CONCRETE = PLUGIN_ID + ".compiler.problem.unusedParameterWhenOverridingConcrete"; 294 public static final String COMPILER_PB_UNUSED_PARAMETER_INCLUDE_DOC_COMMENT_REFERENCE = PLUGIN_ID + ".compiler.problem.unusedParameterIncludeDocCommentReference"; 300 public static final String COMPILER_PB_UNUSED_IMPORT = PLUGIN_ID + ".compiler.problem.unusedImport"; 305 public static final String COMPILER_PB_SYNTHETIC_ACCESS_EMULATION = PLUGIN_ID + ".compiler.problem.syntheticAccessEmulation"; 311 public static final String COMPILER_PB_NON_NLS_STRING_LITERAL = PLUGIN_ID + ".compiler.problem.nonExternalizedStringLiteral"; 317 public static final String COMPILER_PB_ASSERT_IDENTIFIER = PLUGIN_ID + ".compiler.problem.assertIdentifier"; 323 public static final String COMPILER_PB_ENUM_IDENTIFIER = PLUGIN_ID + ".compiler.problem.enumIdentifier"; 329 public static final String COMPILER_PB_STATIC_ACCESS_RECEIVER = PLUGIN_ID + ".compiler.problem.staticAccessReceiver"; 335 public static final String COMPILER_PB_INDIRECT_STATIC_ACCESS = PLUGIN_ID + ".compiler.problem.indirectStaticAccess"; 341 public static final String COMPILER_PB_NO_EFFECT_ASSIGNMENT = PLUGIN_ID + ".compiler.problem.noEffectAssignment"; 347 public static final String COMPILER_PB_INCOMPATIBLE_NON_INHERITED_INTERFACE_METHOD = PLUGIN_ID + ".compiler.problem.incompatibleNonInheritedInterfaceMethod"; 353 public static final String COMPILER_PB_UNUSED_PRIVATE_MEMBER = PLUGIN_ID + ".compiler.problem.unusedPrivateMember"; 359 public static final String COMPILER_PB_LOCAL_VARIABLE_HIDING = PLUGIN_ID + ".compiler.problem.localVariableHiding"; 365 public static final String COMPILER_PB_SPECIAL_PARAMETER_HIDING_FIELD = PLUGIN_ID + ".compiler.problem.specialParameterHidingField"; 371 public static final String COMPILER_PB_FIELD_HIDING = PLUGIN_ID + ".compiler.problem.fieldHiding"; 377 public static final String COMPILER_PB_TYPE_PARAMETER_HIDING = PLUGIN_ID + ".compiler.problem.typeParameterHiding"; 383 public static final String COMPILER_PB_POSSIBLE_ACCIDENTAL_BOOLEAN_ASSIGNMENT = PLUGIN_ID + ".compiler.problem.possibleAccidentalBooleanAssignment"; 389 public static final String COMPILER_PB_FALLTHROUGH_CASE = PLUGIN_ID + ".compiler.problem.fallthroughCase"; 395 public static final String COMPILER_PB_EMPTY_STATEMENT = PLUGIN_ID + ".compiler.problem.emptyStatement"; 401 public static final String COMPILER_PB_BOOLEAN_METHOD_THROWING_EXCEPTION = PLUGIN_ID + ".compiler.problem.booleanMethodThrowingException"; 407 public static final String COMPILER_PB_UNNECESSARY_TYPE_CHECK = PLUGIN_ID + ".compiler.problem.unnecessaryTypeCheck"; 413 public static final String COMPILER_PB_UNNECESSARY_ELSE = PLUGIN_ID + ".compiler.problem.unnecessaryElse"; 419 public static final String COMPILER_PB_UNDOCUMENTED_EMPTY_BLOCK = PLUGIN_ID + ".compiler.problem.undocumentedEmptyBlock"; 425 public static final String COMPILER_PB_FINALLY_BLOCK_NOT_COMPLETING = PLUGIN_ID + ".compiler.problem.finallyBlockNotCompletingNormally"; 431 public static final String COMPILER_PB_UNUSED_DECLARED_THROWN_EXCEPTION = PLUGIN_ID + ".compiler.problem.unusedDeclaredThrownException"; 437 public static final String COMPILER_PB_UNUSED_DECLARED_THROWN_EXCEPTION_WHEN_OVERRIDING = PLUGIN_ID + ".compiler.problem.unusedDeclaredThrownExceptionWhenOverriding"; 443 public static final String COMPILER_PB_UNQUALIFIED_FIELD_ACCESS = PLUGIN_ID + ".compiler.problem.unqualifiedFieldAccess"; 450 public static final String COMPILER_PB_UNSAFE_TYPE_OPERATION = PLUGIN_ID + ".compiler.problem.uncheckedTypeOperation"; 456 public static final String COMPILER_PB_UNCHECKED_TYPE_OPERATION = PLUGIN_ID + ".compiler.problem.uncheckedTypeOperation"; 462 public static final String COMPILER_PB_RAW_TYPE_REFERENCE = PLUGIN_ID + ".compiler.problem.rawTypeReference"; 468 public static final String COMPILER_PB_FINAL_PARAMETER_BOUND = PLUGIN_ID + ".compiler.problem.finalParameterBound"; 474 public static final String COMPILER_PB_MISSING_SERIAL_VERSION = PLUGIN_ID + ".compiler.problem.missingSerialVersion"; 480 public static final String COMPILER_PB_VARARGS_ARGUMENT_NEED_CAST = PLUGIN_ID + ".compiler.problem.varargsArgumentNeedCast"; 486 public static final String COMPILER_PB_AUTOBOXING = PLUGIN_ID + ".compiler.problem.autoboxing"; 492 public static final String COMPILER_PB_ANNOTATION_SUPER_INTERFACE = PLUGIN_ID + ".compiler.problem.annotationSuperInterface"; 498 public static final String COMPILER_PB_MISSING_OVERRIDE_ANNOTATION = PLUGIN_ID + ".compiler.problem.missingOverrideAnnotation"; 504 public static final String COMPILER_PB_MISSING_DEPRECATED_ANNOTATION = PLUGIN_ID + ".compiler.problem.missingDeprecatedAnnotation"; 510 public static final String COMPILER_PB_INCOMPLETE_ENUM_SWITCH = PLUGIN_ID + ".compiler.problem.incompleteEnumSwitch"; 516 public static final String COMPILER_PB_INCONSISTENT_NULL_CHECK = PLUGIN_ID + ".compiler.problem.inconsistentNullCheck"; 522 public static final String COMPILER_PB_UNUSED_LABEL = PLUGIN_ID + ".compiler.problem.unusedLabel"; 528 public static final String COMPILER_PB_INVALID_JAVADOC = PLUGIN_ID + ".compiler.problem.invalidJavadoc"; 534 public static final String COMPILER_PB_INVALID_JAVADOC_TAGS = PLUGIN_ID + ".compiler.problem.invalidJavadocTags"; 540 public static final String COMPILER_PB_INVALID_JAVADOC_TAGS__DEPRECATED_REF = PLUGIN_ID + ".compiler.problem.invalidJavadocTagsDeprecatedRef"; 546 public static final String COMPILER_PB_INVALID_JAVADOC_TAGS__NOT_VISIBLE_REF = PLUGIN_ID + ".compiler.problem.invalidJavadocTagsNotVisibleRef"; 552 public static final String COMPILER_PB_INVALID_JAVADOC_TAGS_VISIBILITY = PLUGIN_ID + ".compiler.problem.invalidJavadocTagsVisibility"; 558 public static final String COMPILER_PB_MISSING_JAVADOC_TAGS = PLUGIN_ID + ".compiler.problem.missingJavadocTags"; 564 public static final String COMPILER_PB_MISSING_JAVADOC_TAGS_VISIBILITY = PLUGIN_ID + ".compiler.problem.missingJavadocTagsVisibility"; 570 public static final String COMPILER_PB_MISSING_JAVADOC_TAGS_OVERRIDING = PLUGIN_ID + ".compiler.problem.missingJavadocTagsOverriding"; 576 public static final String COMPILER_PB_MISSING_JAVADOC_COMMENTS = PLUGIN_ID + ".compiler.problem.missingJavadocComments"; 582 public static final String COMPILER_PB_MISSING_JAVADOC_COMMENTS_VISIBILITY = PLUGIN_ID + ".compiler.problem.missingJavadocCommentsVisibility"; 588 public static final String COMPILER_PB_MISSING_JAVADOC_COMMENTS_OVERRIDING = PLUGIN_ID + ".compiler.problem.missingJavadocCommentsOverriding"; 594 public static final String COMPILER_PB_CHAR_ARRAY_IN_STRING_CONCATENATION = PLUGIN_ID + ".compiler.problem.noImplicitStringConversion"; 600 public static final String COMPILER_PB_MAX_PER_UNIT = PLUGIN_ID + ".compiler.maxProblemPerUnit"; 606 public static final String COMPILER_PB_FATAL_OPTIONAL_ERROR = PLUGIN_ID + ".compiler.problem.fatalOptionalError"; 612 public static final String COMPILER_PB_PARAMETER_ASSIGNMENT = PLUGIN_ID + ".compiler.problem.parameterAssignment"; 618 public static final String COMPILER_SOURCE = PLUGIN_ID + ".compiler.source"; 624 public static final String COMPILER_COMPLIANCE = PLUGIN_ID + ".compiler.compliance"; 630 public static final String COMPILER_TASK_PRIORITIES = PLUGIN_ID + ".compiler.taskPriorities"; 636 public static final String COMPILER_TASK_PRIORITY_HIGH = "HIGH"; 642 public static final String COMPILER_TASK_PRIORITY_LOW = "LOW"; 648 public static final String COMPILER_TASK_PRIORITY_NORMAL = "NORMAL"; 654 public static final String COMPILER_TASK_TAGS = PLUGIN_ID + ".compiler.taskTags"; 660 public static final String COMPILER_TASK_CASE_SENSITIVE = PLUGIN_ID + ".compiler.taskCaseSensitive"; 666 public static final String COMPILER_PB_FORBIDDEN_REFERENCE = PLUGIN_ID + ".compiler.problem.forbiddenReference"; 672 public static final String COMPILER_PB_DISCOURAGED_REFERENCE = PLUGIN_ID + ".compiler.problem.discouragedReference"; 678 public static final String COMPILER_PB_SUPPRESS_WARNINGS = PLUGIN_ID + ".compiler.problem.suppressWarnings"; 684 public static final String COMPILER_PB_UNHANDLED_WARNING_TOKEN = PLUGIN_ID + ".compiler.problem.unhandledWarningToken"; 690 public static final String COMPILER_PB_NULL_REFERENCE = PLUGIN_ID + ".compiler.problem.nullReference"; 696 public static final String COMPILER_PB_POTENTIAL_NULL_REFERENCE = PLUGIN_ID + ".compiler.problem.potentialNullReference"; 702 public static final String COMPILER_PB_REDUNDANT_NULL_CHECK = PLUGIN_ID + ".compiler.problem.redundantNullCheck"; 708 public static final String COMPILER_PB_OVERRIDING_METHOD_WITHOUT_SUPER_INVOCATION = PLUGIN_ID + ".compiler.problem.overridingMethodWithoutSuperInvocation"; 713 public static final String CORE_JAVA_BUILD_ORDER = PLUGIN_ID + ".computeJavaBuildOrder"; 719 public static final String CORE_JAVA_BUILD_RESOURCE_COPY_FILTER = PLUGIN_ID + ".builder.resourceCopyExclusionFilter"; 725 public static final String CORE_JAVA_BUILD_DUPLICATE_RESOURCE = PLUGIN_ID + ".builder.duplicateResourceTask"; 731 public static final String CORE_JAVA_BUILD_CLEAN_OUTPUT_FOLDER = PLUGIN_ID + ".builder.cleanOutputFolder"; 737 public static final String CORE_JAVA_BUILD_RECREATE_MODIFIED_CLASS_FILES_IN_OUTPUT_FOLDER = PLUGIN_ID + ".builder.recreateModifiedClassFileInOutputFolder"; 743 public static final String CORE_INCOMPLETE_CLASSPATH = PLUGIN_ID + ".incompleteClasspath"; 749 public static final String CORE_CIRCULAR_CLASSPATH = PLUGIN_ID + ".circularClasspath"; 755 public static final String CORE_INCOMPATIBLE_JDK_LEVEL = PLUGIN_ID + ".incompatibleJDKLevel"; 761 public static final String CORE_JAVA_BUILD_INVALID_CLASSPATH = PLUGIN_ID + ".builder.invalidClasspath"; 767 public static final String CORE_ENCODING = PLUGIN_ID + ".encoding"; 773 public static final String CORE_ENABLE_CLASSPATH_EXCLUSION_PATTERNS = PLUGIN_ID + ".classpath.exclusionPatterns"; 779 public static final String CORE_ENABLE_CLASSPATH_MULTIPLE_OUTPUT_LOCATIONS = PLUGIN_ID + ".classpath.multipleOutputLocations"; 785 public static final String DEFAULT_TASK_TAG = "TODO"; 791 public static final String DEFAULT_TASK_PRIORITY = "NORMAL"; 796 public static final String DEFAULT_TASK_TAGS = "TODO,FIXME,XXX"; 801 public static final String DEFAULT_TASK_PRIORITIES = "NORMAL,HIGH,NORMAL"; 813 public static final String FORMATTER_NEWLINE_OPENING_BRACE = PLUGIN_ID + ".formatter.newline.openingBrace"; 823 public static final String FORMATTER_NEWLINE_CONTROL = PLUGIN_ID + ".formatter.newline.controlStatement"; 830 public static final String FORMATTER_NEWLINE_ELSE_IF = PLUGIN_ID + ".formatter.newline.elseIf"; 837 public static final String FORMATTER_NEWLINE_EMPTY_BLOCK = PLUGIN_ID + ".formatter.newline.emptyBlock"; 844 public static final String FORMATTER_CLEAR_BLANK_LINES = PLUGIN_ID + ".formatter.newline.clearAll"; 851 public static final String FORMATTER_LINE_SPLIT = PLUGIN_ID + ".formatter.lineSplit"; 858 public static final String FORMATTER_COMPACT_ASSIGNMENT = PLUGIN_ID + ".formatter.style.assignment"; 865 public static final String FORMATTER_TAB_CHAR = PLUGIN_ID + ".formatter.tabulation.char"; 872 public static final String FORMATTER_TAB_SIZE = PLUGIN_ID + ".formatter.tabulation.size"; 879 public static final String FORMATTER_SPACE_CASTEXPRESSION = PLUGIN_ID + ".formatter.space.castexpression"; 885 public static final String CODEASSIST_VISIBILITY_CHECK = PLUGIN_ID + ".codeComplete.visibilityCheck"; 891 public static final String CODEASSIST_DEPRECATION_CHECK = PLUGIN_ID + ".codeComplete.deprecationCheck"; 897 public static final String CODEASSIST_CAMEL_CASE_MATCH = PLUGIN_ID + ".codeComplete.camelCaseMatch"; 903 public static final String CODEASSIST_IMPLICIT_QUALIFICATION = PLUGIN_ID + ".codeComplete.forceImplicitQualification"; 909 public static final String CODEASSIST_FIELD_PREFIXES = PLUGIN_ID + ".codeComplete.fieldPrefixes"; 915 public static final String CODEASSIST_STATIC_FIELD_PREFIXES = PLUGIN_ID + ".codeComplete.staticFieldPrefixes"; 921 public static final String CODEASSIST_LOCAL_PREFIXES = PLUGIN_ID + ".codeComplete.localPrefixes"; 927 public static final String CODEASSIST_ARGUMENT_PREFIXES = PLUGIN_ID + ".codeComplete.argumentPrefixes"; 933 public static final String CODEASSIST_FIELD_SUFFIXES = PLUGIN_ID + ".codeComplete.fieldSuffixes"; 939 public static final String CODEASSIST_STATIC_FIELD_SUFFIXES = PLUGIN_ID + ".codeComplete.staticFieldSuffixes"; 945 public static final String CODEASSIST_LOCAL_SUFFIXES = PLUGIN_ID + ".codeComplete.localSuffixes"; 951 public static final String CODEASSIST_ARGUMENT_SUFFIXES = PLUGIN_ID + ".codeComplete.argumentSuffixes"; 957 public static final String CODEASSIST_FORBIDDEN_REFERENCE_CHECK= PLUGIN_ID + ".codeComplete.forbiddenReferenceCheck"; 963 public static final String CODEASSIST_DISCOURAGED_REFERENCE_CHECK= PLUGIN_ID + ".codeComplete.discouragedReferenceCheck"; 969 public static final String CODEASSIST_SUGGEST_STATIC_IMPORTS= PLUGIN_ID + ".codeComplete.suggestStaticImports"; 975 public static final String TIMEOUT_FOR_PARAMETER_NAME_FROM_ATTACHED_JAVADOC = PLUGIN_ID + ".timeoutForParameterNameFromAttachedJavadoc"; 977 981 public static final String GENERATE = "generate"; 986 public static final String DO_NOT_GENERATE = "do not generate"; 991 public static final String PRESERVE = "preserve"; 996 public static final String OPTIMIZE_OUT = "optimize out"; 1001 public static final String VERSION_1_1 = "1.1"; 1006 public static final String VERSION_1_2 = "1.2"; 1012 public static final String VERSION_1_3 = "1.3"; 1018 public static final String VERSION_1_4 = "1.4"; 1024 public static final String VERSION_1_5 = "1.5"; 1030 public static final String VERSION_1_6 = "1.6"; 1036 public static final String VERSION_1_7 = "1.7"; 1042 public static final String ABORT = "abort"; 1047 public static final String ERROR = "error"; 1052 public static final String WARNING = "warning"; 1057 public static final String IGNORE = "ignore"; 1062 public static final String COMPUTE = "compute"; 1068 public static final String INSERT = "insert"; 1074 public static final String DO_NOT_INSERT = "do not insert"; 1080 public static final String PRESERVE_ONE = "preserve one"; 1086 public static final String CLEAR_ALL = "clear all"; 1092 public static final String NORMAL = "normal"; 1098 public static final String COMPACT = "compact"; 1104 public static final String TAB = "tab"; 1110 public static final String SPACE = "space"; 1116 public static final String ENABLED = "enabled"; 1122 public static final String DISABLED = "disabled"; 1128 public static final String CLEAN = "clean"; 1134 public static final String PUBLIC = "public"; 1140 public static final String PROTECTED = "protected"; 1146 public static final String DEFAULT = "default"; 1152 public static final String PRIVATE = "private"; 1158 public static final String NEVER = "never"; 1160 1168 public static final String JAVA_SOURCE_CONTENT_TYPE = JavaCore.PLUGIN_ID+".javaSource" ; 1170 1179 public JavaCore() { 1180 super(); 1181 JAVA_CORE_PLUGIN = this; 1182 } 1183 1184 1196 public static void addElementChangedListener(IElementChangedListener listener) { 1197 addElementChangedListener(listener, ElementChangedEvent.POST_CHANGE | ElementChangedEvent.POST_RECONCILE); 1198 } 1199 1200 1226 public static void addElementChangedListener(IElementChangedListener listener, int eventMask) { 1227 JavaModelManager.getJavaModelManager().deltaState.addElementChangedListener(listener, eventMask); 1228 } 1229 1230 1238 public static void addJavaElementMarkerAttributes( 1239 Map attributes, 1240 IJavaElement element) { 1241 if (element instanceof IMember) 1242 element = ((IMember) element).getClassFile(); 1243 if (attributes != null && element != null) 1244 attributes.put(ATT_HANDLE_ID, element.getHandleIdentifier()); 1245 } 1246 1247 private static void addNonJavaResources(Object [] nonJavaResources, 1248 IContainer container, 1249 int rootPathSegmentCounts, 1250 ArrayList collector) { 1251 for (int i = 0, max = nonJavaResources.length; i < max; i++) { 1252 Object nonJavaResource = nonJavaResources[i]; 1253 if (nonJavaResource instanceof IFile) { 1254 IFile file = (IFile) nonJavaResource; 1255 IPath path = file.getFullPath().removeFirstSegments(rootPathSegmentCounts); 1256 IResource member = container.findMember(path); 1257 if (member != null && member.exists()) { 1258 collector.add(member); 1259 } 1260 } else if (nonJavaResource instanceof IFolder) { 1261 IFolder folder = (IFolder) nonJavaResource; 1262 IResource[] members = null; 1263 try { 1264 members = folder.members(); 1265 } catch (CoreException e) { 1266 } 1268 if (members != null) { 1269 addNonJavaResources(members, container, rootPathSegmentCounts, collector); 1270 } 1271 } 1272 } 1273 } 1274 1275 1288 public static void addPreProcessingResourceChangedListener(IResourceChangeListener listener) { 1289 addPreProcessingResourceChangedListener(listener, IResourceChangeEvent.POST_CHANGE); 1290 } 1291 1292 1319 public static void addPreProcessingResourceChangedListener(IResourceChangeListener listener, int eventMask) { 1320 JavaModelManager.getJavaModelManager().deltaState.addPreResourceChangedListener(listener, eventMask); 1321 } 1322 1323 1331 public void configureJavaElementMarker(IMarker marker, IJavaElement element) 1332 throws CoreException { 1333 if (element instanceof IMember) 1334 element = ((IMember) element).getClassFile(); 1335 if (marker != null && element != null) 1336 marker.setAttribute(ATT_HANDLE_ID, element.getHandleIdentifier()); 1337 } 1338 1339 1347 public static IJavaElement create(String handleIdentifier) { 1348 return create(handleIdentifier, DefaultWorkingCopyOwner.PRIMARY); 1349 } 1350 1351 1365 public static IJavaElement create(String handleIdentifier, WorkingCopyOwner owner) { 1366 if (handleIdentifier == null) { 1367 return null; 1368 } 1369 MementoTokenizer memento = new MementoTokenizer(handleIdentifier); 1370 JavaModel model = JavaModelManager.getJavaModelManager().getJavaModel(); 1371 return model.getHandleFromMemento(memento, owner); 1372 } 1373 1374 1394 public static IJavaElement create(IFile file) { 1395 return JavaModelManager.create(file, null); 1396 } 1397 1410 public static IJavaElement create(IFolder folder) { 1411 return JavaModelManager.create(folder, null); 1412 } 1413 1424 public static IJavaProject create(IProject project) { 1425 if (project == null) { 1426 return null; 1427 } 1428 JavaModel javaModel = JavaModelManager.getJavaModelManager().getJavaModel(); 1429 return javaModel.getJavaProject(project); 1430 } 1431 1455 public static IJavaElement create(IResource resource) { 1456 return JavaModelManager.create(resource, null); 1457 } 1458 1483 public static IJavaElement create(IResource resource, IJavaProject project) { 1484 return JavaModelManager.create(resource, project); 1485 } 1486 1492 public static IJavaModel create(IWorkspaceRoot root) { 1493 if (root == null) { 1494 return null; 1495 } 1496 return JavaModelManager.getJavaModelManager().getJavaModel(); 1497 } 1498 1507 public static IClassFile createClassFileFrom(IFile file) { 1508 return JavaModelManager.createClassFileFrom(file, null); 1509 } 1510 1520 public static ICompilationUnit createCompilationUnitFrom(IFile file) { 1521 return JavaModelManager.createCompilationUnitFrom(file, null); 1522 } 1523 1532 public static IPackageFragmentRoot createJarPackageFragmentRootFrom(IFile file) { 1533 return JavaModelManager.createJarPackageFragmentRootFrom(file, null); 1534 } 1535 1536 1568 public static IClasspathContainer getClasspathContainer(IPath containerPath, IJavaProject project) throws JavaModelException { 1569 1570 JavaModelManager manager = JavaModelManager.getJavaModelManager(); 1571 IClasspathContainer container = manager.getClasspathContainer(containerPath, project); 1572 if (container == JavaModelManager.CONTAINER_INITIALIZATION_IN_PROGRESS) { 1573 return manager.getPreviousSessionContainer(containerPath, project); 1574 } 1575 return container; 1576 } 1577 1578 1590 public static ClasspathContainerInitializer getClasspathContainerInitializer(String containerID) { 1591 HashMap containerInitializersCache = JavaModelManager.getJavaModelManager().containerInitializersCache; 1592 ClasspathContainerInitializer initializer = (ClasspathContainerInitializer) containerInitializersCache.get(containerID); 1593 if (initializer == null) { 1594 initializer = computeClasspathContainerInitializer(containerID); 1595 if (initializer == null) 1596 return null; 1597 containerInitializersCache.put(containerID, initializer); 1598 } 1599 return initializer; 1600 } 1601 1602 private static ClasspathContainerInitializer computeClasspathContainerInitializer(String containerID) { 1603 Plugin jdtCorePlugin = JavaCore.getPlugin(); 1604 if (jdtCorePlugin == null) return null; 1605 1606 IExtensionPoint extension = Platform.getExtensionRegistry().getExtensionPoint(JavaCore.PLUGIN_ID, JavaModelManager.CPCONTAINER_INITIALIZER_EXTPOINT_ID); 1607 if (extension != null) { 1608 IExtension[] extensions = extension.getExtensions(); 1609 for(int i = 0; i < extensions.length; i++){ 1610 IConfigurationElement [] configElements = extensions[i].getConfigurationElements(); 1611 for(int j = 0; j < configElements.length; j++){ 1612 IConfigurationElement configurationElement = configElements[j]; 1613 String initializerID = configurationElement.getAttribute("id"); if (initializerID != null && initializerID.equals(containerID)){ 1615 if (JavaModelManager.CP_RESOLVE_VERBOSE_ADVANCED) 1616 verbose_found_container_initializer(containerID, configurationElement); 1617 try { 1618 Object execExt = configurationElement.createExecutableExtension("class"); if (execExt instanceof ClasspathContainerInitializer){ 1620 return (ClasspathContainerInitializer)execExt; 1621 } 1622 } catch(CoreException e) { 1623 if (JavaModelManager.CP_RESOLVE_VERBOSE) { 1625 verbose_failed_to_instanciate_container_initializer(containerID, configurationElement); 1626 e.printStackTrace(); 1627 } 1628 } 1629 } 1630 } 1631 } 1632 } 1633 return null; 1634 } 1635 1636 private static void verbose_failed_to_instanciate_container_initializer(String containerID, IConfigurationElement configurationElement) { 1637 Util.verbose( 1638 "CPContainer INIT - failed to instanciate initializer\n" + " container ID: " + containerID + '\n' + " class: " + configurationElement.getAttribute("class"), System.err); 1642 } 1643 1644 private static void verbose_found_container_initializer(String containerID, IConfigurationElement configurationElement) { 1645 Util.verbose( 1646 "CPContainer INIT - found initializer\n" + " container ID: " + containerID + '\n' + " class: " + configurationElement.getAttribute("class")); } 1650 1651 1668 public static IPath getClasspathVariable(final String variableName) { 1669 1670 JavaModelManager manager = JavaModelManager.getJavaModelManager(); 1671 IPath variablePath = manager.variableGet(variableName); 1672 if (variablePath == JavaModelManager.VARIABLE_INITIALIZATION_IN_PROGRESS){ 1673 return manager.getPreviousSessionVariable(variableName); 1674 } 1675 1676 if (variablePath != null) { 1677 if (variablePath == JavaModelManager.CP_ENTRY_IGNORE_PATH) 1678 return null; 1679 return variablePath; 1680 } 1681 1682 final ClasspathVariableInitializer initializer = JavaCore.getClasspathVariableInitializer(variableName); 1684 if (initializer != null){ 1685 if (JavaModelManager.CP_RESOLVE_VERBOSE) 1686 verbose_triggering_variable_initialization(variableName, initializer); 1687 if (JavaModelManager.CP_RESOLVE_VERBOSE_ADVANCED) 1688 verbose_triggering_variable_initialization_invocation_trace(); 1689 manager.variablePut(variableName, JavaModelManager.VARIABLE_INITIALIZATION_IN_PROGRESS); boolean ok = false; 1691 try { 1692 initializer.initialize(variableName); 1695 1696 variablePath = manager.variableGet(variableName); if (variablePath == JavaModelManager.VARIABLE_INITIALIZATION_IN_PROGRESS) return null; if (JavaModelManager.CP_RESOLVE_VERBOSE_ADVANCED) 1699 verbose_variable_value_after_initialization(variableName, variablePath); 1700 manager.variablesWithInitializer.add(variableName); 1701 ok = true; 1702 } catch (RuntimeException e) { 1703 if (JavaModelManager.CP_RESOLVE_VERBOSE) 1704 e.printStackTrace(); 1705 throw e; 1706 } catch (Error e) { 1707 if (JavaModelManager.CP_RESOLVE_VERBOSE) 1708 e.printStackTrace(); 1709 throw e; 1710 } finally { 1711 if (!ok) JavaModelManager.getJavaModelManager().variablePut(variableName, null); } 1713 } else { 1714 if (JavaModelManager.CP_RESOLVE_VERBOSE_ADVANCED) 1715 verbose_no_variable_initializer_found(variableName); 1716 } 1717 return variablePath; 1718 } 1719 1720 private static void verbose_no_variable_initializer_found(String variableName) { 1721 Util.verbose( 1722 "CPVariable INIT - no initializer found\n" + " variable: " + variableName); } 1725 1726 private static void verbose_variable_value_after_initialization(String variableName, IPath variablePath) { 1727 Util.verbose( 1728 "CPVariable INIT - after initialization\n" + " variable: " + variableName +'\n' + " variable path: " + variablePath); } 1732 1733 private static void verbose_triggering_variable_initialization(String variableName, ClasspathVariableInitializer initializer) { 1734 Util.verbose( 1735 "CPVariable INIT - triggering initialization\n" + " variable: " + variableName + '\n' + " initializer: " + initializer); } 1739 1740 private static void verbose_triggering_variable_initialization_invocation_trace() { 1741 Util.verbose( 1742 "CPVariable INIT - triggering initialization\n" + " invocation trace:"); new Exception ("<Fake exception>").printStackTrace(System.out); } 1746 1747 1754 public static String getClasspathVariableDeprecationMessage(String variableName) { 1755 return (String ) JavaModelManager.getJavaModelManager().deprecatedVariables.get(variableName); 1756 } 1757 1758 1768 public static ClasspathVariableInitializer getClasspathVariableInitializer(String variable){ 1769 1770 Plugin jdtCorePlugin = JavaCore.getPlugin(); 1771 if (jdtCorePlugin == null) return null; 1772 1773 IExtensionPoint extension = Platform.getExtensionRegistry().getExtensionPoint(JavaCore.PLUGIN_ID, JavaModelManager.CPVARIABLE_INITIALIZER_EXTPOINT_ID); 1774 if (extension != null) { 1775 IExtension[] extensions = extension.getExtensions(); 1776 for(int i = 0; i < extensions.length; i++){ 1777 IConfigurationElement [] configElements = extensions[i].getConfigurationElements(); 1778 for(int j = 0; j < configElements.length; j++){ 1779 IConfigurationElement configElement = configElements[j]; 1780 try { 1781 String varAttribute = configElement.getAttribute("variable"); if (variable.equals(varAttribute)) { 1783 if (JavaModelManager.CP_RESOLVE_VERBOSE_ADVANCED) 1784 verbose_found_variable_initializer(variable, configElement); 1785 Object execExt = configElement.createExecutableExtension("class"); if (execExt instanceof ClasspathVariableInitializer){ 1787 ClasspathVariableInitializer initializer = (ClasspathVariableInitializer)execExt; 1788 String deprecatedAttribute = configElement.getAttribute("deprecated"); if (deprecatedAttribute != null) { 1790 JavaModelManager.getJavaModelManager().deprecatedVariables.put(variable, deprecatedAttribute); 1791 } 1792 String readOnlyAttribute = configElement.getAttribute("readOnly"); if (JavaModelManager.TRUE.equals(readOnlyAttribute)) { 1794 JavaModelManager.getJavaModelManager().readOnlyVariables.add(variable); 1795 } 1796 return initializer; 1797 } 1798 } 1799 } catch(CoreException e){ 1800 if (JavaModelManager.CP_RESOLVE_VERBOSE) { 1802 verbose_failed_to_instanciate_variable_initializer(variable, configElement); 1803 e.printStackTrace(); 1804 } 1805 } 1806 } 1807 } 1808 } 1809 return null; 1810 } 1811 1812 private static void verbose_failed_to_instanciate_variable_initializer(String variable, IConfigurationElement configElement) { 1813 Util.verbose( 1814 "CPContainer INIT - failed to instanciate initializer\n" + " variable: " + variable + '\n' + " class: " + configElement.getAttribute("class"), System.err); 1818 } 1819 1820 private static void verbose_found_variable_initializer(String variable, IConfigurationElement configElement) { 1821 Util.verbose( 1822 "CPVariable INIT - found initializer\n" + " variable: " + variable + '\n' + " class: " + configElement.getAttribute("class")); } 1826 1827 1837 public static String [] getClasspathVariableNames() { 1838 return JavaModelManager.getJavaModelManager().variableNames(); 1839 } 1840 1841 2751 public static Hashtable getDefaultOptions(){ 2752 return JavaModelManager.getJavaModelManager().getDefaultOptions(); 2753 } 2754 2755 2763 public static String getEncoding() { 2764 IWorkspace workspace = ResourcesPlugin.getWorkspace(); 2766 if (workspace != null) { 2767 try { 2768 return workspace.getRoot().getDefaultCharset(); 2769 } catch (CoreException e) { 2770 } 2772 } 2773 return ResourcesPlugin.getEncoding(); 2774 } 2775 2776 2797 public static IResource[] getGeneratedResources(IRegion region, boolean includesNonJavaResources) { 2798 if (region == null) throw new IllegalArgumentException ("region cannot be null"); IJavaElement[] elements = region.getElements(); 2800 HashMap projectsStates = new HashMap (); 2801 ArrayList collector = new ArrayList (); 2802 for (int i = 0, max = elements.length; i < max; i++) { 2803 IJavaElement element = elements[i]; 2805 IJavaProject javaProject = element.getJavaProject(); 2806 IProject project = javaProject.getProject(); 2807 State state = null; 2808 State currentState = (State) projectsStates.get(project); 2809 if (currentState != null) { 2810 state = currentState; 2811 } else { 2812 state = (State) JavaModelManager.getJavaModelManager().getLastBuiltState(project, null); 2813 if (state != null) { 2814 projectsStates.put(project, state); 2815 } 2816 } 2817 if (state == null) continue; 2818 if (element.getElementType() == IJavaElement.JAVA_PROJECT) { 2819 IPackageFragmentRoot[] roots = null; 2820 try { 2821 roots = javaProject.getPackageFragmentRoots(); 2822 } catch (JavaModelException e) { 2823 } 2825 if (roots == null) continue; 2826 IRegion region2 = JavaCore.newRegion(); 2827 for (int j = 0; j < roots.length; j++) { 2828 region2.add(roots[j]); 2829 } 2830 IResource[] res = getGeneratedResources(region2, includesNonJavaResources); 2831 for (int j = 0, max2 = res.length; j < max2; j++) { 2832 collector.add(res[j]); 2833 } 2834 continue; 2835 } 2836 IPath outputLocation = null; 2837 try { 2838 outputLocation = javaProject.getOutputLocation(); 2839 } catch (JavaModelException e) { 2840 } 2842 IJavaElement root = element; 2843 while (root != null && root.getElementType() != IJavaElement.PACKAGE_FRAGMENT_ROOT) { 2844 root = root.getParent(); 2845 } 2846 if (root == null) continue; 2847 IPackageFragmentRoot packageFragmentRoot = (IPackageFragmentRoot) root; 2848 int rootPathSegmentCounts = packageFragmentRoot.getPath().segmentCount(); 2849 try { 2850 IClasspathEntry entry = packageFragmentRoot.getRawClasspathEntry(); 2851 IPath entryOutputLocation = entry.getOutputLocation(); 2852 if (entryOutputLocation != null) { 2853 outputLocation = entryOutputLocation; 2854 } 2855 } catch (JavaModelException e) { 2856 e.printStackTrace(); 2857 } 2858 if (outputLocation == null) continue; 2859 IContainer container = (IContainer) project.getWorkspace().getRoot().findMember(outputLocation); 2860 switch(element.getElementType()) { 2861 case IJavaElement.COMPILATION_UNIT : 2862 ICompilationUnit unit = (ICompilationUnit) element; 2864 getGeneratedResource(unit, container, state, rootPathSegmentCounts, collector); 2865 break; 2866 case IJavaElement.PACKAGE_FRAGMENT : 2867 IPackageFragment fragment = (IPackageFragment) element; 2869 ICompilationUnit[] compilationUnits = null; 2870 try { 2871 compilationUnits = fragment.getCompilationUnits(); 2872 } catch (JavaModelException e) { 2873 } 2875 if (compilationUnits == null) continue; 2876 for (int j = 0, max2 = compilationUnits.length; j < max2; j++) { 2877 getGeneratedResource(compilationUnits[j], container, state, rootPathSegmentCounts, collector); 2878 } 2879 if (includesNonJavaResources) { 2880 Object [] nonJavaResources = null; 2882 try { 2883 nonJavaResources = fragment.getNonJavaResources(); 2884 } catch (JavaModelException e) { 2885 } 2887 if (nonJavaResources != null) { 2888 addNonJavaResources(nonJavaResources, container, rootPathSegmentCounts, collector); 2889 } 2890 } 2891 break; 2892 case IJavaElement.PACKAGE_FRAGMENT_ROOT : 2893 IPackageFragmentRoot fragmentRoot = (IPackageFragmentRoot) element; 2895 if (fragmentRoot.isArchive()) continue; 2896 IJavaElement[] children = null; 2897 try { 2898 children = fragmentRoot.getChildren(); 2899 } catch (JavaModelException e) { 2900 } 2902 if (children == null) continue; 2903 for (int j = 0, max2 = children.length; j < max2; j++) { 2904 fragment = (IPackageFragment) children[j]; 2905 ICompilationUnit[] units = null; 2906 try { 2907 units = fragment.getCompilationUnits(); 2908 } catch (JavaModelException e) { 2909 } 2911 if (units == null) continue; 2912 for (int n = 0, max3 = units.length; n < max3; n++) { 2913 getGeneratedResource(units[n], container, state, rootPathSegmentCounts, collector); 2914 } 2915 if (includesNonJavaResources) { 2916 Object [] nonJavaResources = null; 2918 try { 2919 nonJavaResources = fragment.getNonJavaResources(); 2920 } catch (JavaModelException e) { 2921 } 2923 if (nonJavaResources != null) { 2924 addNonJavaResources(nonJavaResources, container, rootPathSegmentCounts, collector); 2925 } 2926 } 2927 } 2928 break; 2929 } 2930 } 2931 int size = collector.size(); 2932 if (size != 0) { 2933 IResource[] result = new IResource[size]; 2934 collector.toArray(result); 2935 return result; 2936 } 2937 return NO_GENERATED_RESOURCES; 2938 } 2939 2940 private static void getGeneratedResource(ICompilationUnit unit, 2941 IContainer container, 2942 State state, 2943 int rootPathSegmentCounts, 2944 ArrayList collector) { 2945 IResource resource = unit.getResource(); 2946 char[][] typeNames = state.getDefinedTypeNamesFor(resource.getProjectRelativePath().toString()); 2947 if (typeNames != null) { 2948 IPath path = unit.getPath().removeFirstSegments(rootPathSegmentCounts).removeLastSegments(1); 2949 for (int j = 0, max2 = typeNames.length; j < max2; j++) { 2950 IPath localPath = path.append(new String (typeNames[j]) + ".class"); IResource member = container.findMember(localPath); 2952 if (member != null && member.exists()) { 2953 collector.add(member); 2954 } 2955 } 2956 } else { 2957 IPath path = unit.getPath().removeFirstSegments(rootPathSegmentCounts).removeLastSegments(1); 2958 path = path.append(Util.getNameWithoutJavaLikeExtension(unit.getElementName()) + ".class"); IResource member = container.findMember(path); 2960 if (member != null && member.exists()) { 2961 collector.add(member); 2962 } 2963 } 2964 } 2965 2966 2972 public static JavaCore getJavaCore() { 2973 return (JavaCore) getPlugin(); 2974 } 2975 2976 2986 public static String [] getJavaLikeExtensions() { 2987 return CharOperation.toStrings(Util.getJavaLikeExtensions()); 2988 } 2989 2990 3003 public static String getOption(String optionName) { 3004 return JavaModelManager.getJavaModelManager().getOption(optionName); 3005 } 3006 3007 3018 public static Hashtable getOptions() { 3019 return JavaModelManager.getJavaModelManager().getOptions(); 3020 } 3021 3022 3027 public static Plugin getPlugin() { 3028 return JAVA_CORE_PLUGIN; 3029 } 3030 3031 3053 public static IClasspathEntry getResolvedClasspathEntry(IClasspathEntry entry) { 3054 3055 if (entry.getEntryKind() != IClasspathEntry.CPE_VARIABLE) 3056 return entry; 3057 3058 IWorkspaceRoot workspaceRoot = ResourcesPlugin.getWorkspace().getRoot(); 3059 IPath resolvedPath = JavaCore.getResolvedVariablePath(entry.getPath()); 3060 if (resolvedPath == null) 3061 return null; 3062 3063 Object target = JavaModel.getTarget(workspaceRoot, resolvedPath, false); 3064 if (target == null) 3065 return null; 3066 3067 if (target instanceof IResource) { 3069 IResource resolvedResource = (IResource) target; 3070 switch (resolvedResource.getType()) { 3071 3072 case IResource.PROJECT : 3073 return JavaCore.newProjectEntry( 3075 resolvedPath, 3076 entry.getAccessRules(), 3077 entry.combineAccessRules(), 3078 entry.getExtraAttributes(), 3079 entry.isExported()); 3080 case IResource.FILE : 3081 if (org.eclipse.jdt.internal.compiler.util.Util.isArchiveFileName(resolvedResource.getName())) { 3082 return JavaCore.newLibraryEntry( 3084 resolvedPath, 3085 getResolvedVariablePath(entry.getSourceAttachmentPath()), 3086 getResolvedVariablePath(entry.getSourceAttachmentRootPath()), 3087 entry.getAccessRules(), 3088 entry.getExtraAttributes(), 3089 entry.isExported()); 3090 } 3091 break; 3092 3093 case IResource.FOLDER : 3094 return JavaCore.newLibraryEntry( 3096 resolvedPath, 3097 getResolvedVariablePath(entry.getSourceAttachmentPath()), 3098 getResolvedVariablePath(entry.getSourceAttachmentRootPath()), 3099 entry.getAccessRules(), 3100 entry.getExtraAttributes(), 3101 entry.isExported()); 3102 } 3103 } 3104 if (target instanceof File ) { 3106 File externalFile = JavaModel.getFile(target); 3107 if (externalFile != null) { 3108 String fileName = externalFile.getName().toLowerCase(); 3109 if (fileName.endsWith(SuffixConstants.SUFFIX_STRING_jar) || fileName.endsWith(SuffixConstants.SUFFIX_STRING_zip)) { 3110 return JavaCore.newLibraryEntry( 3112 resolvedPath, 3113 getResolvedVariablePath(entry.getSourceAttachmentPath()), 3114 getResolvedVariablePath(entry.getSourceAttachmentRootPath()), 3115 entry.getAccessRules(), 3116 entry.getExtraAttributes(), 3117 entry.isExported()); 3118 } 3119 } else { if (resolvedPath.isAbsolute()){ 3121 return JavaCore.newLibraryEntry( 3122 resolvedPath, 3123 getResolvedVariablePath(entry.getSourceAttachmentPath()), 3124 getResolvedVariablePath(entry.getSourceAttachmentRootPath()), 3125 entry.getAccessRules(), 3126 entry.getExtraAttributes(), 3127 entry.isExported()); 3128 } 3129 } 3130 } 3131 return null; 3132 } 3133 3134 3135 3141 public static IPath getResolvedVariablePath(IPath variablePath) { 3142 3143 if (variablePath == null) 3144 return null; 3145 int count = variablePath.segmentCount(); 3146 if (count == 0) 3147 return null; 3148 3149 String variableName = variablePath.segment(0); 3151 IPath resolvedPath = JavaCore.getClasspathVariable(variableName); 3152 if (resolvedPath == null) 3153 return null; 3154 3155 if (count > 1) { 3157 resolvedPath = resolvedPath.append(variablePath.removeFirstSegments(1)); 3158 } 3159 return resolvedPath; 3160 } 3161 3162 3172 public static IWorkingCopy[] getSharedWorkingCopies(IBufferFactory factory){ 3173 3174 if (factory == null) factory = BufferManager.getDefaultBufferManager().getDefaultBufferFactory(); 3176 3177 return getWorkingCopies(BufferFactoryWrapper.create(factory)); 3178 } 3179 3180 3186 public static String [] getUserLibraryNames() { 3187 return JavaModelManager.getUserLibraryManager().getUserLibraryNames(); 3188 } 3189 3190 3199 public static ICompilationUnit[] getWorkingCopies(WorkingCopyOwner owner){ 3200 3201 JavaModelManager manager = JavaModelManager.getJavaModelManager(); 3202 if (owner == null) owner = DefaultWorkingCopyOwner.PRIMARY; 3203 ICompilationUnit[] result = manager.getWorkingCopies(owner, false); 3204 if (result == null) return JavaModelManager.NO_WORKING_COPY; 3205 return result; 3206 } 3207 3208 3234 public static void initializeAfterLoad(IProgressMonitor monitor) throws CoreException { 3235 try { 3236 if (monitor != null) monitor.beginTask(Messages.javamodel_initialization, 100); 3237 3238 JavaModelManager manager = JavaModelManager.getJavaModelManager(); 3240 try { 3241 if (monitor != null) { 3242 monitor.subTask(Messages.javamodel_configuring_classpath_containers); 3243 manager.batchContainerInitializationsProgress.set(new SubProgressMonitor(monitor, 50)); } 3245 3246 manager.batchContainerInitializations = true; 3248 3249 IJavaProject[] projects = manager.getJavaModel().getJavaProjects(); 3251 for (int i = 0, length = projects.length; i < length; i++) { 3252 IClasspathEntry[] classpath; 3253 try { 3254 classpath = ((JavaProject) projects[i]).getResolvedClasspath(); 3255 } catch (JavaModelException e) { 3256 continue; 3258 } 3259 if (classpath != null) { 3260 for (int j = 0, length2 = classpath.length; j < length2; j++) { 3261 IClasspathEntry entry = classpath[j]; 3262 if (entry.getSourceAttachmentPath() != null) 3263 Util.setSourceAttachmentProperty(entry.getPath(), null); 3264 } 3266 } 3267 } 3268 3269 manager.deltaState.rootsAreStale = true; manager.deltaState.initializeRoots(); 3272 } finally { 3273 manager.batchContainerInitializationsProgress.set(null); 3274 } 3275 3276 SearchEngine engine = new SearchEngine(); 3278 IJavaSearchScope scope = SearchEngine.createWorkspaceScope(); 3279 try { 3280 if (monitor != null) 3281 monitor.subTask(Messages.javamodel_configuring_searchengine); 3282 engine.searchAllTypeNames( 3283 null, 3284 SearchPattern.R_EXACT_MATCH, 3285 "!@$#!@".toCharArray(), SearchPattern.R_PATTERN_MATCH | SearchPattern.R_CASE_SENSITIVE, 3287 IJavaSearchConstants.CLASS, 3288 scope, 3289 new TypeNameRequestor() { 3290 public void acceptType( 3291 int modifiers, 3292 char[] packageName, 3293 char[] simpleTypeName, 3294 char[][] enclosingTypeNames, 3295 String path) { 3296 } 3298 }, 3299 IJavaSearchConstants.CANCEL_IF_NOT_READY_TO_SEARCH, 3302 monitor == null ? null : new SubProgressMonitor(monitor, 49) ); 3304 } catch (JavaModelException e) { 3305 } catch (OperationCanceledException e) { 3307 if (monitor != null && monitor.isCanceled()) 3308 throw e; 3309 } 3311 3312 if (monitor != null) 3315 monitor.subTask(Messages.javamodel_getting_build_state_number); 3316 QualifiedName qName = new QualifiedName(JavaCore.PLUGIN_ID, "stateVersionNumber"); IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot(); 3318 String versionNumber = null; 3319 try { 3320 versionNumber = root.getPersistentProperty(qName); 3321 } catch (CoreException e) { 3322 } 3324 final JavaModel model = manager.getJavaModel(); 3325 String newVersionNumber = Byte.toString(State.VERSION); 3326 if (!newVersionNumber.equals(versionNumber)) { 3327 if (JavaBuilder.DEBUG) 3329 System.out.println("Build state version number has changed"); IWorkspaceRunnable runnable = new IWorkspaceRunnable() { 3331 public void run(IProgressMonitor progressMonitor2) throws CoreException { 3332 IJavaProject[] projects = null; 3333 try { 3334 projects = model.getJavaProjects(); 3335 } catch (JavaModelException e) { 3336 } 3338 if (projects != null) { 3339 for (int i = 0, length = projects.length; i < length; i++) { 3340 IJavaProject project = projects[i]; 3341 try { 3342 if (JavaBuilder.DEBUG) 3343 System.out.println("Touching " + project.getElementName()); project.getProject().touch(progressMonitor2); 3345 } catch (CoreException e) { 3346 } 3348 } 3349 } 3350 } 3351 }; 3352 if (monitor != null) 3353 monitor.subTask(Messages.javamodel_building_after_upgrade); 3354 try { 3355 ResourcesPlugin.getWorkspace().run(runnable, monitor); 3356 } catch (CoreException e) { 3357 } 3359 try { 3360 root.setPersistentProperty(qName, newVersionNumber); 3361 } catch (CoreException e) { 3362 Util.log(e, "Could not persist build state version number"); } 3364 } 3365 3366 try { 3368 if (monitor != null) 3369 monitor.subTask(Messages.javamodel_refreshing_external_jars); 3370 model.refreshExternalArchives( 3371 null, 3372 monitor == null ? null : new SubProgressMonitor(monitor, 1) ); 3374 } catch (JavaModelException e) { 3375 } 3377 3378 } finally { 3379 if (monitor != null) monitor.done(); 3380 } 3381 } 3382 3383 3391 public static boolean isClasspathVariableReadOnly(String variableName) { 3392 return JavaModelManager.getJavaModelManager().readOnlyVariables.contains(variableName); 3393 } 3394 3395 3402 public static boolean isJavaLikeFileName(String fileName) { 3403 return Util.isJavaLikeFileName(fileName); 3404 } 3405 3406 3415 public static boolean isReferencedBy(IJavaElement element, IMarker marker) throws CoreException { 3416 3417 if (element instanceof IMember){ 3419 IMember member = (IMember) element; 3420 if (member.isBinary()){ 3421 element = member.getClassFile(); 3422 } else { 3423 element = member.getCompilationUnit(); 3424 } 3425 } 3426 if (element == null) return false; 3427 if (marker == null) return false; 3428 3429 String markerHandleId = (String )marker.getAttribute(ATT_HANDLE_ID); 3430 if (markerHandleId == null) return false; 3431 3432 IJavaElement markerElement = JavaCore.create(markerHandleId); 3433 while (true){ 3434 if (element.equals(markerElement)) return true; 3436 if (markerElement instanceof IClassFile){ 3438 IType enclosingType = ((IClassFile)markerElement).getType().getDeclaringType(); 3439 if (enclosingType != null){ 3440 markerElement = enclosingType.getClassFile(); continue; 3442 } 3443 } 3444 break; 3445 } 3446 return false; 3447 } 3448 3449 3458 public static boolean isReferencedBy(IJavaElement element, IMarkerDelta markerDelta) throws CoreException { 3459 3460 if (element instanceof IMember){ 3462 IMember member = (IMember) element; 3463 if (member.isBinary()){ 3464 element = member.getClassFile(); 3465 } else { 3466 element = member.getCompilationUnit(); 3467 } 3468 } 3469 if (element == null) return false; 3470 if (markerDelta == null) return false; 3471 3472 String markerDeltarHandleId = (String )markerDelta.getAttribute(ATT_HANDLE_ID); 3473 if (markerDeltarHandleId == null) return false; 3474 3475 IJavaElement markerElement = JavaCore.create(markerDeltarHandleId); 3476 while (true){ 3477 if (element.equals(markerElement)) return true; 3479 if (markerElement instanceof IClassFile){ 3481 IType enclosingType = ((IClassFile)markerElement).getType().getDeclaringType(); 3482 if (enclosingType != null){ 3483 markerElement = enclosingType.getClassFile(); continue; 3485 } 3486 } 3487 break; 3488 } 3489 return false; 3490 } 3491 3492 3507 public static IAccessRule newAccessRule(IPath filePattern, int kind) { 3508 return new ClasspathAccessRule(filePattern, kind); 3509 } 3510 3511 3517 public static IClasspathAttribute newClasspathAttribute(String name, String value) { 3518 return new ClasspathAttribute(name, value); 3519 } 3520 3521 3534 public static IClasspathEntry newContainerEntry(IPath containerPath) { 3535 return newContainerEntry( 3536 containerPath, 3537 ClasspathEntry.NO_ACCESS_RULES, 3538 ClasspathEntry.NO_EXTRA_ATTRIBUTES, 3539 false); 3540 } 3541 3542 3558 public static IClasspathEntry newContainerEntry(IPath containerPath, boolean isExported) { 3559 return newContainerEntry( 3560 containerPath, 3561 ClasspathEntry.NO_ACCESS_RULES, 3562 ClasspathEntry.NO_EXTRA_ATTRIBUTES, 3563 isExported); 3564 } 3565 3566 3637 public static IClasspathEntry newContainerEntry( 3638 IPath containerPath, 3639 IAccessRule[] accessRules, 3640 IClasspathAttribute[] extraAttributes, 3641 boolean isExported) { 3642 3643 if (containerPath == null) { 3644 Assert.isTrue(false, "Container path cannot be null"); } else if (containerPath.segmentCount() < 1) { 3646 Assert.isTrue( 3647 false, 3648 "Illegal classpath container path: \'" + containerPath.makeRelative().toString() + "\', must have at least one segment (containerID+hints)"); } 3650 return new ClasspathEntry( 3651 IPackageFragmentRoot.K_SOURCE, 3652 IClasspathEntry.CPE_CONTAINER, 3653 containerPath, 3654 ClasspathEntry.INCLUDE_ALL, ClasspathEntry.EXCLUDE_NONE, null, null, null, isExported, 3660 accessRules, 3661 true, extraAttributes); 3663 } 3664 3665 3687 public static ITypeHierarchy newTypeHierarchy(IRegion region, WorkingCopyOwner owner, IProgressMonitor monitor) throws JavaModelException { 3688 if (region == null) { 3689 throw new IllegalArgumentException (Messages.hierarchy_nullRegion); 3690 } 3691 ICompilationUnit[] workingCopies = JavaModelManager.getJavaModelManager().getWorkingCopies(owner, true); 3692 CreateTypeHierarchyOperation op = 3693 new CreateTypeHierarchyOperation(region, workingCopies, null, true); 3694 op.runOperation(monitor); 3695 return op.getResult(); 3696 } 3697 3698 3714 public static IClasspathEntry newLibraryEntry( 3715 IPath path, 3716 IPath sourceAttachmentPath, 3717 IPath sourceAttachmentRootPath) { 3718 3719 return newLibraryEntry( 3720 path, 3721 sourceAttachmentPath, 3722 sourceAttachmentRootPath, 3723 ClasspathEntry.NO_ACCESS_RULES, 3724 ClasspathEntry.NO_EXTRA_ATTRIBUTES, 3725 false); 3726 } 3727 3728 3747 public static IClasspathEntry newLibraryEntry( 3748 IPath path, 3749 IPath sourceAttachmentPath, 3750 IPath sourceAttachmentRootPath, 3751 boolean isExported) { 3752 3753 return newLibraryEntry( 3754 path, 3755 sourceAttachmentPath, 3756 sourceAttachmentRootPath, 3757 ClasspathEntry.NO_ACCESS_RULES, 3758 ClasspathEntry.NO_EXTRA_ATTRIBUTES, 3759 isExported); 3760 } 3761 3762 3820 public static IClasspathEntry newLibraryEntry( 3821 IPath path, 3822 IPath sourceAttachmentPath, 3823 IPath sourceAttachmentRootPath, 3824 IAccessRule[] accessRules, 3825 IClasspathAttribute[] extraAttributes, 3826 boolean isExported) { 3827 3828 if (path == null) Assert.isTrue(false, "Library path cannot be null"); if (!path.isAbsolute()) Assert.isTrue(false, "Path for IClasspathEntry must be absolute"); if (sourceAttachmentPath != null) { 3831 if (sourceAttachmentPath.isEmpty()) { 3832 sourceAttachmentPath = null; } else if (!sourceAttachmentPath.isAbsolute()) { 3834 Assert.isTrue(false, "Source attachment path '" + sourceAttachmentPath 3836 + "' for IClasspathEntry must be absolute"); } 3838 } 3839 return new ClasspathEntry( 3840 IPackageFragmentRoot.K_BINARY, 3841 IClasspathEntry.CPE_LIBRARY, 3842 JavaProject.canonicalizedPath(path), 3843 ClasspathEntry.INCLUDE_ALL, ClasspathEntry.EXCLUDE_NONE, sourceAttachmentPath, 3846 sourceAttachmentRootPath, 3847 null, isExported, 3849 accessRules, 3850 false, extraAttributes); 3852 } 3853 3854 3864 public static IClasspathEntry newProjectEntry(IPath path) { 3865 return newProjectEntry(path, false); 3866 } 3867 3868 3881 public static IClasspathEntry newProjectEntry(IPath path, boolean isExported) { 3882 3883 if (!path.isAbsolute()) Assert.isTrue(false, "Path for IClasspathEntry must be absolute"); 3885 return newProjectEntry( 3886 path, 3887 ClasspathEntry.NO_ACCESS_RULES, 3888 true, 3889 ClasspathEntry.NO_EXTRA_ATTRIBUTES, 3890 isExported); 3891 } 3892 3893 3941 public static IClasspathEntry newProjectEntry( 3942 IPath path, 3943 IAccessRule[] accessRules, 3944 boolean combineAccessRules, 3945 IClasspathAttribute[] extraAttributes, 3946 boolean isExported) { 3947 3948 if (!path.isAbsolute()) Assert.isTrue(false, "Path for IClasspathEntry must be absolute"); 3950 return new ClasspathEntry( 3951 IPackageFragmentRoot.K_SOURCE, 3952 IClasspathEntry.CPE_PROJECT, 3953 path, 3954 ClasspathEntry.INCLUDE_ALL, ClasspathEntry.EXCLUDE_NONE, null, null, null, isExported, 3960 accessRules, 3961 combineAccessRules, 3962 extraAttributes); 3963 } 3964 3965 3970 public static IRegion newRegion() { 3971 return new Region(); 3972 } 3973 3974 3989 public static IClasspathEntry newSourceEntry(IPath path) { 3990 3991 return newSourceEntry(path, ClasspathEntry.INCLUDE_ALL, ClasspathEntry.EXCLUDE_NONE, null ); 3992 } 3993 3994 4013 public static IClasspathEntry newSourceEntry(IPath path, IPath[] exclusionPatterns) { 4014 4015 return newSourceEntry(path, ClasspathEntry.INCLUDE_ALL, exclusionPatterns, null ); 4016 } 4017 4018 4039 public static IClasspathEntry newSourceEntry(IPath path, IPath[] exclusionPatterns, IPath specificOutputLocation) { 4040 4041 return newSourceEntry(path, ClasspathEntry.INCLUDE_ALL, exclusionPatterns, specificOutputLocation); 4042 } 4043 4044 4067 public static IClasspathEntry newSourceEntry(IPath path, IPath[] inclusionPatterns, IPath[] exclusionPatterns, IPath specificOutputLocation) { 4068 return newSourceEntry(path, inclusionPatterns, exclusionPatterns, specificOutputLocation, ClasspathEntry.NO_EXTRA_ATTRIBUTES); 4069 } 4070 4071 4148 public static IClasspathEntry newSourceEntry(IPath path, IPath[] inclusionPatterns, IPath[] exclusionPatterns, IPath specificOutputLocation, IClasspathAttribute[] extraAttributes) { 4149 4150 if (path == null) Assert.isTrue(false, "Source path cannot be null"); if (!path.isAbsolute()) Assert.isTrue(false, "Path for IClasspathEntry must be absolute"); if (exclusionPatterns == null) Assert.isTrue(false, "Exclusion pattern set cannot be null"); if (inclusionPatterns == null) Assert.isTrue(false, "Inclusion pattern set cannot be null"); 4155 return new ClasspathEntry( 4156 IPackageFragmentRoot.K_SOURCE, 4157 IClasspathEntry.CPE_SOURCE, 4158 path, 4159 inclusionPatterns, 4160 exclusionPatterns, 4161 null, null, specificOutputLocation, false, 4165 null, 4166 false, extraAttributes); 4168 } 4169 4170 4186 public static IClasspathEntry newVariableEntry( 4187 IPath variablePath, 4188 IPath variableSourceAttachmentPath, 4189 IPath sourceAttachmentRootPath) { 4190 4191 return newVariableEntry(variablePath, variableSourceAttachmentPath, sourceAttachmentRootPath, false); 4192 } 4193 4194 4213 public static IClasspathEntry newVariableEntry( 4214 IPath variablePath, 4215 IPath variableSourceAttachmentPath, 4216 IPath variableSourceAttachmentRootPath, 4217 boolean isExported) { 4218 4219 return newVariableEntry( 4220 variablePath, 4221 variableSourceAttachmentPath, 4222 variableSourceAttachmentRootPath, 4223 ClasspathEntry.NO_ACCESS_RULES, 4224 ClasspathEntry.NO_EXTRA_ATTRIBUTES, 4225 isExported); 4226 } 4227 4228 4286 public static IClasspathEntry newVariableEntry( 4287 IPath variablePath, 4288 IPath variableSourceAttachmentPath, 4289 IPath variableSourceAttachmentRootPath, 4290 IAccessRule[] accessRules, 4291 IClasspathAttribute[] extraAttributes, 4292 boolean isExported) { 4293 4294 if (variablePath == null) Assert.isTrue(false, "Variable path cannot be null"); if (variablePath.segmentCount() < 1) { 4296 Assert.isTrue( 4297 false, 4298 "Illegal classpath variable path: \'" + variablePath.makeRelative().toString() + "\', must have at least one segment"); } 4300 4301 return new ClasspathEntry( 4302 IPackageFragmentRoot.K_SOURCE, 4303 IClasspathEntry.CPE_VARIABLE, 4304 variablePath, 4305 ClasspathEntry.INCLUDE_ALL, ClasspathEntry.EXCLUDE_NONE, variableSourceAttachmentPath, variableSourceAttachmentRootPath, null, isExported, 4311 accessRules, 4312 false, extraAttributes); 4314 } 4315 4330 public static void removeClasspathVariable(String variableName) { 4331 removeClasspathVariable(variableName, null); 4332 } 4333 4334 4348 public static void removeClasspathVariable(String variableName, IProgressMonitor monitor) { 4349 try { 4350 SetVariablesOperation operation = new SetVariablesOperation(new String []{ variableName}, new IPath[]{ null }, true); 4351 operation.runOperation(monitor); 4352 } catch (JavaModelException e) { 4353 Util.log(e, "Exception while removing variable " + variableName); } 4355 } 4356 4357 4363 public static void removeElementChangedListener(IElementChangedListener listener) { 4364 JavaModelManager.getJavaModelManager().deltaState.removeElementChangedListener(listener); 4365 } 4366 4367 4376 public static String removeJavaLikeExtension(String fileName) { 4377 return Util.getNameWithoutJavaLikeExtension(fileName); 4378 } 4379 4380 4388 public static void removePreProcessingResourceChangedListener(IResourceChangeListener listener) { 4389 JavaModelManager.getJavaModelManager().deltaState.removePreResourceChangedListener(listener); 4390 } 4391 4392 4393 4394 4422 public static void run(IWorkspaceRunnable action, IProgressMonitor monitor) throws CoreException { 4423 run(action, ResourcesPlugin.getWorkspace().getRoot(), monitor); 4424 } 4425 4460 public static void run(IWorkspaceRunnable action, ISchedulingRule rule, IProgressMonitor monitor) throws CoreException { 4461 IWorkspace workspace = ResourcesPlugin.getWorkspace(); 4462 if (workspace.isTreeLocked()) { 4463 new BatchOperation(action).run(monitor); 4464 } else { 4465 workspace.run(new BatchOperation(action), rule, IWorkspace.AVOID_UPDATE, monitor); 4467 } 4468 } 4469 4515 public static void setClasspathContainer(IPath containerPath, IJavaProject[] affectedProjects, IClasspathContainer[] respectiveContainers, IProgressMonitor monitor) throws JavaModelException { 4516 if (affectedProjects.length != respectiveContainers.length) 4517 Assert.isTrue(false, "Projects and containers collections should have the same size"); SetContainerOperation operation = new SetContainerOperation(containerPath, affectedProjects, respectiveContainers); 4519 operation.runOperation(monitor); 4520 } 4521 4522 4539 public static void setClasspathVariable(String variableName, IPath path) 4540 throws JavaModelException { 4541 4542 setClasspathVariable(variableName, path, null); 4543 } 4544 4545 4562 public static void setClasspathVariable( 4563 String variableName, 4564 IPath path, 4565 IProgressMonitor monitor) 4566 throws JavaModelException { 4567 4568 if (path == null) Assert.isTrue(false, "Variable path cannot be null"); setClasspathVariables(new String []{variableName}, new IPath[]{ path }, monitor); 4570 } 4571 4572 4597 public static void setClasspathVariables( 4598 String [] variableNames, 4599 IPath[] paths, 4600 IProgressMonitor monitor) 4601 throws JavaModelException { 4602 4603 if (variableNames.length != paths.length) Assert.isTrue(false, "Variable names and paths collections should have the same size"); SetVariablesOperation operation = new SetVariablesOperation(variableNames, paths, true); 4605 operation.runOperation(monitor); 4606 } 4607 4608 4630 public static void setComplianceOptions(String compliance, Map options) { 4631 switch((int) (CompilerOptions.versionToJdkLevel(compliance) >>> 16)) { 4632 case ClassFileConstants.MAJOR_VERSION_1_3: 4633 options.put(JavaCore.COMPILER_COMPLIANCE, JavaCore.VERSION_1_3); 4634 options.put(JavaCore.COMPILER_SOURCE, JavaCore.VERSION_1_3); 4635 options.put(JavaCore.COMPILER_CODEGEN_TARGET_PLATFORM, JavaCore.VERSION_1_1); 4636 options.put(JavaCore.COMPILER_PB_ASSERT_IDENTIFIER, JavaCore.IGNORE); 4637 options.put(JavaCore.COMPILER_PB_ENUM_IDENTIFIER, JavaCore.IGNORE); 4638 break; 4639 case ClassFileConstants.MAJOR_VERSION_1_4: 4640 options.put(JavaCore.COMPILER_COMPLIANCE, JavaCore.VERSION_1_4); 4641 options.put(JavaCore.COMPILER_SOURCE, JavaCore.VERSION_1_3); 4642 options.put(JavaCore.COMPILER_CODEGEN_TARGET_PLATFORM, JavaCore.VERSION_1_2); 4643 options.put(JavaCore.COMPILER_PB_ASSERT_IDENTIFIER, JavaCore.WARNING); 4644 options.put(JavaCore.COMPILER_PB_ENUM_IDENTIFIER, JavaCore.WARNING); 4645 break; 4646 case ClassFileConstants.MAJOR_VERSION_1_5: 4647 options.put(JavaCore.COMPILER_COMPLIANCE, JavaCore.VERSION_1_5); 4648 options.put(JavaCore.COMPILER_SOURCE, JavaCore.VERSION_1_5); 4649 options.put(JavaCore.COMPILER_CODEGEN_TARGET_PLATFORM, JavaCore.VERSION_1_5); 4650 options.put(JavaCore.COMPILER_PB_ASSERT_IDENTIFIER, JavaCore.ERROR); 4651 options.put(JavaCore.COMPILER_PB_ENUM_IDENTIFIER, JavaCore.ERROR); 4652 options.put(JavaCore.COMPILER_CODEGEN_INLINE_JSR_BYTECODE, JavaCore.ENABLED); 4653 break; 4654 case ClassFileConstants.MAJOR_VERSION_1_6: 4655 options.put(JavaCore.COMPILER_COMPLIANCE, JavaCore.VERSION_1_6); 4656 options.put(JavaCore.COMPILER_SOURCE, JavaCore.VERSION_1_6); 4657 options.put(JavaCore.COMPILER_CODEGEN_TARGET_PLATFORM, JavaCore.VERSION_1_6); 4658 options.put(JavaCore.COMPILER_PB_ASSERT_IDENTIFIER, JavaCore.ERROR); 4659 options.put(JavaCore.COMPILER_PB_ENUM_IDENTIFIER, JavaCore.ERROR); 4660 options.put(JavaCore.COMPILER_CODEGEN_INLINE_JSR_BYTECODE, JavaCore.ENABLED); 4661 break; 4662 case ClassFileConstants.MAJOR_VERSION_1_7: 4663 options.put(JavaCore.COMPILER_COMPLIANCE, JavaCore.VERSION_1_7); 4664 options.put(JavaCore.COMPILER_SOURCE, JavaCore.VERSION_1_7); 4665 options.put(JavaCore.COMPILER_CODEGEN_TARGET_PLATFORM, JavaCore.VERSION_1_7); 4666 options.put(JavaCore.COMPILER_PB_ASSERT_IDENTIFIER, JavaCore.ERROR); 4667 options.put(JavaCore.COMPILER_PB_ENUM_IDENTIFIER, JavaCore.ERROR); 4668 options.put(JavaCore.COMPILER_CODEGEN_INLINE_JSR_BYTECODE, JavaCore.ENABLED); 4669 } 4670 } 4671 4672 4688 public static void setOptions(Hashtable newOptions) { 4689 JavaModelManager.getJavaModelManager().setOptions(newOptions); 4690 } 4691 4692 4699 public void stop(BundleContext context) throws Exception { 4700 try { 4701 JavaModelManager.getJavaModelManager().shutdown(); 4702 } finally { 4703 super.stop(context); 4705 } 4706 } 4707 4708 4717 public void start(BundleContext context) throws Exception { 4718 super.start(context); 4719 JavaModelManager.getJavaModelManager().startup(); 4720 } 4721} | Popular Tags |