Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core')
-rw-r--r--bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/AbstractAdapterFactory.java80
-rw-r--r--bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/AbstractModelLoader.java499
-rw-r--r--bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/AbstractNotifier.java232
-rw-r--r--bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/AbstractStructuredModel.java1595
-rw-r--r--bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/AdapterFactory.java44
-rw-r--r--bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/DocumentChanged.java60
-rw-r--r--bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/FactoryRegistry.java175
-rw-r--r--bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/IFactoryRegistry.java58
-rw-r--r--bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/IModelLifecycleListener.java25
-rw-r--r--bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/IModelLoaderExtension.java26
-rw-r--r--bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/IModelManager.java326
-rw-r--r--bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/IModelManagerListener.java37
-rw-r--r--bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/IModelManagerPlugin.java38
-rw-r--r--bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/IModelStateListener.java58
-rw-r--r--bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/IModelStateListenerExtended.java30
-rw-r--r--bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/INodeAdapter.java28
-rw-r--r--bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/INodeNotifier.java71
-rw-r--r--bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/IStateMemento.java22
-rw-r--r--bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/IStructuredModel.java397
-rw-r--r--bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/IndexedRegion.java28
-rw-r--r--bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/LifecycleNotificationManager.java123
-rw-r--r--bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/ModelDumper.java34
-rw-r--r--bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/ModelLifecycleEvent.java115
-rw-r--r--bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/ModelLoader.java81
-rw-r--r--bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/ModelManagerImpl.java1748
-rw-r--r--bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/ModelPlugin.java31
-rw-r--r--bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/ModelStateMemento.java111
-rw-r--r--bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/NullModelManager.java504
-rw-r--r--bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/PropagatingAdapter.java34
-rw-r--r--bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/PropagatingAdapterFactory.java27
-rw-r--r--bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/StructuredModelManager.java57
-rw-r--r--bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/builder/IBuilderDelegate.java60
-rw-r--r--bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/builder/IBuilderModelProvider.java42
-rw-r--r--bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/builder/IBuilderParticipant.java124
-rw-r--r--bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/cleanup/AbstractCleanupProcessor.java241
-rw-r--r--bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/cleanup/AbstractStructuredCleanupProcessor.java456
-rw-r--r--bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/cleanup/CleanupProcessor.java88
-rw-r--r--bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/cleanup/IStructuredCleanupHandler.java23
-rw-r--r--bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/cleanup/IStructuredCleanupPreferences.java56
-rw-r--r--bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/cleanup/IStructuredCleanupProcessor.java109
-rw-r--r--bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/cleanup/StructuredCleanupPreferences.java135
-rw-r--r--bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/cleanup/StructuredContentCleanupHandler.java20
-rw-r--r--bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/cleanup/StructuredContentCleanupHandlerImpl.java50
-rw-r--r--bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/contentmodel/CMDocType.java21
-rw-r--r--bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/contentmodel/CMDocumentTracker.java32
-rw-r--r--bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/contentmodel/CMNodeWrapper.java21
-rw-r--r--bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/contentmodel/ContentModelAdapter.java56
-rw-r--r--bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/contentmodel/NullContentModel.java101
-rw-r--r--bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/contenttype/ContentTypeIdForCSS.java29
-rw-r--r--bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/document/AbstractDocumentLoader.java396
-rw-r--r--bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/document/DocumentReader.java125
-rw-r--r--bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/document/IDocumentCharsetDetector.java22
-rw-r--r--bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/document/IDocumentLoader.java72
-rw-r--r--bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/document/IDocumentLoaderForFileBuffers.java27
-rw-r--r--bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/document/IEncodedDocument.java31
-rw-r--r--bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/document/IExecutionDelegate.java20
-rw-r--r--bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/document/ILockable.java30
-rw-r--r--bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/document/StructuredDocumentFactory.java83
-rw-r--r--bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/document/StructuredDocumentLoader.java141
-rw-r--r--bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/events/AboutToBeChangeEvent.java29
-rw-r--r--bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/events/IModelAboutToBeChangedListener.java26
-rw-r--r--bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/events/IStructuredDocumentListener.java28
-rw-r--r--bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/events/NewDocumentContentEvent.java29
-rw-r--r--bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/events/NewDocumentEvent.java81
-rw-r--r--bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/events/NewModelEvent.java26
-rw-r--r--bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/events/NoChangeEvent.java72
-rw-r--r--bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/events/RegionChangedEvent.java48
-rw-r--r--bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/events/RegionsReplacedEvent.java48
-rw-r--r--bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/events/StructuredDocumentEvent.java127
-rw-r--r--bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/events/StructuredDocumentRegionsReplacedEvent.java44
-rw-r--r--bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/exceptions/ResourceAlreadyExists.java40
-rw-r--r--bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/exceptions/ResourceInUse.java40
-rw-r--r--bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/exceptions/SourceEditingException.java85
-rw-r--r--bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/exceptions/SourceEditingRuntimeException.java89
-rw-r--r--bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/filebuffers/BasicStructuredDocumentFactory.java75
-rw-r--r--bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/format/AbstractStructuredFormatProcessor.java479
-rw-r--r--bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/format/IStructuredContentFormatter.java19
-rw-r--r--bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/format/IStructuredFormatContraints.java27
-rw-r--r--bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/format/IStructuredFormatPreferences.java27
-rw-r--r--bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/format/IStructuredFormatProcessor.java107
-rw-r--r--bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/format/IStructuredFormatter.java30
-rw-r--r--bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/format/StructuredFormatContraints.java44
-rw-r--r--bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/format/StructuredFormatPreferences.java43
-rw-r--r--bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/FileBufferModelManager.java513
-rw-r--r--bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/JSPAwareAdapterFactory.java22
-rw-r--r--bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/Logger.java175
-rw-r--r--bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/ModelManagerPluginRegistryReader.java170
-rw-r--r--bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/NoCancelProgressMonitor.java35
-rw-r--r--bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/NotImplementedException.java37
-rw-r--r--bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/NullMemento.java38
-rw-r--r--bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/SSECorePlugin.java192
-rw-r--r--bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/SSECorePluginResources.properties69
-rw-r--r--bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/builder/BuilderModelProvider.java179
-rw-r--r--bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/builder/BuilderParticipantRegistryReader.java150
-rw-r--r--bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/builder/StructuredDocumentBuilder.java575
-rw-r--r--bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/document/NullStructuredDocumentPartitioner.java115
-rw-r--r--bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/document/TextUtilities.java73
-rw-r--r--bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/modelhandler/EmbeddedTypeRegistry.java35
-rw-r--r--bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/modelhandler/EmbeddedTypeRegistryImpl.java120
-rw-r--r--bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/modelhandler/EmbeddedTypeRegistryReader.java71
-rw-r--r--bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/modelhandler/ModelHandlerRegistry.java279
-rw-r--r--bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/modelhandler/ModelHandlerRegistryReader.java106
-rw-r--r--bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/modelhandler/ModelHandlerUtility.java50
-rw-r--r--bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/modelhandler/PluginContributedFactoryReader.java126
-rw-r--r--bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/parser/ContextRegion.java242
-rw-r--r--bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/parser/ForeignRegion.java88
-rw-r--r--bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/text/BasicStructuredDocument.java2614
-rw-r--r--bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/text/BasicStructuredDocumentRegion.java688
-rw-r--r--bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/text/CharSequenceReader.java127
-rw-r--r--bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/text/CoreNodeList.java132
-rw-r--r--bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/text/DocumentInternalStateRule.java56
-rw-r--r--bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/text/GenericPositionManager.java401
-rw-r--r--bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/text/IExecutionDelegatable.java20
-rw-r--r--bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/text/IRegionComparible.java20
-rw-r--r--bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/text/JobSafeStructuredDocument.java179
-rw-r--r--bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/text/MinimalDocument.java427
-rw-r--r--bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/text/StructuredDocumentReParser.java1660
-rw-r--r--bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/text/StructuredDocumentRegionEnumeration.java87
-rw-r--r--bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/text/StructuredDocumentRegionIterator.java115
-rw-r--r--bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/text/StructuredDocumentSequentialRewriteTextStore.java132
-rw-r--r--bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/text/StructuredDocumentTextStore.java189
-rw-r--r--bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/text/SubSetTextStore.java127
-rw-r--r--bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/text/TextRegionListImpl.java223
-rw-r--r--bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/undo/StructuredTextCommandImpl.java138
-rw-r--r--bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/undo/StructuredTextCompoundCommandImpl.java261
-rw-r--r--bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/undo/StructuredTextUndoManager.java617
-rw-r--r--bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/modelhandler/AbstractModelHandler.java72
-rw-r--r--bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/modelhandler/EmbeddedTypeHandler.java63
-rw-r--r--bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/modelhandler/IDocumentTypeHandler.java42
-rw-r--r--bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/modelhandler/IModelHandler.java43
-rw-r--r--bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/modelquery/ModelQueryAdapter.java32
-rw-r--r--bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/modelquery/ModelQueryAdapterImpl.java76
-rw-r--r--bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/modelquery/MovableModelQuery.java23
-rw-r--r--bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/parser/BlockMarker.java107
-rw-r--r--bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/parser/BlockTagParser.java32
-rw-r--r--bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/parser/BlockTokenizer.java58
-rw-r--r--bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/parser/IBlockedStructuredDocumentRegion.java24
-rw-r--r--bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/parser/JSPCapableParser.java28
-rw-r--r--bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/parser/RegionParser.java52
-rw-r--r--bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/parser/StructuredDocumentRegionHandler.java28
-rw-r--r--bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/parser/StructuredDocumentRegionHandlerExtension.java20
-rw-r--r--bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/parser/StructuredDocumentRegionParser.java24
-rw-r--r--bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/parser/StructuredDocumentRegionParserExtension.java28
-rw-r--r--bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/parser/TagMarker.java80
-rw-r--r--bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/participants/AbstractBuilderParticipant.java183
-rw-r--r--bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/participants/TaskTagSeeker.java468
-rw-r--r--bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/preferences/CommonModelPreferenceNames.java161
-rw-r--r--bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/preferences/PreferenceChangeListener.java24
-rw-r--r--bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/text/DeleteEqualPositionUpdater.java66
-rw-r--r--bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/text/IStructuredDocument.java199
-rw-r--r--bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/text/IStructuredDocumentRegion.java96
-rw-r--r--bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/text/IStructuredDocumentRegionList.java31
-rw-r--r--bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/text/IStructuredTextPartitioner.java47
-rw-r--r--bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/text/IStructuredTextReParser.java41
-rw-r--r--bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/text/ITextRegion.java82
-rw-r--r--bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/text/ITextRegionCollection.java59
-rw-r--r--bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/text/ITextRegionContainer.java27
-rw-r--r--bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/text/ITextRegionList.java43
-rw-r--r--bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/text/SimpleStructuredRegion.java91
-rw-r--r--bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/text/SimpleStructuredTypedRegion.java87
-rw-r--r--bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/text/StructuredRegion.java27
-rw-r--r--bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/text/StructuredTypedRegion.java24
-rw-r--r--bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/text/rules/StructuredTextPartitioner.java609
-rw-r--r--bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/undo/CommandCursorPosition.java66
-rw-r--r--bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/undo/IDocumentSelectionMediator.java35
-rw-r--r--bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/undo/IStructuredTextUndoManager.java155
-rw-r--r--bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/undo/StructuredTextCommand.java34
-rw-r--r--bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/undo/UndoDocumentEvent.java45
-rw-r--r--bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/util/Assert.java166
-rw-r--r--bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/util/Debug.java221
-rw-r--r--bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/util/DocumentInputStream.java108
-rw-r--r--bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/util/JarUtilities.java210
-rw-r--r--bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/util/PathHelper.java148
-rw-r--r--bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/util/ProjectResolver.java228
-rw-r--r--bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/util/ResourceUtil.java69
-rw-r--r--bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/util/ScriptLanguageKeys.java39
-rw-r--r--bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/util/StringUtils.java742
-rw-r--r--bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/util/TextUtilities.java63
-rw-r--r--bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/util/URIResolver.java82
-rw-r--r--bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/util/Utilities.java130
-rw-r--r--bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/validate/ValidationAdapter.java31
-rw-r--r--bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/validate/ValidationMessage.java69
-rw-r--r--bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/validate/ValidationReporter.java24
183 files changed, 0 insertions, 28503 deletions
diff --git a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/AbstractAdapterFactory.java b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/AbstractAdapterFactory.java
deleted file mode 100644
index 4aa3d3eacf..0000000000
--- a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/AbstractAdapterFactory.java
+++ /dev/null
@@ -1,80 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Jens Lukowski/Innoopract - initial renaming/restructuring
- *
- *******************************************************************************/
-package org.eclipse.wst.sse.core;
-
-/**
- * An abstract implementation of AdapterFactory that uses itself as the key.
- * Subclass to override behavior.
- */
-abstract public class AbstractAdapterFactory implements AdapterFactory {
-
- protected Object adapterKey;
- protected boolean shouldRegisterAdapter = true;
-
- public AbstractAdapterFactory() {
- // default constructor sets the adapterKey to the adapter factory
- // itself (i.e. "this")
- adapterKey = this;
- }
-
- public AbstractAdapterFactory(Object adapterKey, boolean registerAdapters) {
- this.adapterKey = adapterKey;
- this.shouldRegisterAdapter = registerAdapters;
- }
-
- public INodeAdapter adapt(INodeNotifier target) {
- // target was null when all text deleted?
- if (target == null)
- return null;
- INodeAdapter adapter = target.getExistingAdapter(adapterKey);
- return adapter != null ? adapter : adaptNew(target);
- }
-
- public INodeAdapter adaptNew(INodeNotifier target) {
- INodeAdapter adapter = createAdapter(target);
- if (adapter == null)
- return adapter;
- if (shouldRegisterAdapter)
- target.addAdapter(adapter);
- return adapter;
- }
-
- /**
- * Subclasses should normally implement their own 'copy' method. By
- * default, we'll return the same instance, for convenience of those using
- * singleton factories.
- */
- public AdapterFactory copy() {
- return this;
- }
-
- abstract protected INodeAdapter createAdapter(INodeNotifier target);
-
- public boolean isFactoryForType(Object type) {
- return type.equals(adapterKey);
- }
-
- public void release() {
- // default is to do nothing
- }
-
- public void setAdapterKey(Object key) {
- if (adapterKey != null)
- throw new IllegalAccessError("INodeAdapter Key cannot be set more than once."); //$NON-NLS-1$
- adapterKey = key;
- }
-
- public void setRegisterAdapters(boolean flag) {
- shouldRegisterAdapter = flag;
- }
-}
diff --git a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/AbstractModelLoader.java b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/AbstractModelLoader.java
deleted file mode 100644
index 01cfed6e7d..0000000000
--- a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/AbstractModelLoader.java
+++ /dev/null
@@ -1,499 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Jens Lukowski/Innoopract - initial renaming/restructuring
- *
- *******************************************************************************/
-package org.eclipse.wst.sse.core;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.UnsupportedEncodingException;
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.jface.text.IDocumentExtension3;
-import org.eclipse.wst.common.encoding.EncodingMemento;
-import org.eclipse.wst.common.encoding.EncodingRule;
-import org.eclipse.wst.sse.core.document.IDocumentLoader;
-import org.eclipse.wst.sse.core.document.IEncodedDocument;
-import org.eclipse.wst.sse.core.internal.Logger;
-import org.eclipse.wst.sse.core.internal.text.BasicStructuredDocument;
-import org.eclipse.wst.sse.core.parser.BlockMarker;
-import org.eclipse.wst.sse.core.parser.BlockTagParser;
-import org.eclipse.wst.sse.core.parser.RegionParser;
-import org.eclipse.wst.sse.core.parser.StructuredDocumentRegionHandler;
-import org.eclipse.wst.sse.core.parser.StructuredDocumentRegionHandlerExtension;
-import org.eclipse.wst.sse.core.parser.StructuredDocumentRegionParser;
-import org.eclipse.wst.sse.core.parser.StructuredDocumentRegionParserExtension;
-import org.eclipse.wst.sse.core.text.IStructuredDocument;
-import org.eclipse.wst.sse.core.text.rules.StructuredTextPartitioner;
-import org.eclipse.wst.sse.core.util.Assert;
-
-
-/**
- * This class reads a file and creates an Structured Model.
- */
-public abstract class AbstractModelLoader implements ModelLoader, IModelLoaderExtension {
- protected static final int encodingNameSearchLimit = 1000;
-
- private static long computeMem() {
- for (int i = 0; i < 5; i++) {
- System.gc();
- System.runFinalization();
- }
- return Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory();
- }
-
- private boolean DEBUG = false;
- protected IDocumentLoader documentLoaderInstance;
-
- /**
- * AbstractLoader constructor also initializes encoding converter/mapper
- */
- public AbstractModelLoader() {
- super();
- }
-
- protected void addFactories(IStructuredModel model, List factoryList) {
- Assert.isNotNull(model);
- IFactoryRegistry registry = model.getFactoryRegistry();
- Assert.isNotNull(registry, "IStructuredModel " + model.getId() + " has a null IFactoryRegistry");
- if (factoryList != null) {
- Iterator iterator = factoryList.iterator();
- while (iterator.hasNext()) {
- AdapterFactory factory = (AdapterFactory) iterator.next();
- registry.addFactory(factory);
- }
- }
- }
-
- /**
- * This method should perform all the model initialization required before
- * it contains content, namely, it should call newModel, the
- * createNewStructuredDocument(), then add those adapter factories which
- * must be set before content is applied. This method should be called by
- * "load" method. (this is tentative API)
- */
- public IStructuredModel createModel() {
- documentLoaderInstance = null;
- IStructuredModel model = newModel();
- IEncodedDocument structuredDocument = getDocumentLoader().createNewStructuredDocument();
- if (structuredDocument instanceof IStructuredDocument) {
- model.setStructuredDocument((IStructuredDocument) structuredDocument);
- addFactories(model, getAdapterFactories());
- //
- initEmbeddedType(model);
- // For types with propagating adapters, its important
- // that the propagating adapter be in place before the contents
- // are set.
- preLoadAdapt(model);
- }
- return model;
- }
-
- public IStructuredModel createModel(IStructuredDocument structuredDocument, String baseLocation) {
- documentLoaderInstance = null;
- IStructuredModel model = newModel();
- model.setBaseLocation(baseLocation);
-
- addFactories(model, getAdapterFactories());
- // For types with propagating adapters, it's important
- // that the propagating adapter be in place before the contents
- // are set.
- preLoadAdapt(model);
-
- model.setStructuredDocument(structuredDocument);
- //
- initEmbeddedType(model);
-
- return model;
- }
-
- /**
- * This method is used for cloning models.
- */
- public IStructuredModel createModel(IStructuredModel oldModel) {
- documentLoaderInstance = null;
- IStructuredModel newModel = newModel();
- IStructuredDocument oldStructuredDocument = oldModel.getStructuredDocument();
- IStructuredDocument newStructuredDocument = oldStructuredDocument.newInstance();
- newModel.setStructuredDocument(newStructuredDocument);
- // NOTE: we DO NOT simply add the standard ones to the new model
- // addFactories(newModel, getAdapterFactories());
- // Now, we take the opportunity to add Factories from the oldModel's
- // registry to the new model's registry .. if they do not already
- // exist there.
- duplicateFactoryRegistry(newModel, oldModel);
- if (newModel instanceof AbstractStructuredModel) {
- ((AbstractStructuredModel) newModel).setContentTypeIdentifier(oldModel.getContentTypeIdentifier());
- }
- //addFactories(newModel, oldModel);
- initEmbeddedType(oldModel, newModel);
- // For types with propagating adapters, its important
- // that the propagating adapter be in place before the contents
- // are set.
- preLoadAdapt(newModel);
- return newModel;
- }
-
- private void duplicateFactoryRegistry(IStructuredModel newModel, IStructuredModel oldModel) {
- List oldAdapterFactories = oldModel.getFactoryRegistry().getFactories();
- List newAdapterFactories = new ArrayList();
- Iterator oldListIterator = oldAdapterFactories.iterator();
- while (oldListIterator.hasNext()) {
- AdapterFactory oldAdapterFactory = (AdapterFactory) oldListIterator.next();
- // now "clone" the adapterfactory
- newAdapterFactories.add(oldAdapterFactory.copy());
- }
- // now that we have the "cloned" list, add to new model
- addFactories(newModel, newAdapterFactories);
- }
-
- /**
- * This method must return those factories which must be attached to the
- * structuredModel before content is applied.
- */
- public List getAdapterFactories() {
- // abstract method returns none
- return new ArrayList(0);
- }
-
- abstract public IDocumentLoader getDocumentLoader();
-
- /**
- * Method initEmbeddedType. Nothing to do here in super class.
- *
- * @param model
- */
- protected void initEmbeddedType(IStructuredModel model) {
- }
-
- /**
- * Method initEmbeddedType. Nothing to do here in super class.
- *
- * @param oldModel
- * @param newModel
- */
- protected void initEmbeddedType(IStructuredModel oldModel, IStructuredModel newModel) {
- }
-
- public void load(IFile file, IStructuredModel model) throws IOException, CoreException {
- IEncodedDocument structuredDocument = model.getStructuredDocument();
- if (file == null)
- structuredDocument = getDocumentLoader().createNewStructuredDocument();
- else
- structuredDocument = getDocumentLoader().createNewStructuredDocument(file);
-
- // TODO: need to straighten out IEncodedDocument mess
- if (structuredDocument instanceof IStructuredDocument)
- transformInstance(model.getStructuredDocument(), (IStructuredDocument) structuredDocument);
- else
- model.getStructuredDocument().set(structuredDocument.get());
-
- // original hack
- //model.setStructuredDocument((IStructuredDocument)
- // structuredDocument);
- //((IStructuredDocument) structuredDocument).fireNewDocument(this);
- documentLoaderInstance = null;
- //technicq of future
- //model.setStructuredDocument((IStructuredDocument)
- // structuredDocument);
- //documentLoaderInstance = null;
- }
-
- public void load(InputStream inputStream, IStructuredModel model, EncodingRule encodingRule) throws UnsupportedEncodingException, java.io.IOException {
- // note we don't open the stream, so we don't close it
- IEncodedDocument structuredDocument = model.getStructuredDocument();
- if (inputStream == null) {
- structuredDocument = getDocumentLoader().createNewStructuredDocument();
- } else {
- // assume's model has been initialized already with base location
- structuredDocument = getDocumentLoader().createNewStructuredDocument(model.getBaseLocation(), inputStream, encodingRule);
- // TODO: model's not designed for this!
- // we want to move to this "set" method, but the 'fire' was needed
- // as
- // a work around for strucutredModel not handling 'set' right, but
- // that 'fireNewDocument' method was causing unbalance
- // "aboutToChange" and "changed"
- // events.
- // model.setStructuredDocument((IStructuredDocument)
- // structuredDocument);
- // ((IStructuredDocument)
- // structuredDocument).fireNewDocument(this);
- model.getStructuredDocument().set(structuredDocument.get());
-
- }
- documentLoaderInstance = null;
-
- }
-
- /**
- * deprecated -- use EncodingRule form
- */
- synchronized public void load(InputStream inputStream, IStructuredModel model, String encodingName, String lineDelimiter) throws UnsupportedEncodingException, java.io.IOException {
- // note we don't open the stream, so we don't close it
- // TEMP work around to maintain previous function,
- // until everyone can change to EncodingRule.FORCE_DEFAULT
- if (encodingName != null && encodingName.trim().length() == 0) {
- // redirect to new method
- load(inputStream, model, EncodingRule.FORCE_DEFAULT);
- } else {
- load(inputStream, model, EncodingRule.CONTENT_BASED);
- }
- }
-
- public void load(String filename, InputStream inputStream, IStructuredModel model, String junk, String dummy) throws UnsupportedEncodingException, java.io.IOException {
-
- long memoryUsed = 0;
- if (DEBUG) {
- memoryUsed = computeMem();
- System.out.println("measuring heap memory for " + filename);
- //System.out.println("heap memory used before load: " +
- // memoryUsed);
- }
-
- // during an initial load, we expect the olddocument to be empty
- // during re-load, however, it would be full.
- IEncodedDocument newstructuredDocument = null;
- IEncodedDocument oldStructuredDocument = model.getStructuredDocument();
-
- // get new document
- if (inputStream == null) {
- newstructuredDocument = getDocumentLoader().createNewStructuredDocument();
- } else {
- newstructuredDocument = getDocumentLoader().createNewStructuredDocument(filename, inputStream);
- }
- if (DEBUG) {
- long memoryAtEnd = computeMem();
- //System.out.println("heap memory used after loading new
- // document: " + memoryAtEnd);
- System.out.println(" heap memory implied used by document: " + (memoryAtEnd - memoryUsed));
- }
-
-
- // TODO: need to straighten out IEncodedDocument mess
- if (newstructuredDocument instanceof IStructuredDocument) {
- transformInstance((IStructuredDocument) oldStructuredDocument, (IStructuredDocument) newstructuredDocument);
- } else {
- // we don't really expect this case, just included for safety
- oldStructuredDocument.set(newstructuredDocument.get());
- }
- // original hack
- //model.setStructuredDocument((IStructuredDocument)
- // structuredDocument);
- //((IStructuredDocument) structuredDocument).fireNewDocument(this);
- documentLoaderInstance = null;
- //technicq of future
- //model.setStructuredDocument((IStructuredDocument)
- // structuredDocument);
- //documentLoaderInstance = null;
- if (DEBUG) {
- long memoryAtEnd = computeMem();
- //System.out.println("heap memory used after setting to model: "
- // + memoryAtEnd);
- System.out.println(" heap memory implied used by document and model: " + (memoryAtEnd - memoryUsed));
- }
-
- }
-
- /**
- * required by interface, being declared here abstractly just as another
- * reminder.
- */
- abstract public IStructuredModel newModel();
-
- /**
- * There's nothing to do here in abstract class for initializing adapters.
- * Subclasses can and should override this method and provide proper
- * intialization (For example, to get DOM document and 'getAdapter' on it,
- * so that the first node/notifier has the adapter on it.)
- */
- protected void preLoadAdapt(IStructuredModel structuredModel) {
-
-
- }
-
- /**
- * Normally, here in the abstact class, there's nothing to do, but we will
- * reset text, since this MIGHT end up being called to recover from error
- * conditions (e.g. IStructuredDocument exceptions) And, can be called by
- * subclasses.
- */
- public IStructuredModel reinitialize(IStructuredModel model) {
- // Note: the "minimumization" routines
- // of 'replaceText' allow many old nodes to pass through, when
- // really its assumed they are created anew.
- // so we need to use 'setText' (I think "setText' ends up
- // throwing a 'newModel' event though, that may have some
- // implications.
- model.getStructuredDocument().setText(this, model.getStructuredDocument().get());
- return model;
- }
-
- /**
- * This method gets a fresh copy of the data, and repopulates the models
- * ... by a call to setText on the structuredDocument. This method is
- * needed in some cases where clients are sharing a model and then changes
- * canceled. Say for example, one editor and several "displays" are
- * sharing a model, if the editor is closed without saving changes, then
- * the displays still need a model, but they should revert to the original
- * unsaved version.
- */
- synchronized public void reload(InputStream inputStream, IStructuredModel structuredModel) {
- documentLoaderInstance = null;
- try {
- // temp solution ... we should be able to do better (more
- // efficient) in future.
- // Adapters will (probably) need to be sensitive to the fact that
- // the document instance changed
- // (by being life cycle listeners)
- load(inputStream, structuredModel, EncodingRule.CONTENT_BASED);
-
- // // Note: we apparently read the data (and encoding) correctly
- // // before, we just need to make sure we followed the same rule
- // as
- // // before.
- // EncodingMemento previousMemento =
- // structuredModel.getStructuredDocument().getEncodingMemento();
- // EncodingRule previousRule = previousMemento.getEncodingRule();
- // //IFile file = ResourceUtil.getFileFor(structuredModel);
- // // Note: there's opportunity here for some odd behavior, if the
- // // settings have changed from the first load to the reload.
- // But,
- // // hopefully,
- // // will result in the intended behavior.
- // Reader allTextReader =
- // getDocumentLoader().readInputStream(inputStream, previousRule);
- //
- // // TODO: avoid use of String instance
- // getDocumentLoader().reload(structuredModel.getStructuredDocument(),
- // allTextReader);
- // // and now "reset" encoding memento to keep it current with the
- // // one
- // // that was just determined.
- // structuredModel.getStructuredDocument().setEncodingMemento(getDocumentLoader().getEncodingMemento());
- // structuredModel.setDirtyState(false);
- // StructuredTextUndoManager undoMgr =
- // structuredModel.getUndoManager();
- // if (undoMgr != null) {
- // undoMgr.reset();
- // }
- } catch (UnsupportedEncodingException e) {
- // couldn't happen. The program has apparently
- // read the model once, and there'd be no reason the encoding
- // could not be used again.
- Logger.logException("Warning: XMLLoader::reload. This exception really should not have happened!! But will attemp to continue after dumping stack trace", e); //$NON-NLS-1$
- throw new Error("Program Error", e); //$NON-NLS-1$
- } catch (IOException e) {
- // couldn't happen. The program has apparently
- // read the model once, and there'd be no (common) reason it
- // couldn't be loaded again.
- Logger.logException("Warning: XMLLoader::reload. This exception really should not have happened!! But will attemp to continue after dumping stack trace", e); //$NON-NLS-1$
- throw new Error("Program Error", e); //$NON-NLS-1$
- }
- }
-
- /**
- * this work is done better elsewhere, but done here for this version to
- * reduce changes. especially since the need for it should go away once we
- * no longer need to re-use old document instance.
- */
- private void transformInstance(IStructuredDocument oldInstance, IStructuredDocument newInstance) {
- /**
- * https://w3.opensource.ibm.com/bugzilla/show_bug.cgi?id=4920
- *
- * JSP taglib support broken, correct by duplicating extended setup
- * information (BlockTagParser extension,
- * StructuredDocumentRegionParser extensions)
- */
- RegionParser oldParser = oldInstance.getParser();
- RegionParser newParser = newInstance.getParser().newInstance();
- // Register all of the old StructuredDocumentRegionHandlers on the new
- // parser
- if (oldParser instanceof StructuredDocumentRegionParserExtension && newParser instanceof StructuredDocumentRegionParserExtension) {
- List oldHandlers = ((StructuredDocumentRegionParserExtension) oldParser).getStructuredDocumentRegionHandlers();
- for (int i = 0; i < oldHandlers.size(); i++) {
- StructuredDocumentRegionHandler handler = ((StructuredDocumentRegionHandler) oldHandlers.get(i));
- if (handler instanceof StructuredDocumentRegionHandlerExtension) {
- /**
- * Skip the transferring here, the handler will do this
- * after everything else but the source is transferred.
- */
- } else {
- ((StructuredDocumentRegionParser) oldParser).removeStructuredDocumentRegionHandler(handler);
- ((StructuredDocumentRegionParser) newParser).addStructuredDocumentRegionHandler(handler);
- handler.resetNodes();
- }
- }
- }
- // Add any global BlockMarkers to the new parser
- if (oldParser instanceof BlockTagParser && newParser instanceof BlockTagParser) {
- List oldBlockMarkers = ((BlockTagParser) oldParser).getBlockMarkers();
- for (int i = 0; i < oldBlockMarkers.size(); i++) {
- BlockMarker blockMarker = ((BlockMarker) oldBlockMarkers.get(i));
- if (blockMarker.isGlobal()) {
- ((BlockTagParser) newParser).addBlockMarker(blockMarker);
- }
- }
- }
-
- ((BasicStructuredDocument) oldInstance).setParser(newParser);
-
- ((BasicStructuredDocument) oldInstance).setReParser(newInstance.getReParser().newInstance());
-
- if (newInstance.getDocumentPartitioner() instanceof StructuredTextPartitioner) {
- StructuredTextPartitioner partitioner = null;
- if (oldInstance instanceof IDocumentExtension3 && newInstance instanceof IDocumentExtension3) {
- partitioner = ((StructuredTextPartitioner) ((IDocumentExtension3) newInstance).getDocumentPartitioner(IStructuredDocument.DEFAULT_STRUCTURED_PARTITIONING));
- if (partitioner != null) {
- partitioner = (StructuredTextPartitioner) partitioner.newInstance();
- }
- ((IDocumentExtension3) oldInstance).setDocumentPartitioner(IStructuredDocument.DEFAULT_STRUCTURED_PARTITIONING, partitioner);
- }
- if (partitioner == null) {
- partitioner = (StructuredTextPartitioner) ((StructuredTextPartitioner) newInstance.getDocumentPartitioner()).newInstance();
- oldInstance.setDocumentPartitioner(partitioner);
- }
- if (partitioner != null) {
- partitioner.connect(oldInstance);
- }
- }
-
- oldInstance.setLineDelimiter(newInstance.getLineDelimiter());
- if (newInstance.getEncodingMemento() != null) {
- oldInstance.setEncodingMemento((EncodingMemento) newInstance.getEncodingMemento().clone());
- }
-
- /**
- * https://w3.opensource.ibm.com/bugzilla/show_bug.cgi?id=4920
- *
- * JSP taglib support broken, correct by duplicating extended setup
- * information (BlockTagParser extension,
- * StructuredDocumentRegionParser extensions)
- */
- if (oldParser instanceof StructuredDocumentRegionParserExtension && newParser instanceof StructuredDocumentRegionParserExtension) {
- List oldHandlers = ((StructuredDocumentRegionParserExtension) oldParser).getStructuredDocumentRegionHandlers();
- for (int i = 0; i < oldHandlers.size(); i++) {
- StructuredDocumentRegionHandler handler = ((StructuredDocumentRegionHandler) oldHandlers.get(i));
- if (handler instanceof StructuredDocumentRegionHandlerExtension) {
- StructuredDocumentRegionHandlerExtension handlerExtension = (StructuredDocumentRegionHandlerExtension) handler;
- handlerExtension.setStructuredDocument(oldInstance);
- }
- }
- }
- String holdString = newInstance.get();
- newInstance = null;
- oldInstance.set(holdString);
- }
-
-}
diff --git a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/AbstractNotifier.java b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/AbstractNotifier.java
deleted file mode 100644
index b8a691e190..0000000000
--- a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/AbstractNotifier.java
+++ /dev/null
@@ -1,232 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Jens Lukowski/Innoopract - initial renaming/restructuring
- *
- *******************************************************************************/
-package org.eclipse.wst.sse.core;
-
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Collections;
-
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.wst.sse.core.internal.Logger;
-
-
-
-/**
- * AbstractNotifier is similar to (and based on) the EMF NotifierImpl class.
- * This class is simpler (that is, not as many functions).
- */
-public abstract class AbstractNotifier implements INodeNotifier {
- private final static boolean debugAdapterNotificationTime = "true".equalsIgnoreCase(Platform.getDebugOption("org.eclipse.wst.sse.core/dom/adapter/notification/time")); //$NON-NLS-1$ //$NON-NLS-2$
- private final static int growthConstant = 3;
- private int adapterCount = 0;
-
- private INodeAdapter[] fAdapters;
-
- /**
- * AbstractNotifier constructor comment.
- */
- public AbstractNotifier() {
- super();
- }
-
- /**
- * addAdapter method comment.
- */
- public synchronized void addAdapter(INodeAdapter adapter) {
-
- if (adapter == null)
- return;
- ensureCapacity(adapterCount + 1);
- fAdapters[adapterCount++] = adapter;
- }
-
- private void ensureCapacity(int needed) {
- if (fAdapters == null) {
- // first time
- fAdapters = new INodeAdapter[needed + growthConstant];
- return;
- }
- int oldLength = fAdapters.length;
- if (oldLength < needed) {
- INodeAdapter[] oldAdapters = fAdapters;
- INodeAdapter[] newAdapters = new INodeAdapter[needed + growthConstant];
- System.arraycopy(oldAdapters, 0, newAdapters, 0, adapterCount);
- fAdapters = newAdapters;
- }
- }
-
- /**
- * Returns the adapterCount. Equivilent to, but faster than,
- * getAdapters().size();
- *
- * @return int
- */
- public int getAdapterCount() {
- return adapterCount;
- }
-
- /**
- * Default behavior for getting an adapter.
- */
- public INodeAdapter getAdapterFor(Object type) {
- // first, we'll see if we already have one
- INodeAdapter result = getExistingAdapter(type);
- // if we didn't find one in our list already,
- // let's create it
- if (result == null) {
- IFactoryRegistry reg = getFactoryRegistry();
- if (reg != null) {
- AdapterFactory factory = reg.getFactoryFor(type);
- if (factory != null) {
- result = factory.adapt(this);
- }
- }
- // We won't prevent null from being returned, but it would be
- // unusual.
- // It might be because Factory is not working correctly, or
- // not installed, so we'll allow warning message.
- if ((result == null) && (org.eclipse.wst.sse.core.util.Debug.displayWarnings)) {
- System.out.println("Warning: no adapter was found or created for " + type); //$NON-NLS-1$
- }
- }
- return result;
- }
-
- /**
- * Returns a shallow clone of list, since clients should not manipulate
- * our list directly. Instead, they should use add/removeAdapter.
- */
- public Collection getAdapters() {
- if (fAdapters != null) {
- if (adapterCount == 0) {
- fAdapters = null;
- return Collections.EMPTY_LIST;
- } else {
- // we need to make a new array, to be sure
- // it doesn't contain nulls at end, which may be
- // present there for "growth".
- INodeAdapter[] tempAdapters = new INodeAdapter[adapterCount];
- System.arraycopy(fAdapters, 0, tempAdapters, 0, adapterCount);
- // EMF uses the unmodifiableCollection. Its a bit of a
- // performance
- // drain, but may want to leave in since
- // it would "fail fast" if someone was trying to modify the
- // list.
- return Collections.unmodifiableCollection(Arrays.asList(tempAdapters));
- //return Arrays.asList(newAdapters);
- }
- } else
- return Collections.EMPTY_LIST;
- }
-
- private long getAdapterTimeCriteria() {
- // to "re-get" the property each time is a little awkward, but we
- // do it that way to avoid adding instance variable just for
- // debugging.
- // This method should only be called if debugAdapterNotifcationTime
- // is true.
- final String criteriaStr = Platform.getDebugOption("org.eclipse.wst.sse.core/dom/adapter/notification/time/criteria"); //$NON-NLS-1$
- long criteria = -1;
- if (criteriaStr != null) {
- try {
- criteria = Long.parseLong(criteriaStr);
- } catch (NumberFormatException e) {
- // catch to be sure we don't burb in notification loop,
- // but ignore, since just a debug aid
- }
- }
- return criteria;
- }
-
- public INodeAdapter getExistingAdapter(Object type) {
- INodeAdapter result = null;
- for (int i = 0; i < adapterCount; i++) {
- INodeAdapter a = fAdapters[i];
- if (a.isAdapterForType(type)) {
- result = a;
- break;
- }
- }
- // if we didn't find one in our list,
- // return the null result
- return result;
- }
-
- abstract public IFactoryRegistry getFactoryRegistry();
-
- public void notify(int eventType, Object changedFeature, Object oldValue, Object newValue, int pos) {
-
- if (fAdapters != null) {
- int localAdapterCount = 0;
- INodeAdapter[] localAdapters = null;
-
- // lock object while making local assignments
- synchronized (this) {
- localAdapterCount = adapterCount;
- localAdapters = new INodeAdapter[localAdapterCount];
- System.arraycopy(fAdapters, 0, localAdapters, 0, localAdapterCount);
- }
-
- for (int i = 0; i < localAdapterCount; i++) {
- INodeAdapter a = localAdapters[i];
-
- if (debugAdapterNotificationTime) {
- long getAdapterTimeCriteria = getAdapterTimeCriteria();
- long startTime = System.currentTimeMillis();
- // ** keep this line identical with non-debug version!!
- a.notifyChanged(this, eventType, changedFeature, oldValue, newValue, pos);
- long notifyDuration = System.currentTimeMillis() - startTime;
- if (getAdapterTimeCriteria >= 0 && notifyDuration > getAdapterTimeCriteria) {
- System.out.println("adapter notifyDuration: " + notifyDuration + " class: " + a.getClass()); //$NON-NLS-1$ //$NON-NLS-2$
- }
- } else {
- try {
- // ** keep this line identical with debug version!!
- a.notifyChanged(this, eventType, changedFeature, oldValue, newValue, pos);
- } catch (Exception e) {
- // Its important to "keep going", since notifications
- // occur between an
- // aboutToChange event and a changed event -- the
- // changed event typically being require
- // to restore state, etc. So, we just log message, do
- // not re-throw it, but
- // typically the exception does indicate a serious
- // program error.
- Logger.logException("A structured model client, " + a + " threw following exception during adapter notification (" + INodeNotifier.EVENT_TYPE_STRINGS[eventType] + " )", e); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- }
- }
-
- }
- }
- }
-
- public synchronized void removeAdapter(INodeAdapter a) {
- if (fAdapters == null || a == null)
- return;
- int newIndex = 0;
- INodeAdapter[] newAdapters = new INodeAdapter[fAdapters.length];
- int oldAdapterCount = adapterCount;
- boolean found = false;
- for (int oldIndex = 0; oldIndex < oldAdapterCount; oldIndex++) {
- INodeAdapter candidate = fAdapters[oldIndex];
- if (a == candidate) {
- adapterCount--;
- found = true;
- } else
- newAdapters[newIndex++] = fAdapters[oldIndex];
- }
- if (found)
- fAdapters = newAdapters;
- }
-
-}
diff --git a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/AbstractStructuredModel.java b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/AbstractStructuredModel.java
deleted file mode 100644
index 7a3b4651ae..0000000000
--- a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/AbstractStructuredModel.java
+++ /dev/null
@@ -1,1595 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Jens Lukowski/Innoopract - initial renaming/restructuring
- *
- *******************************************************************************/
-package org.eclipse.wst.sse.core;
-
-import java.io.File;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.io.UnsupportedEncodingException;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.core.runtime.jobs.ILock;
-import org.eclipse.wst.common.encoding.EncodingRule;
-import org.eclipse.wst.sse.core.document.ILockable;
-import org.eclipse.wst.sse.core.events.AboutToBeChangeEvent;
-import org.eclipse.wst.sse.core.events.IModelAboutToBeChangedListener;
-import org.eclipse.wst.sse.core.events.IStructuredDocumentListener;
-import org.eclipse.wst.sse.core.events.NewDocumentEvent;
-import org.eclipse.wst.sse.core.events.NoChangeEvent;
-import org.eclipse.wst.sse.core.events.RegionChangedEvent;
-import org.eclipse.wst.sse.core.events.RegionsReplacedEvent;
-import org.eclipse.wst.sse.core.events.StructuredDocumentRegionsReplacedEvent;
-import org.eclipse.wst.sse.core.exceptions.ResourceInUse;
-import org.eclipse.wst.sse.core.exceptions.SourceEditingRuntimeException;
-import org.eclipse.wst.sse.core.internal.Logger;
-import org.eclipse.wst.sse.core.internal.SSECorePlugin;
-import org.eclipse.wst.sse.core.modelhandler.IModelHandler;
-import org.eclipse.wst.sse.core.text.IStructuredDocument;
-import org.eclipse.wst.sse.core.undo.IStructuredTextUndoManager;
-import org.eclipse.wst.sse.core.util.URIResolver;
-import org.eclipse.wst.sse.core.util.Utilities;
-
-
-public abstract class AbstractStructuredModel implements IStructuredModel {
-
- class DirtyStateWatcher implements IStructuredDocumentListener {
-
- public void newModel(NewDocumentEvent structuredDocumentEvent) {
-
- // I don't think its safe to assume a new model
- // is always "fresh", so we'll leave dirty state
- // unchanged;
- // but we'll tell everyone about it.
- setDirtyState(fDirtyState);
- }
-
- public void noChange(NoChangeEvent structuredDocumentEvent) {
-
- // don't change dirty state
- }
-
- public void nodesReplaced(StructuredDocumentRegionsReplacedEvent structuredDocumentEvent) {
-
- setDirtyState(true);
- // no need to listen any more
- if (fStructuredDocument != null) {
- fStructuredDocument.removeDocumentChangedListener(fDirtyStateWatcher);
- }
- }
-
- public void regionChanged(RegionChangedEvent structuredDocumentEvent) {
-
- setDirtyState(true);
- // no need to listen any more
- if (fStructuredDocument != null) {
- fStructuredDocument.removeDocumentChangedListener(fDirtyStateWatcher);
- }
- }
-
- public void regionsReplaced(RegionsReplacedEvent structuredDocumentEvent) {
-
- setDirtyState(true);
- // no need to listen any more
- if (fStructuredDocument != null) {
- fStructuredDocument.removeDocumentChangedListener(fDirtyStateWatcher);
- }
- }
- }
-
- class DocumentToModelNotifier implements IStructuredDocumentListener, IModelAboutToBeChangedListener {
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.wst.sse.core.events.IModelAboutToBeChangedListener#modelAboutToBeChanged(org.eclipse.wst.sse.core.events.AboutToBeChangeEvent)
- */
- public void modelAboutToBeChanged(AboutToBeChangeEvent structuredDocumentEvent) {
- // If we didn't originate the change, take note we are about to
- // change based on our underlying document changing.
- // If we did originate the change, we, or client, should have
- // already called aboutToChangeModel.
- if (structuredDocumentEvent.getOriginalSource() != this) {
- aboutToChangeModel();
- }
-
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.wst.sse.core.events.IStructuredDocumentListener#newModel(org.eclipse.wst.sse.core.events.NewDocumentEvent)
- */
- public void newModel(NewDocumentEvent structuredDocumentEvent) {
- // if we didn't originate the change, take note we have changed
- if (structuredDocumentEvent.getOriginalSource() != this) {
- changedModel();
- }
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.wst.sse.core.events.IStructuredDocumentListener#noChange(org.eclipse.wst.sse.core.events.NoChangeEvent)
- */
- public void noChange(NoChangeEvent structuredDocumentEvent) {
- // if we didn't originate the change, take note we have changed
- if (structuredDocumentEvent.getOriginalSource() != this) {
- changedModel();
- }
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.wst.sse.core.events.IStructuredDocumentListener#nodesReplaced(org.eclipse.wst.sse.core.events.StructuredDocumentRegionsReplacedEvent)
- */
- public void nodesReplaced(StructuredDocumentRegionsReplacedEvent structuredDocumentEvent) {
- // if we didn't originate the change, take note we have changed
- if (structuredDocumentEvent.getOriginalSource() != this) {
- changedModel();
- }
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.wst.sse.core.events.IStructuredDocumentListener#regionChanged(org.eclipse.wst.sse.core.events.RegionChangedEvent)
- */
- public void regionChanged(RegionChangedEvent structuredDocumentEvent) {
- // if we didn't originate the change, take note we have changed
- if (structuredDocumentEvent.getOriginalSource() != this) {
- changedModel();
- }
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.wst.sse.core.events.IStructuredDocumentListener#regionsReplaced(org.eclipse.wst.sse.core.events.RegionsReplacedEvent)
- */
- public void regionsReplaced(RegionsReplacedEvent structuredDocumentEvent) {
- // if we didn't originate the change, take note we have changed
- if (structuredDocumentEvent.getOriginalSource() != this) {
- changedModel();
- }
- }
-
- }
-
- static final String DEBUG_STATE_TRACE_CATEGORY = "org.eclipse.wst.sse.core/structuredmodel/state";
- static final boolean DEBUG_STATE = "true".equalsIgnoreCase(Platform.getDebugOption(DEBUG_STATE_TRACE_CATEGORY));
-
- private IFactoryRegistry factoryRegistry;
- private String fBaseLocation;
- boolean fDirtyState;
- DirtyStateWatcher fDirtyStateWatcher;
- DocumentToModelNotifier fDocumentToModelNotifier;
- private String fExplicitContentTypeIdentifier;
- private String fId;
-
- private LifecycleNotificationManager fLifecycleNotificationManager;
-
- private final Object fListenerLock = new byte[0];
- private ILock fLockObject;
- // private String fLineDelimiter;
- // private Object fType;
- private IModelHandler fModelHandler;
- private IModelManager fModelManager;
- private int fModelStateChanging;
- private Object[] fModelStateListeners;
- private boolean fNewState = false;
- private URIResolver fResolver;
- IStructuredDocument fStructuredDocument;
- /**
- * The time stamp of the underlying resource's modification date, at the
- * time this model was created, or the last time it was saved. Note: for
- * this version, this variable is not set automatically, be needs to be
- * managed by client. The FileModelProvider does this for most cases, but
- * if client do not use FileModelProvider, they must set this variable
- */
- public long fSynchronizationStamp = IResource.NULL_STAMP;
- private boolean reinitializationNeeded;
- private Object reinitializeStateData;
-
- /**
- * AbstractStructuredModel constructor comment.
- */
- public AbstractStructuredModel() {
-
- super();
- fDirtyStateWatcher = new DirtyStateWatcher();
- fDocumentToModelNotifier = new DocumentToModelNotifier();
- }
-
-
- private void _commonRelease() {
-
- if (factoryRegistry != null) {
- factoryRegistry.release();
- }
- // if document as not been changed, we'll still be listening for
- // first change. This is not a critical clean up, since presumanly
- // whole model and document are "going away", but can make
- // other memory leaks harder to find if we stay attached.
- // (Note: my first thought was to set fStructuredDocument to null
- // also,
- // but there's others in shutdown process that still need to
- // get it, in order to disconnect from it.)
- if (fStructuredDocument != null) {
- fStructuredDocument.removeDocumentChangedListener(fDirtyStateWatcher);
- }
- }
-
- /**
- * This method is just for getting an instance of the model manager of the
- * right Impl type, to be used "internally" for making protected calls
- * directly to the impl class.
- */
- private ModelManagerImpl _getModelManager() {
- // TODO_future: redesign so we don't need this 'Impl' version
- if (fModelManager == null) {
- fModelManager = StructuredModelManager.getModelManager();
- }
-
- return (ModelManagerImpl) fModelManager;
- }
-
- /**
- * This API allows clients to declare that they are about to make a
- * "large" change to the model. This change might be in terms of content
- * or it might be in terms of the model id or base location. Note that in
- * the case of embedded calls, notification to listners is sent only once.
- * Note that the client who is making these changes has the responsibility
- * to restore the models state once finished with the changes. See
- * getMemento and restoreState. The method isModelStateChanging can be
- * used by a client to determine if the model is already in a change
- * sequence.
- */
- public void aboutToChangeModel() {
-
-
- // notice this is just a public avenue to our protected method
- internalAboutToBeChanged();
- }
-
-
- public void aboutToReinitializeModel() {
-
-
-
- // notice this is just a public avenue to our protected method
- fireModelAboutToBeReinitialized();
- }
-
-
- public void addModelLifecycleListener(IModelLifecycleListener listener) {
-
- synchronized (fListenerLock) {
-
- if (fLifecycleNotificationManager == null) {
- fLifecycleNotificationManager = new LifecycleNotificationManager();
- }
- fLifecycleNotificationManager.addListener(listener);
- }
- }
-
- public void addModelStateListener(IModelStateListener listener) {
-
- synchronized (fListenerLock) {
-
- if (!Utilities.contains(fModelStateListeners, listener)) {
- int oldSize = 0;
- if (fModelStateListeners != null) {
- // normally won't be null, but we need to be sure, for
- // first
- // time through
- oldSize = fModelStateListeners.length;
- }
- int newSize = oldSize + 1;
- Object[] newListeners = new Object[newSize];
- if (fModelStateListeners != null) {
- System.arraycopy(fModelStateListeners, 0, newListeners, 0, oldSize);
- }
- // add listener to last position
- newListeners[newSize - 1] = listener;
- //
- // now switch new for old
- fModelStateListeners = newListeners;
- }
- }
- }
-
- /**
- *
- */
- private void beginLock() {
- fLockObject = getLockObject();
- if (fLockObject != null)
- fLockObject.acquire();
- }
-
- public void beginRecording(Object requester) {
-
- beginRecording(requester, null, null);
- }
-
- public void beginRecording(Object requester, int cursorPosition, int selectionLength) {
-
- beginRecording(requester, null, null, cursorPosition, selectionLength);
- }
-
- public void beginRecording(Object requester, String label) {
-
- beginRecording(requester, label, null);
- }
-
- public void beginRecording(Object requester, String label, int cursorPosition, int selectionLength) {
-
- beginRecording(requester, label, null, cursorPosition, selectionLength);
- }
-
- public void beginRecording(Object requester, String label, String description) {
-
- if (getUndoManager() != null)
- getUndoManager().beginRecording(requester, label, description);
- }
-
- public void beginRecording(Object requester, String label, String description, int cursorPosition, int selectionLength) {
-
- if (getUndoManager() != null)
- getUndoManager().beginRecording(requester, label, description, cursorPosition, selectionLength);
- }
-
- /**
- * This API allows a client controlled way of notifying all ModelEvent
- * listners that the model has been changed. This method is a matched pair
- * to aboutToChangeModel, and *must* be called after aboutToChangeModel
- * ... or some listeners could be left waiting indefinitely for the
- * changed event. So, its suggested that changedModel always be in a
- * finally clause. Likewise, a client should never call changedModel
- * without calling aboutToChangeModel first. In the case of embedded
- * calls, the notification is just sent once.
- */
- public void changedModel() {
-
-
- // notice this is just a public avenue to our protected method
- internalModelChanged();
- // also note!
- // if we've been "changed" by a client, we might still need
- // to be re-initialized, so we'll check and handle that here.
- // Note only does this provide a solution to some "missed"
- // re-inits, in provides a built in way for clients to
- // "force" the model to handle itself, by bracketing any
- // changes with aboutToChange and changed, the model itself
- // will check. But only call re-init if all other pending
- // modelChanged states have been handled.
- if (fModelStateChanging == 0 && isReinitializationNeeded()) {
- reinit();
- }
- }
-
-
- /**
- * Based on similar method in FileDocumentProvider. It will provide what
- * the modificationStamp would be if resetSynchronzationStamp(resource)
- * were used, although for this 'compute' API, no changes to the instance
- * are made.
- */
- public long computeModificationStamp(IResource resource) {
-
-
- long modificationStamp = resource.getModificationStamp();
- IPath path = resource.getLocation();
- if (path == null) {
- return modificationStamp;
- }
- // Note: checking existence of file is a little different than
- // impl in
- // the FileDocumentProvider. See defect number 223790.
- File file = path.toFile();
- if (!file.exists()) {
- return modificationStamp;
- }
- modificationStamp = file.lastModified();
- return modificationStamp;
- }
-
-
- /**
- * Provides a copy of the model, but a new ID must be provided. The
- * principle of this copy is not to copy fields, etc., as is typically
- * done in a clone method, but to return a model with the same content in
- * the structuredDocument. Note: It is the callers responsibility to
- * setBaseLocation, listners, etc., as appropriate. Type and Encoding are
- * the only fields set by this method. If the newId provided already exist
- * in the model manager, a ResourceInUse exception is thrown.
- */
- public IStructuredModel copy(String newId) throws ResourceInUse {
-
-
- IStructuredModel newModel = null;
- // this first one should fail, if not, its treated as an error
- // If the caller wants to use an existing one, they can call
- // getExisting
- // after this failure
- newModel = getModelManager().getExistingModelForEdit(newId);
- if (newModel != null) {
- // be sure to release the reference we got "by accident" (and
- // no
- // longer need)
- newModel.releaseFromEdit();
- throw new ResourceInUse();
- }
- newModel = getModelManager().copyModelForEdit(getId(), newId);
- return newModel;
- }
-
-
- /**
- * Disable undo management.
- */
- public void disableUndoManagement() {
-
- if (getUndoManager() != null)
- getUndoManager().disableUndoManagement();
- }
-
- /**
- * Enable undo management.
- */
- public void enableUndoManagement() {
-
- if (getUndoManager() != null)
- getUndoManager().enableUndoManagement();
- }
-
- /**
- * endLock is protected only for a very special purpose. So subclasses can
- * call it to end the lock after updates have been made, but before
- * notifications are sent
- *
- */
- protected final void endLock() {
- if (fLockObject != null) {
- fLockObject.release();
- }
- // fLock being null is used as an indicator that
- // we are not locked (and used in logic to decide
- // acquire/release.
- fLockObject = null;
-
- }
-
- public void endRecording(Object requester) {
-
- if (getUndoManager() != null)
- getUndoManager().endRecording(requester);
- }
-
- public void endRecording(Object requester, int cursorPosition, int selectionLength) {
-
- if (getUndoManager() != null)
- getUndoManager().endRecording(requester, cursorPosition, selectionLength);
- }
-
- /**
- * Informs all registered model state listeners that the the model is
- * about to under go a change. This change might be in terms of contents
- * or might be in terms of the model's id or base location.
- */
- private void fireModelAboutToBeChanged() {
-
- // we must assign listeners to local variable, since the add and
- // remove listner
- // methods can change the actual instance of the listener array
- // from another thread
- if (fModelStateListeners != null) {
- Object[] holdListeners = fModelStateListeners;
- for (int i = 0; i < holdListeners.length; i++) {
- ((IModelStateListener) holdListeners[i]).modelAboutToBeChanged(this);
- }
- }
-
- }
-
- protected void fireModelAboutToBeReinitialized() {
-
- // we must assign listeners to local variable, since the add and
- // remove
- // listner
- // methods can change the actual instance of the listener array from
- // another thread
- if (fModelStateListeners != null) {
- if (DEBUG_STATE) {
- System.out.println("IModelStateListener event for " + getId() + " : modelAboutToBeReinitialized");
- }
- Object[] holdListeners = fModelStateListeners;
- for (int i = 0; i < holdListeners.length; i++) {
- // NOTE: trick for transition. We actual use the same
- // listeners
- // as modelState, but only send this to those that have
- // implemented ModelStateExtended.
- IModelStateListener listener = (IModelStateListener) holdListeners[i];
- if (listener instanceof IModelStateListenerExtended) {
- IModelStateListenerExtended extendedListner = (IModelStateListenerExtended) listener;
- extendedListner.modelAboutToBeReinitialized(this);
- }
- }
- }
- }
-
- private void fireModelChanged() {
- // we must assign listeners
- // to local variable, since the add
- // and remove listner
- // methods can change the actual instance of the listener
- // array from another thread
- if (fModelStateListeners != null) {
- Object[] holdListeners = fModelStateListeners;
- for (int i = 0; i < holdListeners.length; i++) {
- try {
- ((IModelStateListener) holdListeners[i]).modelChanged(this);
- }
- // its so criticial that the begin/end arrive in
- // pairs,
- // if there happends to be an error in one of the
- // modelChanged,
- // they we want to be sure rest complete ok.
- catch (Exception e) {
- Logger.logException(e);
- }
- }
-
- }
- }
-
- /**
- * Informs all registered model state listeners about a change in the
- * dirty state of the model. The dirty state is entirely about changes in
- * the content of the model (not, for example, about changes to id, or
- * base location -- see modelMoved).
- */
- protected void fireModelDirtyStateChanged(IStructuredModel element, boolean isDirty) {
-
- // we must assign listeners to local variable, since the add and
- // remove
- // listner
- // methods can change the actual instance of the listener array from
- // another thread
- if (fModelStateListeners != null) {
- if (DEBUG_STATE) {
- System.out.println("IModelStateListener event for " + getId() + " : modelDirtyStateChanged");
- }
- Object[] holdListeners = fModelStateListeners;
- for (int i = 0; i < holdListeners.length; i++) {
- ((IModelStateListener) holdListeners[i]).modelDirtyStateChanged(element, isDirty);
- }
- }
- }
-
- protected void fireModelReinitialized() {
-
- // we must assign listeners to local variable, since the add and
- // remove
- // listner
- // methods can change the actual instance of the listener array from
- // another thread
- if (fModelStateListeners != null) {
- if (DEBUG_STATE) {
- System.out.println("IModelStateListener event for " + getId() + " : modelReinitialized");
- }
- Object[] holdListeners = fModelStateListeners;
- for (int i = 0; i < holdListeners.length; i++) {
- // NOTE: trick for transition. We actual use the same
- // listeners
- // as modelState, but only send this to those that have
- // implemented ModelStateExtended.
- IModelStateListener listener = (IModelStateListener) holdListeners[i];
- if (listener instanceof IModelStateListenerExtended) {
- IModelStateListenerExtended extendedListner = (IModelStateListenerExtended) listener;
- extendedListner.modelReinitialized(this);
- }
- }
- }
- }
-
- /**
- * Informs all registered model state listeners about the deletion of a
- * model's underlying resource.
- */
- protected void fireModelResourceDeleted(IStructuredModel element) {
-
- // we must assign listeners to local variable, since the add and
- // remove
- // listner
- // methods can change the actual instance of the listener array from
- // another thread
- if (fModelStateListeners != null) {
- if (DEBUG_STATE) {
- System.out.println("IModelStateListener event for " + getId() + " : modelResourceDeleted");
- }
- Object[] holdListeners = fModelStateListeners;
- for (int i = 0; i < holdListeners.length; i++) {
- ((IModelStateListener) holdListeners[i]).modelResourceDeleted(element);
- }
- }
- }
-
- /**
- * Informs all registered model state listeners that the resource
- * underlying a model has been moved. This is typically reflected in a
- * change to the id, baseLocation, or both.
- */
- protected void fireModelResourceMoved(IStructuredModel originalElement, IStructuredModel movedElement) {
-
- // we must assign listeners to local variable, since the add and
- // remove
- // listner
- // methods can change the actual instance of the listener array from
- // another thread
- if (fModelStateListeners != null) {
- if (DEBUG_STATE) {
- System.out.println("IModelStateListener event for " + getId() + " : modelResourceMoved");
- }
- Object[] holdListeners = fModelStateListeners;
- for (int i = 0; i < holdListeners.length; i++) {
- ((IModelStateListener) holdListeners[i]).modelResourceMoved(originalElement, movedElement);
- }
- }
- }
-
- public Object getAdapter(Class adapter) {
-
- return Platform.getAdapterManager().getAdapter(this, adapter);
- }
-
- /**
- * @return java.lang.String
- */
- public java.lang.String getBaseLocation() {
-
- return fBaseLocation;
- }
-
- /**
- * @see org.eclipse.wst.sse.core.IStructuredModel#getContentTypeIdentifier()
- */
- public String getContentTypeIdentifier() {
- if (fExplicitContentTypeIdentifier != null)
- return fExplicitContentTypeIdentifier;
- return fModelHandler.getAssociatedContentTypeId();
- }
-
- /**
- *
- */
- public IFactoryRegistry getFactoryRegistry() {
- if (factoryRegistry == null) {
- factoryRegistry = new FactoryRegistry();
- }
- return factoryRegistry;
- }
-
- /**
- * The id is the id that the model manager uses to identify this model
- */
- public String getId() {
-
-
- return fId;
- }
-
- public abstract IndexedRegion getIndexedRegion(int offset);
-
- /**
- * @return
- */
- private ILock getLockObject() {
-
- // we always "get afresh" the lock object from our document,
- // just in case the instance of the document changes.
- ILock result = null;
- IStructuredDocument doc = getStructuredDocument();
- if (doc instanceof ILockable) {
- // remember, more than one client can get the
- // lock object, its during the aquire that the
- // lock on the thread is obtained.
- result = ((ILockable) doc).getLockObject();
- }
- return result;
- }
-
-
- /**
- * This method returns a mememto that can later be used to restore the
- * state at this point. A model's state, in this sense, does not relate to
- * its content, or Ids, etc., just its dirty state, and its
- * synchronization state with its underlying resource. The 'resource'
- * argument must be the resource that underlies the instance of the model
- * this method is sent to. Note: this parameter will not be required in
- * future versions of 'strucutured model'.
- */
- public IStateMemento getMemento(IResource resource) {
-
- ModelStateMemento memento = new ModelStateMemento();
- memento.setUnderlyingResource(resource);
- memento.setDirtyState(isDirty());
- long modDate = computeModificationStamp(resource);
- memento.setDatesInSync(fSynchronizationStamp == modDate);
- return memento;
- }
-
- /**
- * Gets the contentTypeDescription.
- *
- * @return Returns a ContentTypeDescription
- */
- public IModelHandler getModelHandler() {
-
- return fModelHandler;
- }
-
- /**
- * @return com.ibm.sed.model.IModelManager
- */
- public IModelManager getModelManager() {
-
- return _getModelManager();
- }
-
- /**
- * This function returns the reference count of underlying model.
- */
- // TODO: try to refine the design not to use this function
- public int getReferenceCount() {
-
-
- if (getModelManager() == null)
- return 0;
- return getModelManager().getReferenceCount(getId());
- }
-
-
- /**
- * This function returns the reference count of underlying model.
- */
- // TODO: try to refine the design not to use this function
- public int getReferenceCountForEdit() {
-
-
-
- if (getModelManager() == null)
- return 0;
- return getModelManager().getReferenceCountForEdit(getId());
- }
-
-
- /**
- * This function returns the reference count of underlying model.
- */
- // TODO: try to refine the design not to use this function
- public int getReferenceCountForRead() {
-
-
-
- if (getModelManager() == null)
- return 0;
- return getModelManager().getReferenceCountForRead(getId());
- }
-
- public Object getReinitializeStateData() {
-
- return reinitializeStateData;
- }
-
-
- /**
- * @return com.ibm.sed.util.URIResolver
- */
- public URIResolver getResolver() {
-
- return fResolver;
- }
-
- /**
- * @return com.ibm.sed.structuredDocument.IStructuredDocument
- */
- public IStructuredDocument getStructuredDocument() {
-
- return fStructuredDocument;
- }
-
- /**
- * Insert the method's description here. Creation date: (9/7/2001 2:30:26
- * PM)
- *
- * @return long
- */
- public long getSynchronizationStamp() {
-
- return fSynchronizationStamp;
- }
-
- public IStructuredTextUndoManager getUndoManager() {
-
- IStructuredTextUndoManager structuredTextUndoManager = null;
- IStructuredDocument structuredDocument = getStructuredDocument();
- if (structuredDocument == null) {
- structuredTextUndoManager = null;
- } else {
- structuredTextUndoManager = structuredDocument.getUndoManager();
- }
- return structuredTextUndoManager;
- }
-
- public void initId(String id) {
- fId = id;
- }
-
- protected void internalAboutToBeChanged() {
-
- // notice we only fire this event if we are not
- // already in a model state changing sequence
- if (fModelStateChanging == 0) {
-
- if (DEBUG_STATE) {
- System.out.println("IModelStateListener event for " + getId() + " : modelAboutToBeChanged"); //$NON-NLS-1$
- }
-
- fireModelAboutToBeChanged();
- // begin lock after listeners notified, otherwise
- // deadlock could occur if they call us back.
- beginLock();
-
- }
- // we always increment counter, for every request (so *must* receive
- // corresponding number of 'changedModel' requests)
- fModelStateChanging++;
- }
-
- /**
- * Informs all registered model state listeners that an impending change
- * is now complete. This method must only be called by 'modelChanged'
- * since it keeps track of counts.
- */
- protected void internalModelChanged() {
-
- // always decrement
- fModelStateChanging--;
-
-
- // Check integrity
- // to be less than zero is a programming error,
- // but we'll reset to zero
- // and try to continue
- if (fModelStateChanging < 0) {
- fModelStateChanging = 0;
- Logger.log(Logger.ERROR, "Program Error: modelStateChanging was less than zero");
- }
-
-
- // We only fire this event if all pending requests are done.
- // That is, if we've received the same number of modelChanged as
- // we have aboutToChangeModel.
- if (fModelStateChanging == 0) {
- if (DEBUG_STATE) {
- System.out.println("IModelStateListener event for " + getId() + " : modelChanged"); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- endLock();
- // notifify listeners outline locked state (or deadlock
- // can occur if one of them calls us back.
- fireModelChanged();
- }
- }
-
- public boolean isDirty() {
-
- return fDirtyState;
- }
-
- /**
- * This method has very special purpose, its used in subclass
- * 'changedModel' to know when to do "ending" sorts of things, right
- * before a call to super.ChangedModel would in deed put the model in
- * 'end' state. Put another way, at the beginning of the subclasses's
- * changedModel, the isModelStateChanging is true, but at end, it will be
- * false. So, this method allows a small "peek ahead".
- */
- protected boolean isModelChangeStateOnVergeOfEnding() {
-
-
- return fModelStateChanging == 1;
- }
-
- /**
- * This method can be called to determine if the model is within a
- * "aboutToChange" and "changed" sequence.
- */
- public boolean isModelStateChanging() {
-
-
- return fModelStateChanging > 0;
- }
-
- public boolean isNew() {
-
- return fNewState;
- }
-
- public boolean isReinitializationNeeded() {
-
- return reinitializationNeeded;
- }
-
- public boolean isSaveNeeded() {
-
-
- if (!isSharedForEdit())
- return isDirty();
- else
- return false;
- }
-
-
- /**
- * This function returns true if there are other references to the
- * underlying model.
- */
- public boolean isShared() {
- if (getModelManager() == null)
- return false;
- return getModelManager().isShared(getId());
- }
-
-
- /**
- * This function returns true if there are other references to the
- * underlying model.
- */
- public boolean isSharedForEdit() {
-
-
- if (getModelManager() == null)
- return false;
- return getModelManager().isSharedForEdit(getId());
- }
-
-
- /**
- * This function returns true if there are other references to the
- * underlying model.
- */
- public boolean isSharedForRead() {
-
-
- if (getModelManager() == null)
- return false;
- return getModelManager().isSharedForRead(getId());
- }
-
-
- public void modelReinitialized() {
-
-
- // notice this is just a public avenue to our protected method
- fireModelReinitialized();
- }
-
- public IStructuredModel newInstance() throws IOException {
-
- IStructuredModel newModel = null;
- // we delegate to the model manager, so loader, etc., can be
- // used.
- newModel = getModelManager().createNewInstance(this);
- return newModel;
- }
-
- public IStructuredModel reinit() {
-
-
- IStructuredModel result = null;
- if (fModelStateChanging == 0) {
- try {
- aboutToChangeModel();
- aboutToReinitializeModel();
- result = _getModelManager().reinitialize(this);
- } finally {
- setReinitializeNeeded(false);
- setReinitializeStateData(null);
- modelReinitialized();
- changedModel();
- }
- } else {
- System.out.println("indeed!!!"); //$NON-NLS-1$
- }
- return result;
- }
-
-
- /**
- * This function allows the model to free up any resources it might be
- * using. In particular, itself, as stored in the IModelManager.
- */
- public void releaseFromEdit() {
-
-
- if (getModelManager() == null) {
- throw new SourceEditingRuntimeException("Warning: AbstractStructuredModel::close: model manager was null during a close of a model (which should be impossible)"); //$NON-NLS-1$
- } else {
- // be sure to check the shared state before releasing. (Since
- // isShared assumes a count
- // of 1 means not shared ... and we want our '1' to be that
- // one.)
- boolean isShared = isShared();
-
- if (!isShared) {
- signalPreLifeCycleEventRelease(this);
- }
-
- _getModelManager().releaseFromEdit(getId());
- // if no one else is using us, free up
- // an resources
- if (!isShared) {
- _commonRelease();
- signalPostLifeCycleListenerRelease(this);
- }
- }
- }
-
- /**
- * This function allows the model to free up any resources it might be
- * using. In particular, itself, as stored in the IModelManager.
- */
- public void releaseFromRead() {
-
-
- if (getModelManager() == null) {
- throw new SourceEditingRuntimeException("Warning: AbstractStructuredModel::close: model manager was null during a close of a model (which should be impossible)"); //$NON-NLS-1$
- } else {
- // be sure to check the shared state before
- // releasing. (Since isShared assumes a count
- // of 1 means not shared ... and we want
- // our '1' to be that one.)
- boolean isShared = isShared();
-
- if (!isShared) {
- signalPreLifeCycleEventRelease(this);
- }
-
- _getModelManager().releaseFromRead(getId());
- // if no one else is using us, free up
- // an resources
- if (!isShared) {
- // factoryRegistry.release();
- _commonRelease();
- signalPostLifeCycleListenerRelease(this);
- }
- }
- }
-
-
- /**
- * This function replenishes the model with the resource without saving
- * any possible changes. It is used when one editor may be closing, and
- * specifially says not to save the model, but another "display" of the
- * model still needs to hang on to some model, so needs a fresh copy.
- */
- public IStructuredModel reload(InputStream inputStream) throws IOException {
- IStructuredModel result = null;
- try {
- aboutToChangeModel();
- result = _getModelManager().reloadModel(getId(), inputStream);
- } catch (UnsupportedEncodingException e) {
- // its a very serious error to get an unsupported encoding
- // exception,
- // since we've presumable loaded it once already, so won't
- // bother
- // with a checked exception.
- throw new SourceEditingRuntimeException(e);
- } finally {
- changedModel();
- }
- return result;
- }
-
- public void removeModelLifecycleListener(IModelLifecycleListener listener) {
-
- // if manager is null, then none have been added, so
- // no need to remove it.
- if (fLifecycleNotificationManager == null)
- return;
- synchronized (fListenerLock) {
- fLifecycleNotificationManager.removeListener(listener);
- }
- }
-
-
- public void removeModelStateListener(IModelStateListener listener) {
-
- if (listener == null)
- return;
- if (fModelStateListeners == null)
- return;
- // if its not in the listeners, we'll ignore the request
- synchronized (fListenerLock) {
- if (Utilities.contains(fModelStateListeners, listener)) {
- int oldSize = fModelStateListeners.length;
- int newSize = oldSize - 1;
- Object[] newListeners = new Object[newSize];
- int index = 0;
- for (int i = 0; i < oldSize; i++) {
- if (fModelStateListeners[i] == listener) { // ignore
- } else {
- // copy old to new if its not the one we are
- // removing
- newListeners[index++] = fModelStateListeners[i];
- }
- }
- // now that we have a new array, let's switch it for the
- // old
- // one
- fModelStateListeners = newListeners;
- }
- }
- }
-
-
- /**
- * A method that modififies the model's synchonization stamp to match the
- * resource. Turns out there's several ways of doing it, so this ensures a
- * common algorithm.
- */
- public void resetSynchronizationStamp(IResource resource) {
-
-
- setSynchronizationStamp(computeModificationStamp(resource));
- }
-
-
- /**
- * This API allows a client to initiate notification to all interested
- * parties that a model's underlying resource has been deleted.
- */
- public void resourceDeleted() {
-
-
- // notice this is just a public avenue to our protected method
- fireModelResourceDeleted(this);
- }
-
-
- /**
- * This method allows a model client to initiate notification to all
- * interested parties that a model's underlying resource location has
- * changed. Note: we assume caller has already changed baseLocation, Id,
- * etc., since its really up to the client to determine what's "new" about
- * a moved model. Caution: 'this' and 'newModel' may be the same object.
- * This is the case for current working with FileModelProvider, but have
- * left the dual argument for future possiblities.
- */
- public void resourceMoved(IStructuredModel newModel) {
-
-
- // notice this is just a public avenue to our protected method
- fireModelResourceMoved(this, newModel);
- }
-
-
- public void restoreState(IStateMemento memento) {
-
-
- ModelStateMemento mMemento = (ModelStateMemento) memento;
- // be sure to use setter, so side effects take place.
- setDirtyState(mMemento.isDirtyState());
- if (mMemento.isDatesInSync()) {
- IResource resource = mMemento.getUnderlyingResource();
- setSynchronizationStamp(computeModificationStamp(resource));
- }
- }
-
-
- public void save() throws UnsupportedEncodingException, IOException, CoreException {
-
- int type = ModelLifecycleEvent.MODEL_SAVED | ModelLifecycleEvent.PRE_EVENT;
- ModelLifecycleEvent modelLifecycleEvent = new ModelLifecycleEvent(this, type);
- signalLifecycleEvent(modelLifecycleEvent);
-
- try {
- String stringId = getId();
- _getModelManager().saveModel(stringId, EncodingRule.CONTENT_BASED);
- }
-
- finally {
- // we put end notificatin in finally block, so even if
- // error occurs during save, listeners are still notified,
- // since their code could depend on receiving, to clean up
- // some state, or coordinate other resources.
- type = ModelLifecycleEvent.MODEL_SAVED | ModelLifecycleEvent.POST_EVENT;
- modelLifecycleEvent = new ModelLifecycleEvent(this, type);
- signalLifecycleEvent(modelLifecycleEvent);
- }
- }
-
-
- public void save(EncodingRule encodingRule) throws UnsupportedEncodingException, IOException, CoreException {
-
- int type = ModelLifecycleEvent.MODEL_SAVED | ModelLifecycleEvent.PRE_EVENT;
- ModelLifecycleEvent modelLifecycleEvent = new ModelLifecycleEvent(this, type);
- signalLifecycleEvent(modelLifecycleEvent);
-
- try {
- String stringId = getId();
- _getModelManager().saveModel(stringId, encodingRule);
- } finally {
- // we put end notificatin in finally block, so even if
- // error occurs during save, listeners are still notified,
- // since their code could depend on receiving, to clean up
- // some state, or coordinate other resources.
- type = ModelLifecycleEvent.MODEL_SAVED | ModelLifecycleEvent.POST_EVENT;
- modelLifecycleEvent = new ModelLifecycleEvent(this, type);
- signalLifecycleEvent(modelLifecycleEvent);
- }
- }
-
-
- public void save(IFile iFile) throws UnsupportedEncodingException, IOException, CoreException {
-
- int type = ModelLifecycleEvent.MODEL_SAVED | ModelLifecycleEvent.PRE_EVENT;
- ModelLifecycleEvent modelLifecycleEvent = new ModelLifecycleEvent(this, type);
- signalLifecycleEvent(modelLifecycleEvent);
-
- try {
- String stringId = getId();
- _getModelManager().saveModel(iFile, stringId, EncodingRule.CONTENT_BASED);
- }
-
- finally {
- // we put end notificatin in finally block, so even if
- // error occurs during save, listeners are still notified,
- // since their code could depend on receiving, to clean up
- // some state, or coordinate other resources.
- type = ModelLifecycleEvent.MODEL_SAVED | ModelLifecycleEvent.POST_EVENT;
- modelLifecycleEvent = new ModelLifecycleEvent(this, type);
- signalLifecycleEvent(modelLifecycleEvent);
- }
- }
-
-
- public void save(IFile iFile, EncodingRule encodingRule) throws UnsupportedEncodingException, IOException, CoreException {
-
- int type = ModelLifecycleEvent.MODEL_SAVED | ModelLifecycleEvent.PRE_EVENT;
- ModelLifecycleEvent modelLifecycleEvent = new ModelLifecycleEvent(this, type);
- signalLifecycleEvent(modelLifecycleEvent);
-
- try {
- String stringId = getId();
- _getModelManager().saveModel(iFile, stringId, encodingRule);
- } finally {
- // we put end notificatin in finally block, so even if
- // error occurs during save, listeners are still notified,
- // since their code could depend on receiving, to clean up
- // some state, or coordinate other resources.
- type = ModelLifecycleEvent.MODEL_SAVED | ModelLifecycleEvent.POST_EVENT;
- modelLifecycleEvent = new ModelLifecycleEvent(this, type);
- signalLifecycleEvent(modelLifecycleEvent);
- }
- }
-
-
- public void save(OutputStream outputStream) throws UnsupportedEncodingException, CoreException, IOException {
-
- int type = ModelLifecycleEvent.MODEL_SAVED | ModelLifecycleEvent.PRE_EVENT;
- ModelLifecycleEvent modelLifecycleEvent = new ModelLifecycleEvent(this, type);
- signalLifecycleEvent(modelLifecycleEvent);
-
- try {
- String stringId = getId();
- _getModelManager().saveModel(stringId, outputStream, EncodingRule.CONTENT_BASED);
- }
-
- finally {
- // we put end notificatin in finally block, so even if
- // error occurs during save, listeners are still notified,
- // since their code could depend on receiving, to clean up
- // some state, or coordinate other resources.
- type = ModelLifecycleEvent.MODEL_SAVED | ModelLifecycleEvent.POST_EVENT;
- modelLifecycleEvent = new ModelLifecycleEvent(this, type);
- signalLifecycleEvent(modelLifecycleEvent);
- }
- }
-
-
- /**
- * This attribute is typically used to denote the model's underlying
- * resource.
- */
- public void setBaseLocation(java.lang.String newBaseLocation) {
-
- fBaseLocation = newBaseLocation;
- }
-
- public void setContentTypeIdentifier(String contentTypeIdentifier) {
- fExplicitContentTypeIdentifier = contentTypeIdentifier;
- }
-
- /**
- *
- */
- public void setDirtyState(boolean dirtyState) {
-
- // no need to process (set or fire event), if same value
- if (fDirtyState != dirtyState) {
- // prechange notificaiton
- int type = ModelLifecycleEvent.MODEL_DIRTY_STATE | ModelLifecycleEvent.PRE_EVENT;
- ModelLifecycleEvent modelLifecycleEvent = new ModelLifecycleEvent(this, type);
- signalLifecycleEvent(modelLifecycleEvent);
-
-
- // the actual change
- fDirtyState = dirtyState;
-
- // old notification
- // TODO: C3 remove old notification
- if (fDirtyState == false) {
- // if we are being set to not dirty (such as just been saved)
- // then we need to start listening for changes
- // again to know when to set state to true;
- getStructuredDocument().addDocumentChangedListener(fDirtyStateWatcher);
- }
- fireModelDirtyStateChanged(this, dirtyState);
-
-
- // post change notification
- type = ModelLifecycleEvent.MODEL_DIRTY_STATE | ModelLifecycleEvent.POST_EVENT;
- modelLifecycleEvent = new ModelLifecycleEvent(this, type);
- signalLifecycleEvent(modelLifecycleEvent);
- }
- }
-
- /**
- * @deprecated - will likely be deprecated soon, in favor of direct 'adds'
- * ... but takes some redesign.
- */
- public void setFactoryRegistry(IFactoryRegistry factoryRegistry) {
- this.factoryRegistry = factoryRegistry;
- }
-
- /**
- * The id is the id that the model manager uses to identify this model. If
- * it is being set here, it means the model manger is already managing the
- * model with another id, so we have to keep it in sync. This method calls
- * notifies listners, if they haven't been notified already, that a "model
- * state change" is about to occur.
- */
- public void setId(String newId) throws ResourceInUse {
-
-
- // It makes no sense, I don't think, to have an id of null, so
- // we'll throw an illegal argument exception if someone trys. Note:
- // the IModelManager could not manage a model with an id of null,
- // since it uses hashtables, and you can't have a null id for a
- // hashtable.
- if (newId == null)
- throw new IllegalArgumentException(SSECorePlugin.getResourceString("%A_model's_id_can_not_be_nu_EXC_")); //$NON-NLS-1$ = "A model's id can not be null"
- // To gaurd againt throwing a spurious ResourceInUse exception,
- // which can occur when two pieces of code both want to change the id,
- // so the second request is spurious, we'll ignore any requests that
- // attempt to change the id to what it already is ... note, we use
- // 'equals', not identity ('==') so that things like
- // strings can be used. This is the same criteria that ids are
- // found in model manager -- well, actually, I just checked, and for
- // the hashtable impl, the criteria uses .equals AND the condition
- // that the hash values be identical (I'm assuming this is always
- // true, if equals is true, for now, I'm not sure
- // we can assume that hashtable will always be used, but in
- // general, should match.)
- //
- if (newId.equals(fId))
- return;
- // we must gaurd against reassigning an id to one that we already
- // are managing.
- if (getModelManager() != null) {
- IStructuredModel newModel = getModelManager().getExistingModelForEdit(newId);
- if (newModel != null) {
- // be sure to release the reference we got unexepectantly
- // (and no longer need)
- newModel.releaseFromEdit();
- throw new ResourceInUse();
- }
- }
- try {
- // normal code path
- aboutToChangeModel();
- String oldId = fId;
- fId = newId;
- if (getModelManager() != null) {
- // if managed and the id has changed, notify to
- // IModelManager
- // TODO: try to refine the design not to do that
- if (oldId != null && newId != null && !newId.equals(oldId)) {
- getModelManager().moveModel(oldId, newId);
- }
- }
- } finally {
- // make sure this finally is only executed if 'about to Change
- // model' has
- // ben executed.
- changedModel();
- }
- }
-
- /**
- * Sets the contentTypeDescription.
- *
- * @param contentTypeDescription
- * The contentTypeDescription to set
- */
- public void setModelHandler(IModelHandler modelHandler) {
-
- // no need to fire events if modelHandler has been null
- // for this model --
- // this is an attempt at initialization optimization and may need
- // to change in future.
- boolean trueChange = false;
- if (fModelHandler != null)
- trueChange = true;
- if (trueChange) {
- internalAboutToBeChanged();
- }
- fModelHandler = modelHandler;
- if (trueChange) {
- internalModelChanged();
- }
- }
-
-
-
- /**
- * @param newModelManager
- * com.ibm.sed.model.IModelManager
- */
- public void setModelManager(IModelManager newModelManager) {
-
- fModelManager = newModelManager;
- }
-
- /**
- *
- */
- public void setNewState(boolean newState) {
-
- fNewState = newState;
- }
-
- /**
- * Sets a "flag" that reinitialization is needed.
- */
- public void setReinitializeNeeded(boolean needed) {
-
- reinitializationNeeded = needed;
- }
-
- /**
- * Holds any data that the reinit procedure might find useful in
- * reinitializing the model. This is handy, since the reinitialization may
- * not take place at once, and some "old" data may be needed to properly
- * undo previous settings. Note: the parameter was intentially made to be
- * of type 'Object' so different models can use in different ways.
- */
- public void setReinitializeStateData(Object object) {
-
- reinitializeStateData = object;
- }
-
- /**
- * @param newResolver
- * com.ibm.sed.util.URIResolver
- */
- public void setResolver(URIResolver newResolver) {
-
- fResolver = newResolver;
- }
-
- /**
- * @param newStructuredDocument
- * com.ibm.sed.structuredDocument.IStructuredDocument
- */
- public void setStructuredDocument(IStructuredDocument newStructuredDocument) {
-
- boolean lifeCycleNotification = false;
- if (fStructuredDocument != null) {
- fStructuredDocument.removeDocumentChangedListener(fDirtyStateWatcher);
- fStructuredDocument.removeDocumentAboutToChangeListener(fDocumentToModelNotifier);
- fStructuredDocument.removeDocumentChangedListener(fDocumentToModelNotifier);
- // prechange notificaiton
- lifeCycleNotification = true;
- ModelLifecycleEvent modelLifecycleEvent = new DocumentChanged(ModelLifecycleEvent.PRE_EVENT, this, fStructuredDocument, newStructuredDocument);
- signalLifecycleEvent(modelLifecycleEvent);
- }
-
- // hold for life cycle notification
- IStructuredDocument previousDocument = fStructuredDocument;
- // the actual change
- fStructuredDocument = newStructuredDocument;
-
-
- // at the super class level, we'll listen for structuredDocument
- // changes
- // so we can set our dirty state flag
- if (fStructuredDocument != null) {
- fStructuredDocument.addDocumentChangedListener(fDirtyStateWatcher);
- fStructuredDocument.addDocumentAboutToChangeListener(fDocumentToModelNotifier);
- fStructuredDocument.addDocumentChangedListener(fDocumentToModelNotifier);
- }
-
- if (lifeCycleNotification) {
- // post change notification
- ModelLifecycleEvent modelLifecycleEvent = new DocumentChanged(ModelLifecycleEvent.POST_EVENT, this, previousDocument, newStructuredDocument);
- signalLifecycleEvent(modelLifecycleEvent);
- }
-
- }
-
- /**
- * Insert the method's description here. Creation date: (9/7/2001 2:30:26
- * PM)
- *
- * @param newSynchronizationStamp
- * long
- */
- protected void setSynchronizationStamp(long newSynchronizationStamp) {
-
- fSynchronizationStamp = newSynchronizationStamp;
- }
-
- public void setUndoManager(IStructuredTextUndoManager undoManager) {
-
- IStructuredDocument structuredDocument = getStructuredDocument();
- if (structuredDocument == null) {
- throw new IllegalStateException("document was null when undo manager set on model"); //$NON-NLS-1$
- }
- structuredDocument.setUndoManager(undoManager);
- }
-
- /**
- * to be called only be "friendly" classes, such as ModelManger, and
- * subclasses.
- */
- protected void signalLifecycleEvent(ModelLifecycleEvent event) {
-
- if (fLifecycleNotificationManager == null)
- return;
- fLifecycleNotificationManager.signalLifecycleEvent(event);
- }
-
- private void signalPostLifeCycleListenerRelease(IStructuredModel structuredModel) {
- int type = ModelLifecycleEvent.MODEL_RELEASED | ModelLifecycleEvent.POST_EVENT;
- // what's wrong with this design that a cast is needed here!?
- ModelLifecycleEvent event = new ModelLifecycleEvent(structuredModel, type);
- ((AbstractStructuredModel) structuredModel).signalLifecycleEvent(event);
- }
-
- private void signalPreLifeCycleEventRelease(IStructuredModel structuredModel) {
- int type = ModelLifecycleEvent.MODEL_RELEASED | ModelLifecycleEvent.PRE_EVENT;
- // what's wrong with this design that a cast is needed here!?
- ModelLifecycleEvent event = new ModelLifecycleEvent(structuredModel, type);
- ((AbstractStructuredModel) structuredModel).signalLifecycleEvent(event);
- }
-}
diff --git a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/AdapterFactory.java b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/AdapterFactory.java
deleted file mode 100644
index 720f5e7117..0000000000
--- a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/AdapterFactory.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Jens Lukowski/Innoopract - initial renaming/restructuring
- *
- *******************************************************************************/
-package org.eclipse.wst.sse.core;
-
-
-
-public interface AdapterFactory {
-
- /**
- * Method that returns the adapter associated with the given object. It
- * may be a singleton or not ... depending on the needs of the
- * INodeAdapter ... but in general it is recommended for an adapter to be
- * stateless, so the efficiencies of a singleton can be gained.
- *
- * The implementation of this method should call addAdapter on the adapted
- * object with the correct instance of the adapter.
- */
- INodeAdapter adapt(INodeNotifier object);
-
- /**
- * returns an instance of the adapter factory. Unlike clone, this method
- * may return the same instance, such as in the case where the
- * AdapterFactory is intended to be a singleton.
- */
- public AdapterFactory copy();
-
- boolean isFactoryForType(Object type);
-
- /**
- *
- */
- public void release();
-
-}
diff --git a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/DocumentChanged.java b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/DocumentChanged.java
deleted file mode 100644
index 4a61dfa0d8..0000000000
--- a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/DocumentChanged.java
+++ /dev/null
@@ -1,60 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Jens Lukowski/Innoopract - initial renaming/restructuring
- *
- *******************************************************************************/
-package org.eclipse.wst.sse.core;
-
-import org.eclipse.wst.sse.core.text.IStructuredDocument;
-
-public class DocumentChanged extends ModelLifecycleEvent {
- private IStructuredDocument fNewDocument;
-
- private IStructuredDocument fOldDocument;
-
- protected DocumentChanged() {
-
- super(ModelLifecycleEvent.MODEL_DOCUMENT_CHANGED);
-
- }
-
- protected DocumentChanged(int additionalType, IStructuredModel model) {
-
- super(model, ModelLifecycleEvent.MODEL_DOCUMENT_CHANGED | additionalType);
-
- }
-
- public DocumentChanged(int additionalType, IStructuredModel model, IStructuredDocument oldDocument, IStructuredDocument newDocument) {
-
- this(additionalType, model);
- fOldDocument = oldDocument;
- fNewDocument = newDocument;
- }
-
- public IStructuredDocument getNewDocument() {
-
- return fNewDocument;
- }
-
- public IStructuredDocument getOldDocument() {
-
- return fOldDocument;
- }
-
- void setNewDocument(IStructuredDocument newDocument) {
-
- fNewDocument = newDocument;
- }
-
- void setOldDocument(IStructuredDocument oldDocument) {
-
- fOldDocument = oldDocument;
- }
-}
diff --git a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/FactoryRegistry.java b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/FactoryRegistry.java
deleted file mode 100644
index f7e745e989..0000000000
--- a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/FactoryRegistry.java
+++ /dev/null
@@ -1,175 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Jens Lukowski/Innoopract - initial renaming/restructuring
- *
- *******************************************************************************/
-package org.eclipse.wst.sse.core;
-
-
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.wst.sse.core.internal.Logger;
-
-
-/**
- * This class simply maintains the list of factories and returns singleton
- * instances of them. Some "built in" types are automatically created form
- * FactoryConfig, if not found registerd, but normally clients can/should
- * register their own factories.
- *
- */
-public class FactoryRegistry implements IFactoryRegistry {
-
- private List factories;
-
- /**
- *
- */
- public FactoryRegistry() {
- super();
-
- }
-
- protected List _getFactories() {
-
- if (factories == null) {
- // may need to use java.util.Collections.synchronizedList() if
- // syncronization becomes
- // necessary (and if so, remember to synchronize on factories)
- factories = new ArrayList();
- }
- return factories;
-
- }
-
- public void addFactory(AdapterFactory factory) {
- _getFactories().add(factory);
- }
-
- public void clearFactories() {
- factories.clear();
- }
-
- /*
- * @see IFactoryRegistry#contains(Object)
- */
- public boolean contains(Object type) {
- boolean result = false;
- // note: we're not using cloned list, so strictly speaking
- // is not thread safe.
- List internalList = _getFactories();
- for (int i = 0; i < internalList.size(); i++) {
- AdapterFactory factory = (AdapterFactory) internalList.get(i);
- if (factory.isFactoryForType(type)) {
- result = true;
- break;
- }
- }
- return result;
- }
-
- /**
- * Returns a shallow copy of the list of factories in the registry. Note:
- * this can not be used to add/remove factories. Its primarily provided
- * for those few cases where a list of factories must be copied from one
- * model and added to another.
- */
- public List getFactories() {
- // note: for object integrity, we don't let anyone get
- // our main list (so they have to add through addFactory),
- // but we will return a shallow "cloned" list.
- List factoryList = new ArrayList(_getFactories());
- return factoryList;
- }
-
- /**
- * This method is a not a pure resistry. Factories retrieved based on
- * their response to "isFactoryForType(type)". Note that if there is more
- * than one factory that can answer 'true' that the most recently added
- * factory is used.
- */
- public AdapterFactory getFactoryFor(Object type) {
-
- AdapterFactory result = null;
- if (factories == null)
- return null;
- int listSize = factories.size();
- for (int i = listSize - 1; i >= 0; i--) {
- // It is the adapter factories responsibility to answer
- // isFactoryForType so it gets choosen.
- // Notice we are going through the list backwards to get the
- // factory added last.
- AdapterFactory a = (AdapterFactory) factories.get(i);
- if (a.isFactoryForType(type)) {
- result = a;
- break;
- }
- }
- return result;
-
- }
-
- /**
- *
- */
- public void release() {
- // modified to work on copy of list, for V5PTF1
- // send release to local copy of list
- // of factories, since some factories, during
- // their release function, may remove
- // themselves from the registry.
- List localList = getFactories();
- for (int i = 0; i < localList.size(); i++) {
- AdapterFactory a = (AdapterFactory) localList.get(i);
- // To help bullet proof code, we'll catch and log
- // any messages thrown by factories during release,
- // but we'll attempt to keep going.
- // In nearly all cases, though, such errors are
- // severe for product/client, and need to be fixed.
- try {
- a.release();
- } catch (Exception e) {
- Logger.logException("Program problem releasing factory" + a, e); //$NON-NLS-1$
- }
- }
- }
-
- /**
- * Removes a factory if it can be retrieved by getFactoryFor(type). If
- * there is more than one, all are removed. If there is none, the call
- * simply returns (that is, it is not considered an error).
- */
- public void removeFactoriesFor(java.lang.Object type) {
- if (factories != null) {
- int listSize = factories.size();
- // we'll go backwards through list, since we're removing, so
- // 'size' change won't matter.
- // Note: I'm assuming other items in the collection do not change
- // position
- // simply because another was removed.
- for (int i = listSize - 1; i >= 0; i--) {
- // It is the adapter factories responsibility to answer
- // isFactoryForType so it gets choosen.
- AdapterFactory a = (AdapterFactory) factories.get(i);
- if (a.isFactoryForType(type)) {
- factories.remove(a);
- }
- }
- }
- }
-
- public void removeFactory(AdapterFactory factory) {
- _getFactories().remove(factory);
-
- }
-
-}
diff --git a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/IFactoryRegistry.java b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/IFactoryRegistry.java
deleted file mode 100644
index 2bf4052d97..0000000000
--- a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/IFactoryRegistry.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Jens Lukowski/Innoopract - initial renaming/restructuring
- *
- *******************************************************************************/
-package org.eclipse.wst.sse.core;
-
-
-
-import java.util.List;
-
-public interface IFactoryRegistry {
-
- void addFactory(AdapterFactory factory);
-
- void clearFactories();
-
- /**
- * returns true if already contains a factory for the given type. This is
- * purely a convenience method for those few cases that want to avoid
- * adding a factory if it is already in the registry.
- */
- boolean contains(Object type);
-
- /**
- * Returns a shallow cloned list of the factories in the registry.
- */
- List getFactories();
-
- /**
- * This method is a not a pure resistry. Factories retrieved based on
- * their response to "isFactoryForType(type)". Note that if there is more
- * than one factory that can answer 'true' that the most recently added
- * factory is used.
- */
- AdapterFactory getFactoryFor(Object type);
-
- /**
- *
- */
- void release();
-
- /**
- * Removes a factory if it can be retrieved by getFactoryFor(type). If
- * there is more than one, all are removed. If there is none, the call
- * simply returns (that is, it is not considered an error).
- */
- void removeFactoriesFor(Object type);
-
- void removeFactory(AdapterFactory factory);
-}
diff --git a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/IModelLifecycleListener.java b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/IModelLifecycleListener.java
deleted file mode 100644
index 1be20b7ae7..0000000000
--- a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/IModelLifecycleListener.java
+++ /dev/null
@@ -1,25 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Jens Lukowski/Innoopract - initial renaming/restructuring
- *
- *******************************************************************************/
-package org.eclipse.wst.sse.core;
-
-/**
- * This is an early version of a class that may change over the next few
- * milestones.
- */
-
-public interface IModelLifecycleListener {
-
- void processPostModelEvent(ModelLifecycleEvent event);
-
- void processPreModelEvent(ModelLifecycleEvent event);
-}
diff --git a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/IModelLoaderExtension.java b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/IModelLoaderExtension.java
deleted file mode 100644
index 2d6e2be199..0000000000
--- a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/IModelLoaderExtension.java
+++ /dev/null
@@ -1,26 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Jens Lukowski/Innoopract - initial renaming/restructuring
- *
- *******************************************************************************/
-package org.eclipse.wst.sse.core;
-
-import org.eclipse.wst.sse.core.text.IStructuredDocument;
-
-/**
- * @author nsd
- */
-public interface IModelLoaderExtension {
- /**
- * Create a Structured Model with the given StructuredDocument instance as
- * its document (instead of a new document instance as well)
- */
- IStructuredModel createModel(IStructuredDocument document, String baseLocation);
-}
diff --git a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/IModelManager.java b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/IModelManager.java
deleted file mode 100644
index 31c83e20cd..0000000000
--- a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/IModelManager.java
+++ /dev/null
@@ -1,326 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Jens Lukowski/Innoopract - initial renaming/restructuring
- *
- *******************************************************************************/
-package org.eclipse.wst.sse.core;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.UnsupportedEncodingException;
-import java.util.Enumeration;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.wst.common.encoding.EncodingRule;
-import org.eclipse.wst.sse.core.exceptions.ResourceAlreadyExists;
-import org.eclipse.wst.sse.core.exceptions.ResourceInUse;
-import org.eclipse.wst.sse.core.text.IStructuredDocument;
-import org.eclipse.wst.sse.core.util.URIResolver;
-
-
-/**
- * Responsible for providing a set of APIs for creating a new model manager,
- * for managing (add or remove) model loaders and model dumpers, and for
- * managing (get, release, save, and save as) models.
- *
- * Clients should not implement.
- */
-public interface IModelManager {
-
- public final static String DUPLICATED_MODEL = "org.eclipse.wst.sse.core.IModelManager.DUPLICATED_MODEL"; //$NON-NLS-1$
- public final static String UNMANAGED_MODEL = "org.eclipse.wst.sse.core.IModelManager.UNMANAGED_MODEL"; //$NON-NLS-1$
-
- /**
- * This API allows clients to declare that they are about to make a
- * "large" change to the model. This change might be in terms of content
- * or it might be in terms of the model id or base location.
- *
- * Note that in the case of embedded calls, notification to listners is
- * sent only once.
- *
- * The method isModelStateChanging can be used by a client to determin if
- * the model is already in a change sequence.
- */
- void aboutToChangeModels();
-
- void addModelManagerListener(IModelManagerListener listener);
-
- /**
- * Calculate id provides a common way to determine the id from the input
- * ... needed to get and save the model. It is a simple class utility, but
- * is an instance method so can be accessed via interface.
- */
- public String calculateId(IFile file);
-
- /**
- * This API allows a client controlled way of notifying all ModelEvent
- * listners that the model has been changed. This method is a matched pair
- * to aboutToChangeModel, and must be called after aboutToChangeModel ...
- * or some listeners could be left waiting indefinitely for the changed
- * event. So, its suggested that changedModel always be in a finally
- * clause. Likewise, a client should never call changedModel without
- * calling aboutToChangeModel first.
- *
- * In the case of embedded calls, the notification is just sent once.
- *
- */
- void changedModels();
-
- IStructuredModel copyModelForEdit(String oldId, String newId) throws ResourceInUse;
-
- /**
- * createNewInstance is similar to clone, except the new instance has no
- * content. Note: this produces an unmanaged model, for temporary use. If
- * a true shared model is desired, use "copy".
- */
- public IStructuredModel createNewInstance(IStructuredModel model) throws IOException;
-
- /**
- * Factory method, since a proper IStructuredDocument must have a proper
- * parser assigned. Note: its assume that IFile does not actually exist as
- * a resource yet. If it does, ResourceAlreadyExists exception is thrown.
- * If the resource does already exist, then createStructuredDocumentFor is
- * the right API to use.
- *
- */
- IStructuredDocument createNewStructuredDocumentFor(IFile iFile) throws ResourceAlreadyExists, IOException, CoreException;
-
- /**
- * Factory method, since a proper IStructuredDocument must have a proper
- * parser assigned. Note: clients should verify IFile exists before using
- * this method. If this IFile does not exist, then
- * createNewStructuredDocument is the correct API to use.
- */
- IStructuredDocument createStructuredDocumentFor(IFile iFile) throws IOException, CoreException;
-
- /**
- * Conveience method, since a proper IStructuredDocument must have a
- * proper parser assigned. It should only be used when an empty
- * structuredDocument is needed. Otherwise, use IFile form.
- */
- IStructuredDocument createStructuredDocumentFor(String contentTypeId);
-
- /**
- * @deprecated -- I marked as deprecated to discouage use of this method.
- * It does not really work for JSP fragments, since JSP
- * Fragments need an IFile to correctly look up the content
- * settings. Use IFile form instead. Note: some confustion
- * with it and the form for HTPP encoding, so once a null arg
- * is allowed in that API ... we can remove this one. (after
- * verifying again with Tom/Linksbuild)
- */
- IStructuredDocument createStructuredDocumentFor(String filename, InputStream inputStream, URIResolver resolver) throws IOException;
-
- IStructuredDocument createStructuredDocumentFor(String filename, InputStream inputStream, URIResolver resolver, String ianaEncodingName) throws IOException;
-
- IStructuredDocument createStructuredDocumentFor(String filename, String content, URIResolver resolver) throws IOException;
-
- /**
- * Conveience method. It depends on the loaders newModel method to return
- * an appropriate StrucuturedModel appropriately initialized.
- */
- IStructuredModel createUnManagedStructuredModelFor(IFile iFile) throws IOException, CoreException;
-
- /**
- * Conveience method. It depends on the loaders newModel method to return
- * an appropriate StrucuturedModel appropriately initialized.
- */
- IStructuredModel createUnManagedStructuredModelFor(String contentTypeId);
-
- IStructuredModel createUnManagedStructuredModelFor(String contentTypeId, URIResolver resolver);
-
- /**
- * Note: users of this 'model' must still release it when finished.
- * Returns null if there's not a model corresponding to document.
- */
- IStructuredModel getExistingModelForEdit(IDocument document);
-
- public IStructuredModel getExistingModelForEdit(IFile iFile);
-
- /**
- * This is similar to the getModel method, except this method does not
- * create a model. This method does increment the reference count (if it
- * exists). If the model does not already exist in the cache of models,
- * null is returned.
- */
- public IStructuredModel getExistingModelForEdit(Object id);
-
- /**
- * Note: users of this 'model' must still release it when finished.
- * Returns null if there's not a model corresponding to document.
- */
- IStructuredModel getExistingModelForRead(IDocument document);
-
- public IStructuredModel getExistingModelForRead(IFile iFile);
-
- /**
- * This is similar to the getModel method, except this method does not
- * create a model. This method does increment the reference count (if it
- * exists). If the model does not already exist in the cache of models,
- * null is returned.
- */
- public IStructuredModel getExistingModelForRead(Object id);
-
- public Enumeration getExistingModelIds();
-
- public IStructuredModel getModelForEdit(IFile iFile) throws IOException, CoreException;
-
- /*
- * @deprecated - encoding is handled automatically
- */
- public IStructuredModel getModelForEdit(IFile iFile, EncodingRule encodingRule) throws UnsupportedEncodingException, IOException, CoreException;
-
- public IStructuredModel getModelForEdit(IFile iFile, String encoding, String lineDelimiter) throws UnsupportedEncodingException, IOException, CoreException;
-
- public IStructuredModel getModelForEdit(IStructuredDocument textFileBufferDocument);
-
- /*
- * @deprecated - a URI resolver should be automatically created when
- * needed
- */
- public IStructuredModel getModelForEdit(String id, InputStream inStream, URIResolver resolver) throws UnsupportedEncodingException, IOException;
-
- public IStructuredModel getModelForRead(IFile iFile) throws IOException, CoreException;
-
- /*
- * @deprecated - encoding is handled automatically
- */
- public IStructuredModel getModelForRead(IFile iFile, EncodingRule encodingRule) throws UnsupportedEncodingException, IOException, CoreException;
-
- /*
- * @deprecated - encoding and line delimiters are handled automatically
- */
- public IStructuredModel getModelForRead(IFile iFile, String encoding, String lineDelimiter) throws UnsupportedEncodingException, IOException, CoreException;
-
- public IStructuredModel getModelForRead(IStructuredDocument textFileBufferDocument);
-
- /*
- * @deprecated - a URI resolver should be automatically created when
- * needed
- */
- public IStructuredModel getModelForRead(String filename, InputStream inStream, URIResolver resolver) throws UnsupportedEncodingException, IOException;
-
- /**
- * This method will not create a new model if it already exists ... if
- * force is false. The idea is that a client should call this method once
- * with force set to false. If the exception is thrown, then prompt client
- * if they want to overwrite.
- */
- IStructuredModel getNewModelForEdit(IFile iFile, boolean force) throws ResourceAlreadyExists, ResourceInUse, IOException, CoreException;
-
- /**
- * This method will not create a new model if it already exists ... if
- * force is false. The idea is that a client should call this method once
- * with force set to false. If the exception is thrown, then prompt client
- * if they want to overwrite.
- */
- IStructuredModel getNewModelForRead(IFile iFile, boolean force) throws ResourceAlreadyExists, ResourceInUse, IOException, CoreException;
-
- /**
- * This function returns the reference count of underlying model.
- *
- * @param id
- * Object The id of the model TODO: try to refine the design
- * not to use this function
- * @deprecated
- */
- int getReferenceCount(Object id);
-
- /**
- * This function returns the reference count of underlying model.
- *
- * @param id
- * Object The id of the model TODO: try to refine the design
- * not to use this function
- * @deprecated
- */
- int getReferenceCountForEdit(Object id);
-
- /**
- * This function returns the reference count of underlying model.
- *
- * @param id
- * Object The id of the model TODO: try to refine the design
- * not to use this function
- * @deprecated
- */
- int getReferenceCountForRead(Object id);
-
- /**
- * This function returns true if there are other references to the
- * underlying model.
- *
- * @param id
- * Object The id of the model
- */
- boolean isShared(Object id);
-
- /**
- * This function returns true if there are other references to the
- * underlying model.
- *
- * @param id
- * Object The id of the model
- */
- boolean isSharedForEdit(Object id);
-
- /**
- * This function returns true if there are other references to the
- * underlying model.
- *
- * @param id
- * Object The id of the model
- */
- boolean isSharedForRead(Object id);
-
- /**
- * This method can be called to determine if the model manager is within a
- * "aboutToChange" and "changed" sequence.
- */
- public boolean isStateChanging();
-
- /**
- * This method changes the id of the model. TODO: try to refine the design
- * not to use this function
- *
- * @deprecated
- */
- void moveModel(Object oldId, Object newId);
-
- /**
- * This method can be called when the content type of a model changes. Its
- * assumed the contentType has already been changed, and this method uses
- * the text of the old one, to repopulate the text of the new one. In
- * theory, the actual instance could change, (e.g. using 'saveAs' to go
- * from xml to dtd), but in practice, the intent of this API is to return
- * the same instance, just using different handlers, adapter factories,
- * etc.
- */
- IStructuredModel reinitialize(IStructuredModel model) throws IOException;
-
- /**
- * This is similar to the getModel method, except this method does not use
- * the cached version, but forces the cached version to be replaced with a
- * fresh, unchanged version. Note: this method does not change any
- * reference counts. Also, if there is not already a cached version of the
- * model, then this call is essentially ignored (that is, it does not put
- * a model in the cache) and returns null.
- *
- * @deprecated
- */
- IStructuredModel reloadModel(Object id, InputStream inStream) throws UnsupportedEncodingException;
-
- void removeModelManagerListener(IModelManagerListener listener);
-
- void saveStructuredDocument(IStructuredDocument structuredDocument, IFile iFile) throws UnsupportedEncodingException, IOException, CoreException;
-
-}
diff --git a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/IModelManagerListener.java b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/IModelManagerListener.java
deleted file mode 100644
index bb7a3eefcb..0000000000
--- a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/IModelManagerListener.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Jens Lukowski/Innoopract - initial renaming/restructuring
- *
- *******************************************************************************/
-package org.eclipse.wst.sse.core;
-
-
-
-/**
- * Interface for those wanting to listen to events fired by the model manager.
- */
-public interface IModelManagerListener {
-
- /**
- * One or more models are about to be changed. This typically is initiated
- * by one client of the model (such as LinksBuilder), to signal that
- * several models are about to be changed. These models might be
- * interrelated, so a listener (such as FrameManger) will know to a
- * "massive" change is about to take place.
- */
- void modelsAboutToBeChanged();
-
- /**
- * Signals that the changes foretold by modelsAboutToBeChanged have been
- * made. A typical use might be to refresh, or to resume processing that
- * was suspended as a result of modelsAboutToBeChanged.
- */
- void modelsChanged();
-}
diff --git a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/IModelManagerPlugin.java b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/IModelManagerPlugin.java
deleted file mode 100644
index 7df2c0c0ec..0000000000
--- a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/IModelManagerPlugin.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Jens Lukowski/Innoopract - initial renaming/restructuring
- *
- *******************************************************************************/
-
-package org.eclipse.wst.sse.core;
-
-import org.eclipse.core.runtime.Preferences;
-import org.eclipse.wst.sse.core.internal.modelhandler.ModelHandlerRegistry;
-
-
-/**
- * @deprecated use StructuredModelManager instead
- */
-public interface IModelManagerPlugin {
- // private static ModelManagerPlugin instance;
- public final static String ID = "org.eclipse.wst.sse.core"; //$NON-NLS-1$
-
- /**
- * @deprecated use ModelHandlerRegistry.getInstance() instead
- */
- public abstract ModelHandlerRegistry getModelHandlerRegistry();
-
- /**
- * @deprecated use StructuredModelManager.getInstance().getModelManager() instead
- */
- public abstract IModelManager getModelManager();
-
- public Preferences getPluginPreferences();
-}
diff --git a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/IModelStateListener.java b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/IModelStateListener.java
deleted file mode 100644
index 0659752435..0000000000
--- a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/IModelStateListener.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Jens Lukowski/Innoopract - initial renaming/restructuring
- *
- *******************************************************************************/
-package org.eclipse.wst.sse.core;
-
-
-
-/**
- * Interface for those wanting to listen to a model's state changing.
- */
-public interface IModelStateListener {
-
- /**
- * A model is about to be changed. This typically is initiated by one
- * client of the model, to signal a large change and/or a change to the
- * model's ID or base Location. A typical use might be if a client might
- * want to suspend processing until all changes have been made.
- */
- void modelAboutToBeChanged(IStructuredModel model);
-
- /**
- * Signals that the changes foretold by modelAboutToBeChanged have been
- * made. A typical use might be to refresh, or to resume processing that
- * was suspended as a result of modelAboutToBeChanged.
- */
- void modelChanged(IStructuredModel model);
-
- /**
- * Notifies that a model's dirty state has changed, and passes that state
- * in isDirty. A model becomes dirty when any change is made, and becomes
- * not-dirty when the model is saved.
- */
- void modelDirtyStateChanged(IStructuredModel model, boolean isDirty);
-
- /**
- * A modelDeleted means the underlying resource has been deleted. The
- * model itself is not removed from model management until all have
- * released it. Note: baseLocation is not (necessarily) changed in this
- * event, but may not be accurate.
- */
- void modelResourceDeleted(IStructuredModel model);
-
- /**
- * A model has been renamed or copied (as in saveAs..). In the renamed
- * case, the two paramenters are the same instance, and only contain the
- * new info for id and base location.
- */
- void modelResourceMoved(IStructuredModel oldModel, IStructuredModel newModel);
-}
diff --git a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/IModelStateListenerExtended.java b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/IModelStateListenerExtended.java
deleted file mode 100644
index 4d5e02617c..0000000000
--- a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/IModelStateListenerExtended.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Jens Lukowski/Innoopract - initial renaming/restructuring
- *
- *******************************************************************************/
-package org.eclipse.wst.sse.core;
-
-
-
-/**
- * This interface defines two new model level events. In order to avoid
- * unnecessary last minute changes from clients, this interface was created as
- * a "stop gap" measure. Eventually, it will become part of the normal
- * ModelStateListener interface.
- */
-public interface IModelStateListenerExtended extends IModelStateListener {
-
-
- void modelAboutToBeReinitialized(IStructuredModel structuredModel);
-
- void modelReinitialized(IStructuredModel structuredModel);
-
-}
diff --git a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/INodeAdapter.java b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/INodeAdapter.java
deleted file mode 100644
index 644f46c058..0000000000
--- a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/INodeAdapter.java
+++ /dev/null
@@ -1,28 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Jens Lukowski/Innoopract - initial renaming/restructuring
- *
- *******************************************************************************/
-package org.eclipse.wst.sse.core;
-
-
-
-public interface INodeAdapter {
-
- /**
- * Allowing the INodeAdapter to compare itself against the type allows it
- * to return true in more than one case.
- */
- boolean isAdapterForType(Object type);
-
- /**
- */
- void notifyChanged(INodeNotifier notifier, int eventType, Object changedFeature, Object oldValue, Object newValue, int pos);
-}
diff --git a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/INodeNotifier.java b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/INodeNotifier.java
deleted file mode 100644
index 0900799904..0000000000
--- a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/INodeNotifier.java
+++ /dev/null
@@ -1,71 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Jens Lukowski/Innoopract - initial renaming/restructuring
- *
- *******************************************************************************/
-package org.eclipse.wst.sse.core;
-
-
-
-import java.util.Collection;
-
-public interface INodeNotifier {
- static final int ADD = 2;
-
- // Possible values for eventType
- static final int CHANGE = 1; // update - non structural
- // removed
- // when large changes are made to a sub-tree
- static final int CONTENT_CHANGED = 5; // sent to the parent notifier
- // these strings are for printing, such as during debuging
- static final String[] EVENT_TYPE_STRINGS = new String[]{"undefined", "CHANGE", "ADD", "REMOVE", "STRUCUTRED_CHANGED", "CONTENT_CHANGED"}; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$
- static final int REMOVE = 3;
- static final int STRUCTURE_CHANGED = 4; // sent in addition to adds and
-
- // when the child value changed
-
- /**
- * Add an adapter of this notifier.
- *
- * @param o
- * com.ibm.etools.emf.notify.INodeAdapter
- */
- void addAdapter(INodeAdapter o);
-
- /**
- * Return an exisiting adapter of type "type" or if none found create a
- * new adapter using a registered adapter factory
- */
- INodeAdapter getAdapterFor(Object type);
-
- /**
- * Return a read-only Collection of the Adapters to this notifier.
- *
- * @return com.ibm.etools.emf.notify.INodeAdapter
- */
- Collection getAdapters();
-
- /**
- * Return an exisiting adapter of type "type" or null if none found
- */
- INodeAdapter getExistingAdapter(Object type);
-
- /**
- */
- void notify(int eventType, Object changedFeature, Object oldValue, Object newValue, int pos);
-
- /**
- * Remove an adapter of this notifier.
- *
- * @param o
- * com.ibm.etools.emf.notify.INodeAdapter
- */
- void removeAdapter(INodeAdapter o);
-}
diff --git a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/IStateMemento.java b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/IStateMemento.java
deleted file mode 100644
index ae5373ef59..0000000000
--- a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/IStateMemento.java
+++ /dev/null
@@ -1,22 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Jens Lukowski/Innoopract - initial renaming/restructuring
- *
- *******************************************************************************/
-package org.eclipse.wst.sse.core;
-
-
-
-/**
- * Marker-only interface, at this point.
- */
-public interface IStateMemento {
-
-}
diff --git a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/IStructuredModel.java b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/IStructuredModel.java
deleted file mode 100644
index 90ea167855..0000000000
--- a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/IStructuredModel.java
+++ /dev/null
@@ -1,397 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Jens Lukowski/Innoopract - initial renaming/restructuring
- *
- *******************************************************************************/
-package org.eclipse.wst.sse.core;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.io.UnsupportedEncodingException;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IAdaptable;
-import org.eclipse.wst.common.encoding.EncodingRule;
-import org.eclipse.wst.sse.core.exceptions.ResourceAlreadyExists;
-import org.eclipse.wst.sse.core.exceptions.ResourceInUse;
-import org.eclipse.wst.sse.core.modelhandler.IModelHandler;
-import org.eclipse.wst.sse.core.text.IStructuredDocument;
-import org.eclipse.wst.sse.core.undo.IStructuredTextUndoManager;
-import org.eclipse.wst.sse.core.util.URIResolver;
-
-
-/**
- */
-public interface IStructuredModel extends IAdaptable {
-
-
- /**
- * This API allows clients to declare that they are about to make a
- * "large" change to the model. This change might be in terms of content
- * or it might be in terms of the model id or base location.
- *
- * Note that in the case of embedded calls, notification to listeners is
- * sent only once.
- *
- * Note that the client who is making these changes has the responsibility
- * to restore the model's state once finished with the changes. See
- * getMemento and restoreState.
- *
- * The method isModelStateChanging can be used by a client to determine if
- * the model is already in a change sequence.
- *
- * This method is a matched pair to changedModel, and must be called
- * before changedModel. A client should never call changedModel without
- * calling aboutToChangeModel first nor call aboutToChangeModel without
- * calling changedModel later from the same Thread.
- */
- void aboutToChangeModel();
-
- void addModelLifecycleListener(IModelLifecycleListener listener);
-
- void addModelStateListener(IModelStateListener listener);
-
- /**
- * Begin recording undo transactions.
- */
- void beginRecording(Object requester);
-
- /**
- * Begin recording undo transactions.
- */
- void beginRecording(Object requester, int cursorPosition, int selectionLength);
-
- /**
- * Begin recording undo transactions.
- */
- void beginRecording(Object requester, String label);
-
- /**
- * Begin recording undo transactions.
- */
- void beginRecording(Object requester, String label, int cursorPosition, int selectionLength);
-
- /**
- * Begin recording undo transactions.
- */
- void beginRecording(Object requester, String label, String description);
-
- /**
- * Begin recording undo transactions.
- */
- void beginRecording(Object requester, String label, String description, int cursorPosition, int selectionLength);
-
- /**
- * This API allows a client controlled way of notifying all ModelEvent
- * listners that the model has been changed. This method is a matched pair
- * to aboutToChangeModel, and must be called after aboutToChangeModel ...
- * or some listeners could be left waiting indefinitely for the changed
- * event. So, its suggested that changedModel always be in a finally
- * clause. Likewise, a client should never call changedModel without
- * calling aboutToChangeModel first.
- *
- * In the case of embedded calls, the notification is just sent once.
- *
- */
- void changedModel();
-
- long computeModificationStamp(IResource resource);
-
- /**
- * @deprecated
- * @return com.ibm.sed.model.IStructuredModel
- */
- IStructuredModel copy(String id) throws ResourceInUse, ResourceAlreadyExists;
-
- /**
- * Disable undo management.
- */
- void disableUndoManagement();
-
- /**
- * Enable undo management.
- */
- void enableUndoManagement();
-
- /**
- * End recording undo transactions.
- */
- void endRecording(Object requester);
-
- /**
- * End recording undo transactions.
- */
- void endRecording(Object requester, int cursorPosition, int selectionLength);
-
- /**
- * This is a client-defined value for what that client (and/or loader)
- * considers the "base" of the structured model. Frequently the location
- * is either a workspace root-relative path of a workspace resource or an
- * absolute path in the local file system.
- */
- String getBaseLocation();
-
- /**
- * @return The associated content type identifier (String) for this model.
- */
- String getContentTypeIdentifier();
-
- /**
- *
- * @return The model's IFactoryRegistry. A model is not valid without one.
- */
- IFactoryRegistry getFactoryRegistry();
-
- /**
- * The id is the id that the model manager uses to identify this model
- */
- String getId();
-
- /**
- *
- */
- IndexedRegion getIndexedRegion(int offset);
-
- /**
- * This method returns a mememto that can later be used to restore the
- * state at this point. A model's state, in this sense, does not relate to
- * its content, or Ids, etc., just its dirty state, and its
- * synchronization state with its underlying resource.
- *
- * The 'resource' argument must be the resource that underlies the
- * instance of the model this method is sent to. Note: this parameter will
- * not be required in future versions of 'strucutured model'.
- */
- IStateMemento getMemento(IResource resource);
-
- /**
- * ContentTypeDescription provides an object that describes what the
- * content of the file is, e.g. HTML, XML, etc. Compare with
- * getExternalFileTypeDescription. Though they both return objects of type
- * ContentTypeDescription, the external file type is intended to denote
- * JSP, regardless of what the content of that JSP file is. Even for a JSP
- * file, the ContentTypeDescription will be set according to that file's
- * "internal" contents.
- *
- * @return ContentTypeDescription
- */
- IModelHandler getModelHandler();
-
- IModelManager getModelManager();
-
- /**
- * This function returns the reference count of underlying model.
- *
- * @param id
- * Object The id of the model TODO: try to refine the design
- * not to use this function
- */
- int getReferenceCount();
-
- /**
- * This function returns the reference count of underlying model.
- *
- * @param id
- * Object The id of the model TODO: try to refine the design
- * not to use this function
- */
- int getReferenceCountForEdit();
-
- /**
- * This function returns the reference count of underlying model.
- *
- * @param id
- * Object The id of the model TODO: try to refine the design
- * not to use this function
- */
- int getReferenceCountForRead();
-
- Object getReinitializeStateData();
-
- /**
- * Get URI resolution helper
- */
- URIResolver getResolver();
-
- IStructuredDocument getStructuredDocument();
-
- /**
- * modification date of underlying resource, when this model was open, or
- * last saved. (Note: for this version, the client must manage the
- * accuracy of this data)
- */
- long getSynchronizationStamp();
-
- /**
- * Get undo manager.
- */
- IStructuredTextUndoManager getUndoManager();
-
- /**
- *
- */
- boolean isDirty();
-
- /**
- * This method can be called to determine if the model is within a
- * "aboutToChange" and "changed" sequence.
- */
- public boolean isModelStateChanging();
-
- /**
- *
- */
- boolean isNew();
-
- boolean isReinitializationNeeded();
-
- /**
- * This is a combination of if the model is dirty and if the model is
- * shared for write access. The last writer as the responsibility to be
- * sure the user is prompted to save.
- */
- public boolean isSaveNeeded();
-
- /**
- * This function returns true if either isSharedForRead or isSharedForEdit
- * is true.
- */
- boolean isShared();
-
- /**
- * This function returns true if there are other references to the
- * underlying model.
- */
- boolean isSharedForEdit();
-
- /**
- * This function returns true if there are other references to the
- * underlying model.
- */
- boolean isSharedForRead();
-
- /**
- * newInstance is similar to clone, except that the newInstance contains
- * no content. Its purpose is so clients can get a temporary, unmanaged,
- * model of the same "type" as the original. Note: the client may still
- * need to do some intialization of the model returned by newInstance,
- * depending on desired use. For example, the only factories in the
- * newInstance are those that would be normally be created for a model of
- * the given contentType. Others are not copied automatically, and if
- * desired, should be added by client.
- */
- IStructuredModel newInstance() throws IOException;
-
- /**
- * Performs a reinit procedure. For this model. Note for future: there may
- * be a day where the model returned from this method is a different
- * instance than the instance it was called on. This will occur when there
- * is full support for "save as" type functions, where the model could
- * theoretically change completely.
- */
- IStructuredModel reinit() throws IOException;
-
- /**
- * This function allows the model to free up any resources it might be
- * using. In particular, itself, as stored in the IModelManager.
- *
- */
- void releaseFromEdit();
-
- /**
- * This function allows the model to free up any resources it might be
- * using. In particular, itself, as stored in the IModelManager.
- *
- */
- void releaseFromRead();
-
- /**
- * This function replenishes the model with the resource without saving
- * any possible changes. It is used when one editor may be closing, and
- * specifially says not to save the model, but another "display" of the
- * model still needs to hang on to some model, so needs a fresh copy.
- *
- * Only valid for use with managed models.
- */
- IStructuredModel reload(InputStream inputStream) throws IOException;
-
- void removeModelLifecycleListener(IModelLifecycleListener listener);
-
- void removeModelStateListener(IModelStateListener listener);
-
- /**
- * A method that modififies the model's synchonization stamp to match the
- * resource. Turns out there's several ways of doing it, so this ensures a
- * common algorithm.
- */
- void resetSynchronizationStamp(IResource resource);
-
- void resourceDeleted();
-
- void resourceMoved(IStructuredModel newModel);
-
- void restoreState(IStateMemento memento);
-
- void save() throws UnsupportedEncodingException, IOException, CoreException;
-
- void save(EncodingRule encodingRule) throws UnsupportedEncodingException, IOException, CoreException;
-
- void save(IFile iFile) throws UnsupportedEncodingException, IOException, CoreException;
-
- void save(IFile iFile, EncodingRule encodingRule) throws UnsupportedEncodingException, IOException, CoreException;
-
- void save(OutputStream outputStream) throws UnsupportedEncodingException, IOException, CoreException;
-
- void setBaseLocation(String newBaseLocation);
-
- public void setDirtyState(boolean dirtyState);
-
- void setFactoryRegistry(IFactoryRegistry registry);
-
- /**
- * The id is the id that the model manager uses to identify this model
- */
- void setId(String id) throws ResourceInUse;
-
- void setModelHandler(IModelHandler modelHandler);
-
- void setModelManager(IModelManager modelManager);
-
- public void setNewState(boolean newState);
-
- /**
- * Sets a "flag" that reinitialization is needed.
- */
- void setReinitializeNeeded(boolean b);
-
- /**
- * Holds any data that the reinit procedure might find useful in
- * reinitializing the model. This is handy, since the reinitialization may
- * not take place at once, and some "old" data may be needed to properly
- * undo previous settings. Note: the parameter was intentially made to be
- * of type 'Object' so different models can use in different ways.
- */
- void setReinitializeStateData(Object object);
-
- /**
- * Set the URI resolution helper
- */
- void setResolver(URIResolver uriResolver);
-
- void setStructuredDocument(IStructuredDocument structuredDocument);
-
- /**
- * Set undo manager.
- */
- void setUndoManager(IStructuredTextUndoManager undoManager);
-}
diff --git a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/IndexedRegion.java b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/IndexedRegion.java
deleted file mode 100644
index 6785a0b4f5..0000000000
--- a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/IndexedRegion.java
+++ /dev/null
@@ -1,28 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Jens Lukowski/Innoopract - initial renaming/restructuring
- *
- *******************************************************************************/
-package org.eclipse.wst.sse.core;
-
-
-
-/**
- * These are APIs found to be needed in our tree outline viewer, that go
- * beyond the standard DOM Node Interface.
- */
-public interface IndexedRegion {
-
- boolean contains(int testPosition);
-
- int getEndOffset();
-
- int getStartOffset();
-}
diff --git a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/LifecycleNotificationManager.java b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/LifecycleNotificationManager.java
deleted file mode 100644
index 5976905eef..0000000000
--- a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/LifecycleNotificationManager.java
+++ /dev/null
@@ -1,123 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Jens Lukowski/Innoopract - initial renaming/restructuring
- *
- *******************************************************************************/
-package org.eclipse.wst.sse.core;
-
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.wst.sse.core.internal.Logger;
-import org.eclipse.wst.sse.core.util.Utilities;
-
-
-/**
- * For "internal use" only by AbstractStructuredModel
- */
-
-class LifecycleNotificationManager {
- static final String DEFAULT_TRACE_CATEGORY = "org.eclipse.wst.sse.core/structuredmodel/lifecycle";
- static final boolean DEBUG = "true".equalsIgnoreCase(Platform.getDebugOption(DEFAULT_TRACE_CATEGORY));
-
-
- private Object[] fListeners;
-
- LifecycleNotificationManager() {
- super();
- }
-
- /**
- * Adds a new copy of the given listener to the list of Life Cycle
- * Listeners.
- *
- * Multiple copies of the same listener are allowed. This is required to
- * support threaded listener management properly and for model-driven move
- * to work. For example, two adds and a single remove should result in the
- * listener still listening for events.
- *
- * @param listener
- */
- void addListener(IModelLifecycleListener listener) {
- if (Utilities.contains(fListeners, listener)) {
- Logger.log(Logger.WARNING_DEBUG, "IModelLifecycleListener " + listener + " listening more than once");
- }
- int oldSize = 0;
- if (fListeners != null) {
- // normally won't be null, but we need to be sure, for first
- // time through
- oldSize = fListeners.length;
- }
- int newSize = oldSize + 1;
- Object[] newListeners = new Object[newSize];
- if (fListeners != null) {
- System.arraycopy(fListeners, 0, newListeners, 0, oldSize);
- }
- // add listener to last position
- newListeners[newSize - 1] = listener;
- //
- // now switch new for old
- fListeners = newListeners;
- }
-
- /**
- * Removes a single copy of the given listener from the list of Life Cycle
- * Listeners.
- *
- * @param listener
- */
- void removeListener(IModelLifecycleListener listener) {
- if (Utilities.contains(fListeners, listener)) {
- // if its not in the listeners, we'll ignore the request
- int oldSize = fListeners.length;
- int newSize = oldSize - 1;
- Object[] newListeners = new Object[newSize];
- int index = 0;
- boolean removedOnce = false;
- for (int i = 0; i < oldSize; i++) {
- if (fListeners[i] == listener && !removedOnce) {
- // ignore on the first match
- removedOnce = true;
- } else {
- // copy old to new if it's not the one we are removing
- newListeners[index++] = fListeners[i];
- }
- }
- // now that we have a new array, let's switch it for the old
- // one
- fListeners = newListeners;
- }
- if (Utilities.contains(fListeners, listener)) {
- Logger.log(Logger.WARNING_DEBUG, "IModelLifecycleListener " + listener + " removed once but still listening");
- }
- }
-
- void signalLifecycleEvent(ModelLifecycleEvent event) {
- if (DEBUG) {
- Logger.trace(DEFAULT_TRACE_CATEGORY, "ModelLifecycleEvent fired for " + event.getModel().getId() + ": " + event.toString());
- System.out.println("ModelLifecycleEvent fired for " + event.getModel().getId() + ": " + event.toString());
- }
- // We must assign listeners to local variable, since the add and
- // remove listener methods can change the actual instance of the
- // listener array from another thread
- if (fListeners != null) {
- Object[] holdListeners = fListeners;
- for (int i = 0; i < holdListeners.length; i++) {
- IModelLifecycleListener listener = (IModelLifecycleListener) holdListeners[i];
- // only one type of listener for now ... this could become
- // more complex
- if ((event.getInternalType() & ModelLifecycleEvent.PRE_EVENT) == ModelLifecycleEvent.PRE_EVENT) {
- listener.processPreModelEvent(event);
- }
- if ((event.getInternalType() & ModelLifecycleEvent.POST_EVENT) == ModelLifecycleEvent.POST_EVENT) {
- listener.processPostModelEvent(event);
- }
- }
- }
- }
-}
diff --git a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/ModelDumper.java b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/ModelDumper.java
deleted file mode 100644
index 7cf9cae993..0000000000
--- a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/ModelDumper.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Jens Lukowski/Innoopract - initial renaming/restructuring
- *
- *******************************************************************************/
-package org.eclipse.wst.sse.core;
-
-
-
-import java.io.IOException;
-import java.io.OutputStream;
-import java.io.UnsupportedEncodingException;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.wst.common.encoding.EncodingRule;
-
-
-/**
- * Classes that implement this interface are responsible for saving the model
- * to the file system (or wherever the dumpter wants).
- *
- */
-public interface ModelDumper {
-
- void dump(IStructuredModel model, OutputStream outputStream, EncodingRule encodingRule, IFile iFile) throws UnsupportedEncodingException, IOException, CoreException;
-}
diff --git a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/ModelLifecycleEvent.java b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/ModelLifecycleEvent.java
deleted file mode 100644
index 82e2e1139e..0000000000
--- a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/ModelLifecycleEvent.java
+++ /dev/null
@@ -1,115 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Jens Lukowski/Innoopract - initial renaming/restructuring
- *
- *******************************************************************************/
-package org.eclipse.wst.sse.core;
-
-/**
- * This is an early version of a class that may change over the next few
- * milestones.
- */
-
-
-public class ModelLifecycleEvent {
-
-
- private final static int MASK = 0x00FF;
- public static final int MODEL_DIRTY_STATE = 0x0004;
- public static final int MODEL_DOCUMENT_CHANGED = 0x0003;
- public static final int MODEL_RELEASED = 0x00002;
- // this list is for "public" consumption
- public static final int MODEL_SAVED = 0x0001;
- protected static final int POST_EVENT = 0x0200;
-
- // TODO: finish support for these
- // following not implemented yet
- //public static final int MODEL_REINITIALIZED = 0x0005;
- //public static final int MODEL_RELOADED = 0x0006;
- //public static final int ADAPTERS_NOTIFIED = 0x0007;
- //public static final int MODEL_RESOURCE_MOVED = 0x0008;
- //public static final int MODEL_RESOURCE_DELETED = 0x0009;
-
- // This list (upper two bytes) is for only internal mechanisms and
- // subclasses
- // For simplicity they are "masked out" when client calls getType()
- protected static final int PRE_EVENT = 0x0100;
-
-
- private IStructuredModel fModel;
- private int fType;
-
- public ModelLifecycleEvent() {
- super();
- }
-
- public ModelLifecycleEvent(int type) {
- this();
- fType = type;
- }
-
- public ModelLifecycleEvent(IStructuredModel structuredModel, int type) {
- this(type);
- fModel = structuredModel;
- }
-
- private String debugString(int type) {
- String result = null;
- switch (type & MASK) {
- case MODEL_SAVED :
- result = "MODEL_SAVED"; //$NON-NLS-1$
- break;
- case MODEL_RELEASED :
- result = "MODEL_RELEASED"; //$NON-NLS-1$
- break;
- case MODEL_DOCUMENT_CHANGED :
- result = "MODEL_DOCUMENT_CHANGED"; //$NON-NLS-1$
- break;
- case MODEL_DIRTY_STATE :
- result = "MODEL_DIRTY_STATE"; //$NON-NLS-1$
- break;
- /*
- * case MODEL_REINITIALIZED : result = "MODEL_REINITIALIZED";
- * break; case MODEL_RELOADED : result = "MODEL_RELOADED"; break;
- * case ADAPTERS_NOTIFIED : result = "ADAPTERS_NOTIFIED"; break;
- * case MODEL_RESOURCE_MOVED : result = "MODEL_RESOURCE_MOVED";
- * break; case MODEL_RESOURCE_DELETED : result =
- * "MODEL_RESOURCE_DELETED"; break;
- */
- default :
- throw new IllegalStateException("ModelLifecycleEvent did not have valid type"); //$NON-NLS-1$
- }
- return result;
- }
-
- protected int getInternalType() {
-
- return fType;
- }
-
- public IStructuredModel getModel() {
-
- return fModel;
- }
-
- public int getType() {
-
- // for now, we'll mask type to "public" ones this easy
- // way ... but I know there must be a better way
- return fType & MASK;
- }
-
- public String toString() {
- String result = null;
- result = "ModelLifecycleEvent: " + debugString(fType); //$NON-NLS-1$
- return result;
- }
-
-}
diff --git a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/ModelLoader.java b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/ModelLoader.java
deleted file mode 100644
index b44c521a11..0000000000
--- a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/ModelLoader.java
+++ /dev/null
@@ -1,81 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Jens Lukowski/Innoopract - initial renaming/restructuring
- *
- *******************************************************************************/
-package org.eclipse.wst.sse.core;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.List;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.wst.common.encoding.EncodingRule;
-
-
-/**
- * Responsible for creating a new Model from a resource, or as a new, empty
- * instance.
- *
- */
-public interface ModelLoader {
- /**
- * This method should perform all the model initialization required before
- * it contains content, namely, it should call newModel, the
- * createNewStructuredDocument(), then setAdapterFactories. (this is
- * tentative)
- */
- IStructuredModel createModel();
-
- /**
- * Method createModel. Creates a new model based on old one.
- *
- * @param oldModel
- * @return IStructuredModel
- */
- IStructuredModel createModel(IStructuredModel oldModel);
-
- /**
- * This method must return those factories which must be attached to the
- * structuredModel before content is applied.
- */
- List getAdapterFactories();
-
- void load(IFile file, IStructuredModel model) throws IOException, CoreException;
-
- void load(InputStream inputStream, IStructuredModel model, EncodingRule encodingRule) throws IOException;
-
- void load(InputStream inputStream, IStructuredModel model, String encodingName, String lineDelimiter) throws IOException;
-
- void load(String filename, InputStream inputStream, IStructuredModel model, String encodingName, String lineDelimiter) throws IOException;
-
- ModelLoader newInstance();
-
- /**
- * This method should always return an new, empty Structured Model
- * appropriate for itself.
- */
- IStructuredModel newModel();
-
- IStructuredModel reinitialize(IStructuredModel model);
-
- /**
- * This method should get a fresh copy of the data, and repopulate the
- * models ... normally by a call to setText on the structuredDocument, for
- * StructuredModels. This method is needed in some cases where clients are
- * sharing a model and then changes canceled. Say for example, one editor
- * and several "displays" are sharing a model, if the editor is closed
- * without saving changes, then the displays still need a model, but they
- * should revert to the original unsaved version.
- */
- void reload(InputStream inputStream, IStructuredModel model);
-
-}
diff --git a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/ModelManagerImpl.java b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/ModelManagerImpl.java
deleted file mode 100644
index 2000ffe551..0000000000
--- a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/ModelManagerImpl.java
+++ /dev/null
@@ -1,1748 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Jens Lukowski/Innoopract - initial renaming/restructuring
- *
- *******************************************************************************/
-package org.eclipse.wst.sse.core;
-
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.io.OutputStream;
-import java.io.Reader;
-import java.io.UnsupportedEncodingException;
-import java.util.Dictionary;
-import java.util.Enumeration;
-import java.util.Hashtable;
-import java.util.Iterator;
-import java.util.List;
-import java.util.NoSuchElementException;
-
-import org.eclipse.core.filebuffers.FileBuffers;
-import org.eclipse.core.filebuffers.ITextFileBuffer;
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IWorkspaceRoot;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.NullProgressMonitor;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.jface.text.BadLocationException;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.IRegion;
-import org.eclipse.text.edits.MultiTextEdit;
-import org.eclipse.text.edits.ReplaceEdit;
-import org.eclipse.text.edits.TextEdit;
-import org.eclipse.wst.common.encoding.CodedIO;
-import org.eclipse.wst.common.encoding.CodedStreamCreator;
-import org.eclipse.wst.common.encoding.CommonEncodingPreferenceNames;
-import org.eclipse.wst.common.encoding.ContentBasedPreferenceGateway;
-import org.eclipse.wst.common.encoding.EncodingMemento;
-import org.eclipse.wst.common.encoding.EncodingRule;
-import org.eclipse.wst.common.encoding.exceptions.MalformedOutputExceptionWithDetail;
-import org.eclipse.wst.sse.core.document.DocumentReader;
-import org.eclipse.wst.sse.core.document.IDocumentLoader;
-import org.eclipse.wst.sse.core.document.IEncodedDocument;
-import org.eclipse.wst.sse.core.exceptions.ResourceAlreadyExists;
-import org.eclipse.wst.sse.core.exceptions.ResourceInUse;
-import org.eclipse.wst.sse.core.exceptions.SourceEditingRuntimeException;
-import org.eclipse.wst.sse.core.internal.FileBufferModelManager;
-import org.eclipse.wst.sse.core.internal.Logger;
-import org.eclipse.wst.sse.core.internal.NullMemento;
-import org.eclipse.wst.sse.core.internal.SSECorePlugin;
-import org.eclipse.wst.sse.core.internal.modelhandler.ModelHandlerRegistry;
-import org.eclipse.wst.sse.core.modelhandler.IModelHandler;
-import org.eclipse.wst.sse.core.text.IStructuredDocument;
-import org.eclipse.wst.sse.core.util.Assert;
-import org.eclipse.wst.sse.core.util.ProjectResolver;
-import org.eclipse.wst.sse.core.util.URIResolver;
-import org.eclipse.wst.sse.core.util.Utilities;
-
-/**
- * Not intended to be subclassed.
- *
- * This class is responsible for creating, retriving, and caching
- * StructuredModels It retrieves the cached objects by an id which is
- * typically a String representing the resources URI. Note: Its important that
- * all clients that share a resource do so using <b>identical </b>
- * identifiers, or else different instances will be created and retrieved,
- * even if they all technically point to the same resource on the file system.
- * This class also provides a convenient place to register Model Loaders and
- * Dumpers based on 'type'.
- */
-class ModelManagerImpl implements IModelManager {
-
- static class EnumeratedModelIds implements Enumeration {
-
- Enumeration fSharedObjectKeys;
-
- protected EnumeratedModelIds(Dictionary sharedObjects) {
-
- if (sharedObjects == null) {
- // if no shared objects yet, return empty enumeration
- fSharedObjectKeys = null;
- }
- else {
- fSharedObjectKeys = sharedObjects.keys();
- }
- }
-
- public boolean hasMoreElements() {
-
- boolean result = false;
- if (fSharedObjectKeys != null)
- result = fSharedObjectKeys.hasMoreElements();
- return result;
- }
-
- public Object nextElement() {
-
- if (fSharedObjectKeys == null)
- throw new NoSuchElementException();
- return fSharedObjectKeys.nextElement();
- }
- }
-
- static class ReadEditType {
- ReadEditType(String type) {
- }
- }
-
- /**
- * A Data class to track our shared objects
- */
- static class SharedObject {
- int referenceCountForEdit;
- int referenceCountForRead;
- IStructuredModel theSharedModel;
-
- SharedObject(IStructuredModel sharedModel) {
- theSharedModel = sharedModel;
- referenceCountForRead = 0;
- referenceCountForEdit = 0;
- }
- }
-
- private static final String IMODELMANAGER_TRACE_CATEGORY = "IModelManager"; //$NON-NLS-1$
-
- /**
- * Our singleton instance
- */
- private static ModelManagerImpl instance;
- private final static int READ_BUFFER_SIZE = 4096;
-
- synchronized static IModelManager getInstance() {
-
- if (instance == null) {
- instance = new ModelManagerImpl();
- }
- return instance;
- }
-
- private final ReadEditType EDIT = new ReadEditType("edit"); //$NON-NLS-1$
- /**
- * Our cache of managed objects
- */
- private Dictionary fManagedObjects;
-
- private ModelHandlerRegistry fModelHandlerRegistry;
- private Object[] fModelManagerListeners;
- private int modelManagerStateChanging;
- private final ReadEditType READ = new ReadEditType("read"); //$NON-NLS-1$
-
- ModelManagerImpl() {
-
- super();
- fManagedObjects = new Hashtable();
- }
-
- private IStructuredModel _commonCreateModel(InputStream inputStream, String id, IModelHandler handler, URIResolver resolver, ReadEditType rwType, EncodingRule encodingRule) throws IOException {
-
- SharedObject sharedObject = (SharedObject) fManagedObjects.get(id);
- IStructuredModel model = null;
- if (sharedObject == null) {
- try {
- model = _commonCreateModel(id, handler, resolver);
- ModelLoader loader = handler.getModelLoader();
- loader.load(Utilities.getMarkSupportedStream(inputStream), model, encodingRule);
- }
- catch (ResourceInUse e) {
- // impossible, since we've already found
- handleProgramError(e);
- }
- if (model != null) {
- // add to our cache
- sharedObject = new SharedObject(model);
- _initCount(sharedObject, rwType);
- fManagedObjects.put(id, sharedObject);
- }
- }
- else {
- // if shared object is initially in our cache, then simply
- // increment its ref count,
- // and return the object.
- _incrCount(sharedObject, rwType);
- }
- // we expect to always return something
- Assert.isNotNull(sharedObject, "Program Error: no model recorded for id " + id); //$NON-NLS-1$
- // note: clients must call release for each time they call get.
- return sharedObject.theSharedModel;
- }
-
- private IStructuredModel _commonCreateModel(InputStream inputStream, String id, IModelHandler handler, URIResolver resolver, ReadEditType rwType, String encoding, String lineDelimiter) throws IOException {
-
- if (id == null) {
- throw new IllegalArgumentException("Program Error: id may not be null"); //$NON-NLS-1$
- }
- SharedObject sharedObject = (SharedObject) fManagedObjects.get(id);
- IStructuredModel model = null;
- if (sharedObject == null) {
- try {
- model = _commonCreateModel(id, handler, resolver);
- ModelLoader loader = handler.getModelLoader();
- if (inputStream == null) {
- Logger.log(Logger.WARNING, "model was requested for id " + id + " without a content InputStream");
- }
- loader.load(id, Utilities.getMarkSupportedStream(inputStream), model, encoding, lineDelimiter);
- }
- catch (ResourceInUse e) {
- // impossible, since we've already found
- handleProgramError(e);
- }
- if (model != null) {
- // add to our cache
- sharedObject = new SharedObject(model);
- _initCount(sharedObject, rwType);
- fManagedObjects.put(id, sharedObject);
- }
- }
- else {
- // if shared object is initially in our cache, then simply
- // increment its ref count,
- // and return the object.
- _incrCount(sharedObject, rwType);
- }
- // we expect to always return something
- Assert.isNotNull(sharedObject, "Program Error: no model recorded for id " + id); //$NON-NLS-1$
- // note: clients must call release for each time they call get.
- return sharedObject.theSharedModel;
- }
-
- private IStructuredModel _commonCreateModel(String id, IModelHandler handler, URIResolver resolver) throws ResourceInUse {
-
- Assert.isNotNull(handler, "model handler can not be null"); //$NON-NLS-1$
- ModelLoader loader = handler.getModelLoader();
- IStructuredModel result = loader.createModel();
- // in the past, id was null for "unmanaged" case, so we won't
- // try and set it
- if (id != null) {
- result.setId(id);
- }
- result.setModelHandler(handler);
- result.setResolver(resolver);
- // some obvious redunancy here that maybe could be improved
- // in future, but is necessary for now
- result.setBaseLocation(id);
- if (resolver != null) {
- resolver.setFileBaseLocation(id);
- }
- addFactories(result, handler);
- return result;
- }
-
- private IStructuredModel _commonGetModel(IFile iFile, ReadEditType rwType, EncodingRule encodingRule) throws UnsupportedEncodingException, IOException, CoreException {
- IStructuredModel model = null;
-
- if (iFile != null && iFile.exists()) {
- String id = calculateId(iFile);
- IModelHandler handler = calculateType(iFile);
- URIResolver resolver = calculateURIResolver(iFile);
- InputStream inputStream = Utilities.getMarkSupportedStream(iFile.getContents(true));
- try {
- model = _commonCreateModel(inputStream, id, handler, resolver, rwType, encodingRule);
- }
- finally {
- if (inputStream != null) {
- inputStream.close();
- }
- }
- }
-
- return model;
- }
-
- private IStructuredModel _commonGetModel(IFile iFile, ReadEditType rwType, String encoding, String lineDelimiter) throws UnsupportedEncodingException, IOException, CoreException {
- String id = calculateId(iFile);
- IModelHandler handler = calculateType(iFile);
- URIResolver resolver = calculateURIResolver(iFile);
- IStructuredModel model = _commonGetModel(iFile, id, handler, resolver, rwType, encoding, lineDelimiter);
-
- return model;
- }
-
- private IStructuredModel _commonGetModel(IFile file, String id, IModelHandler handler, URIResolver resolver, ReadEditType rwType, String encoding, String lineDelimiter) throws IOException, CoreException {
- if (id == null)
- throw new IllegalArgumentException("Program Error: id may not be null"); //$NON-NLS-1$
-
- IStructuredModel model = null;
-
- if (file != null && file.exists()) {
- SharedObject sharedObject = (SharedObject) fManagedObjects.get(id);
- if (sharedObject == null) {
- model = FileBufferModelManager.getInstance().getModel(file);
- if (model != null) {
- // add to our cache
- sharedObject = new SharedObject(model);
- _initCount(sharedObject, rwType);
- fManagedObjects.put(id, sharedObject);
- }
- }
- else {
- // if shared object is initially in our cache, then simply
- // increment its ref count,
- // and return the object.
- _incrCount(sharedObject, rwType);
- }
-
- // we expect to always return something
- Assert.isNotNull(sharedObject, "Program Error: no model recorded for id " + id); //$NON-NLS-1$
-
- // note: clients must call release for each time they call get.
- model = sharedObject.theSharedModel;
- }
-
- return model;
- }
-
- private SharedObject _commonNewModel(IFile iFile, boolean force) throws ResourceAlreadyExists, ResourceInUse, IOException, CoreException {
- // let's check to see if resource already exists, either in our cache,
- // or on the system
- String id = calculateId(iFile);
- SharedObject sharedObject = (SharedObject) fManagedObjects.get(id);
- IStructuredModel aSharedModel = null;
- // if shared object is null, then we do not have it already, which is
- // as normally expected.
- if (sharedObject == null) {
- // if not in cache, see if we can retrieve it
- aSharedModel = FileBufferModelManager.getInstance().getModel(iFile);
- }
- else {
- // if sharedObject is not null, then
- // someone has asked us to create a new model for a given id, but
- // it in fact
- // is already in our cache with that id. In this case we will
- // throw
- // an "in use" exception,
- // (unless force is set to true). Because, to do otherwise we will
- // basically be
- // over writing a model that another client is already using. Not
- // nice.
- if (!force) {
- throw new ResourceInUse();
- }
- }
- // if we get here, and result (and shared object) are still null,
- // then all is ok, and we can create it,
- if (aSharedModel == null) {
- aSharedModel = FileBufferModelManager.getInstance().getModel(iFile);
- // rembember, don't set 'true' in model init, since that's always
- // used,
- // even when not new. 'new' is intended to mean "there is not yet
- // a
- // file" for the model.
- aSharedModel.setNewState(true);
- sharedObject = addToCache(id, aSharedModel);
- // when resource is provided, we can set
- // synchronization stamp ... otherwise client should
- // Note: one client which does this is FileModelProvider.
- aSharedModel.resetSynchronizationStamp(iFile);
- }
- else {
- // if result is not null, then we have to check
- // if 'force' was false before deciding to
- // throw an already exists exception.
- if (force) {
- sharedObject = addToCache(id, aSharedModel);
- // when resource is provided, we can set
- // synchronization stamp ... otherwise client should
- // Note: one client which does this is FileModelProvider.
- aSharedModel.resetSynchronizationStamp(iFile);
- }
- else {
- throw new ResourceAlreadyExists();
- }
- }
- return sharedObject;
- }
-
- public IStructuredModel _getModelFor(IStructuredDocument document, ReadEditType accessType) {
- IStructuredModel model = null;
- String id = FileBufferModelManager.getInstance().calculateId(document);
- Assert.isNotNull(id, "unknown IStructuredDocument " + document);
- SharedObject sharedObject = (SharedObject) fManagedObjects.get(id);
- if (sharedObject != null) {
- sharedObject = (SharedObject) fManagedObjects.get(id);
- _incrCount(sharedObject, accessType);
- model = sharedObject.theSharedModel;
- }
- else {
- model = FileBufferModelManager.getInstance().getModel(document);
- sharedObject = new SharedObject(model);
- _initCount(sharedObject, accessType);
- fManagedObjects.put(id, sharedObject);
- }
- return model;
- }
-
- private void _incrCount(SharedObject sharedObject, ReadEditType type) {
- if (type == READ) {
- sharedObject.referenceCountForRead++;
- }
- else if (type == EDIT) {
- sharedObject.referenceCountForEdit++;
- }
- else
- throw new IllegalArgumentException();
- }
-
- private void _initCount(SharedObject sharedObject, ReadEditType type) {
- if (type == READ) {
- sharedObject.referenceCountForRead = 1;
- }
- else if (type == EDIT) {
- sharedObject.referenceCountForEdit = 1;
- }
- else
- throw new IllegalArgumentException();
- }
-
- /**
- * This API allows clients to declare that they are about to make a
- * "massive" change one or more models. This change might be in terms of
- * content or it might be in terms of the model id or base location. Note
- * that in the case of embedded calls, notification to listners is sent
- * only once. The method isModelStateChanging can be used by a client to
- * determine if the model is already in a change sequence.
- */
- public synchronized void aboutToChangeModels() {
- // notice this is just a public avenue to our protected method
- fireModelsAboutToBeChanged();
- }
-
- protected void addFactories(IStructuredModel model, IModelHandler handler) {
- Assert.isNotNull(model, "model can not be null"); //$NON-NLS-1$
- Assert.isNotNull(handler, "model handler can not be null"); //$NON-NLS-1$
- IFactoryRegistry registry = model.getFactoryRegistry();
- Assert.isNotNull(registry, "Factory Registry can not be null"); //$NON-NLS-1$
- List factoryList = handler.getAdapterFactories();
- addFactories(model, factoryList);
- }
-
- protected void addFactories(IStructuredModel model, List factoryList) {
- Assert.isNotNull(model, "model can not be null"); //$NON-NLS-1$
- IFactoryRegistry registry = model.getFactoryRegistry();
- Assert.isNotNull(registry, "Factory Registry can not be null"); //$NON-NLS-1$
- // Note: we add all of them from handler, even if
- // already exists. May need to reconsider this.
- if (factoryList != null) {
- Iterator iterator = factoryList.iterator();
- while (iterator.hasNext()) {
- AdapterFactory factory = (AdapterFactory) iterator.next();
- registry.addFactory(factory);
- }
- }
- }
-
- public synchronized void addModelManagerListener(IModelManagerListener listener) {
- if (!Utilities.contains(fModelManagerListeners, listener)) {
- int oldSize = 0;
- if (fModelManagerListeners != null) {
- // normally won't be null, but we need to be sure, for first
- // time through
- oldSize = fModelManagerListeners.length;
- }
- int newSize = oldSize + 1;
- Object[] newListeners = new Object[newSize];
- if (fModelManagerListeners != null) {
- System.arraycopy(fModelManagerListeners, 0, newListeners, 0, oldSize);
- }
- // add listener to last position
- newListeners[newSize - 1] = listener;
- //
- // now switch new for old
- fModelManagerListeners = newListeners;
- //
- }
- }
-
- private SharedObject addToCache(String id, IStructuredModel aSharedModel) {
- SharedObject sharedObject;
- sharedObject = new SharedObject(aSharedModel);
- fManagedObjects.put(id, sharedObject);
- return sharedObject;
- }
-
- /**
- * Calculate id provides a common way to determine the id from the input
- * ... needed to get and save the model. It is a simple class utility, but
- * is an instance method so can be accessed via interface.
- */
- public String calculateId(IFile file) {
- return FileBufferModelManager.getInstance().calculateId(file);
- }
-
- /**
- * CalculateId provides a common way to determine the id from the provided
- * filename.
- */
- public String calculateId(String filename) {
- // providing common method for consistency.
- // May eventually need to "clean up"
- // any initial "file://" protocols, etc., but currently don't
- // know of anyone doing that.
- String id = filename;
- return id;
- }
-
- protected IModelHandler calculateType(IFile iFile) throws CoreException {
- // IModelManager mm = ((ModelManagerPlugin)
- // Platform.getPlugin(ModelManagerPlugin.ID)).getModelManager();
- ModelHandlerRegistry cr = getModelHandlerRegistry();
- IModelHandler cd = cr.getHandlerFor(iFile);
- return cd;
- }
-
- private IModelHandler calculateType(String filename, InputStream inputStream) throws IOException {
- ModelHandlerRegistry cr = getModelHandlerRegistry();
- IModelHandler cd = cr.getHandlerFor(filename, inputStream);
- return cd;
- }
-
- /**
- *
- */
- private URIResolver calculateURIResolver(IFile file) {
- // Note: see comment in plugin.xml for potentially
- // breaking change in behavior.
-
- IProject project = file.getProject();
- URIResolver resolver = (URIResolver) project.getAdapter(URIResolver.class);
- if (resolver == null)
- resolver = new ProjectResolver(project);
- resolver.setFileBaseLocation(file.getLocation().toString());
- return resolver;
- }
-
- /**
- * This API allows a client controlled way of notifying all
- * IModelManagerEvent listners that several models have changed. This
- * method is a matched pair to aboutToChangeModels, and must be called
- * after aboutToChangeModel ... or some listeners could be left waiting
- * indefinitely for the changed event. So, its suggested that
- * changedModels always be in a finally clause. Likewise, a client should
- * never call changedModel without calling aboutToChangeModel first. In
- * the case of embedded calls, the notification is just sent once.
- */
- public synchronized void changedModels() {
- // notice this is just a public avenue to our protected method
- fireModelsChanged();
- }
-
- /*
- * Note: This method appears in both ModelManagerImpl and JSEditor (with
- * just a minor difference). They should be kept the same.
- *
- * @deprecated - handled by platform
- */
- private void convertLineDelimiters(IDocument document, IFile iFile) throws CoreException {
- // Note: calculateType(iFile) returns a default xml model handler if
- // content type is null.
- String contentTypeId = calculateType(iFile).getAssociatedContentTypeId();
- String endOfLineCode = ContentBasedPreferenceGateway.getPreferencesString(contentTypeId, CommonEncodingPreferenceNames.END_OF_LINE_CODE);
- // endOfLineCode == null means the content type does not support this
- // function (e.g. DTD)
- // endOfLineCode == "" means no translation
- if (endOfLineCode != null && endOfLineCode.length() > 0) {
- String lineDelimiterToUse = System.getProperty("line.separator"); //$NON-NLS-1$
- if (endOfLineCode.equals(CommonEncodingPreferenceNames.CR))
- lineDelimiterToUse = CommonEncodingPreferenceNames.STRING_CR;
- else if (endOfLineCode.equals(CommonEncodingPreferenceNames.LF))
- lineDelimiterToUse = CommonEncodingPreferenceNames.STRING_LF;
- else if (endOfLineCode.equals(CommonEncodingPreferenceNames.CRLF))
- lineDelimiterToUse = CommonEncodingPreferenceNames.STRING_CRLF;
-
- TextEdit multiTextEdit = new MultiTextEdit();
- int lineCount = document.getNumberOfLines();
- try {
- for (int i = 0; i < lineCount; i++) {
- IRegion lineInfo = document.getLineInformation(i);
- int lineStartOffset = lineInfo.getOffset();
- int lineLength = lineInfo.getLength();
- int lineEndOffset = lineStartOffset + lineLength;
-
- if (i < lineCount - 1) {
- String currentLineDelimiter = document.getLineDelimiter(i);
- if (currentLineDelimiter != null && currentLineDelimiter.compareTo(lineDelimiterToUse) != 0)
- multiTextEdit.addChild(new ReplaceEdit(lineEndOffset, currentLineDelimiter.length(), lineDelimiterToUse));
- }
- }
-
- if (multiTextEdit.getChildrenSize() > 0)
- multiTextEdit.apply(document);
- }
- catch (BadLocationException exception) {
- throw new SourceEditingRuntimeException(exception);
- }
- }
- }
-
- /**
- * this used to be in loader, but has been moved here
- */
- protected IStructuredModel copy(IStructuredModel model, String newId) throws ResourceInUse {
- IStructuredModel newModel = null;
- IStructuredModel oldModel = model;
- IModelHandler modelHandler = oldModel.getModelHandler();
- ModelLoader loader = modelHandler.getModelLoader();
- // newModel = loader.newModel();
- newModel = loader.createModel(oldModel);
- // newId, oldModel.getResolver(), oldModel.getModelManager());
- newModel.setModelHandler(modelHandler);
- // IStructuredDocument oldStructuredDocument =
- // oldModel.getStructuredDocument();
- // IStructuredDocument newStructuredDocument =
- // oldStructuredDocument.newInstance();
- // newModel.setStructuredDocument(newStructuredDocument);
- newModel.setResolver(oldModel.getResolver());
- newModel.setModelManager(oldModel.getModelManager());
- // duplicateFactoryRegistry(newModel, oldModel);
- newModel.setId(newId);
- // set text of new one after all initialization is done
- String contents = oldModel.getStructuredDocument().getText();
- newModel.getStructuredDocument().setText(this, contents);
- return newModel;
- }
-
- /**
- */
- public synchronized IStructuredModel copyModelForEdit(String oldId, String newId) throws ResourceInUse {
- IStructuredModel newModel = null;
- // get the existing model associated with this id
- IStructuredModel model = getExistingModel(oldId);
- // if it doesn't exist, ignore request (though this would normally
- // be a programming error.
- if (model == null)
- return null;
- // now be sure newModel does not exist
- SharedObject sharedObject = (SharedObject) fManagedObjects.get(newId);
- if (sharedObject != null) {
- throw new ResourceInUse();
- }
- // get loader based on existing type (note the type assumption)
- // Object type = ((IStructuredModel) model).getType();
- // IModelHandler type = model.getModelHandler();
- // ModelLoader loader = (ModelLoader) getModelLoaders().get(type);
- // ModelLoader loader = (ModelLoader) getModelLoaders().get(type);
- // ask the loader to copy
- newModel = copy(model, newId);
- if (newModel != null) {
- // add to our cache
- sharedObject = new SharedObject(newModel);
- sharedObject.referenceCountForEdit = 1;
- fManagedObjects.put(newId, sharedObject);
- trace("copied model", newId, sharedObject.referenceCountForEdit); //$NON-NLS-1$
- }
- return newModel;
- }
-
- /**
- * Similar to clone, except the new instance has no content. Note: this
- * produces an unmanaged model, for temporary use. If a true shared model
- * is desired, use "copy".
- */
- public synchronized IStructuredModel createNewInstance(IStructuredModel oldModel) throws IOException {
- IModelHandler handler = oldModel.getModelHandler();
- ModelLoader loader = handler.getModelLoader();
- IStructuredModel newModel = loader.createModel(oldModel);
- newModel.setModelHandler(handler);
- if (newModel instanceof AbstractStructuredModel) {
- ((AbstractStructuredModel) newModel).setContentTypeIdentifier(oldModel.getContentTypeIdentifier());
- }
- URIResolver oldResolver = oldModel.getResolver();
- newModel.setResolver(oldResolver);
- try {
- newModel.setId(DUPLICATED_MODEL);
- }
- catch (ResourceInUse e) {
- // impossible, since this is an unmanaged model
- }
- // base location should be null, but we'll set to
- // null to be sure.
- newModel.setBaseLocation(null);
- return newModel;
- }
-
- /**
- * Factory method, since a proper IStructuredDocument must have a proper
- * parser assigned. Note: its assume that IFile does not actually exist as
- * a resource yet. If it does, ResourceAlreadyExists exception is thrown.
- * If the resource does already exist, then createStructuredDocumentFor is
- * the right API to use.
- *
- * @throws ResourceInUse
- *
- */
- public synchronized IStructuredDocument createNewStructuredDocumentFor(IFile iFile) throws ResourceAlreadyExists, IOException, CoreException {
- if (iFile.exists()) {
- throw new ResourceAlreadyExists(iFile.getFullPath().toOSString());
- }
- // Will reconsider in future version
- // String id = calculateId(iFile);
- // if (isResourceInUse(id)) {
- // throw new ResourceInUse(iFile.getFullPath().toOSString());
- // }
- IDocumentLoader loader = null;
- IModelHandler handler = calculateType(iFile);
- loader = handler.getDocumentLoader();
- // for this API, "createNew" we assume the IFile does not exist yet
- // as checked above, so just create empty document.
- IStructuredDocument result = (IStructuredDocument) loader.createNewStructuredDocument();
- return result;
- }
-
- /**
- * Factory method, since a proper IStructuredDocument must have a proper
- * parser assigned. Note: clients should verify IFile exists before using
- * this method. If this IFile does not exist, then
- * createNewStructuredDocument is the correct API to use.
- *
- * @throws ResourceInUse
- */
- public synchronized IStructuredDocument createStructuredDocumentFor(IFile iFile) throws IOException, CoreException {
- if (!iFile.exists()) {
- throw new FileNotFoundException(iFile.getFullPath().toOSString());
- }
- // Will reconsider in future version
- // String id = calculateId(iFile);
- // if (isResourceInUse(id)) {
- // throw new ResourceInUse(iFile.getFullPath().toOSString());
- // }
- IDocumentLoader loader = null;
- IModelHandler handler = calculateType(iFile);
- loader = handler.getDocumentLoader();
- IStructuredDocument result = (IStructuredDocument) loader.createNewStructuredDocument(iFile);
- return result;
- }
-
- /**
- * Conveience method, since a proper IStructuredDocument must have a
- * proper parser assigned. It should only be used when an empty
- * structuredDocument is needed. Otherwise, use IFile form.
- *
- * @deprecated - TODO: to be removed by C4 do we really need this? I
- * recommend to - use createStructuredDocumentFor(filename,
- * null, null) - the filename does not need to represent a
- * real - file, but can take for form of dummy.jsp, test.xml,
- * etc. - That way we don't hard code the handler, but specify
- * we - want the handler that "goes with" a certain type of -
- * file.
- */
- public synchronized IStructuredDocument createStructuredDocumentFor(String contentTypeId) {
- IDocumentLoader loader = null;
- ModelHandlerRegistry cr = getModelHandlerRegistry();
- IModelHandler handler = cr.getHandlerForContentTypeId(contentTypeId);
- if (handler == null)
- Logger.log(Logger.ERROR, "Program error: no model handler found for " + contentTypeId);
- loader = handler.getDocumentLoader();
- IStructuredDocument result = (IStructuredDocument) loader.createNewStructuredDocument();
- return result;
- }
-
- /**
- * Conveience method, since a proper IStructuredDocument must have a
- * proper parser assigned.
- *
- * @deprecated -- - TODO: to be removed by C4 I marked as deprecated to
- * discouage use of this method. It does not really work for
- * JSP fragments, since JSP Fragments need an IFile to
- * correctly look up the content settings. Use IFile form
- * instead.
- */
- public IStructuredDocument createStructuredDocumentFor(String filename, InputStream inputStream, URIResolver resolver) throws IOException {
- IDocumentLoader loader = null;
- InputStream istream = Utilities.getMarkSupportedStream(inputStream);
- if (istream != null) {
- istream.reset();
- }
- IModelHandler handler = calculateType(filename, istream);
- loader = handler.getDocumentLoader();
- IStructuredDocument result = null;
- if (inputStream == null) {
- result = (IStructuredDocument) loader.createNewStructuredDocument();
- }
- else {
- result = (IStructuredDocument) loader.createNewStructuredDocument(filename, istream);
- }
- return result;
- }
-
- /**
- * Special case method. This method was created for the special case where
- * there is an encoding for input stream that should override all the
- * normal rules for encoding. For example, if there is an encoding
- * (charset) specified in HTTP response header, then that encoding is used
- * to translate the input stream to a string, but then the normal encoding
- * rules are ignored, so that the string is not translated twice (for
- * example, if its an HTML "file", then even if it contains a charset in
- * meta tag, its ignored since its assumed its all correctly decoded by
- * the HTTP charset.
- */
- public synchronized IStructuredDocument createStructuredDocumentFor(String filename, InputStream inputStream, URIResolver resolver, String encoding) throws IOException {
- String content = readInputStream(inputStream, encoding);
- IStructuredDocument result = createStructuredDocumentFor(filename, content, resolver);
- return result;
- }
-
- /**
- * Convenience method. This method can be used when the resource does not
- * really exist (e.g. when content is being created, but hasn't been
- * written to disk yet). Note that since the content is being provided as
- * a String, it is assumed to already be decoded correctly so no
- * transformation is done.
- */
- public synchronized IStructuredDocument createStructuredDocumentFor(String filename, String content, URIResolver resolver) throws IOException {
- // TODO: avoid all these String instances
- StringBuffer contentBuffer = new StringBuffer(content);
- IDocumentLoader loader = null;
- IModelHandler handler = calculateType(filename, null);
- loader = handler.getDocumentLoader();
- IStructuredDocument result = (IStructuredDocument) loader.createNewStructuredDocument();
- StringBuffer convertedContent = loader.handleLineDelimiter(contentBuffer, result);
- result.setEncodingMemento(new NullMemento());
- result.setText(this, convertedContent.toString());
- return result;
- }
-
- /**
- * @param iFile
- * @param result
- * @return
- * @throws CoreException
- */
- private IStructuredModel createUnManagedEmptyModelFor(IFile iFile) throws CoreException {
- IStructuredModel result = null;
- IModelHandler handler = calculateType(iFile);
- String id = calculateId(iFile);
- URIResolver resolver = calculateURIResolver(iFile);
-
- try {
- result = _commonCreateModel(id, handler, resolver);
- }
- catch (ResourceInUse e) {
- // impossible, since we're not sharing
- // (even if it really is in use ... we don't care)
- // this may need to be re-examined.
- Logger.trace(IMODELMANAGER_TRACE_CATEGORY, "ModelMangerImpl::createUnManagedStructuredModelFor. Model unexpectedly in use."); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- return result;
- }
-
- /**
- * Conveience method. It depends on the loaders newModel method to return
- * an appropriate StrucuturedModel appropriately initialized.
- */
- public synchronized IStructuredModel createUnManagedStructuredModelFor(IFile iFile) throws IOException, CoreException {
- IStructuredModel result = null;
- result = createUnManagedEmptyModelFor(iFile);
-
- IDocumentLoader loader = result.getModelHandler().getDocumentLoader();
- IEncodedDocument document = loader.createNewStructuredDocument(iFile);
-
- result.getStructuredDocument().setText(this, document.get());
-
- return result;
- }
-
- /**
- * Conveience method. It depends on the loaders newModel method to return
- * an appropriate StrucuturedModel appropriately initialized.
- */
- public synchronized IStructuredModel createUnManagedStructuredModelFor(String contentTypeId) {
- return createUnManagedStructuredModelFor(contentTypeId, null);
- }
-
- /**
- * Conveience method. It depends on the loaders newModel method to return
- * an appropriate StrucuturedModel appropriately initialized.
- */
- public synchronized IStructuredModel createUnManagedStructuredModelFor(String contentTypeId, URIResolver resolver) {
- IStructuredModel result = null;
- ModelHandlerRegistry cr = getModelHandlerRegistry();
- IModelHandler handler = cr.getHandlerForContentTypeId(contentTypeId);
- try {
- result = _commonCreateModel(UNMANAGED_MODEL, handler, resolver); //$NON-NLS-1$
- }
- catch (ResourceInUse e) {
- // impossible, since we're not sharing
- // (even if it really is in use ... we don't care)
- // this may need to be re-examined.
- Logger.trace(IMODELMANAGER_TRACE_CATEGORY, "ModelMangerImpl::createUnManagedStructuredModelFor. Model unexpectedly in use."); //$NON-NLS-1$ //$NON-NLS-2$
- }
- return result;
- }
-
- void dump(IStructuredModel model, OutputStream outputStream, EncodingRule encodingRule, IFile iFile) throws UnsupportedEncodingException, IOException, CoreException {
- IStructuredDocument structuredDocument = model.getStructuredDocument();
- CodedStreamCreator codedStreamCreator = new CodedStreamCreator();
- Reader reader = new DocumentReader(structuredDocument);
- codedStreamCreator.set(iFile, reader);
- codedStreamCreator.setPreviousEncodingMemento(structuredDocument.getEncodingMemento());
- ByteArrayOutputStream codedByteStream = codedStreamCreator.getCodedByteArrayOutputStream(EncodingRule.CONTENT_BASED);
- InputStream codedStream = new ByteArrayInputStream(codedByteStream.toByteArray());
- iFile.setContents(codedStream, true, true, null);
-
- // getDocumentDumper().dump(outputStream, structuredDocument,
- // encodingRule, use3ByteBOM, file);
- model.setDirtyState(false);
- model.setNewState(false);
- }
-
- /**
- * Informs all registered model state listeners that the the model is
- * about to under go a "large" change. This change might be interms of
- * contents, in might be in terms of the model id or base location.
- */
- protected void fireModelsAboutToBeChanged() {
- // notice we only fire this event if we are not already in a model
- // state changing sequence
- if (modelManagerStateChanging == 0) {
- // we must assign listeners to local variable, since the add and
- // remove listner
- // methods can change the actual instance of the listener array
- // from another thread
- if (fModelManagerListeners != null) {
- Object[] holdListeners = fModelManagerListeners;
- for (int i = 0; i < holdListeners.length; i++) {
- ((IModelManagerListener) holdListeners[i]).modelsAboutToBeChanged();
- }
- }
- }
- // we always increment counter, for every request (so must receive
- // corresponding number of 'changedModel' requests)
- modelManagerStateChanging++;
- }
-
- /**
- * Informs all registered model state listeners that an impending change
- * is now complete. This method must only be called by 'modelChanged'
- * since it keeps track of counts.
- */
- protected void fireModelsChanged() {
- // always decrement
- modelManagerStateChanging--;
- // to be less than zero is a programming error, but we'll reset to
- // zero
- // with no error messages.
- if (modelManagerStateChanging < 0)
- modelManagerStateChanging = 0;
- // We only fire this event if all pending requests are done.
- // That is, if we've received the same number of fireModelChanged as
- // we
- // have fireModelAboutToBeChanged.
- if (modelManagerStateChanging == 0) {
- // we must assign listeners to local variable, since the add and
- // remove listner
- // methods can change the actual instance of the listener array
- // from another thread
- if (fModelManagerListeners != null) {
- Object[] holdListeners = fModelManagerListeners;
- for (int i = 0; i < holdListeners.length; i++) {
- ((IModelManagerListener) holdListeners[i]).modelsChanged();
- }
- }
- }
- }
-
- private EnumeratedModelIds getEnumeratedModelIds() {
- // return new instance each time so will "act like" proper enumeration
- // to client
- // (if we cached, may not be at beginning).
- return new EnumeratedModelIds(fManagedObjects);
- }
-
- private IStructuredModel getExistingModel(Object id) {
-
- IStructuredModel result = null;
- // let's see if we already have it in our cache
- SharedObject sharedObject = (SharedObject) fManagedObjects.get(id);
- // if not, then we'll simply return null
- if (sharedObject != null) {
- result = sharedObject.theSharedModel;
- }
- return result;
- }
-
- /**
- * Note: users of this 'model' must still release it when finished.
- * Returns null if there's not a model corresponding to document.
- */
- public synchronized IStructuredModel getExistingModelForEdit(IDocument document) {
- IStructuredModel result = null;
- Enumeration ids = getEnumeratedModelIds();
- while (ids.hasMoreElements()) {
- Object potentialId = ids.nextElement();
- IStructuredModel tempResult = getExistingModel(potentialId);
- if (document == tempResult.getStructuredDocument()) {
- result = getExistingModelForEdit(potentialId);
- break;
- }
- }
- return result;
- }
-
- /**
- * This is similar to the getModel method, except this method does not
- * create a model. This method does increment the reference count (if it
- * exists). If the model does not already exist in the cache of models,
- * null is returned.
- */
- public synchronized IStructuredModel getExistingModelForEdit(IFile iFile) {
-
- Assert.isNotNull(iFile, "IFile parameter can not be null"); //$NON-NLS-1$
- Object id = calculateId(iFile);
- IStructuredModel result = getExistingModelForEdit(id);
- return result;
- }
-
- /**
- * This is similar to the getModel method, except this method does not
- * create a model. This method does increment the reference count (if it
- * exists). If the model does not already exist in the cache of models,
- * null is returned.
- *
- * @deprecated use IFile form - this one will become protected or private
- */
- public synchronized IStructuredModel getExistingModelForEdit(Object id) {
-
- Assert.isNotNull(id, "id parameter can not be null"); //$NON-NLS-1$
- IStructuredModel result = null;
- // let's see if we already have it in our cache
- SharedObject sharedObject = (SharedObject) fManagedObjects.get(id);
- // if not, then we'll simply return null
- if (sharedObject != null) {
- // if shared object is in our cache, then simply increment its ref
- // count,
- // and return the object.
- sharedObject.referenceCountForEdit++;
- result = sharedObject.theSharedModel;
- trace("got existing model for Edit: ", id); //$NON-NLS-1$
- trace(" incremented referenceCountForEdit ", id, sharedObject.referenceCountForEdit); //$NON-NLS-1$
- }
- return result;
- }
-
- /**
- * Note: users of this 'model' must still release it when finished.
- * Returns null if there's not a model corresponding to document.
- */
- public synchronized IStructuredModel getExistingModelForRead(IDocument document) {
- IStructuredModel result = null;
- Enumeration ids = getEnumeratedModelIds();
- while (ids.hasMoreElements()) {
- Object potentialId = ids.nextElement();
- IStructuredModel tempResult = getExistingModel(potentialId);
- if (document == tempResult.getStructuredDocument()) {
- result = getExistingModelForRead(potentialId);
- break;
- }
- }
- return result;
- }
-
- public synchronized IStructuredModel getExistingModelForRead(IFile iFile) {
-
- Assert.isNotNull(iFile, "IFile parameter can not be null"); //$NON-NLS-1$
- Object id = calculateId(iFile);
- IStructuredModel result = getExistingModelForRead(id);
- return result;
- }
-
- /**
- * This is similar to the getModel method, except this method does not
- * create a model. This method does increment the reference count (if it
- * exists). If the model does not already exist in the cache of models,
- * null is returned.
- *
- * @deprecated use IFile form - this one will become protected or private
- */
- public synchronized IStructuredModel getExistingModelForRead(Object id) {
-
- Assert.isNotNull(id, "id parameter can not be null"); //$NON-NLS-1$
- IStructuredModel result = null;
- // let's see if we already have it in our cache
- SharedObject sharedObject = (SharedObject) fManagedObjects.get(id);
- // if not, then we'll simply return null
- if (sharedObject != null) {
- // if shared object is in our cache, then simply increment its ref
- // count,
- // and return the object.
- sharedObject.referenceCountForRead++;
- result = sharedObject.theSharedModel;
- }
- return result;
- }
-
- /**
- * @deprecated DMW: Tom, this is "special" for links builder Assuming its
- * still needed, wouldn't it be better to change to
- * getExistingModels()? -- will be removed. Its not thread
- * safe for one thread to get the Enumeration, when underlying
- * data could be changed in another thread.
- */
- public synchronized Enumeration getExistingModelIds() {
-
- Enumeration result = getEnumeratedModelIds();
- return result;
- }
-
- // TODO: replace (or supplement) this is a "model info" association to the
- // IFile that created the model
- protected IFile getFileFor(IStructuredModel model) {
- if (model == null)
- return null;
- String path = model.getBaseLocation();
- if (path == null || path.length() == 0) {
- Object id = model.getId();
- if (id == null)
- return null;
- path = id.toString();
- }
- // TOODO needs rework for linked resources
- IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
- IFile file = root.getFileForLocation(new Path(path));
- return file;
- }
-
- /**
- * One of the primary forms to get a managed model
- */
- public synchronized IStructuredModel getModelForEdit(IFile iFile) throws IOException, CoreException {
- Assert.isNotNull(iFile, "IFile parameter can not be null"); //$NON-NLS-1$
- return _commonGetModel(iFile, EDIT, null, null);
- }
-
- /**
- * @see com.ibm.sed.model.IModelManager#getModelForEdit(IFile,
- * EncodingRule)
- */
- public synchronized IStructuredModel getModelForEdit(IFile iFile, EncodingRule encodingRule) throws UnsupportedEncodingException, IOException, CoreException {
-
- Assert.isNotNull(iFile, "IFile parameter can not be null"); //$NON-NLS-1$
- return _commonGetModel(iFile, EDIT, encodingRule);
- }
-
- public synchronized IStructuredModel getModelForEdit(IFile iFile, String encoding, String lineDelimiter) throws java.io.UnsupportedEncodingException, IOException, CoreException {
-
- Assert.isNotNull(iFile, "IFile parameter can not be null"); //$NON-NLS-1$
- return _commonGetModel(iFile, EDIT, encoding, lineDelimiter);
- }
-
- public synchronized IStructuredModel getModelForEdit(IStructuredDocument document) {
- return _getModelFor(document, EDIT);
- }
-
- /**
- * @see IModelManager
- * @deprecated use IFile or String form
- */
- public synchronized IStructuredModel getModelForEdit(Object id, InputStream inputStream, URIResolver resolver) throws java.io.UnsupportedEncodingException, IOException {
-
- Assert.isNotNull(id, "IFile parameter can not be null"); //$NON-NLS-1$
- String stringId = id.toString();
- return getModelForEdit(stringId, Utilities.getMarkSupportedStream(inputStream), resolver);
- }
-
- /**
- * @see IModelManager
- * @deprecated - use IFile or String form
- */
- public synchronized IStructuredModel getModelForEdit(Object id, Object modelType, String encodingName, String lineDelimiter, InputStream inputStream, URIResolver resolver) throws java.io.UnsupportedEncodingException, IOException {
-
- Assert.isNotNull(id, "id parameter can not be null"); //$NON-NLS-1$
- String stringId = id.toString();
- return getModelForEdit(stringId, Utilities.getMarkSupportedStream(inputStream), resolver);
- }
-
- public synchronized IStructuredModel getModelForEdit(String id, InputStream inputStream, URIResolver resolver) throws IOException {
- if (id == null) {
- throw new IllegalArgumentException("Program Error: id may not be null"); //$NON-NLS-1$
- }
-
- InputStream istream = Utilities.getMarkSupportedStream(inputStream);
- IModelHandler handler = calculateType(id, istream);
- Assert.isNotNull(handler, "model handler can not be null"); //$NON-NLS-1$
- IStructuredModel result = null;
- result = _commonCreateModel(istream, id, handler, resolver, EDIT, null, null);
- return result;
- }
-
- /**
- * One of the primary forms to get a managed model
- */
- public synchronized IStructuredModel getModelForRead(IFile iFile) throws IOException, CoreException {
-
- Assert.isNotNull(iFile, "IFile parameter can not be null"); //$NON-NLS-1$
- return _commonGetModel(iFile, READ, null, null);
- }
-
- public synchronized IStructuredModel getModelForRead(IFile iFile, EncodingRule encodingRule) throws UnsupportedEncodingException, IOException, CoreException {
- Assert.isNotNull(iFile, "IFile parameter can not be null"); //$NON-NLS-1$
- return _commonGetModel(iFile, READ, encodingRule);
- }
-
- public synchronized IStructuredModel getModelForRead(IFile iFile, String encodingName, String lineDelimiter) throws java.io.UnsupportedEncodingException, IOException, CoreException {
- Assert.isNotNull(iFile, "IFile parameter can not be null"); //$NON-NLS-1$
- return _commonGetModel(iFile, READ, encodingName, lineDelimiter);
- }
-
- public synchronized IStructuredModel getModelForRead(IStructuredDocument document) {
- return _getModelFor(document, READ);
- }
-
- /**
- * @see IModelManager
- * @deprecated use IFile or String form
- */
- public synchronized IStructuredModel getModelForRead(Object id, InputStream inputStream, URIResolver resolver) throws java.io.UnsupportedEncodingException, IOException {
- Assert.isNotNull(id, "id parameter can not be null"); //$NON-NLS-1$
- String stringId = id.toString();
- return getModelForRead(stringId, Utilities.getMarkSupportedStream(inputStream), resolver);
- }
-
- /**
- * @see IModelManager
- * @deprecated use IFile form
- */
- public synchronized IStructuredModel getModelForRead(Object id, Object modelType, String encodingName, String lineDelimiter, InputStream inputStream, URIResolver resolver) throws java.io.UnsupportedEncodingException, IOException {
- Assert.isNotNull(id, "id parameter can not be null"); //$NON-NLS-1$
- String stringId = id.toString();
- return getModelForRead(stringId, Utilities.getMarkSupportedStream(inputStream), resolver);
- }
-
- public synchronized IStructuredModel getModelForRead(String id, InputStream inputStream, URIResolver resolver) throws IOException {
- InputStream istream = Utilities.getMarkSupportedStream(inputStream);
- IModelHandler handler = calculateType(id, istream);
- IStructuredModel result = null;
- result = _commonCreateModel(istream, id, handler, resolver, READ, null, null);
- return result;
- }
-
- /**
- * @deprecated - only temporarily visible
- */
- public ModelHandlerRegistry getModelHandlerRegistry() {
- if (fModelHandlerRegistry == null) {
- fModelHandlerRegistry = ModelHandlerRegistry.getInstance();
- }
- return fModelHandlerRegistry;
- }
-
- /**
- * @see IModelManager#getNewModelForEdit(IFile, boolean)
- */
- public synchronized IStructuredModel getNewModelForEdit(IFile iFile, boolean force) throws ResourceAlreadyExists, ResourceInUse, IOException, CoreException {
- Assert.isNotNull(iFile, "IFile parameter can not be null"); //$NON-NLS-1$
- SharedObject sharedObject = _commonNewModel(iFile, force);
- sharedObject.referenceCountForEdit = 1;
- return sharedObject.theSharedModel;
- }
-
- /**
- * @see IModelManager#getNewModelForRead(IFile, boolean)
- */
- public synchronized IStructuredModel getNewModelForRead(IFile iFile, boolean force) throws ResourceAlreadyExists, ResourceInUse, IOException, CoreException {
-
- Assert.isNotNull(iFile, "IFile parameter can not be null"); //$NON-NLS-1$
- SharedObject sharedObject = _commonNewModel(iFile, force);
- sharedObject.referenceCountForRead = 1;
- return sharedObject.theSharedModel;
- }
-
- /**
- * This function returns the reference count of underlying model.
- *
- * @param id
- * Object The id of the model TODO: try to refine the design
- * not to use this function
- */
- public synchronized int getReferenceCount(Object id) {
- Assert.isNotNull(id, "id parameter can not be null"); //$NON-NLS-1$
- int count = 0;
- SharedObject sharedObject = (SharedObject) fManagedObjects.get(id);
- if (sharedObject != null)
- count = sharedObject.referenceCountForRead + sharedObject.referenceCountForEdit;
- return count;
- }
-
- /**
- * This function returns the reference count of underlying model.
- *
- * @param id
- * Object The id of the model TODO: try to refine the design
- * not to use this function
- */
- public synchronized int getReferenceCountForEdit(Object id) {
- Assert.isNotNull(id, "id parameter can not be null"); //$NON-NLS-1$
- int count = 0;
- SharedObject sharedObject = (SharedObject) fManagedObjects.get(id);
- if (sharedObject != null)
- count = sharedObject.referenceCountForEdit;
- return count;
- }
-
- /**
- * This function returns the reference count of underlying model.
- *
- * @param id
- * Object The id of the model TODO: try to refine the design
- * not to use this function
- */
- public synchronized int getReferenceCountForRead(Object id) {
- Assert.isNotNull(id, "id parameter can not be null"); //$NON-NLS-1$
- int count = 0;
- SharedObject sharedObject = (SharedObject) fManagedObjects.get(id);
- if (sharedObject != null)
- count = sharedObject.referenceCountForRead;
- return count;
- }
-
- private void handleConvertLineDelimiters(IStructuredDocument structuredDocument, IFile iFile, EncodingRule encodingRule, EncodingMemento encodingMemento) throws CoreException, MalformedOutputExceptionWithDetail, UnsupportedEncodingException {
- if (structuredDocument.getNumberOfLines() > 1) {
- String originalText = structuredDocument.get();
- convertLineDelimiters(structuredDocument, iFile);
- }
- }
-
- private void handleProgramError(Throwable t) {
-
- Logger.logException("Impossible Program Error", t); //$NON-NLS-1$
- }
-
- /**
- * Register adapters for resources using an extension point. Required to
- * ensure that calculateURIResolver has the necessary factories registered
- * before any models are loaded.
- *
- * @deprecated - wrong place to do this
- */
- protected void initResourceAdapters() {
-
- // Note: see comment in plugin.xml for potentially
- // breaking change in behavior.
-
- // new URIResolverAdapterFactoryRegistryReader().loadRegistry();
- }
-
- // private boolean isResourceInUse(String id) {
- //
- // boolean result = false;
- // IStructuredModel model = null;
- // Enumeration ids = getEnumeratedModelIds();
- // while (ids.hasMoreElements()) {
- // Object inUseID = ids.nextElement();
- // if (id.equals(inUseID)) {
- // result = true;
- // break;
- // }
- // }
- // return result;
- // }
-
- /**
- * This function returns true if there are other references to the
- * underlying model.
- */
- public synchronized boolean isShared(Object id) {
- Assert.isNotNull(id, "id parameter can not be null"); //$NON-NLS-1$
- int count = 0;
- boolean result = false;
- SharedObject sharedObject = (SharedObject) fManagedObjects.get(id);
- if (sharedObject != null)
- count = sharedObject.referenceCountForRead + sharedObject.referenceCountForEdit;
- result = count > 1;
- return result;
- }
-
- /**
- * This function returns true if there are other references to the
- * underlying model.
- *
- * @param id
- * Object The id of the model
- */
- public synchronized boolean isSharedForEdit(Object id) {
- Assert.isNotNull(id, "id parameter can not be null"); //$NON-NLS-1$
- int count = 0;
- boolean result = false;
- SharedObject sharedObject = (SharedObject) fManagedObjects.get(id);
- if (sharedObject != null)
- count = sharedObject.referenceCountForEdit;
- result = count > 1;
- return result;
- }
-
- /**
- * This function returns true if there are other references to the
- * underlying model.
- *
- * @param id
- * Object The id of the model
- */
- public synchronized boolean isSharedForRead(Object id) {
- Assert.isNotNull(id, "id parameter can not be null"); //$NON-NLS-1$
- int count = 0;
- boolean result = false;
- SharedObject sharedObject = (SharedObject) fManagedObjects.get(id);
- if (sharedObject != null)
- count = sharedObject.referenceCountForRead;
- result = count > 1;
- return result;
- }
-
- /**
- * This method can be called to determine if the model manager is within a
- * "aboutToChange" and "changed" sequence.
- */
- public synchronized boolean isStateChanging() {
-
- return modelManagerStateChanging > 0;
- }
-
- /**
- * This method changes the id of the model. TODO: try to refine the design
- * not to use this function
- */
- public synchronized void moveModel(Object oldId, Object newId) {
- org.eclipse.wst.sse.core.util.Assert.isNotNull(oldId, "id parameter can not be null"); //$NON-NLS-1$
- SharedObject sharedObject = (SharedObject) fManagedObjects.get(oldId);
- // if not found in cache, ignore request.
- // this would normally be a program error
- if (sharedObject != null) {
- fManagedObjects.remove(oldId);
- fManagedObjects.put(newId, sharedObject);
- }
- }
-
- private String readInputStream(InputStream inputStream, String ianaEncodingName) throws UnsupportedEncodingException, IOException {
-
- String allText = null;
- if ((ianaEncodingName != null) && (ianaEncodingName.length() != 0)) {
- String enc = CodedIO.getAppropriateJavaCharset(ianaEncodingName);
- if (enc == null) {
- // if no conversion was possible, let's assume that
- // the encoding is already a java encoding name, so we'll
- // proceed with that assumption. This is the case, for
- // example,
- // for the reload() procedure.
- // If in fact it is not a valid java encoding, then
- // the "allText=" line will cause an
- // UnsupportedEncodingException
- enc = ianaEncodingName;
- }
- allText = readInputStream(new InputStreamReader(inputStream, enc));
- }
- else {
- // we normally assume encoding is provided for this method, but if
- // not,
- // we'll use platform default
- allText = readInputStream(new InputStreamReader(inputStream));
- }
- return allText;
- }
-
- private String readInputStream(InputStreamReader inputStream) throws IOException {
-
- int numRead = 0;
- StringBuffer buffer = new StringBuffer();
- char tBuff[] = new char[READ_BUFFER_SIZE];
- while ((numRead = inputStream.read(tBuff, 0, tBuff.length)) != -1) {
- buffer.append(tBuff, 0, numRead);
- }
- // remember -- we didn't open stream ... so we don't close it
- return buffer.toString();
- }
-
- /*
- * @see IModelManager#reinitialize(IStructuredModel)
- */
- public synchronized IStructuredModel reinitialize(IStructuredModel model) {
-
- // getHandler (assume its the "new one")
- IModelHandler handler = model.getModelHandler();
- // getLoader for that new one
- ModelLoader loader = handler.getModelLoader();
- // ask it to reinitialize
- model = loader.reinitialize(model);
- // the loader should check to see if the one it received
- // is the same type it would normally create.
- // if not, it must "start from scratch" and create a whole
- // new one.
- // if it is of the same type, it should just 'replace text'
- // replacing all the existing text with the new text.
- // the important one is the JSP loader ... it should go through
- // its embedded content checking and initialization
- return model;
- }
-
- /**
- * protected for use in same package, not subclasses
- *
- */
- protected synchronized void releaseFromEdit(Object id) {
- Assert.isNotNull(id, "id parameter can not be null"); //$NON-NLS-1$
- SharedObject sharedObject = null;
-
- sharedObject = (SharedObject) fManagedObjects.get(id);
- Assert.isNotNull(sharedObject);
- if (sharedObject != null) {
- sharedObject.referenceCountForEdit--;
- if ((sharedObject.referenceCountForRead == 0) && (sharedObject.referenceCountForEdit == 0)) {
- fManagedObjects.remove(id);
- FileBufferModelManager.getInstance().releaseModel(sharedObject.theSharedModel.getStructuredDocument());
- }
- }
- }
-
- /**
- * protected for use in same package, not subclasses
- *
- */
- protected synchronized void releaseFromRead(Object id) {
- Assert.isNotNull(id, "id parameter can not be null"); //$NON-NLS-1$
- SharedObject sharedObject = null;
-
- sharedObject = (SharedObject) fManagedObjects.get(id);
- Assert.isNotNull(sharedObject);
- if (sharedObject != null) {
- sharedObject.referenceCountForRead--;
- if ((sharedObject.referenceCountForRead == 0) && (sharedObject.referenceCountForEdit == 0)) {
- fManagedObjects.remove(id);
- FileBufferModelManager.getInstance().releaseModel(sharedObject.theSharedModel.getStructuredDocument());
- }
- }
- }
-
- /**
- * This is similar to the getModel method, except this method does not use
- * the cached version, but forces the cached version to be replaced with a
- * fresh, unchanged version. Note: this method does not change any
- * reference counts. Also, if there is not already a cached version of the
- * model, then this call is essentially ignored (that is, it does not put
- * a model in the cache) and returns null.
- *
- * @deprecated - will become protected, use reload directly on model
- */
- public synchronized IStructuredModel reloadModel(Object id, java.io.InputStream inputStream) throws java.io.UnsupportedEncodingException {
-
- // get the existing model associated with this id
- IStructuredModel structuredModel = getExistingModel(id);
- // for the model to be null is probably an error (that is,
- // reload should not have been called, but we'll guard against
- // a null pointer example and return null if we are no longer managing
- // that model.
- if (structuredModel != null) {
- // get loader based on existing type
- // dmwTODO evaluate when reload should occur
- // with potentially new type (e.g. html 'save as' jsp).
- IModelHandler handler = structuredModel.getModelHandler();
- ModelLoader loader = handler.getModelLoader();
- // ask the loader to re-load
- loader.reload(Utilities.getMarkSupportedStream(inputStream), structuredModel);
- trace("re-loading model", id); //$NON-NLS-1$
- }
- return structuredModel;
- }
-
- public synchronized void removeModelManagerListener(IModelManagerListener listener) {
-
- if ((fModelManagerListeners != null) && (listener != null)) {
- // if its not in the listeners, we'll ignore the request
- if (Utilities.contains(fModelManagerListeners, listener)) {
- int oldSize = fModelManagerListeners.length;
- int newSize = oldSize - 1;
- Object[] newListeners = new Object[newSize];
- int index = 0;
- for (int i = 0; i < oldSize; i++) {
- if (fModelManagerListeners[i] == listener) { // ignore
- }
- else {
- // copy old to new if its not the one we are removing
- newListeners[index++] = fModelManagerListeners[i];
- }
- }
- // now that we have a new array, let's switch it for the old
- // one
- fModelManagerListeners = newListeners;
- }
- }
- }
-
- public void saveModel(IFile iFile, String id, EncodingRule encodingRule) throws UnsupportedEncodingException, IOException, CoreException {
- // let's see if we already have it in our cache
- SharedObject sharedObject = (SharedObject) fManagedObjects.get(id);
- if (sharedObject == null || sharedObject.theSharedModel == null) {
- throw new SourceEditingRuntimeException(SSECorePlugin.getResourceString("%Program_Error__ModelManage_EXC_")); //$NON-NLS-1$ = "Program Error: ModelManagerImpl::saveModel. Model should be in the cache"
- }
- else {
- boolean saved = false;
- // if this model was based on a File Buffer and we're writing back
- // to the same location, use the buffer to do the writing
- if (FileBufferModelManager.getInstance().isExistingBuffer(sharedObject.theSharedModel.getStructuredDocument())) {
- ITextFileBuffer buffer = FileBufferModelManager.getInstance().getBuffer(sharedObject.theSharedModel.getStructuredDocument());
- IPath fileLocation = FileBuffers.normalizeLocation(iFile.getFullPath());
- if (fileLocation.equals(buffer.getLocation())) {
- buffer.commit(new NullProgressMonitor(), true);
- saved = true;
- }
- }
- if (!saved) {
- IStructuredModel model = sharedObject.theSharedModel;
- IStructuredDocument document = model.getStructuredDocument();
- saveStructuredDocument(document, iFile, encodingRule);
- trace("saving model", id); //$NON-NLS-1$
- }
- sharedObject.theSharedModel.setDirtyState(false);
- sharedObject.theSharedModel.setNewState(false);
- }
- }
-
- /**
- * Saving the model really just means to save it's structured document.
- *
- * @param id
- * @param outputStream
- * @param encodingRule
- * @throws UnsupportedEncodingException
- * @throws IOException
- * @throws CoreException
- */
- public void saveModel(String id, EncodingRule encodingRule) throws UnsupportedEncodingException, IOException, CoreException {
- // let's see if we already have it in our cache
- SharedObject sharedObject = (SharedObject) fManagedObjects.get(id);
- if (sharedObject == null) {
- throw new SourceEditingRuntimeException(SSECorePlugin.getResourceString("%Program_Error__ModelManage_EXC_")); //$NON-NLS-1$ = "Program Error: ModelManagerImpl::saveModel. Model should be in the cache"
- }
- else {
- // if this model was based on a File Buffer and we're writing back
- // to the same location, use the buffer to do the writing
- if (FileBufferModelManager.getInstance().isExistingBuffer(sharedObject.theSharedModel.getStructuredDocument())) {
- ITextFileBuffer buffer = FileBufferModelManager.getInstance().getBuffer(sharedObject.theSharedModel.getStructuredDocument());
- buffer.commit(new NullProgressMonitor(), true);
- }
- else {
- IFile iFile = getFileFor(sharedObject.theSharedModel);
- IStructuredModel model = sharedObject.theSharedModel;
- IStructuredDocument document = model.getStructuredDocument();
- saveStructuredDocument(document, iFile);
- trace("saving model", id); //$NON-NLS-1$
- }
- }
- sharedObject.theSharedModel.setDirtyState(false);
- sharedObject.theSharedModel.setNewState(false);
- }
-
- /**
- * @deprecated - this method is less efficient than IFile form, since it
- * requires an extra "copy" of byte array, and should be avoid
- * in favor of the IFile form.
- */
- public void saveModel(String id, OutputStream outputStream, EncodingRule encodingRule) throws UnsupportedEncodingException, CoreException, IOException {
-
- // let's see if we already have it in our cache
- SharedObject sharedObject = (SharedObject) fManagedObjects.get(id);
- if (sharedObject == null) {
- throw new SourceEditingRuntimeException(SSECorePlugin.getResourceString("%Program_Error__ModelManage_EXC_")); //$NON-NLS-1$ = "Program Error: ModelManagerImpl::saveModel. Model should be in the cache"
- }
- else {
- CodedStreamCreator codedStreamCreator = new CodedStreamCreator();
- codedStreamCreator.set(sharedObject.theSharedModel.getId(), new DocumentReader(sharedObject.theSharedModel.getStructuredDocument()));
- codedStreamCreator.setPreviousEncodingMemento(sharedObject.theSharedModel.getStructuredDocument().getEncodingMemento());
- ByteArrayOutputStream byteArrayOutputStream = codedStreamCreator.getCodedByteArrayOutputStream(encodingRule);
- byte[] outputBytes = byteArrayOutputStream.toByteArray();
- outputStream.write(outputBytes);
- trace("saving model", id); //$NON-NLS-1$
- }
- sharedObject.theSharedModel.setDirtyState(false);
- sharedObject.theSharedModel.setNewState(false);
- }
-
- public void saveStructuredDocument(IStructuredDocument structuredDocument, IFile iFile) throws UnsupportedEncodingException, CoreException, IOException {
- saveStructuredDocument(structuredDocument, iFile, EncodingRule.CONTENT_BASED);
- }
-
- public void saveStructuredDocument(IStructuredDocument structuredDocument, IFile iFile, EncodingRule encodingRule) throws UnsupportedEncodingException, CoreException, IOException {
- if (FileBufferModelManager.getInstance().isExistingBuffer(structuredDocument)) {
- ITextFileBuffer buffer = FileBufferModelManager.getInstance().getBuffer(structuredDocument);
- if (iFile.getLocation().equals(buffer.getLocation())) {
- buffer.commit(new NullProgressMonitor(), true);
- }
- }
- else {
- // IModelHandler handler = calculateType(iFile);
- // IDocumentDumper dumper = handler.getDocumentDumper();
- CodedStreamCreator codedStreamCreator = new CodedStreamCreator();
- Reader reader = new DocumentReader(structuredDocument);
- codedStreamCreator.set(iFile, reader);
- codedStreamCreator.setPreviousEncodingMemento(structuredDocument.getEncodingMemento());
- EncodingMemento encodingMemento = codedStreamCreator.getCurrentEncodingMemento();
-
- // be sure document's is updated, in case exception is thrown in
- // getCodedByteArrayOutputStream
- structuredDocument.setEncodingMemento(encodingMemento);
-
- // Convert line delimiters after encoding memento is figured out,
- // but
- // before writing to output stream.
- handleConvertLineDelimiters(structuredDocument, iFile, encodingRule, encodingMemento);
-
- ByteArrayOutputStream codedByteStream = codedStreamCreator.getCodedByteArrayOutputStream(encodingRule);
- InputStream codedStream = new ByteArrayInputStream(codedByteStream.toByteArray());
- if (iFile.exists())
- iFile.setContents(codedStream, true, true, null);
- else
- iFile.create(codedStream, false, null);
- codedByteStream.close();
- codedStream.close();
- }
- }
-
- /**
- * Common trace method
- */
- private void trace(String msg, Object id) {
- if (Logger.isTracing(IMODELMANAGER_TRACE_CATEGORY)) {
- Logger.trace(IMODELMANAGER_TRACE_CATEGORY, msg + " " + Utilities.makeShortId(id)); //$NON-NLS-1$ //$NON-NLS-2$
- }
- }
-
- /**
- * Common trace method
- */
- private void trace(String msg, Object id, int value) {
- if (Logger.isTracing(IMODELMANAGER_TRACE_CATEGORY)) {
- Logger.trace(IMODELMANAGER_TRACE_CATEGORY, msg + Utilities.makeShortId(id) + " (" + value + ")"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- }
- }
-}
diff --git a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/ModelPlugin.java b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/ModelPlugin.java
deleted file mode 100644
index 51d1faa281..0000000000
--- a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/ModelPlugin.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Jens Lukowski/Innoopract - initial renaming/restructuring
- *
- *******************************************************************************/
-package org.eclipse.wst.sse.core;
-
-import org.eclipse.wst.sse.core.internal.SSECorePlugin;
-
-
-/**
- * @deprecated use internal SSECorePlugin class or StructuredModelManager instead
- */
-public class ModelPlugin extends SSECorePlugin {
-
- public ModelPlugin() {
- super();
- }
-
- public static String getID() {
- return SSECorePlugin.ID;
- }
-
-}
diff --git a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/ModelStateMemento.java b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/ModelStateMemento.java
deleted file mode 100644
index 108be07491..0000000000
--- a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/ModelStateMemento.java
+++ /dev/null
@@ -1,111 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Jens Lukowski/Innoopract - initial renaming/restructuring
- *
- *******************************************************************************/
-package org.eclipse.wst.sse.core;
-
-
-
-import org.eclipse.core.resources.IResource;
-
-/**
- * Used my AbstractStructuredModel to keep track of what state it should be
- * in, when restoreState(memento) is called. See also getMemento.
- */
-class ModelStateMemento implements IStateMemento {
- /**
- * datesInSynch records whether or not the resource modification date, and
- * synchronization date are the same when getMemento is called. If so,
- * they should be forced to be the same in restoreState
- */
- private boolean datesInSync;
- /**
- * dirty State when 'getMemento' called. restoreState should set it back
- * to this value.
- */
- private boolean dirtyState;
-
- /**
- * the resource used in 'getMemento'. Eventually (V2) will be part of the
- * Model itself
- */
- private IResource underlyingResource;
-
- /**
- * ModelStateMemento constructor comment.
- */
- ModelStateMemento() {
- super();
- }
-
- /**
- * Insert the method's description here. Creation date: (9/7/2001 1:15:06
- * PM)
- *
- * @return org.eclipse.core.resources.IResource
- */
- org.eclipse.core.resources.IResource getUnderlyingResource() {
- return underlyingResource;
- }
-
- /**
- * Insert the method's description here. Creation date: (9/7/2001 2:18:03
- * PM)
- *
- * @return boolean
- */
- boolean isDatesInSync() {
- return datesInSync;
- }
-
- /**
- * Insert the method's description here. Creation date: (9/7/2001 1:15:06
- * PM)
- *
- * @return boolean
- */
- boolean isDirtyState() {
- return dirtyState;
- }
-
- /**
- * Insert the method's description here. Creation date: (9/7/2001 2:18:03
- * PM)
- *
- * @param newDatesInSync
- * boolean
- */
- void setDatesInSync(boolean newDatesInSync) {
- datesInSync = newDatesInSync;
- }
-
- /**
- * Insert the method's description here. Creation date: (9/7/2001 1:15:06
- * PM)
- *
- * @param newDirtyState
- * boolean
- */
- void setDirtyState(boolean newDirtyState) {
- dirtyState = newDirtyState;
- }
-
- /**
- * Insert the method's description here. Creation date: (9/7/2001 1:15:06
- * PM)
- *
- * @param newUnderlyingResource
- * org.eclipse.core.resources.IResource
- */
- void setUnderlyingResource(org.eclipse.core.resources.IResource newUnderlyingResource) {
- underlyingResource = newUnderlyingResource;
- }
-}
diff --git a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/NullModelManager.java b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/NullModelManager.java
deleted file mode 100644
index 5be0556458..0000000000
--- a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/NullModelManager.java
+++ /dev/null
@@ -1,504 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Jens Lukowski/Innoopract - initial renaming/restructuring
- *
- *******************************************************************************/
-package org.eclipse.wst.sse.core;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.UnsupportedEncodingException;
-import java.util.Enumeration;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.wst.common.encoding.EncodingRule;
-import org.eclipse.wst.sse.core.exceptions.ResourceAlreadyExists;
-import org.eclipse.wst.sse.core.exceptions.ResourceInUse;
-import org.eclipse.wst.sse.core.text.IStructuredDocument;
-import org.eclipse.wst.sse.core.util.URIResolver;
-
-
-/**
- * Simple "null" implementation, entirely to more easily handle case where
- * model manager can't be retrieved due to workspace shutting down. Its intent
- * is to help minimize null checks (especially new null checks :)
- */
-public class NullModelManager extends ModelManagerImpl implements IModelManager {
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.wst.sse.core.IModelManager#aboutToChangeModels()
- */
- public void aboutToChangeModels() {
-
-
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.wst.sse.core.IModelManager#addModelManagerListener(org.eclipse.wst.sse.core.IModelManagerListener)
- */
- public void addModelManagerListener(IModelManagerListener listener) {
-
-
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.wst.sse.core.IModelManager#calculateBaseLocation(org.eclipse.core.resources.IFile)
- */
- public String calculateBaseLocation(IFile file) {
-
- return null;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.wst.sse.core.IModelManager#calculateId(org.eclipse.core.resources.IFile)
- */
- public String calculateId(IFile file) {
-
- return null;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.wst.sse.core.IModelManager#changedModels()
- */
- public void changedModels() {
-
-
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.wst.sse.core.IModelManager#copyModelForEdit(java.lang.String,
- * java.lang.String)
- */
- public IStructuredModel copyModelForEdit(String oldId, String newId) throws ResourceInUse {
-
- return null;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.wst.sse.core.IModelManager#createNewInstance(org.eclipse.wst.sse.core.IStructuredModel)
- */
- public IStructuredModel createNewInstance(IStructuredModel model) throws IOException {
-
- return null;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.wst.sse.core.IModelManager#createNewStructuredDocumentFor(org.eclipse.core.resources.IFile)
- */
- public IStructuredDocument createNewStructuredDocumentFor(IFile iFile) throws ResourceAlreadyExists, IOException, CoreException {
-
- return null;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.wst.sse.core.IModelManager#createStructuredDocumentFor(org.eclipse.core.resources.IFile)
- */
- public IStructuredDocument createStructuredDocumentFor(IFile iFile) throws IOException, CoreException {
-
- return null;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.wst.sse.core.IModelManager#createStructuredDocumentFor(java.lang.String)
- */
- public IStructuredDocument createStructuredDocumentFor(String contentTypeId) {
-
- return null;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.wst.sse.core.IModelManager#createStructuredDocumentFor(java.lang.String,
- * java.io.InputStream, org.eclipse.wst.sse.core.util.URIResolver)
- */
- public IStructuredDocument createStructuredDocumentFor(String filename, InputStream inputStream, URIResolver resolver) throws IOException {
-
- return null;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.wst.sse.core.IModelManager#createStructuredDocumentFor(java.lang.String,
- * java.io.InputStream, org.eclipse.wst.sse.core.util.URIResolver,
- * java.lang.String)
- */
- public IStructuredDocument createStructuredDocumentFor(String filename, InputStream inputStream, URIResolver resolver, String ianaEncodingName) throws IOException {
-
- return null;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.wst.sse.core.IModelManager#createStructuredDocumentFor(java.lang.String,
- * java.lang.String, org.eclipse.wst.sse.core.util.URIResolver)
- */
- public IStructuredDocument createStructuredDocumentFor(String filename, String content, URIResolver resolver) throws IOException {
-
- return null;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.wst.sse.core.IModelManager#createUnManagedStructuredModelFor(org.eclipse.core.resources.IFile)
- */
- public IStructuredModel createUnManagedStructuredModelFor(IFile iFile) throws IOException, CoreException {
-
- return null;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.wst.sse.core.IModelManager#createUnManagedStructuredModelFor(java.lang.String)
- */
- public IStructuredModel createUnManagedStructuredModelFor(String contentTypeId) {
-
- return null;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.wst.sse.core.IModelManager#createUnManagedStructuredModelFor(java.lang.String,
- * org.eclipse.wst.sse.core.util.URIResolver)
- */
- public IStructuredModel createUnManagedStructuredModelFor(String contentTypeId, URIResolver resolver) {
-
- return null;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.wst.sse.core.IModelManager#getExistingModelForEdit(org.eclipse.jface.text.IDocument)
- */
- public IStructuredModel getExistingModelForEdit(IDocument document) {
-
- return null;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.wst.sse.core.IModelManager#getExistingModelForEdit(org.eclipse.core.resources.IFile)
- */
- public IStructuredModel getExistingModelForEdit(IFile iFile) {
-
- return null;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.wst.sse.core.IModelManager#getExistingModelForEdit(java.lang.Object)
- */
- public IStructuredModel getExistingModelForEdit(Object id) {
-
- return null;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.wst.sse.core.IModelManager#getExistingModelForRead(org.eclipse.jface.text.IDocument)
- */
- public IStructuredModel getExistingModelForRead(IDocument document) {
-
- return null;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.wst.sse.core.IModelManager#getExistingModelForRead(org.eclipse.core.resources.IFile)
- */
- public IStructuredModel getExistingModelForRead(IFile iFile) {
-
- return null;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.wst.sse.core.IModelManager#getExistingModelForRead(java.lang.Object)
- */
- public IStructuredModel getExistingModelForRead(Object id) {
-
- return null;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.wst.sse.core.IModelManager#getExistingModelIds()
- */
- public Enumeration getExistingModelIds() {
-
- return null;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.wst.sse.core.IModelManager#getModelForEdit(org.eclipse.core.resources.IFile)
- */
- public IStructuredModel getModelForEdit(IFile iFile) throws IOException, CoreException {
-
- return null;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.wst.sse.core.IModelManager#getModelForEdit(org.eclipse.core.resources.IFile,
- * org.eclipse.wst.common.encoding.EncodingRule)
- */
- public IStructuredModel getModelForEdit(IFile iFile, EncodingRule encodingRule) throws UnsupportedEncodingException, IOException, CoreException {
-
- return null;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.wst.sse.core.IModelManager#getModelForEdit(org.eclipse.core.resources.IFile,
- * java.lang.String, java.lang.String)
- */
- public IStructuredModel getModelForEdit(IFile iFile, String encoding, String lineDelimiter) throws UnsupportedEncodingException, IOException, CoreException {
-
- return null;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.wst.sse.core.IModelManager#getModelForEdit(java.lang.String,
- * java.io.InputStream, org.eclipse.wst.sse.core.util.URIResolver)
- */
- public IStructuredModel getModelForEdit(String filename, InputStream inStream, URIResolver resolver) throws UnsupportedEncodingException, IOException {
-
- return null;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.wst.sse.core.IModelManager#getModelForRead(org.eclipse.core.resources.IFile)
- */
- public IStructuredModel getModelForRead(IFile iFile) throws IOException, CoreException {
-
- return null;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.wst.sse.core.IModelManager#getModelForRead(org.eclipse.core.resources.IFile,
- * org.eclipse.wst.common.encoding.EncodingRule)
- */
- public IStructuredModel getModelForRead(IFile iFile, EncodingRule encodingRule) throws UnsupportedEncodingException, IOException, CoreException {
-
- return null;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.wst.sse.core.IModelManager#getModelForRead(org.eclipse.core.resources.IFile,
- * java.lang.String, java.lang.String)
- */
- public IStructuredModel getModelForRead(IFile iFile, String encoding, String lineDelimiter) throws UnsupportedEncodingException, IOException, CoreException {
-
- return null;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.wst.sse.core.IModelManager#getModelForRead(java.lang.String,
- * java.io.InputStream, org.eclipse.wst.sse.core.util.URIResolver)
- */
- public IStructuredModel getModelForRead(String filename, InputStream inStream, URIResolver resolver) throws UnsupportedEncodingException, IOException {
-
- return null;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.wst.sse.core.IModelManager#getNewModelForEdit(org.eclipse.core.resources.IFile,
- * boolean)
- */
- public IStructuredModel getNewModelForEdit(IFile iFile, boolean force) throws ResourceAlreadyExists, ResourceInUse, IOException, CoreException {
-
- return null;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.wst.sse.core.IModelManager#getNewModelForRead(org.eclipse.core.resources.IFile,
- * boolean)
- */
- public IStructuredModel getNewModelForRead(IFile iFile, boolean force) throws ResourceAlreadyExists, ResourceInUse, IOException, CoreException {
-
- return null;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.wst.sse.core.IModelManager#getReferenceCount(java.lang.Object)
- */
- public int getReferenceCount(Object id) {
-
- return 0;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.wst.sse.core.IModelManager#getReferenceCountForEdit(java.lang.Object)
- */
- public int getReferenceCountForEdit(Object id) {
-
- return 0;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.wst.sse.core.IModelManager#getReferenceCountForRead(java.lang.Object)
- */
- public int getReferenceCountForRead(Object id) {
-
- return 0;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.wst.sse.core.IModelManager#isShared(java.lang.Object)
- */
- public boolean isShared(Object id) {
-
- return false;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.wst.sse.core.IModelManager#isSharedForEdit(java.lang.Object)
- */
- public boolean isSharedForEdit(Object id) {
-
- return false;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.wst.sse.core.IModelManager#isSharedForRead(java.lang.Object)
- */
- public boolean isSharedForRead(Object id) {
-
- return false;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.wst.sse.core.IModelManager#isStateChanging()
- */
- public boolean isStateChanging() {
-
- return false;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.wst.sse.core.IModelManager#moveModel(java.lang.Object,
- * java.lang.Object)
- */
- public void moveModel(Object oldId, Object newId) {
-
-
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.wst.sse.core.IModelManager#reinitialize(org.eclipse.wst.sse.core.IStructuredModel)
- */
- public IStructuredModel reinitialize(IStructuredModel model) {
-
- return null;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.wst.sse.core.IModelManager#reloadModel(java.lang.Object,
- * java.io.InputStream)
- */
- public IStructuredModel reloadModel(Object id, InputStream inStream) throws UnsupportedEncodingException {
-
- return null;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.wst.sse.core.IModelManager#removeModelManagerListener(org.eclipse.wst.sse.core.IModelManagerListener)
- */
- public void removeModelManagerListener(IModelManagerListener listener) {
-
-
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.wst.sse.core.IModelManager#saveStructuredDocument(org.eclipse.wst.sse.core.text.IStructuredDocument,
- * org.eclipse.core.resources.IFile)
- */
- public void saveStructuredDocument(IStructuredDocument structuredDocument, IFile iFile) throws UnsupportedEncodingException, IOException, CoreException {
-
-
- }
-
-}
diff --git a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/PropagatingAdapter.java b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/PropagatingAdapter.java
deleted file mode 100644
index bece75e3de..0000000000
--- a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/PropagatingAdapter.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Jens Lukowski/Innoopract - initial renaming/restructuring
- *
- *******************************************************************************/
-package org.eclipse.wst.sse.core;
-
-import java.util.List;
-
-public interface PropagatingAdapter extends INodeAdapter {
-
- void addAdaptOnCreateFactory(AdapterFactory factory);
-
- List getAdaptOnCreateFactories();
-
- /**
- * This method should be called immediately after adding a factory,
- * typically on the document (top level) node, so all nodes can be
- * adapted, if needed. This is needed for those occasions when a factory
- * is addeded after some nodes may have already been created at the time
- * the factory is added.
- */
- void initializeForFactory(AdapterFactory factory, INodeNotifier node);
-
- // dmw: should have getFactoryFor?
- void release();
-}
diff --git a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/PropagatingAdapterFactory.java b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/PropagatingAdapterFactory.java
deleted file mode 100644
index 7e53a13d08..0000000000
--- a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/PropagatingAdapterFactory.java
+++ /dev/null
@@ -1,27 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Jens Lukowski/Innoopract - initial renaming/restructuring
- *
- *******************************************************************************/
-package org.eclipse.wst.sse.core;
-
-
-
-import java.util.ArrayList;
-
-
-
-public interface PropagatingAdapterFactory extends AdapterFactory {
-
- void addContributedFactories(AdapterFactory factory);
-
- void setContributedFactories(ArrayList list);
-
-}
diff --git a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/StructuredModelManager.java b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/StructuredModelManager.java
deleted file mode 100644
index 4055a410c7..0000000000
--- a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/StructuredModelManager.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *
- *******************************************************************************/
-package org.eclipse.wst.sse.core;
-
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.wst.sse.core.internal.SSECorePlugin;
-import org.osgi.framework.Bundle;
-
-public class StructuredModelManager {
- /**
- * @deprecated - call getModelManager directly
- * @return
- */
- public static StructuredModelManager getInstance() {
- return new StructuredModelManager();
- }
-
- public static IModelManager getModelManager() {
- boolean isReady = false;
- IModelManager modelManager = null;
- while (!isReady) {
- Bundle localBundle = Platform.getBundle(SSECorePlugin.ID);
- int state = localBundle.getState();
- if (state == Bundle.ACTIVE) {
- isReady = true;
- // getInstance is a synchronized static method.
- modelManager = ModelManagerImpl.getInstance();
- }
- else if (state == Bundle.STARTING) {
- try {
- Thread.sleep(100);
- }
- catch (InterruptedException e) {
- // ignore, just loop again
- }
- }
- else if (state == Bundle.STOPPING || state == Bundle.UNINSTALLED) {
- isReady = true;
- modelManager = new NullModelManager();
- }
- else {
- // not sure about other states, 'resolved', 'installed'
- isReady = true;
- }
- }
- return modelManager;
- }
-}
diff --git a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/builder/IBuilderDelegate.java b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/builder/IBuilderDelegate.java
deleted file mode 100644
index 86379ec745..0000000000
--- a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/builder/IBuilderDelegate.java
+++ /dev/null
@@ -1,60 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Jens Lukowski/Innoopract - initial renaming/restructuring
- *
- *******************************************************************************/
-package org.eclipse.wst.sse.core.builder;
-
-import java.util.Map;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-
-/**
- * Delegates for the Structured Builder. Delegates may be contributed using
- * the org.eclipse.wst.sse.core.builderdelegate extension point. For resources and
- * resource deltas with matching content types, the builder will first call
- * the startup() method, build(), and shutdown in sequence. Participant
- * instances will be reused across projects but are not shared per content
- * type. Participants should not hold on to references to models or resources
- * after shutdown().
- */
-public interface IBuilderDelegate {
- IStatus build(IFile file, int kind, Map args, IProgressMonitor monitor);
-
- /**
- * Notifies the participant that building is done for now. Resources held
- * from startup should now be released.
- */
- void shutdown(IProject project);
-
- /**
- * Notifies the participant that a sequence of builds is about to be
- * called. Ideally the time to load preferences and perform any expensive
- * configuration for the given project.
- *
- * @param project -
- * the project that's about to be built
- * @param kind -
- * the kind of build being done; possible values are
- * IncrementalProjectBuilder.AUTO_BUILD,
- * IncrementalProjectBuilder.FULL_BUILD, or
- * IncrementalProjectBuilder.INCREMENTAL_BUILD
- * @param args
- * the table of builder-specific arguments sent to the
- * Structured Document Builder, keyed by argument name (key
- * type: <code>String</code>, value type:
- * <code>String</code>);<code>null</code> is equivalent
- * to an empty map
- */
- void startup(IProject project, int kind, Map args);
-}
diff --git a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/builder/IBuilderModelProvider.java b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/builder/IBuilderModelProvider.java
deleted file mode 100644
index e1c3f917bd..0000000000
--- a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/builder/IBuilderModelProvider.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Jens Lukowski/Innoopract - initial renaming/restructuring
- *
- *******************************************************************************/
-package org.eclipse.wst.sse.core.builder;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.wst.sse.core.IStructuredModel;
-import org.eclipse.wst.sse.core.text.IStructuredDocument;
-
-
-/**
- * Model provider for IBuilderParticipants - provides Structured Documents and
- * Models to participants. Clients should not implement. Models for any
- * resource may be requested, not just for the current delta. The same
- * document and model instances are NOT guaranteed to be returned with each
- * call.
- */
-
-public interface IBuilderModelProvider {
- /**
- * @param file
- * @return an IStructuredDocument with the file's contents if the file's
- * Content Type is supported, null if not
- */
- IStructuredDocument getDocument(IFile file);
-
- /**
- * @param file
- * @return an IStructuredModel with the file's contents if the file's
- * Content Type is supported, null if not
- */
- IStructuredModel getModel(IFile file);
-}
diff --git a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/builder/IBuilderParticipant.java b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/builder/IBuilderParticipant.java
deleted file mode 100644
index fbc4316fde..0000000000
--- a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/builder/IBuilderParticipant.java
+++ /dev/null
@@ -1,124 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Jens Lukowski/Innoopract - initial renaming/restructuring
- *
- *******************************************************************************/
-package org.eclipse.wst.sse.core.builder;
-
-import java.util.Map;
-
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.resources.IResourceDelta;
-import org.eclipse.core.runtime.IProgressMonitor;
-
-/**
- * Participants in the Structured building process. Participants may be
- * contributed using the org.eclipse.wst.sse.core.builderparticipant extension point.
- * For resources and resource deltas with matching content types, the builder
- * will first call the build() method and then the cleanup() method in
- * sequence. Participant instances will be reused across projects but are not
- * shared per content type. Participants should not hold on to references to
- * models or resources after cleanup().
- *
- * @deprecated
- */
-public interface IBuilderParticipant {
-
-
- /**
- * Perform a build for the given resources within this project. May be
- * called multiple times between startup and shutdown.
- *
- * @param resources -
- * an IResource list of resources in this project with the
- * correct content type
- * @param project -
- * the project on which this participant is operating
- * @param provider -
- * a model provider for this project
- * @param monitor
- * @return
- */
- boolean build(IResource[] resources, IProject project, IBuilderModelProvider provider, IProgressMonitor monitor);
-
- /**
- * Perform an incremental build. May be called multiple times between
- * startup and shutdown.
- *
- * @param delta -
- * the IResourceDelta to examine for building
- * @param project -
- * the project on which this participant is operating
- * @param provider -
- * a model provider for this delta's resource
- * @param monitor
- * @return
- */
- boolean build(IResourceDelta delta, IProject project, IBuilderModelProvider provider, IProgressMonitor monitor);
-
- /**
- * Do any post-build cleanup from a full build for a project. Called once
- * for every matching build() call.
- *
- * @param resources -
- * the IResource list of resources in this project with the
- * correct content type
- * @param project -
- * the project on which this participant is operating
- * @param provider -
- * a model provider for this delta's resource
- * @param monitor
- * @return
- */
- boolean cleanup(IResource[] resources, IProject project, IBuilderModelProvider provider, IProgressMonitor monitor);
-
- /**
- * Do any post-build cleanup from building a resource delta. Called once
- * for every matching build() call.
- *
- * @param delta -
- * the IResourceDelta to examine for building
- * @param project -
- * the project on which this participant is operating
- * @param provider -
- * a model provider for this delta's resource
- * @param monitor
- * @return
- */
- boolean cleanup(IResourceDelta delta, IProject project, IBuilderModelProvider provider, IProgressMonitor monitor);
-
- /**
- * Notifies the participant that building is done for now. Resources held
- * from startup should now be released.
- */
- void shutdown(IProject project);
-
- /**
- * Notifies the participant that a sequence of builds is about to be
- * called. Ideally the time to load preferences and perform any expensive
- * configuration for the given project.
- *
- * @param project -
- * the project that's about to be built
- * @param kind -
- * the kind of build being done; possible values are
- * IncrementalProjectBuilder.AUTO_BUILD,
- * IncrementalProjectBuilder.FULL_BUILD, or
- * IncrementalProjectBuilder.INCREMENTAL_BUILD
- * @param args
- * the table of builder-specific arguments sent to the
- * Structured Document Builder, keyed by argument name (key
- * type: <code>String</code>, value type:
- * <code>String</code>);<code>null</code> is equivalent
- * to an empty map
- */
- void startup(IProject project, int kind, Map args);
-}
diff --git a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/cleanup/AbstractCleanupProcessor.java b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/cleanup/AbstractCleanupProcessor.java
deleted file mode 100644
index 0590b28cae..0000000000
--- a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/cleanup/AbstractCleanupProcessor.java
+++ /dev/null
@@ -1,241 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Jens Lukowski/Innoopract - initial renaming/restructuring
- *
- *******************************************************************************/
-package org.eclipse.wst.sse.core.cleanup;
-
-import java.io.ByteArrayInputStream;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.io.UnsupportedEncodingException;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.wst.sse.core.IStructuredModel;
-import org.eclipse.wst.sse.core.StructuredModelManager;
-import org.eclipse.wst.sse.core.exceptions.SourceEditingRuntimeException;
-import org.eclipse.wst.sse.core.internal.Logger;
-
-
-/**
- * @deprecated renamed to AbstractStructuredCleanupProcessor
- *
- * TODO will delete in C5
- */
-abstract public class AbstractCleanupProcessor implements CleanupProcessor {
- public String cleanupContent(String input) {
- IStructuredModel structuredModel = null;
- InputStream inputStream = null;
- try {
- // setup structuredModel
- inputStream = new ByteArrayInputStream(input.getBytes("UTF8")); //$NON-NLS-1$
- String id = inputStream.toString() + getContentType();
- structuredModel = StructuredModelManager.getModelManager().getModelForRead(id, inputStream, null);
-
- // cleanup
- cleanupModel(structuredModel, 0, structuredModel.getStructuredDocument().getLength());
-
- // return output
- return structuredModel.getStructuredDocument().get();
- } catch (UnsupportedEncodingException exception) {
- throw new SourceEditingRuntimeException(exception);
- } catch (IOException exception) {
- throw new SourceEditingRuntimeException(exception);
- } finally {
- ensureClosed(null, inputStream);
- // release from model manager
- if (structuredModel != null)
- structuredModel.releaseFromRead();
- }
- }
-
- public String cleanupContent(String input, int start, int length) {
- IStructuredModel structuredModel = null;
- InputStream inputStream = null;
- try {
- // setup structuredModel
- inputStream = new ByteArrayInputStream(input.getBytes("UTF8")); //$NON-NLS-1$
- String id = inputStream.toString() + getContentType();
- structuredModel = StructuredModelManager.getModelManager().getModelForRead(id, inputStream, null);
-
- // cleanup
- cleanupModel(structuredModel, start, length);
-
- // return output
- return structuredModel.getStructuredDocument().get();
- } catch (UnsupportedEncodingException exception) {
- throw new SourceEditingRuntimeException(exception);
- } catch (IOException exception) {
- throw new SourceEditingRuntimeException(exception);
- } finally {
- ensureClosed(null, inputStream);
- // release from model manager
- if (structuredModel != null)
- structuredModel.releaseFromRead();
- }
- }
-
- public void cleanupFile(IFile file) {
- IStructuredModel structuredModel = null;
- //OutputStream outputStream = null;
- try {
- // setup structuredModel
- structuredModel = StructuredModelManager.getModelManager().getModelForRead(file);
-
- // cleanup
- cleanupModel(structuredModel, 0, structuredModel.getStructuredDocument().getLength());
-
- // save output to file
- //outputStream = new
- // FileOutputStream(file.getLocation().toString());
- structuredModel.save(file);
- } catch (CoreException exception) {
- throw new SourceEditingRuntimeException(exception);
- } catch (IOException exception) {
- throw new SourceEditingRuntimeException(exception);
- } finally {
- //ensureClosed(outputStream, null);
- // release from model manager
- if (structuredModel != null)
- structuredModel.releaseFromRead();
- }
- }
-
- public void cleanupFile(IFile file, int start, int length) {
- IStructuredModel structuredModel = null;
- //OutputStream outputStream = null;
- try {
- // setup structuredModel
- structuredModel = StructuredModelManager.getModelManager().getModelForRead(file);
-
- // cleanup
- cleanupModel(structuredModel, start, length);
-
- // save output to file
- //outputStream = new
- // FileOutputStream(file.getLocation().toString());
- structuredModel.save(file);
- } catch (CoreException exception) {
- throw new SourceEditingRuntimeException(exception);
- } catch (IOException exception) {
- throw new SourceEditingRuntimeException(exception);
- } finally {
- //ensureClosed(outputStream, null);
- // release from model manager
- if (structuredModel != null)
- structuredModel.releaseFromRead();
- }
- }
-
- public void cleanupFileName(String fileName) {
- IStructuredModel structuredModel = null;
- InputStream inputStream = null;
- //OutputStream outputStream = null;
- try {
- // setup structuredModel
- inputStream = new FileInputStream(fileName);
- structuredModel = StructuredModelManager.getModelManager().getModelForRead(fileName, inputStream, null);
-
- // cleanup
- cleanupModel(structuredModel, 0, structuredModel.getStructuredDocument().getLength());
-
- // save output to file
- //outputStream = new FileOutputStream(fileName);
- structuredModel.save();
- }
- //TODO I don't think we should be turning any of these into runtime
- // exceptions
- catch (CoreException exception) {
- throw new SourceEditingRuntimeException(exception);
- } catch (FileNotFoundException exception) {
- throw new SourceEditingRuntimeException(exception);
- } catch (UnsupportedEncodingException exception) {
- throw new SourceEditingRuntimeException(exception);
- } catch (IOException exception) {
- throw new SourceEditingRuntimeException(exception);
- } finally {
- //ensureClosed(outputStream, inputStream);
- // release from model manager
- if (structuredModel != null)
- structuredModel.releaseFromRead();
- }
- }
-
- public void cleanupFileName(String fileName, int start, int length) {
- IStructuredModel structuredModel = null;
- InputStream inputStream = null;
- //OutputStream outputStream = null;
- try {
- // setup structuredModel
- inputStream = new FileInputStream(fileName);
- structuredModel = StructuredModelManager.getModelManager().getModelForRead(fileName, inputStream, null);
-
- // cleanup
- cleanupModel(structuredModel, start, length);
-
- // save output to file
- //outputStream = new FileOutputStream(fileName);
- structuredModel.save();
- }
- //TODO I don't think we should be turning any of these into runtime
- // exceptions
-
- catch (CoreException exception) {
- throw new SourceEditingRuntimeException(exception);
- } catch (FileNotFoundException exception) {
- throw new SourceEditingRuntimeException(exception);
- } catch (UnsupportedEncodingException exception) {
- throw new SourceEditingRuntimeException(exception);
- } catch (IOException exception) {
- throw new SourceEditingRuntimeException(exception);
- } finally {
- //ensureClosed(outputStream, inputStream);
- // release from model manager
- if (structuredModel != null)
- structuredModel.releaseFromRead();
- }
- }
-
- abstract public void cleanupModel(IStructuredModel structuredModel);
-
- abstract public void cleanupModel(IStructuredModel structuredModel, int start, int length);
-
- protected void ensureClosed(OutputStream outputStream, InputStream inputStream) {
- try {
- if (inputStream != null) {
- inputStream.close();
- }
- } catch (IOException e) {
- Logger.logException(e); // hopeless
- }
- try {
- if (outputStream != null) {
- outputStream.close();
- }
- } catch (IOException e) {
- Logger.logException(e); // hopeless
- }
- }
-
- /**
- * The content type string is case insensitive. It may be "XML" for XML,
- * "CSS" for CSS, and "HTML", "JSP", "JHTML", "SHTML", "SHTM", "HTML-SS",
- * "XHTML", "HTM" for HTML.
- * <p>
- * This is needed for creating a temporary model when the
- * cleanupContent(String input) form of CleanupProcessor is called.
- */
- protected abstract String getContentType();
-
-}
diff --git a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/cleanup/AbstractStructuredCleanupProcessor.java b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/cleanup/AbstractStructuredCleanupProcessor.java
deleted file mode 100644
index 1d30f960ab..0000000000
--- a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/cleanup/AbstractStructuredCleanupProcessor.java
+++ /dev/null
@@ -1,456 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Jens Lukowski/Innoopract - initial renaming/restructuring
- *
- *******************************************************************************/
-package org.eclipse.wst.sse.core.cleanup;
-
-import java.io.ByteArrayInputStream;
-import java.io.FileInputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.util.Map;
-import java.util.Vector;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.jface.text.BadLocationException;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.IRegion;
-import org.eclipse.jface.text.TextUtilities;
-import org.eclipse.wst.common.encoding.CommonEncodingPreferenceNames;
-import org.eclipse.wst.sse.core.IStructuredModel;
-import org.eclipse.wst.sse.core.StructuredModelManager;
-import org.eclipse.wst.sse.core.format.IStructuredFormatProcessor;
-import org.eclipse.wst.sse.core.internal.Logger;
-import org.eclipse.wst.sse.core.text.IStructuredDocument;
-import org.w3c.dom.Attr;
-import org.w3c.dom.Node;
-
-
-public abstract class AbstractStructuredCleanupProcessor implements IStructuredCleanupProcessor {
- public boolean refreshCleanupPreferences = true; // special flag for JUnit
-
- // tests to skip refresh
- // of cleanup preferences
- // when it's set to false
-
- public String cleanupContent(String input) throws IOException, CoreException {
- IStructuredModel structuredModel = null;
- InputStream inputStream = null;
- try {
- // setup structuredModel
- inputStream = new ByteArrayInputStream(input.getBytes("UTF8")); //$NON-NLS-1$
- String id = inputStream.toString() + getContentType();
- structuredModel = StructuredModelManager.getModelManager().getModelForRead(id, inputStream, null);
-
- // cleanup
- cleanupModel(structuredModel, 0, structuredModel.getStructuredDocument().getLength());
-
- // return output
- return structuredModel.getStructuredDocument().get();
- } finally {
- ensureClosed(null, inputStream);
- // release from model manager
- if (structuredModel != null)
- structuredModel.releaseFromRead();
- }
- }
-
- public String cleanupContent(String input, int start, int length) throws IOException, CoreException {
- IStructuredModel structuredModel = null;
- InputStream inputStream = null;
- try {
- // setup structuredModel
- inputStream = new ByteArrayInputStream(input.getBytes("UTF8")); //$NON-NLS-1$
- String id = inputStream.toString() + getContentType();
- structuredModel = StructuredModelManager.getModelManager().getModelForRead(id, inputStream, null);
-
- // cleanup
- cleanupModel(structuredModel, start, length);
-
- // return output
- return structuredModel.getStructuredDocument().get();
- } finally {
- ensureClosed(null, inputStream);
- // release from model manager
- if (structuredModel != null)
- structuredModel.releaseFromRead();
- }
- }
-
- public void cleanupDocument(IDocument document) throws IOException, CoreException {
- if (document == null)
- return;
-
- IStructuredModel structuredModel = null;
- //OutputStream outputStream = null;
- try {
- // setup structuredModel
- // Note: We are getting model for edit. Will save model if model
- // changed.
- structuredModel = StructuredModelManager.getModelManager().getExistingModelForEdit(document);
-
- // cleanup
- cleanupModel(structuredModel);
-
- // save model if needed
- if (!structuredModel.isSharedForEdit() && structuredModel.isSaveNeeded())
- structuredModel.save();
- } finally {
- //ensureClosed(outputStream, null);
- // release from model manager
- if (structuredModel != null)
- structuredModel.releaseFromEdit();
- }
- }
-
- public void cleanupDocument(IDocument document, int start, int length) throws IOException, CoreException {
- if (document == null)
- return;
-
- if (start >= 0 && length >= 0 && start + length <= document.getLength()) {
- IStructuredModel structuredModel = null;
- //OutputStream outputStream = null;
- try {
- // setup structuredModel
- // Note: We are getting model for edit. Will save model if
- // model changed.
- structuredModel = StructuredModelManager.getModelManager().getExistingModelForEdit(document);
-
- // cleanup
- cleanupModel(structuredModel, start, length);
-
- // save model if needed
- if (!structuredModel.isSharedForEdit() && structuredModel.isSaveNeeded())
- structuredModel.save();
- } finally {
- //ensureClosed(outputStream, null);
- // release from model manager
- if (structuredModel != null)
- structuredModel.releaseFromEdit();
- }
- }
- }
-
- public void cleanupFile(IFile file) throws IOException, CoreException {
- IStructuredModel structuredModel = null;
- //OutputStream outputStream = null;
- try {
- // setup structuredModel
- structuredModel = StructuredModelManager.getModelManager().getModelForRead(file);
-
- // cleanup
- cleanupModel(structuredModel, 0, structuredModel.getStructuredDocument().getLength());
-
- // save output to file
- //outputStream = new
- // FileOutputStream(file.getLocation().toString());
- structuredModel.save(file);
- } finally {
- //ensureClosed(outputStream, null);
- // release from model manager
- if (structuredModel != null)
- structuredModel.releaseFromRead();
- }
- }
-
- public void cleanupFile(IFile file, int start, int length) throws IOException, CoreException {
- IStructuredModel structuredModel = null;
- //OutputStream outputStream = null;
- try {
- // setup structuredModel
- structuredModel = StructuredModelManager.getModelManager().getModelForRead(file);
-
- // cleanup
- cleanupModel(structuredModel, start, length);
-
- // save output to file
- //outputStream = new
- // FileOutputStream(file.getLocation().toString());
- structuredModel.save(file);
- } finally {
- //ensureClosed(outputStream, null);
- // release from model manager
- if (structuredModel != null)
- structuredModel.releaseFromRead();
- }
- }
-
- public void cleanupFileName(String fileName) throws IOException, CoreException {
- IStructuredModel structuredModel = null;
- InputStream inputStream = null;
- //OutputStream outputStream = null;
- try {
- // setup structuredModel
- inputStream = new FileInputStream(fileName);
- structuredModel = StructuredModelManager.getModelManager().getModelForRead(fileName, inputStream, null);
-
- // cleanup
- cleanupModel(structuredModel, 0, structuredModel.getStructuredDocument().getLength());
-
- // save output to file
- //outputStream = new FileOutputStream(fileName);
- structuredModel.save();
- } finally {
- //ensureClosed(outputStream, inputStream);
- // release from model manager
- if (structuredModel != null)
- structuredModel.releaseFromRead();
- }
- }
-
- public void cleanupFileName(String fileName, int start, int length) throws IOException, CoreException {
- IStructuredModel structuredModel = null;
- InputStream inputStream = null;
- //OutputStream outputStream = null;
- try {
- // setup structuredModel
- inputStream = new FileInputStream(fileName);
- structuredModel = StructuredModelManager.getModelManager().getModelForRead(fileName, inputStream, null);
-
- // cleanup
- cleanupModel(structuredModel, start, length);
-
- // save output to file
- //outputStream = new FileOutputStream(fileName);
- structuredModel.save();
- } finally {
- //ensureClosed(outputStream, inputStream);
- // release from model manager
- if (structuredModel != null)
- structuredModel.releaseFromRead();
- }
- }
-
- public void cleanupModel(IStructuredModel structuredModel) {
-
- int start = 0;
- int length = structuredModel.getStructuredDocument().getLength();
- cleanupModel(structuredModel, start, length);
- }
-
- public void cleanupModel(IStructuredModel structuredModel, int start, int length) {
-
- if (structuredModel != null) {
- if ((start >= 0) && (length <= structuredModel.getStructuredDocument().getLength())) {
- Vector activeNodes = getActiveNodes(structuredModel, start, length);
- if (activeNodes.size() > 0) {
- Node firstNode = (Node) activeNodes.firstElement();
- Node lastNode = (Node) activeNodes.lastElement();
- boolean done = false;
- Node eachNode = firstNode;
- Node nextNode = null;
- while (!done) {
- // update "done"
- done = (eachNode == lastNode);
-
- // get next sibling before cleanup because eachNode
- // may
- // be deleted,
- // for example when it's an empty text node
- nextNode = eachNode.getNextSibling();
-
- // cleanup selected node(s)
- cleanupNode(eachNode);
-
- // update each node
- if (nextNode != null && nextNode.getParentNode() == null)
- // nextNode is deleted during cleanup
- eachNode = eachNode.getNextSibling();
- else
- eachNode = nextNode;
-
- // This should not be needed, but just in case
- // something went wrong with with eachNode.
- // We don't want an infinite loop here.
- if (eachNode == null)
- done = true;
- }
-
- // format source
- if (getFormatSourcePreference(structuredModel)) {
- // format the document
- IStructuredFormatProcessor formatProcessor = getFormatProcessor();
- formatProcessor.formatModel(structuredModel);
- }
-
- // convert EOL codes
- if (getConvertEOLCodesPreference(structuredModel)) {
- IDocument document = structuredModel.getStructuredDocument();
- String endOfLineCode = getEOLCodePreference(structuredModel);
- String endOfLineCodeString = null;
- if (endOfLineCode.compareTo(CommonEncodingPreferenceNames.LF) == 0)
- endOfLineCodeString = CommonEncodingPreferenceNames.STRING_LF;
- else if (endOfLineCode.compareTo(CommonEncodingPreferenceNames.CR) == 0)
- endOfLineCodeString = CommonEncodingPreferenceNames.STRING_CR;
- else if (endOfLineCode.compareTo(CommonEncodingPreferenceNames.CRLF) == 0)
- endOfLineCodeString = CommonEncodingPreferenceNames.STRING_CRLF;
- if (endOfLineCodeString != null) {
- convertLineDelimiters(document, endOfLineCodeString);
- // DMW: 8/24/2002 setting line delimiter in
- // document allows
- // subsequent editing to insert the same line
- // delimiter.
- if (document instanceof IStructuredDocument) {
- ((IStructuredDocument) document).setLineDelimiter(endOfLineCodeString);
- }
- structuredModel.setDirtyState(true);
- }
- }
- }
- }
- }
- }
-
- public void cleanupNode(Node node) {
- if (node != null) {
- Node cleanupNode = node;
-
- // cleanup the owner node if it's an attribute node
- if (cleanupNode.getNodeType() == Node.ATTRIBUTE_NODE)
- cleanupNode = ((Attr) cleanupNode).getOwnerElement();
-
- // refresh cleanup preferences before getting cleanup handler
- if (refreshCleanupPreferences)
- refreshCleanupPreferences();
-
- // get cleanup handler
- IStructuredCleanupHandler cleanupHandler = getCleanupHandler(cleanupNode);
- if (cleanupHandler != null) {
- // cleanup each node
- cleanupHandler.cleanup(cleanupNode);
- }
- }
- }
-
- protected void convertLineDelimiters(IDocument document, String newDelimiter) {
- final int lineCount = document.getNumberOfLines();
- Map partitioners = TextUtilities.removeDocumentPartitioners(document);
- try {
- for (int i = 0; i < lineCount; i++) {
- final String delimiter = document.getLineDelimiter(i);
- if (delimiter != null && delimiter.length() > 0 && !delimiter.equals(newDelimiter)) {
- IRegion region = document.getLineInformation(i);
- document.replace(region.getOffset() + region.getLength(), delimiter.length(), newDelimiter);
- }
- }
- } catch (BadLocationException e) {
- Logger.logException(e);
- } finally {
- TextUtilities.addDocumentPartitioners(document, partitioners);
- }
- }
-
- protected void ensureClosed(OutputStream outputStream, InputStream inputStream) {
- try {
- if (inputStream != null) {
- inputStream.close();
- }
- } catch (IOException e) {
- Logger.logException(e); // hopeless
- }
- try {
- if (outputStream != null) {
- outputStream.close();
- }
- } catch (IOException e) {
- Logger.logException(e); // hopeless
- }
- }
-
- protected Vector getActiveNodes(IStructuredModel structuredModel, int startNodeOffset, int length) {
- Vector activeNodes = new Vector();
-
- if (structuredModel != null) {
- Node startNode = (Node) structuredModel.getIndexedRegion(startNodeOffset);
- Node endNode = (Node) structuredModel.getIndexedRegion(startNodeOffset + length);
-
- // make sure it's an non-empty document
- if (startNode != null) {
- while (isSiblingOf(startNode, endNode) == false) {
- if (endNode != null)
- endNode = endNode.getParentNode();
- if (endNode == null) {
- startNode = startNode.getParentNode();
- endNode = (Node) structuredModel.getIndexedRegion(startNodeOffset + length);
- }
- }
-
- while (startNode != endNode) {
- activeNodes.addElement(startNode);
- startNode = startNode.getNextSibling();
- }
- if (startNode != null)
- activeNodes.addElement(startNode);
- }
- }
-
- return activeNodes;
- }
-
- abstract protected IStructuredCleanupHandler getCleanupHandler(Node node);
-
- abstract protected String getContentType();
-
- protected boolean getConvertEOLCodesPreference(IStructuredModel structuredModel) {
-
- boolean convertEOLCodes = true;
- IStructuredCleanupHandler cleanupHandler = getCleanupHandler((Node) structuredModel.getIndexedRegion(0));
- if (cleanupHandler != null) {
- IStructuredCleanupPreferences cleanupPreferences = cleanupHandler.getCleanupPreferences();
- convertEOLCodes = cleanupPreferences.getConvertEOLCodes();
- }
- return convertEOLCodes;
- }
-
- protected String getEOLCodePreference(IStructuredModel structuredModel) {
-
- String eolCode = System.getProperty("line.separator"); //$NON-NLS-1$
-
- IStructuredCleanupHandler cleanupHandler = getCleanupHandler((Node) structuredModel.getIndexedRegion(0));
- if (cleanupHandler != null) {
- IStructuredCleanupPreferences cleanupPreferences = cleanupHandler.getCleanupPreferences();
- eolCode = cleanupPreferences.getEOLCode();
- }
- return eolCode;
- }
-
- abstract protected IStructuredFormatProcessor getFormatProcessor();
-
- protected boolean getFormatSourcePreference(IStructuredModel structuredModel) {
-
- boolean formatSource = true;
- IStructuredCleanupHandler cleanupHandler = getCleanupHandler((Node) structuredModel.getIndexedRegion(0));
- if (cleanupHandler != null) {
- IStructuredCleanupPreferences cleanupPreferences = cleanupHandler.getCleanupPreferences();
- formatSource = cleanupPreferences.getFormatSource();
- }
- return formatSource;
- }
-
- protected boolean isSiblingOf(Node node, Node endNode) {
- if (endNode == null) {
- return true;
- } else {
- Node siblingNode = node;
- while (siblingNode != null) {
- if (siblingNode == endNode)
- return true;
- else
- siblingNode = siblingNode.getNextSibling();
- }
- return false;
- }
- }
-
- abstract protected void refreshCleanupPreferences();
-}
diff --git a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/cleanup/CleanupProcessor.java b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/cleanup/CleanupProcessor.java
deleted file mode 100644
index 6db0d68e1e..0000000000
--- a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/cleanup/CleanupProcessor.java
+++ /dev/null
@@ -1,88 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Jens Lukowski/Innoopract - initial renaming/restructuring
- *
- *******************************************************************************/
-package org.eclipse.wst.sse.core.cleanup;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.wst.sse.core.IStructuredModel;
-
-
-/**
- * @deprecated renamed to IStructuredCleanupProcessor
- *
- * TODO will delete in C5
- */
-public interface CleanupProcessor {
- /**
- * This form of the CleanupProcessor takes an input string as input,
- * creates an InputStream from the input string, create a temporary model
- * of the content type specified, cleanups the whole model, then returns
- * the cleaned up input string.
- */
- String cleanupContent(String content);
-
- /**
- * This form of the CleanupProcessor takes an input string as input,
- * creates an InputStream from the input string, create a temporary model
- * of the content type specified, cleanups the model within start and
- * length, then returns the cleaned up input string.
- */
- String cleanupContent(String content, int start, int length);
-
- /**
- * This form of the CleanupProcessor takes an IFile as input, creates a
- * temporary model of content type calculated using the IFile's file
- * extension, cleanups the whole model, then releases the model. The IFile
- * is updated when the last reference of the model is released in the
- * model manager.
- */
- void cleanupFile(IFile file);
-
- /**
- * This form of the CleanupProcessor takes an IFile as input, creates a
- * temporary model of content type calculated using the IFile's file
- * extension, cleanups the model within start and length, then releases
- * the model. The IFile is updated when the last reference of the model is
- * released in the model manager.
- */
- void cleanupFile(IFile file, int start, int length);
-
- /**
- * This form of the CleanupProcessor takes a file name as input,creates an
- * InputStream from the file, create a temporary model of content type
- * calculated using the file name's file extension, cleanups the whole
- * model, then releases the model. The file is updated when the last
- * reference of the model is released in the model manager.
- */
- void cleanupFileName(String fileName);
-
- /**
- * This form of the CleanupProcessor takes a file name as input,creates an
- * InputStream from the file, create a temporary model of content type
- * calculated using the file name's file extension, cleanups the model
- * within start and length, then releases the model. The file is updated
- * when the last reference of the model is released in the model manager.
- */
- void cleanupFileName(String fileName, int start, int length);
-
- /**
- * This form of the CleanupProcessor takes a model as input, and cleanups
- * the whole model.
- */
- void cleanupModel(IStructuredModel structuredModel);
-
- /**
- * This form of the CleanupProcessor takes a model as input, and cleanups
- * the model within start and length.
- */
- void cleanupModel(IStructuredModel structuredModel, int start, int length);
-}
diff --git a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/cleanup/IStructuredCleanupHandler.java b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/cleanup/IStructuredCleanupHandler.java
deleted file mode 100644
index 6b80eec34b..0000000000
--- a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/cleanup/IStructuredCleanupHandler.java
+++ /dev/null
@@ -1,23 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Jens Lukowski/Innoopract - initial renaming/restructuring
- *
- *******************************************************************************/
-package org.eclipse.wst.sse.core.cleanup;
-
-import org.w3c.dom.Node;
-
-public interface IStructuredCleanupHandler {
- Node cleanup(Node node);
-
- IStructuredCleanupPreferences getCleanupPreferences();
-
- void setCleanupPreferences(IStructuredCleanupPreferences cleanupPreferences);
-}
diff --git a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/cleanup/IStructuredCleanupPreferences.java b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/cleanup/IStructuredCleanupPreferences.java
deleted file mode 100644
index 3581499aab..0000000000
--- a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/cleanup/IStructuredCleanupPreferences.java
+++ /dev/null
@@ -1,56 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Jens Lukowski/Innoopract - initial renaming/restructuring
- *
- *******************************************************************************/
-package org.eclipse.wst.sse.core.cleanup;
-
-import org.eclipse.core.runtime.Preferences;
-
-public interface IStructuredCleanupPreferences {
-
- int getAttrNameCase();
-
- boolean getCompressEmptyElementTags();
-
- boolean getConvertEOLCodes();
-
- String getEOLCode();
-
- boolean getFormatSource();
-
- boolean getInsertMissingTags();
-
- boolean getInsertRequiredAttrs();
-
- boolean getQuoteAttrValues();
-
- int getTagNameCase();
-
- void setAttrNameCase(int attrNameCase);
-
- void setCompressEmptyElementTags(boolean compressEmptyElementTags);
-
- void setConvertEOLCodes(boolean convertEOLCodes);
-
- void setEOLCode(String EOLCode);
-
- void setFormatSource(boolean formatSource);
-
- void setInsertMissingTags(boolean insertMissingTags);
-
- void setInsertRequiredAttrs(boolean insertRequiredAttrs);
-
- void setPreferences(Preferences preferences);
-
- void setQuoteAttrValues(boolean quoteAttrValues);
-
- void setTagNameCase(int tagNameCase);
-}
diff --git a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/cleanup/IStructuredCleanupProcessor.java b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/cleanup/IStructuredCleanupProcessor.java
deleted file mode 100644
index e7a5c95eea..0000000000
--- a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/cleanup/IStructuredCleanupProcessor.java
+++ /dev/null
@@ -1,109 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Jens Lukowski/Innoopract - initial renaming/restructuring
- *
- *******************************************************************************/
-package org.eclipse.wst.sse.core.cleanup;
-
-import java.io.IOException;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.wst.sse.core.IStructuredModel;
-import org.w3c.dom.Node;
-
-
-public interface IStructuredCleanupProcessor {
- /**
- * This form of the CleanupProcessor takes an input string as input,
- * creates an InputStream from the input string, create a temporary model
- * of the content type specified, cleanups the whole model, then returns
- * the cleaned up input string.
- */
- String cleanupContent(String content) throws IOException, CoreException;
-
- /**
- * This form of the CleanupProcessor takes an input string as input,
- * creates an InputStream from the input string, create a temporary model
- * of the content type specified, cleanups the model within start and
- * length, then returns the cleaned up input string.
- */
- String cleanupContent(String content, int start, int length) throws IOException, CoreException;
-
- /**
- * This form of the CleanupProcessor takes an IDocument as input, creates
- * a temporary model of content type calculated using the IDocument's file
- * extension, cleanups the whole model, then releases the model.
- */
- void cleanupDocument(IDocument document) throws IOException, CoreException;
-
- /**
- * This form of the CleanupProcessor takes an IDocument as input, creates
- * a temporary model of content type calculated using the IDocument's file
- * extension, cleanups the model within start and length, then releases
- * the model.
- */
- void cleanupDocument(IDocument document, int start, int length) throws IOException, CoreException;
-
- /**
- * This form of the CleanupProcessor takes an IFile as input, creates a
- * temporary model of content type calculated using the IFile's file
- * extension, cleanups the whole model, then releases the model. The IFile
- * is updated when the last reference of the model is released in the
- * model manager.
- */
- void cleanupFile(IFile file) throws IOException, CoreException;
-
- /**
- * This form of the CleanupProcessor takes an IFile as input, creates a
- * temporary model of content type calculated using the IFile's file
- * extension, cleanups the model within start and length, then releases
- * the model. The IFile is updated when the last reference of the model is
- * released in the model manager.
- */
- void cleanupFile(IFile file, int start, int length) throws IOException, CoreException;
-
- /**
- * This form of the CleanupProcessor takes a file name as input,creates an
- * InputStream from the file, create a temporary model of content type
- * calculated using the file name's file extension, cleanups the whole
- * model, then releases the model. The file is updated when the last
- * reference of the model is released in the model manager.
- */
- void cleanupFileName(String fileName) throws IOException, CoreException;
-
- /**
- * This form of the CleanupProcessor takes a file name as input,creates an
- * InputStream from the file, create a temporary model of content type
- * calculated using the file name's file extension, cleanups the model
- * within start and length, then releases the model. The file is updated
- * when the last reference of the model is released in the model manager.
- */
- void cleanupFileName(String fileName, int start, int length) throws IOException, CoreException;
-
- /**
- * This form of the CleanupProcessor takes a model as input, and cleanups
- * the whole model.
- */
- void cleanupModel(IStructuredModel structuredModel);
-
- /**
- * This form of the CleanupProcessor takes a model as input, and cleanups
- * the model within start and length.
- */
- void cleanupModel(IStructuredModel structuredModel, int start, int length);
-
- /**
- * This form of the CleanupProcessor takes a node as input, and formats
- * the node and all its children.
- */
- void cleanupNode(Node node);
-}
diff --git a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/cleanup/StructuredCleanupPreferences.java b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/cleanup/StructuredCleanupPreferences.java
deleted file mode 100644
index b236b69658..0000000000
--- a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/cleanup/StructuredCleanupPreferences.java
+++ /dev/null
@@ -1,135 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Jens Lukowski/Innoopract - initial renaming/restructuring
- *
- *******************************************************************************/
-package org.eclipse.wst.sse.core.cleanup;
-
-import org.eclipse.core.runtime.Preferences;
-import org.eclipse.wst.sse.core.internal.SSECorePlugin;
-
-
-public class StructuredCleanupPreferences implements IStructuredCleanupPreferences {
- private int fAttrNameCase;
- private boolean fCompressEmptyElementTags;
- private boolean fConvertEOLCodes;
- private String fEOLCode;
- private boolean fFormatSource;
- private boolean fInsertMissingTags;
- private boolean fInsertRequiredAttrs;
- //private IPreferenceStore fPreferenceStore = null;
- private Preferences fPreferences = null;
- private boolean fQuoteAttrValues;
-
- private int fTagNameCase;
-
- public int getAttrNameCase() {
-
- return fAttrNameCase;
- }
-
- public boolean getCompressEmptyElementTags() {
-
- return fCompressEmptyElementTags;
- }
-
- public boolean getConvertEOLCodes() {
-
- return fConvertEOLCodes;
- }
-
- public String getEOLCode() {
-
- return fEOLCode;
- }
-
- public boolean getFormatSource() {
-
- return fFormatSource;
- }
-
- public boolean getInsertMissingTags() {
-
- return fInsertMissingTags;
- }
-
- public boolean getInsertRequiredAttrs() {
-
- return fInsertRequiredAttrs;
- }
-
- public Preferences getPreferences() {
-
- if (fPreferences == null) {
- fPreferences = SSECorePlugin.getDefault().getPluginPreferences();
- }
- return fPreferences;
- }
-
- public boolean getQuoteAttrValues() {
-
- return fQuoteAttrValues;
- }
-
- public int getTagNameCase() {
-
- return fTagNameCase;
- }
-
- public void setAttrNameCase(int attrNameCase) {
-
- fAttrNameCase = attrNameCase;
- }
-
- public void setCompressEmptyElementTags(boolean compressEmptyElementTags) {
-
- fCompressEmptyElementTags = compressEmptyElementTags;
- }
-
- public void setConvertEOLCodes(boolean convertEOLCodes) {
-
- fConvertEOLCodes = convertEOLCodes;
- }
-
- public void setEOLCode(String EOLCode) {
-
- fEOLCode = EOLCode;
- }
-
- public void setFormatSource(boolean formatSource) {
-
- fFormatSource = formatSource;
- }
-
- public void setInsertMissingTags(boolean insertMissingTags) {
-
- fInsertMissingTags = insertMissingTags;
- }
-
- public void setInsertRequiredAttrs(boolean insertRequiredAttrs) {
-
- fInsertRequiredAttrs = insertRequiredAttrs;
- }
-
- public void setPreferences(Preferences prefs) {
-
- fPreferences = prefs;
- }
-
- public void setQuoteAttrValues(boolean quoteAttrValues) {
-
- fQuoteAttrValues = quoteAttrValues;
- }
-
- public void setTagNameCase(int tagNameCase) {
-
- fTagNameCase = tagNameCase;
- }
-}
diff --git a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/cleanup/StructuredContentCleanupHandler.java b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/cleanup/StructuredContentCleanupHandler.java
deleted file mode 100644
index f55b7d615a..0000000000
--- a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/cleanup/StructuredContentCleanupHandler.java
+++ /dev/null
@@ -1,20 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Jens Lukowski/Innoopract - initial renaming/restructuring
- *
- *******************************************************************************/
-package org.eclipse.wst.sse.core.cleanup;
-
-public interface StructuredContentCleanupHandler {
-
- IStructuredCleanupProcessor getCleanupProcessor(String contentType);
-
- void setCleanupProcessor(IStructuredCleanupProcessor cleanupProcessor, String contentType);
-}
diff --git a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/cleanup/StructuredContentCleanupHandlerImpl.java b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/cleanup/StructuredContentCleanupHandlerImpl.java
deleted file mode 100644
index e9a7f5ea86..0000000000
--- a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/cleanup/StructuredContentCleanupHandlerImpl.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Jens Lukowski/Innoopract - initial renaming/restructuring
- *
- *******************************************************************************/
-package org.eclipse.wst.sse.core.cleanup;
-
-import java.util.HashMap;
-import java.util.Map;
-
-import org.eclipse.jface.text.Assert;
-
-public class StructuredContentCleanupHandlerImpl implements StructuredContentCleanupHandler {
- protected Map fCleanupProcessors;
-
- /**
- * @see com.ibm.sed.partitionCleanup.StructuredContentCleanupHandler#getCleanupProcessor(java.lang.String)
- */
- public IStructuredCleanupProcessor getCleanupProcessor(String contentType) {
- Assert.isNotNull(contentType);
-
- if (fCleanupProcessors == null)
- return null;
-
- return (IStructuredCleanupProcessor) fCleanupProcessors.get(contentType);
- }
-
- /**
- * @see com.ibm.sed.partitionCleanup.StructuredContentCleanupHandler#setCleanupProcessor(com.ibm.sed.partitionCleanup.CleanupProcessor,
- * java.lang.String)
- */
- public void setCleanupProcessor(IStructuredCleanupProcessor cleanupProcessor, String contentType) {
- Assert.isNotNull(contentType);
-
- if (fCleanupProcessors == null)
- fCleanupProcessors = new HashMap();
-
- if (fCleanupProcessors == null)
- fCleanupProcessors.remove(contentType);
- else
- fCleanupProcessors.put(contentType, cleanupProcessor);
- }
-}
diff --git a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/contentmodel/CMDocType.java b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/contentmodel/CMDocType.java
deleted file mode 100644
index 07bd3abc90..0000000000
--- a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/contentmodel/CMDocType.java
+++ /dev/null
@@ -1,21 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Jens Lukowski/Innoopract - initial renaming/restructuring
- *
- *******************************************************************************/
-package org.eclipse.wst.sse.core.contentmodel;
-
-
-public interface CMDocType {
- public final static String CHTML_DOC_TYPE = "CHTML";//$NON-NLS-1$
- public final static String HTML_DOC_TYPE = "HTML";//$NON-NLS-1$
- public final static String JSP11_DOC_TYPE = "JSP11";//$NON-NLS-1$
-
-}
diff --git a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/contentmodel/CMDocumentTracker.java b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/contentmodel/CMDocumentTracker.java
deleted file mode 100644
index 8b862bbdf4..0000000000
--- a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/contentmodel/CMDocumentTracker.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Jens Lukowski/Innoopract - initial renaming/restructuring
- *
- *******************************************************************************/
-package org.eclipse.wst.sse.core.contentmodel;
-
-
-
-import org.eclipse.wst.common.contentmodel.CMDocument;
-import org.eclipse.wst.sse.core.text.IStructuredDocumentRegion;
-
-
-/**
- * Position dependent CMDocument tracker. A tracker matches a
- * IStructuredDocumentRegion with a CMDocument that it enables allowing for
- * position-dependent content models
- */
-public interface CMDocumentTracker {
-
- CMDocument getDocument();
-
- IStructuredDocumentRegion getStructuredDocumentRegion();
-}
-
diff --git a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/contentmodel/CMNodeWrapper.java b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/contentmodel/CMNodeWrapper.java
deleted file mode 100644
index 1e36639601..0000000000
--- a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/contentmodel/CMNodeWrapper.java
+++ /dev/null
@@ -1,21 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Jens Lukowski/Innoopract - initial renaming/restructuring
- *
- *******************************************************************************/
-package org.eclipse.wst.sse.core.contentmodel;
-
-
-
-import org.eclipse.wst.common.contentmodel.CMNode;
-
-public interface CMNodeWrapper extends CMNode {
- CMNode getOriginNode();
-}
diff --git a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/contentmodel/ContentModelAdapter.java b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/contentmodel/ContentModelAdapter.java
deleted file mode 100644
index f8b968bacc..0000000000
--- a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/contentmodel/ContentModelAdapter.java
+++ /dev/null
@@ -1,56 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Jens Lukowski/Innoopract - initial renaming/restructuring
- *
- *******************************************************************************/
-package org.eclipse.wst.sse.core.contentmodel;
-
-
-
-import org.eclipse.wst.common.contentmodel.CMDocument;
-import org.eclipse.wst.common.contentmodel.CMNode;
-
-/**
- * ContentModelAdapter interface
- */
-public interface ContentModelAdapter extends org.eclipse.wst.sse.core.INodeAdapter {
-
- /**
- * getCMDocument method
- *
- * @return CMDocument
- * @param notifer
- * com.ibm.sed.model.INodeNotifier
- *
- * Returns CMDocument associated to the adapting node. For exampl : HTML
- * CMDocument is associated to HTML Document node, DTD CMDocument is
- * associated to DocumentType node, DTD/Schema CMDocument is associated to
- * Element node (sometime with namespace), and taglib CMDocument is
- * associated to taglib directive Element node.
- *
- * INodeNotifier is passed for stateless (singleton) INodeAdapter
- * implementation.
- */
- CMDocument getCMDocument(org.eclipse.wst.sse.core.INodeNotifier notifier);
-
- /**
- * getDeclaration method
- *
- * @return CMNode
- * @param notifer
- * com.ibm.sed.model.INodeNotifier
- *
- * Returns ElementDefinition or AttributeDefinition for the adapting node.
- *
- * INodeNotifier is passed for stateless (singleton) INodeAdapter
- * implementation.
- */
- CMNode getDeclaration(org.eclipse.wst.sse.core.INodeNotifier notifier);
-}
diff --git a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/contentmodel/NullContentModel.java b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/contentmodel/NullContentModel.java
deleted file mode 100644
index 9a72bf507f..0000000000
--- a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/contentmodel/NullContentModel.java
+++ /dev/null
@@ -1,101 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Jens Lukowski/Innoopract - initial renaming/restructuring
- *
- *******************************************************************************/
-package org.eclipse.wst.sse.core.contentmodel;
-
-import java.util.Iterator;
-import java.util.NoSuchElementException;
-
-import org.eclipse.wst.common.contentmodel.CMDocument;
-import org.eclipse.wst.common.contentmodel.CMNamedNodeMap;
-import org.eclipse.wst.common.contentmodel.CMNamespace;
-import org.eclipse.wst.common.contentmodel.CMNode;
-
-
-/**
- * This class can be used to intialize specific variables that need a content
- * model, until the true content model is available. This prevents having to
- * do lots of null checks.
- */
-public class NullContentModel implements CMDocument {
-
- private static class NullCMNamedNodeMap implements CMNamedNodeMap {
- public int getLength() {
- return 0;
- }
-
- public CMNode getNamedItem(String name) {
- return null;
- }
-
- public CMNode item(int index) {
- return null;
- }
-
- public Iterator iterator() {
- return new NullIterator();
- }
-
- }
-
- private static class NullIterator implements Iterator {
- public NullIterator() {
- }
-
- public boolean hasNext() {
- return false;
- }
-
- public Object next() {
- throw new NoSuchElementException();
- }
-
- public void remove() {
- throw new UnsupportedOperationException("can not remove regions via iterator"); //$NON-NLS-1$
-
- }
-
- }
-
- public NullContentModel() {
- super();
- }
-
- public CMNamedNodeMap getElements() {
- return new NullCMNamedNodeMap();
- }
-
- public CMNamedNodeMap getEntities() {
- return new NullCMNamedNodeMap();
- }
-
- public CMNamespace getNamespace() {
- return null;
- }
-
- public String getNodeName() {
- return null;
- }
-
- public int getNodeType() {
- return 0;
- }
-
- public Object getProperty(String propertyName) {
- return null;
- }
-
- public boolean supports(String propertyName) {
- return false;
- }
-
-}
diff --git a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/contenttype/ContentTypeIdForCSS.java b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/contenttype/ContentTypeIdForCSS.java
deleted file mode 100644
index 03e02cbfd2..0000000000
--- a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/contenttype/ContentTypeIdForCSS.java
+++ /dev/null
@@ -1,29 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *
- *******************************************************************************/
-
-package org.eclipse.wst.sse.core.contenttype;
-
-/**
- * This class, with its one field, is a convience to provide compile-time
- * safety when refering to a contentType ID. The value of the contenttype id
- * field must match what is specified in plugin.xml file.
- */
-
-public class ContentTypeIdForCSS {
- /**
- * The value of the contenttype id field must match what is specified in
- * plugin.xml file. Note: this value is intentially not declared as final,
- * so it will not be inlined.
- */
- public static String ContentTypeID_CSS = "org.eclipse.wst.css.core.csssource"; //$NON-NLS-1$
-
-}
diff --git a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/document/AbstractDocumentLoader.java b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/document/AbstractDocumentLoader.java
deleted file mode 100644
index 87997df0c8..0000000000
--- a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/document/AbstractDocumentLoader.java
+++ /dev/null
@@ -1,396 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Jens Lukowski/Innoopract - initial renaming/restructuring
- *
- *******************************************************************************/
-package org.eclipse.wst.sse.core.document;
-
-import java.io.BufferedReader;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.Reader;
-import java.io.UnsupportedEncodingException;
-import java.nio.charset.MalformedInputException;
-import java.nio.charset.UnmappableCharacterException;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.jface.text.Document;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.IDocumentExtension3;
-import org.eclipse.jface.text.IDocumentPartitioner;
-import org.eclipse.wst.common.encoding.CodedIO;
-import org.eclipse.wst.common.encoding.CodedReaderCreator;
-import org.eclipse.wst.common.encoding.ContentTypeEncodingPreferences;
-import org.eclipse.wst.common.encoding.EncodingMemento;
-import org.eclipse.wst.common.encoding.EncodingRule;
-import org.eclipse.wst.common.encoding.exceptions.MalformedInputExceptionWithDetail;
-import org.eclipse.wst.sse.core.internal.document.NullStructuredDocumentPartitioner;
-import org.eclipse.wst.sse.core.internal.document.TextUtilities;
-import org.eclipse.wst.sse.core.text.IStructuredDocument;
-
-
-
-/**
- * This class reads a file and creates an Structured Model.
- */
-public abstract class AbstractDocumentLoader implements IDocumentLoader {
-
- private CodedReaderCreator fCodedReaderCreator;
- protected IDocumentCharsetDetector fDocumentEncodingDetector;
- //private boolean fPropertiesObtained;
-
- protected EncodingMemento fEncodingMemento;
- protected Reader fFullPreparedReader;
-
- /**
- * AbstractLoader constructor also initializes encoding converter/mapper
- */
- public AbstractDocumentLoader() {
- super();
- }
-
- protected final StringBuffer convertLineDelimiters(StringBuffer allTextBuffer, String lineDelimiterToUse) {
- // TODO: avoid use of String instance
- String allText = allTextBuffer.toString();
- IDocument tempDoc = new Document(allText);
- if (lineDelimiterToUse == null)
- lineDelimiterToUse = System.getProperty("line.separator"); //$NON-NLS-1$
- StringBuffer newText = new StringBuffer();
- int lineCount = tempDoc.getNumberOfLines();
- for (int i = 0; i < lineCount; i++) {
- try {
- org.eclipse.jface.text.IRegion lineInfo = tempDoc.getLineInformation(i);
- int lineStartOffset = lineInfo.getOffset();
- int lineLength = lineInfo.getLength();
- int lineEndOffset = lineStartOffset + lineLength;
- newText.append(allText.substring(lineStartOffset, lineEndOffset));
- if ((i < lineCount - 1) && (tempDoc.getLineDelimiter(i) != null))
- newText.append(lineDelimiterToUse);
- } catch (org.eclipse.jface.text.BadLocationException exception) {
- // should fix up to either throw nothing, or the right thing,
- // but
- // in the course of refactoring, this was easiest "quick fix".
- throw new RuntimeException(exception);
- }
- }
- return newText;
- }
-
- /**
- * This method must return a new instance of IEncodedDocument, that has
- * been initialized with appropriate parser. For many loaders, the
- * (default) parser used is known for any input. For others, the correct
- * parser (and its initialization) is normally dependent on the content of
- * the file. This no-argument method should assume "empty input" and would
- * therefore return the default parser for the default contentType.
- */
- public IEncodedDocument createNewStructuredDocument() {
- IEncodedDocument structuredDocument = newEncodedDocument();
- // Make sure every structuredDocument has an Encoding Memento,
- // which is the default one for "empty" structuredDocuments
- String charset = ContentTypeEncodingPreferences.useDefaultNameRules(getDocumentEncodingDetector());
- String specDefaultCharset = getDocumentEncodingDetector().getSpecDefaultEncoding();
- structuredDocument.setEncodingMemento(CodedIO.createEncodingMemento(charset, EncodingMemento.DEFAULTS_ASSUMED_FOR_EMPTY_INPUT, specDefaultCharset));
-
- IDocumentPartitioner defaultPartitioner = getDefaultDocumentPartitioner();
- if (structuredDocument instanceof IDocumentExtension3) {
- ((IDocumentExtension3) structuredDocument).setDocumentPartitioner(IStructuredDocument.DEFAULT_STRUCTURED_PARTITIONING, defaultPartitioner);
- }
- else {
- structuredDocument.setDocumentPartitioner(defaultPartitioner);
- }
- defaultPartitioner.connect(structuredDocument);
-
- return structuredDocument;
- }
-
- /**
- * This abstract version should handle most cases, but won't if
- * contentType is sensitive to encoding, and/or embedded types
- */
- public IEncodedDocument createNewStructuredDocument(IFile iFile) throws IOException, CoreException {
- IEncodedDocument structuredDocument = createNewStructuredDocument();
- try {
-
- CodedReaderCreator creator = getCodedReaderCreator();
- creator.set(iFile);
- fEncodingMemento = creator.getEncodingMemento();
- structuredDocument.setEncodingMemento(fEncodingMemento);
- fFullPreparedReader = getCodedReaderCreator().getCodedReader();
-
- setDocumentContentsFromReader(structuredDocument, fFullPreparedReader);
- } finally {
- if (fFullPreparedReader != null) {
- fFullPreparedReader.close();
- }
- }
- return structuredDocument;
- }
-
- public IEncodedDocument createNewStructuredDocument(Reader reader) throws UnsupportedEncodingException, IOException {
- IEncodedDocument structuredDocument = createNewStructuredDocument();
- StringBuffer allText = readInputStream(fFullPreparedReader);
- structuredDocument.set(allText.toString());
- return structuredDocument;
- }
-
- public IEncodedDocument createNewStructuredDocument(String filename, InputStream inputStream) throws UnsupportedEncodingException, IOException {
- return createNewStructuredDocument(filename, inputStream, EncodingRule.CONTENT_BASED);
- }
-
- public IEncodedDocument createNewStructuredDocument(String filename, InputStream inputStream, EncodingRule encodingRule) throws UnsupportedEncodingException, IOException {
- if (filename == null && inputStream == null) {
- throw new IllegalArgumentException("can not have both null filename and inputstream"); //$NON-NLS-1$
- }
- IEncodedDocument structuredDocument = createNewStructuredDocument();
- CodedReaderCreator codedReaderCreator = getCodedReaderCreator();
- try {
- codedReaderCreator.set(filename, inputStream);
- codedReaderCreator.setEncodingRule(encodingRule);
- fEncodingMemento = codedReaderCreator.getEncodingMemento();
- fFullPreparedReader = codedReaderCreator.getCodedReader();
- structuredDocument.setEncodingMemento(fEncodingMemento);
- setDocumentContentsFromReader(structuredDocument, fFullPreparedReader);
- } catch (CoreException e) {
- // impossible in this context
- throw new Error(e);
- } finally {
- if (fFullPreparedReader != null) {
- fFullPreparedReader.close();
- }
- }
-
- return structuredDocument;
- }
-
- private int getCharPostionOfFailure(BufferedReader inputStream) {
- int charPosition = 1;
- int charRead = -1;
- boolean errorFound = false;
- do {
- try {
- charRead = inputStream.read();
- charPosition++;
- } catch (IOException e) {
- // this is expected, since we're expecting failure,
- // so no need to do anything.
- errorFound = true;
- break;
- }
- } while (!(charRead == -1 || errorFound));
-
- if (errorFound)
- // dmw, blindly modified to +1 to get unit tests to work, moving
- // from Java 1.3, to 1.4
- // not sure how/why this behavior would have changed. (Its as if
- // 'read' is reporting error
- // one character early).
- return charPosition + 1;
- else
- return -1;
- }
-
- /**
- * @return Returns the codedReaderCreator.
- */
- protected CodedReaderCreator getCodedReaderCreator() {
- if (fCodedReaderCreator == null) {
- fCodedReaderCreator = new CodedReaderCreator();
- }
- return fCodedReaderCreator;
- }
-
- /**
- * Method getDefaultDocumentPartitioner.
- *
- * @return IDocumentPartitioner
- */
- public IDocumentPartitioner getDefaultDocumentPartitioner() {
- // be default, we'll provide XML (though could be NOOP?
- // 7/2003 .... changed during re-org ... to be Null instead of XML,
- // so there would be no minor dependancies from higher plugins.
- return new NullStructuredDocumentPartitioner();
- }
-
- /**
- * Returns the encodingMemento.
- *
- * @return EncodingMemento
- */
- public EncodingMemento getEncodingMemento() {
- if (fEncodingMemento == null) {
- throw new IllegalStateException("Program Error: encodingMemento was accessed before it was set"); //$NON-NLS-1$
- }
- return fEncodingMemento;
- }
-
- /**
- * @return Returns the fullPreparedReader.
- */
- protected Reader getFullPreparedReader() throws UnsupportedEncodingException, CoreException, IOException {
- if (fFullPreparedReader == null) {
- fFullPreparedReader = getCodedReaderCreator().getCodedReader();
- }
- return fFullPreparedReader;
- }
-
- /**
- * If subclass doesn't implement, return null
- */
- protected String getPreferredNewLineDelimiter() {
- return null;
- }
-
- /**
- * A utility method, but depends on subclasses to impliment the preferred
- * end of line for a particular content type. Note: subclasses should not
- * re-implement this method (there's no reason to, even though its part of
- * interface). This method not only converts end-of-line characters, if
- * needed, but sets the correct end-of-line delimiter in
- * structuredDocument. Minor note: can't use this exact method in dumpers,
- * since the decision to change or not is a little different, and since
- * there we have to change text of structuredDocument if found to need
- * conversion. (Where as for loading, we assume we haven't yet set text in
- * structuredDocument, but will be done by other method just a tiny biy
- * later). Needs to be public to handle interface. It is in the interface
- * just so ModelManagerImpl can use it in a special circumstance.
- */
- public StringBuffer handleLineDelimiter(StringBuffer originalString, IEncodedDocument theFlatModel) {
- // TODO: need to handle line delimiters so Marker Positions are
- // updated
- StringBuffer convertedText = null;
- // based on text, make a guess on what's being used as
- // line delimiter
- String probableLineDelimiter = TextUtilities.determineLineDelimiter(originalString, theFlatModel.getLegalLineDelimiters(), System.getProperty("line.separator")); //$NON-NLS-1$
- String preferredLineDelimiter = getPreferredNewLineDelimiter();
- if (preferredLineDelimiter == null) {
- // when preferredLineDelimiter is null, it means "leave alone"
- // so no conversion needed.
- // set here, only if null (should already be set, but if not,
- // we'll set so any subsequent editing inserts what we're
- // assuming)
- if (!theFlatModel.getLineDelimiter().equals(probableLineDelimiter)) {
- theFlatModel.setLineDelimiter(probableLineDelimiter);
- }
- convertedText = originalString;
- } else {
- if (!preferredLineDelimiter.equals(probableLineDelimiter)) {
- // technically, wouldn't have to convert line delimiters
- // here at beginning, but when we save, if the preferred
- // line delimter is "leave alone" then we do leave alone,
- // so best to be right from beginning.
- convertedText = convertLineDelimiters(originalString, preferredLineDelimiter);
- theFlatModel.setLineDelimiter(preferredLineDelimiter);
- } else {
- // they are already the same, no conversion needed
- theFlatModel.setLineDelimiter(preferredLineDelimiter);
- convertedText = originalString;
- }
- }
- return convertedText;
- }
-
- protected abstract IEncodedDocument newEncodedDocument();
-
- /**
- * Very mechanical method, just to read the characters, once the reader is
- * correctly created. Can throw MalFormedInputException.
- */
- private StringBuffer readInputStream(Reader reader) throws IOException {
-
- int fBlocksRead = 0;
- StringBuffer buffer = new StringBuffer();
- int numRead = 0;
- try {
- char tBuff[] = new char[CodedIO.MAX_BUF_SIZE];
- while (numRead != -1) {
- numRead = reader.read(tBuff, 0, tBuff.length);
- if (numRead > 0) {
- buffer.append(tBuff, 0, numRead);
- fBlocksRead++;
- }
- }
- } catch (MalformedInputException e) {
- throw new MalformedInputExceptionWithDetail(fEncodingMemento.getJavaCharsetName(), fBlocksRead * CodedIO.MAX_BUF_SIZE + numRead + e.getInputLength());
- } catch (UnmappableCharacterException e) {
- throw new MalformedInputExceptionWithDetail(fEncodingMemento.getJavaCharsetName(), fBlocksRead * CodedIO.MAX_BUF_SIZE + numRead + e.getInputLength());
-
- }
- return buffer;
- }
-
- public void reload(IEncodedDocument encodedDocument, Reader inputStreamReader) throws IOException {
- if (inputStreamReader == null) {
- throw new IllegalArgumentException("stream reader can not be null"); //$NON-NLS-1$
- }
- int READ_BUFFER_SIZE = 8192;
- int MAX_BUFFERED_SIZE_FOR_RESET_MARK = 200000;
- // temp .... eventually we'lll only read as needed
- BufferedReader bufferedReader = new BufferedReader(inputStreamReader, MAX_BUFFERED_SIZE_FOR_RESET_MARK);
- bufferedReader.mark(MAX_BUFFERED_SIZE_FOR_RESET_MARK);
- StringBuffer buffer = new StringBuffer();
- try {
- int numRead = 0;
- char tBuff[] = new char[READ_BUFFER_SIZE];
- while ((numRead = bufferedReader.read(tBuff, 0, tBuff.length)) != -1) {
- buffer.append(tBuff, 0, numRead);
- }
- // remember -- we didn't open stream ... so we don't close it
- } catch (MalformedInputException e) {
-// int pos = e.getInputLength();
- EncodingMemento localEncodingMemento = getEncodingMemento();
- boolean couldReset = true;
- String encodingNameInError = localEncodingMemento.getJavaCharsetName();
- if (encodingNameInError == null) {
- encodingNameInError = localEncodingMemento.getDetectedCharsetName();
- }
- try {
- bufferedReader.reset();
- } catch (IOException resetException) {
- // the only errro that can occur during reset is an
- // IOException
- // due to already being past the rest mark. In that case, we
- // throw more generic message
- couldReset = false;
- }
- // -1 can be used by UI layer as a code that "position could not
- // be
- // determined"
- int charPostion = -1;
- if (couldReset) {
-
- charPostion = getCharPostionOfFailure(bufferedReader);
- //getCharPostionOfFailure(new InputStreamReader(inStream,
- // javaEncodingNameInError));
- }
- // all of that just to throw more accurate error
- // note: we do the conversion to ianaName, instead of using the
- // local
- // variable,
- // because this is ultimately only for the user error message
- // (that
- // is,
- // the error occurred
- // in context of javaEncodingName no matter what ianaEncodingName
- // is
- throw new MalformedInputExceptionWithDetail(encodingNameInError, CodedIO.getAppropriateJavaCharset(encodingNameInError), charPostion, !couldReset, MAX_BUFFERED_SIZE_FOR_RESET_MARK);
- }
- StringBuffer stringbuffer = buffer;
- encodedDocument.set(stringbuffer.toString());
-
- }
-
- protected void setDocumentContentsFromReader(IEncodedDocument structuredDocument, Reader reader) throws IOException {
-
- StringBuffer allText = readInputStream(reader);
- structuredDocument.set(allText.toString());
- }
-}
diff --git a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/document/DocumentReader.java b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/document/DocumentReader.java
deleted file mode 100644
index 75071b505f..0000000000
--- a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/document/DocumentReader.java
+++ /dev/null
@@ -1,125 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Jens Lukowski/Innoopract - initial renaming/restructuring
- *
- *******************************************************************************/
-package org.eclipse.wst.sse.core.document;
-
-import java.io.IOException;
-import java.io.Reader;
-
-import org.eclipse.jface.text.IDocument;
-
-/**
- * A java.io.Reader that can operate off of an IDocument.
- */
-public class DocumentReader extends Reader {
- private IDocument fDocument = null;
- private int mark = 0;
- private int position = 0;
-
- public DocumentReader() {
- super();
- }
-
- public DocumentReader(IDocument document) {
- this(document, 0);
- }
-
- public DocumentReader(IDocument document, int initialPosition) {
- super();
- fDocument = document;
- position = initialPosition;
- }
-
- public void close() throws IOException {
- // do nothing
- }
-
- /**
- * @return
- */
- public IDocument getDocument() {
- return fDocument;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.io.Reader#mark(int)
- */
- public void mark(int readAheadLimit) throws IOException {
- mark = position;
- }
-
- public boolean markSupported() {
- return true;
- }
-
- public int read(char[] cbuf, int off, int len) throws IOException {
- char[] readChars = null;
- try {
- if (position >= fDocument.getLength())
- return -1;
- // the IDocument is likely using a GapTextStore, so we can't
- // retrieve a char[] directly
- if (position + len > fDocument.getLength())
- readChars = fDocument.get(position, fDocument.getLength() - position).toCharArray();
- else
- readChars = fDocument.get(position, len).toCharArray();
- System.arraycopy(readChars, 0, cbuf, off, readChars.length);
- // System.out.println("" + position + ":" + readChars.length + " "
- // + StringUtils.escape(new String(readChars)));
- position += readChars.length;
- return readChars.length;
- } catch (Exception e) {
- throw new IOException("Exception while reading from IDocument: " + e); //$NON-NLS-1$
- }
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.io.Reader#reset()
- */
- public void reset() throws IOException {
- position = mark;
- }
-
- public void reset(IDocument document, int initialPosition) {
- fDocument = document;
- position = initialPosition;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.io.Reader#reset()
- */
- public void reset(int pos) throws IOException {
- position = pos;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.io.Reader#skip(long)
- */
- public long skip(long n) throws IOException {
- long skipped = n;
- if (position + n > fDocument.getLength()) {
- skipped = fDocument.getLength() - position;
- position = fDocument.getLength();
- } else {
- position += n;
- }
- return skipped;
- }
-}
diff --git a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/document/IDocumentCharsetDetector.java b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/document/IDocumentCharsetDetector.java
deleted file mode 100644
index fcd1ce6ef5..0000000000
--- a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/document/IDocumentCharsetDetector.java
+++ /dev/null
@@ -1,22 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Jens Lukowski/Innoopract - initial renaming/restructuring
- *
- *******************************************************************************/
-package org.eclipse.wst.sse.core.document;
-
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.wst.common.encoding.IResourceCharsetDetector;
-
-
-
-public interface IDocumentCharsetDetector extends IResourceCharsetDetector {
- void set(IDocument document);
-}
diff --git a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/document/IDocumentLoader.java b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/document/IDocumentLoader.java
deleted file mode 100644
index 3d73a04cc4..0000000000
--- a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/document/IDocumentLoader.java
+++ /dev/null
@@ -1,72 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Jens Lukowski/Innoopract - initial renaming/restructuring
- *
- *******************************************************************************/
-package org.eclipse.wst.sse.core.document;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.Reader;
-import java.io.UnsupportedEncodingException;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.jface.text.IDocumentPartitioner;
-import org.eclipse.wst.common.encoding.EncodingRule;
-
-
-public interface IDocumentLoader {
-
- IEncodedDocument createNewStructuredDocument();
-
- /**
- * This API is like createNewStructuredDocument, except it should populate
- * the structuredDocument with the contents of IFile. Also, those
- * StructuredDocuments which are sensitive to the input (that is, the
- * parser or parser initialization my require the input) should
- * additionally initialize the parser, etc., appropriate to the input.
- *
- * As always, the appropriate decoding should be used.
- */
- IEncodedDocument createNewStructuredDocument(IFile iFile) throws java.io.IOException, CoreException;
-
- IEncodedDocument createNewStructuredDocument(Reader reader) throws UnsupportedEncodingException, IOException;
-
- /**
- * This method must return a new instance of IEncodedDocument, that has
- * been initialized with appropriate parser. For many loaders, the
- * (default) parser used is known for any input. For others, the correct
- * parser (and its initialization) is normally dependent on the content of
- * the file. This no-argument method should assume "empty input" and would
- * therefore return the default parser for the default contentType.
- */
- IEncodedDocument createNewStructuredDocument(String filename, InputStream istream) throws java.io.IOException;
-
- IEncodedDocument createNewStructuredDocument(String filename, InputStream istream, EncodingRule encodingRule) throws java.io.IOException;
-
- IDocumentPartitioner getDefaultDocumentPartitioner();
-
- IDocumentCharsetDetector getDocumentEncodingDetector();
-
- /**
- * A utility method, but depends on subclasses to impliment the preferred
- * end of line for a particular content type. Note: subclasses should not
- * re-implement this method (there's no reason to, even though its part of
- * interface). This method not only converts end-of-line characters, if
- * needed, but sets the correct end-of-line delimiter in
- * structuredDocument. The returned value is either the original string,
- * if no conversion is needed, or a new string with end-of-lines
- * converted.
- */
- StringBuffer handleLineDelimiter(StringBuffer originalString, IEncodedDocument theStructuredDocument);
-
- void reload(IEncodedDocument document, Reader reader) throws IOException;
-}
diff --git a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/document/IDocumentLoaderForFileBuffers.java b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/document/IDocumentLoaderForFileBuffers.java
deleted file mode 100644
index 1eff6e2999..0000000000
--- a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/document/IDocumentLoaderForFileBuffers.java
+++ /dev/null
@@ -1,27 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Jens Lukowski/Innoopract - initial renaming/restructuring
- *
- *******************************************************************************/
-package org.eclipse.wst.sse.core.document;
-
-import java.io.IOException;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IProgressMonitor;
-
-public interface IDocumentLoaderForFileBuffers extends IDocumentLoader {
-
- IEncodedDocument createNewStructuredDocument(IFile iFile, IProgressMonitor monitor) throws IOException, CoreException;
-
-
- void release(IFile iFile, IProgressMonitor monitor) throws CoreException;
-}
diff --git a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/document/IEncodedDocument.java b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/document/IEncodedDocument.java
deleted file mode 100644
index 95da1bbbb1..0000000000
--- a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/document/IEncodedDocument.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Jens Lukowski/Innoopract - initial renaming/restructuring
- *
- *******************************************************************************/
-package org.eclipse.wst.sse.core.document;
-
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.wst.common.encoding.EncodingMemento;
-
-
-
-
-public interface IEncodedDocument extends IDocument {
-
- EncodingMemento getEncodingMemento();
-
- String getLineDelimiter();
-
- void setEncodingMemento(EncodingMemento localEncodingMemento);
-
- void setLineDelimiter(String probableLineDelimiter);
-
-}
diff --git a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/document/IExecutionDelegate.java b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/document/IExecutionDelegate.java
deleted file mode 100644
index c18fe9b466..0000000000
--- a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/document/IExecutionDelegate.java
+++ /dev/null
@@ -1,20 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Jens Lukowski/Innoopract - initial renaming/restructuring
- *
- *******************************************************************************/
-
-package org.eclipse.wst.sse.core.document;
-
-
-public interface IExecutionDelegate {
-
- void execute(Runnable runnable);
-}
diff --git a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/document/ILockable.java b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/document/ILockable.java
deleted file mode 100644
index 01957b583a..0000000000
--- a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/document/ILockable.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Jens Lukowski/Innoopract - initial renaming/restructuring
- *
- *******************************************************************************/
-
-package org.eclipse.wst.sse.core.document;
-
-import org.eclipse.core.runtime.jobs.ILock;
-
-/**
- *
- * Not API: not to be used or implemented by clients. This is a special
- * purpose interface to help guard some threading issues betweeen model and
- * document. Will be changed soon.
- *
- */
-
-public interface ILockable {
-
- ILock getLockObject();
-
-}
diff --git a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/document/StructuredDocumentFactory.java b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/document/StructuredDocumentFactory.java
deleted file mode 100644
index 437512e826..0000000000
--- a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/document/StructuredDocumentFactory.java
+++ /dev/null
@@ -1,83 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Jens Lukowski/Innoopract - initial renaming/restructuring
- *
- *******************************************************************************/
-package org.eclipse.wst.sse.core.document;
-
-import org.eclipse.wst.sse.core.internal.text.BasicStructuredDocument;
-import org.eclipse.wst.sse.core.internal.text.JobSafeStructuredDocument;
-import org.eclipse.wst.sse.core.parser.RegionParser;
-import org.eclipse.wst.sse.core.text.IStructuredDocument;
-
-
-/**
- * At the moment, this is primarily intended as a convenience to help switch
- * between various types of threading models in the document, all in a central
- * piece of code.
- */
-public class StructuredDocumentFactory {
- public static final int WRITE_SYNCHRONIZED = 3;
- public static final int DEFAULT = WRITE_SYNCHRONIZED;
- public static final int UNSYNCHRONIZED = 1;
-
- public static IStructuredDocument getNewStructuredDocumentInstance() {
- // be default, use thread safe one
- return getNewStructuredDocumentInstance(DEFAULT);
- }
-
- public static IStructuredDocument getNewStructuredDocumentInstance(int type) {
- IStructuredDocument result = null;
- switch (type) {
- case UNSYNCHRONIZED :
- result = new BasicStructuredDocument();
- break;
-
- case WRITE_SYNCHRONIZED :
- result = new JobSafeStructuredDocument();
- break;
-
- default :
- throw new IllegalArgumentException("request document type was not known");
-
- }
- return result;
- }
-
- public static IStructuredDocument getNewStructuredDocumentInstance(int type, RegionParser parser) {
- IStructuredDocument result = null;
- switch (type) {
- case UNSYNCHRONIZED :
- result = new BasicStructuredDocument(parser);
- break;
- case WRITE_SYNCHRONIZED :
- result = new JobSafeStructuredDocument(parser);
- break;
-
- default :
- throw new IllegalArgumentException("request document type was not known");
-
- }
- return result;
- }
-
- public static IStructuredDocument getNewStructuredDocumentInstance(RegionParser parser) {
- // be default, use thread safe one
- return getNewStructuredDocumentInstance(DEFAULT, parser);
- }
-
- /**
- * Not intended to be instantiated
- *
- */
- protected StructuredDocumentFactory() {
- super();
- }
-}
diff --git a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/document/StructuredDocumentLoader.java b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/document/StructuredDocumentLoader.java
deleted file mode 100644
index 25e5a73a06..0000000000
--- a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/document/StructuredDocumentLoader.java
+++ /dev/null
@@ -1,141 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Jens Lukowski/Innoopract - initial renaming/restructuring
- *
- *******************************************************************************/
-
-package org.eclipse.wst.sse.core.document;
-
-import java.io.File;
-import java.io.IOException;
-import java.io.Reader;
-import java.nio.charset.MalformedInputException;
-
-import org.eclipse.core.filebuffers.FileBuffers;
-import org.eclipse.core.filebuffers.ITextFileBuffer;
-import org.eclipse.core.filebuffers.ITextFileBufferManager;
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.core.runtime.QualifiedName;
-import org.eclipse.core.runtime.content.IContentDescription;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.wst.common.encoding.CodedIO;
-import org.eclipse.wst.common.encoding.IContentDescriptionExtended;
-import org.eclipse.wst.common.encoding.exceptions.MalformedInputExceptionWithDetail;
-
-
-public class StructuredDocumentLoader {
-
- private ITextFileBufferManager fBufferManager;
-
- /**
- * @see org.eclipse.wst.sse.core.document.IDocumentLoader#createNewStructuredDocument(org.eclipse.core.resources.IFile)
- * @deprecated - use form with progress monitor
- */
- public IEncodedDocument createNewStructuredDocument(IFile iFile) throws IOException, CoreException {
- return createNewStructuredDocument(iFile, null);
- }
-
- public IEncodedDocument createNewStructuredDocument(IFile iFile, IProgressMonitor monitor) throws IOException, CoreException {
- IDocument document = null;
- IPath locationPath = iFile.getFullPath();
-
- if (iFile.exists()) {
-
- getBufferManager().connect(locationPath, monitor);
- ITextFileBuffer buffer = getBufferManager().getTextFileBuffer(locationPath);
- document = buffer.getDocument();
- } else {
- document = getBufferManager().createEmptyDocument(locationPath);
- }
-
- return (IEncodedDocument) document;
- }
-
- public IEncodedDocument createNewStructuredDocument(IPath locationPath, IProgressMonitor monitor) throws IOException, CoreException {
- IDocument document = null;
- File file = null;
- file = FileBuffers.getSystemFileAtLocation(locationPath);
- if (file.exists()) {
- getBufferManager().connect(locationPath, monitor);
- ITextFileBuffer buffer = getBufferManager().getTextFileBuffer(locationPath);
- document = buffer.getDocument();
- } else {
- document = getBufferManager().createEmptyDocument(locationPath);
- }
- return (IEncodedDocument) document;
- }
-
- /**
- * @return
- */
- protected ITextFileBufferManager getBufferManager() {
- if (fBufferManager == null) {
- fBufferManager = FileBuffers.getTextFileBufferManager();
- }
- return fBufferManager;
- }
-
- private String getCharset(Reader reader) throws IOException {
- String result = null;
- IContentDescription description = Platform.getContentTypeManager().getDescriptionFor(reader, null, new QualifiedName[]{IContentDescription.CHARSET, IContentDescriptionExtended.DETECTED_CHARSET});
- String javaCharset = (String) description.getProperty(IContentDescription.CHARSET);
- String detectedCharset = (String) description.getProperty(IContentDescriptionExtended.DETECTED_CHARSET);
- if (javaCharset != null) {
- result = javaCharset;
- } else {
- result = detectedCharset;
- }
- return result;
- }
-
- /**
- * Very mechanical method, just to read the characters, once the reader is
- * correctly created. Can throw MalFormedInputException.
- */
- protected StringBuffer readInputStream(Reader reader) throws IOException {
-
- int fBlocksRead = 0;
- StringBuffer buffer = new StringBuffer();
- int numRead = 0;
- try {
- char tBuff[] = new char[CodedIO.MAX_BUF_SIZE];
- while ((numRead = reader.read(tBuff, 0, tBuff.length)) != -1) {
- buffer.append(tBuff, 0, numRead);
- fBlocksRead++;
- }
- } catch (MalformedInputException e) {
- String charset = getCharset(reader);
- throw new MalformedInputExceptionWithDetail(charset, fBlocksRead * CodedIO.MAX_BUF_SIZE + e.getInputLength());
- }
- return buffer;
- }
-
- public void release(IFile iFile, IProgressMonitor monitor) throws CoreException {
- IPath locationPath = iFile.getFullPath();
- getBufferManager().disconnect(locationPath, monitor);
-
- }
-
- public void reload(IEncodedDocument document, Reader reader) throws IOException {
- setDocumentContentsFromReader(document, reader);
-
- }
-
- protected void setDocumentContentsFromReader(IEncodedDocument structuredDocument, Reader reader) throws IOException {
-
- StringBuffer allText = readInputStream(reader);
- structuredDocument.set(allText.toString());
- }
-
-}
diff --git a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/events/AboutToBeChangeEvent.java b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/events/AboutToBeChangeEvent.java
deleted file mode 100644
index ad41aa5f0b..0000000000
--- a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/events/AboutToBeChangeEvent.java
+++ /dev/null
@@ -1,29 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Jens Lukowski/Innoopract - initial renaming/restructuring
- *
- *******************************************************************************/
-package org.eclipse.wst.sse.core.events;
-
-import org.eclipse.wst.sse.core.text.IStructuredDocument;
-
-/**
- * This event is send to "StructuredDocumentAboutToChange listners". Its
- * perfectly analagous to the jface DocumentEvent and is provided simply to
- * allow clients to take a pure model point of view, instead of using the
- * document event.
- */
-public class AboutToBeChangeEvent extends StructuredDocumentEvent {
-
-
- public AboutToBeChangeEvent(IStructuredDocument source, Object originalSource, String changes, int offset, int lengthToReplace) {
- super(source, originalSource, changes, offset, lengthToReplace);
- }
-}
diff --git a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/events/IModelAboutToBeChangedListener.java b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/events/IModelAboutToBeChangedListener.java
deleted file mode 100644
index 8306e4edef..0000000000
--- a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/events/IModelAboutToBeChangedListener.java
+++ /dev/null
@@ -1,26 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Jens Lukowski/Innoopract - initial renaming/restructuring
- *
- *******************************************************************************/
-package org.eclipse.wst.sse.core.events;
-
-
-
-/**
- * Clients can implement this interface, and register with the
- * structuredDocument using addAboutToBeChangedListner to be notified that the
- * structuredDocument is about to be changed, but hasn't been changed at the
- * time this event is fired.
- */
-public interface IModelAboutToBeChangedListener {
-
- void modelAboutToBeChanged(AboutToBeChangeEvent structuredDocumentEvent);
-}
diff --git a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/events/IStructuredDocumentListener.java b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/events/IStructuredDocumentListener.java
deleted file mode 100644
index e1d9a5cb6b..0000000000
--- a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/events/IStructuredDocumentListener.java
+++ /dev/null
@@ -1,28 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Jens Lukowski/Innoopract - initial renaming/restructuring
- *
- *******************************************************************************/
-package org.eclipse.wst.sse.core.events;
-
-
-
-public interface IStructuredDocumentListener {
-
- public void newModel(NewDocumentEvent structuredDocumentEvent);
-
- public void noChange(NoChangeEvent structuredDocumentEvent);
-
- public void nodesReplaced(StructuredDocumentRegionsReplacedEvent structuredDocumentEvent);
-
- public void regionChanged(RegionChangedEvent structuredDocumentEvent);
-
- public void regionsReplaced(RegionsReplacedEvent structuredDocumentEvent);
-}
diff --git a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/events/NewDocumentContentEvent.java b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/events/NewDocumentContentEvent.java
deleted file mode 100644
index 8500b85ea4..0000000000
--- a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/events/NewDocumentContentEvent.java
+++ /dev/null
@@ -1,29 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Jens Lukowski/Innoopract - initial renaming/restructuring
- *
- *******************************************************************************/
-package org.eclipse.wst.sse.core.events;
-
-import org.eclipse.wst.sse.core.text.IStructuredDocument;
-
-/**
- * The NewModelEvent is fired when an instance of a IStructuredDocument sets
- * or replaces all of its text. So, in the case of replacement, its a new
- * model, conceptually and practically, even though it is technically the same
- * instance of the IStructuredDocument.
- */
-public class NewDocumentContentEvent extends NewDocumentEvent {
- public NewDocumentContentEvent(IStructuredDocument source, Object originalSource) {
- super(source, originalSource);
- }
-
-
-}
diff --git a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/events/NewDocumentEvent.java b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/events/NewDocumentEvent.java
deleted file mode 100644
index 25dfd03417..0000000000
--- a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/events/NewDocumentEvent.java
+++ /dev/null
@@ -1,81 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Jens Lukowski/Innoopract - initial renaming/restructuring
- *
- *******************************************************************************/
-package org.eclipse.wst.sse.core.events;
-
-import org.eclipse.wst.sse.core.text.IStructuredDocument;
-
-
-public class NewDocumentEvent extends NewModelEvent {
-
- /**
- * @param source
- * @param originalSource
- */
- public NewDocumentEvent(IStructuredDocument source, Object originalSource) {
- super(source, originalSource);
- }
-
- /**
- * This doesn't mean quite the same thing as the IStructuredDocument
- * Events in the super class.
- */
- public int getLength() {
- return fLength;
- }
-
- /**
- * This doesn't mean quite the same thing as the IStructuredDocument
- * Events in the super class. It always will return zero.
- */
- public int getOffset() {
- return 0;
- }
-
- /**
- * This doesn't mean quite the same thing as the IStructuredDocument
- * Events in the super class. All the text of the new model is returned.
- *
- * @deprecated - use getText()
- */
- public String getOriginalChanges() {
- String results = null;
- results = getStructuredDocument().getText();
- return results;
- }
-
- /**
- * This doesn't mean quite the same thing as the IStructuredDocument
- * Events in the super class. Since we have, basically no knowledge of
- * what we are replacing ... so we'll return zero.
- *
- * @deprecated
- */
- public int getOriginalLength() {
- return fLength;
- }
-
- /**
- * This doesn't mean quite the same thing as the IStructuredDocument
- * Events in the super class. It always will return zero.
- *
- * @deprecated
- */
- public int getOriginalStart() {
- return 0;
- }
-
- public String getText() {
- String results = getStructuredDocument().getText();
- return results;
- }
-}
diff --git a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/events/NewModelEvent.java b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/events/NewModelEvent.java
deleted file mode 100644
index d4080427bc..0000000000
--- a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/events/NewModelEvent.java
+++ /dev/null
@@ -1,26 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Jens Lukowski/Innoopract - initial renaming/restructuring
- *
- *******************************************************************************/
-package org.eclipse.wst.sse.core.events;
-
-import org.eclipse.wst.sse.core.text.IStructuredDocument;
-
-/**
- * @deprecated - use NewDocumentEvent or NewDocumentContentEvent (this class
- * will simply be deleted in next version, moving its subclass
- * "up" to take its place.
- */
-public class NewModelEvent extends StructuredDocumentEvent {
- public NewModelEvent(IStructuredDocument source, Object originalSource) {
- super(source, originalSource);
- }
-}
diff --git a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/events/NoChangeEvent.java b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/events/NoChangeEvent.java
deleted file mode 100644
index 22bafe5569..0000000000
--- a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/events/NoChangeEvent.java
+++ /dev/null
@@ -1,72 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Jens Lukowski/Innoopract - initial renaming/restructuring
- *
- *******************************************************************************/
-package org.eclipse.wst.sse.core.events;
-
-import org.eclipse.wst.sse.core.text.IStructuredDocument;
-
-/**
- * this event is thrown if, after analysis, it is found there is no reason to
- * change the structuredDocument. This might occur, for example, if someone
- * pastes in the exact same text that they are replacing, or if someone tries
- * to change a read-only region.
- *
- * This might be important, for example, if some state variables are set on an
- * "about the change" event. then if there is no change (i.e.no other event is
- * fired), those state variables could reset, or whatever, upon receiving this
- * event.
- */
-public class NoChangeEvent extends StructuredDocumentEvent {
- /**
- * NO_CONTENT_CHANGE means that a some text was requested to be replaced
- * with identical text, so no change is actually done.
- */
- public final static int NO_CONTENT_CHANGE = 2;
- /**
- * NO_EVENT is used in rare error conditions, when, basically, a request
- * to change the document is made before the previous request has
- * completed. This event to used so aboutToChange/Changed cycles can
- * complete as required, but the document is most likely not modified as
- * expected.
- */
- public final static int NO_EVENT = 8;
- /**
- * READ_ONLY_STATE_CHANGE means that the "read only" state of the text was
- * changed, not the content itself.
- */
- public final static int READ_ONLY_STATE_CHANGE = 4;
-
- /**
- * set to one of the above detailed reasons for why no change was done.
- */
- public int reason = 0;
-
- /**
- * NoChangeEvent constructor comment. This event can occur if there was a
- * request to modify a document or its properties, but there as not really
- * is no change to a document's content.
- *
- * @param source
- * com.ibm.sed.structuredDocument.IStructuredDocument
- * @param originalSource
- * java.lang.Object
- * @param changes
- * java.lang.String
- * @param offset
- * int
- * @param lengthToReplace
- * int
- */
- public NoChangeEvent(IStructuredDocument source, Object originalSource, String changes, int offset, int lengthToReplace) {
- super(source, originalSource, changes, offset, lengthToReplace);
- }
-}
diff --git a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/events/RegionChangedEvent.java b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/events/RegionChangedEvent.java
deleted file mode 100644
index b663fdd0bb..0000000000
--- a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/events/RegionChangedEvent.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Jens Lukowski/Innoopract - initial renaming/restructuring
- *
- *******************************************************************************/
-package org.eclipse.wst.sse.core.events;
-
-import org.eclipse.wst.sse.core.text.IStructuredDocument;
-import org.eclipse.wst.sse.core.text.IStructuredDocumentRegion;
-import org.eclipse.wst.sse.core.text.ITextRegion;
-
-/**
- * This event is used when a node changes in a non-structural way.
- * Non-structural, that is, as far as the IStructuredDocument is concerned.
- * The whole node, along with the new text is sent, just in case a listener
- * (e.g. a tree model) might make its own determination of what to do, and
- * need the whole node to act appropriately.
- *
- * Note: users should not make assumptions about whether the node is literally
- * the same instance or not -- it is currently a different instance that is
- * identical to the old except for the changed region, but this implementation
- * may change.
- */
-public class RegionChangedEvent extends StructuredDocumentEvent {
- private ITextRegion fChangedRegion;
- private IStructuredDocumentRegion fStructuredDocumentRegion;
-
- public RegionChangedEvent(IStructuredDocument source, Object originalSource, IStructuredDocumentRegion flatNode, ITextRegion changedRegion, String changes, int offset, int lengthToReplace) {
- super(source, originalSource, changes, offset, lengthToReplace);
- fStructuredDocumentRegion = flatNode;
- fChangedRegion = changedRegion;
- }
-
- public ITextRegion getRegion() {
- return fChangedRegion;
- }
-
- public IStructuredDocumentRegion getStructuredDocumentRegion() {
- return fStructuredDocumentRegion;
- }
-}
diff --git a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/events/RegionsReplacedEvent.java b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/events/RegionsReplacedEvent.java
deleted file mode 100644
index 7954b25b96..0000000000
--- a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/events/RegionsReplacedEvent.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Jens Lukowski/Innoopract - initial renaming/restructuring
- *
- *******************************************************************************/
-package org.eclipse.wst.sse.core.events;
-
-import org.eclipse.wst.sse.core.text.IStructuredDocument;
-import org.eclipse.wst.sse.core.text.IStructuredDocumentRegion;
-import org.eclipse.wst.sse.core.text.ITextRegionList;
-
-/**
- * This event is used when a node's regions change, but the node itself
- * doesn't. This says nothing about the semantics of the node, that may still
- * have changed. Also, its assumed/required that ALL the regions are replaced
- * (even those that may not have changed).
- */
-public class RegionsReplacedEvent extends StructuredDocumentEvent {
- private ITextRegionList fNewRegions;
- private ITextRegionList fOldRegions;
- private IStructuredDocumentRegion fStructuredDocumentRegion;
-
- public RegionsReplacedEvent(IStructuredDocument source, Object originalSource, IStructuredDocumentRegion flatNode, ITextRegionList oldRegions, ITextRegionList newRegions, String changes, int offset, int lengthToReplace) {
- super(source, originalSource, changes, offset, lengthToReplace);
- fStructuredDocumentRegion = flatNode;
- fOldRegions = oldRegions;
- fNewRegions = newRegions;
- }
-
- public ITextRegionList getNewRegions() {
- return fNewRegions;
- }
-
- public ITextRegionList getOldRegions() {
- return fOldRegions;
- }
-
- public IStructuredDocumentRegion getStructuredDocumentRegion() {
- return fStructuredDocumentRegion;
- }
-}
diff --git a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/events/StructuredDocumentEvent.java b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/events/StructuredDocumentEvent.java
deleted file mode 100644
index f6f643afac..0000000000
--- a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/events/StructuredDocumentEvent.java
+++ /dev/null
@@ -1,127 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Jens Lukowski/Innoopract - initial renaming/restructuring
- *
- *******************************************************************************/
-package org.eclipse.wst.sse.core.events;
-
-import org.eclipse.jface.text.DocumentEvent;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.wst.sse.core.text.IStructuredDocument;
-
-
-/**
- * IStructuredDocument events are generated by the IStructuredDocument, after
- * the IStructuredDocument acts on a request.
- */
-public abstract class StructuredDocumentEvent extends DocumentEvent {
- protected String fDeletedText;
- protected Object fOriginalRequester;
-
- public IStructuredDocument fStructuredDocument;
-
- //public int fOffset;
- //public int fLength;
- //public String fText;
- /**
- * We assume that IStructuredDocument's are ALWAYS the source of
- * IStructuredDocument events
- */
- protected StructuredDocumentEvent(IStructuredDocument source) {
- super();
- if (source == null)
- throw new IllegalArgumentException("null source"); //$NON-NLS-1$
- fDocument = source;
- fStructuredDocument = source;
- }
-
- protected StructuredDocumentEvent(IStructuredDocument source, Object originalSource) {
- this(source);
- fOriginalRequester = originalSource;
- }
-
- protected StructuredDocumentEvent(IStructuredDocument source, Object originalSource, String changes, int offset, int lengthToReplace) {
- this(source);
- fOriginalRequester = originalSource;
- fText = changes;
- fOffset = offset;
- fLength = lengthToReplace;
- }
-
- /**
- * @return java.lang.String
- */
- public java.lang.String getDeletedText() {
- return fDeletedText;
- }
-
- public IDocument getDocument() {
-
- return fStructuredDocument;
- }
-
- public int getLength() {
-
- return fLength;
- }
-
- public int getOffset() {
-
- return getOriginalStart();
- }
-
- /**
- * This method returns the object that originally caused the event to
- * fire. This is typically not the object that created the event (the
- * IStructuredDocument) but instead the object object that made a request
- * to the IStructuredDocument.
- *
- * @return java.lang.Object
- */
- public java.lang.Object getOriginalSource() {
- return fOriginalRequester;
- }
-
- public int getOriginalStart() {
- return fOffset;
- }
-
- /**
- * This method is equivalent to 'getSource' except it returns an object of
- * the appropriate type (namely, a IStructuredDocument, instead of
- * Object).
- */
- public IStructuredDocument getStructuredDocument() {
- // a safe case, since constructor can only be called with a
- // IStructuredDocument
- return fStructuredDocument;
- }
-
- public String getText() {
-
- return fText;
- }
-
- /**
- * @param newDeletedText
- * java.lang.String
- */
- public void setDeletedText(java.lang.String newDeletedText) {
- fDeletedText = newDeletedText;
- }
-
- /**
- * returns the classname, but not the 'source=' (as super does).
- */
- public String toString() {
- //return getClass().getName() + "[source=" + source + "]";
- return getClass().getName();
- }
-}
diff --git a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/events/StructuredDocumentRegionsReplacedEvent.java b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/events/StructuredDocumentRegionsReplacedEvent.java
deleted file mode 100644
index 59969b6dd6..0000000000
--- a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/events/StructuredDocumentRegionsReplacedEvent.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Jens Lukowski/Innoopract - initial renaming/restructuring
- *
- *******************************************************************************/
-package org.eclipse.wst.sse.core.events;
-
-
-
-import org.eclipse.wst.sse.core.text.IStructuredDocument;
-import org.eclipse.wst.sse.core.text.IStructuredDocumentRegionList;
-
-/**
- * This event is used when a IStructuredDocumentRegion is deleted, or replaced
- * with more than one IStructuredDocumentRegion, or when simply more than one
- * IStructuredDocumentRegion changes.
- */
-
-public class StructuredDocumentRegionsReplacedEvent extends StructuredDocumentEvent {
-
- private IStructuredDocumentRegionList fNewStructuredDocumentRegions;
- private IStructuredDocumentRegionList fOldStructuredDocumentRegions;
-
- public StructuredDocumentRegionsReplacedEvent(IStructuredDocument source, Object originalSource, IStructuredDocumentRegionList oldStructuredDocumentRegions, IStructuredDocumentRegionList newStructuredDocumentRegions, String changes, int offset, int lengthToReplace) {
- super(source, originalSource, changes, offset, lengthToReplace);
- fOldStructuredDocumentRegions = oldStructuredDocumentRegions;
- fNewStructuredDocumentRegions = newStructuredDocumentRegions;
- }
-
- public IStructuredDocumentRegionList getNewStructuredDocumentRegions() {
- return fNewStructuredDocumentRegions;
- }
-
- public IStructuredDocumentRegionList getOldStructuredDocumentRegions() {
- return fOldStructuredDocumentRegions;
- }
-}
diff --git a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/exceptions/ResourceAlreadyExists.java b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/exceptions/ResourceAlreadyExists.java
deleted file mode 100644
index a48bb02c1f..0000000000
--- a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/exceptions/ResourceAlreadyExists.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Jens Lukowski/Innoopract - initial renaming/restructuring
- *
- *******************************************************************************/
-package org.eclipse.wst.sse.core.exceptions;
-
-
-
-public class ResourceAlreadyExists extends Exception {
-
- /**
- * Comment for <code>serialVersionUID</code>
- */
- private static final long serialVersionUID = 1L;
-
- /**
- * ResourceAlreadyExists constructor comment.
- */
- public ResourceAlreadyExists() {
- super();
- }
-
- /**
- * ResourceAlreadyExists constructor comment.
- *
- * @param s
- * java.lang.String
- */
- public ResourceAlreadyExists(String s) {
- super(s);
- }
-}
diff --git a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/exceptions/ResourceInUse.java b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/exceptions/ResourceInUse.java
deleted file mode 100644
index 24f1c8c1e9..0000000000
--- a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/exceptions/ResourceInUse.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Jens Lukowski/Innoopract - initial renaming/restructuring
- *
- *******************************************************************************/
-package org.eclipse.wst.sse.core.exceptions;
-
-
-
-public class ResourceInUse extends Exception {
-
- /**
- * Comment for <code>serialVersionUID</code>
- */
- private static final long serialVersionUID = 1L;
-
- /**
- * ResourceAlreadyExists constructor comment.
- */
- public ResourceInUse() {
- super();
- }
-
- /**
- * ResourceAlreadyExists constructor comment.
- *
- * @param s
- * java.lang.String
- */
- public ResourceInUse(String s) {
- super(s);
- }
-}
diff --git a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/exceptions/SourceEditingException.java b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/exceptions/SourceEditingException.java
deleted file mode 100644
index 4f14749c7f..0000000000
--- a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/exceptions/SourceEditingException.java
+++ /dev/null
@@ -1,85 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Jens Lukowski/Innoopract - initial renaming/restructuring
- *
- *******************************************************************************/
-package org.eclipse.wst.sse.core.exceptions;
-
-import org.eclipse.wst.sse.core.internal.SSECorePlugin;
-
-/**
- * The SourceEditingException is often thrown by Source Editor methods in
- * order to have a predictable, uniform interface to the Source Editing APIs.
- * If the OriginalException is not null, then it must be examined to determine
- * the true cause of the exception.
- */
-public class SourceEditingException extends Exception {
-
- /**
- * Comment for <code>serialVersionUID</code>
- */
- private static final long serialVersionUID = 1L;
- private Throwable originalException;
-
- public SourceEditingException() {
- super();
- }
-
- public SourceEditingException(String s) {
- super(s);
- }
-
- /**
- * This form of the constructor is used to wrapper another exception.
- */
- public SourceEditingException(Throwable t) {
- super();
- originalException = t;
- }
-
- /**
- * This form of the constructor is used to wrapper another exception, but
- * still provide a new descriptive message.
- */
- public SourceEditingException(Throwable t, String s) {
- super(s);
- originalException = t;
- }
-
- /**
- * The message depends on if this is a case that has an embedded
- * exception.
- */
- public String getMessage() {
- String result = null;
- if (originalException != null) {
- result = originalException.getMessage();
- } else {
- result = super.getMessage();
- }
- return result;
- }
-
- public Throwable getOriginalException() {
- return originalException;
- }
-
- public String toString() {
- // we don't put super.toString to "hide" that it was a
- // sourceEditing exception
- String s = null; //super.toString();
- String originalError = SSECorePlugin.getResourceString("%Original_Error__UI_"); //$NON-NLS-1$ = "Original Error:"
-
- if (originalException != null) {
- s = originalError + " " + originalException.toString(); //$NON-NLS-1$
- }
- return s;
- }
-}
diff --git a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/exceptions/SourceEditingRuntimeException.java b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/exceptions/SourceEditingRuntimeException.java
deleted file mode 100644
index 8b09a61156..0000000000
--- a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/exceptions/SourceEditingRuntimeException.java
+++ /dev/null
@@ -1,89 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Jens Lukowski/Innoopract - initial renaming/restructuring
- *
- *******************************************************************************/
-package org.eclipse.wst.sse.core.exceptions;
-
-import org.eclipse.wst.sse.core.internal.SSECorePlugin;
-
-/**
- * The SourceEditingRuntimeException is often thrown by Source Editor methods
- * when a service we use throws a checked exception, but we want to convert
- * and treat as a runtime exception. (Such as BadLocationException is a common
- * example).
- */
-public class SourceEditingRuntimeException extends RuntimeException {
-
- /**
- * Comment for <code>serialVersionUID</code>
- */
- private static final long serialVersionUID = 1L;
- private Throwable originalException;
-
- public SourceEditingRuntimeException() {
- super();
- }
-
- public SourceEditingRuntimeException(String s) {
- super(s);
- }
-
- /**
- * This form of the constructor is used to wrapper another exception.
- */
- public SourceEditingRuntimeException(Throwable t) {
- super();
- originalException = t;
- }
-
- /**
- * This form of the constructor is used to wrapper another exception, but
- * still provide a new descriptive message.
- */
- public SourceEditingRuntimeException(Throwable t, String s) {
- super(s);
- originalException = t;
- }
-
- public String getMessage() {
- String result = super.getMessage();
- if ((result != null) && (!result.endsWith("."))) //$NON-NLS-1$
- result = result + "."; //$NON-NLS-1$
- if (originalException != null) {
- String embeddedMessage = originalException.getMessage();
- embeddedMessage = originalException.getClass().getName() + ": " + originalException.getMessage(); //$NON-NLS-1$
- // not all exceptions have messages (e.g. many
- // NullPointerException)
- String originalError = SSECorePlugin.getResourceString("%Original_Error__UI_"); //$NON-NLS-1$ = "Original Error:"
- if (result == null)
- result = ""; //$NON-NLS-1$
- if (embeddedMessage != null)
- result = result + " " + originalError + " " + embeddedMessage;//$NON-NLS-2$//$NON-NLS-1$
- else
- result = result + " " + originalError + " " + originalException.toString();//$NON-NLS-2$//$NON-NLS-1$
- }
- return result;
- }
-
- public Throwable getOriginalException() {
- return originalException;
- }
-
- public String toString() {
- // we don't put super.toString or getClass to "hide" that it was a
- // SourceEditing exception (otherwise, focus goes on that,
- // instead of original exception.
- String message = getMessage();
- // message should never be null ... but just in case
- return (message != null) ? message : super.toString();
-
- }
-}
diff --git a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/filebuffers/BasicStructuredDocumentFactory.java b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/filebuffers/BasicStructuredDocumentFactory.java
deleted file mode 100644
index e00caa284c..0000000000
--- a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/filebuffers/BasicStructuredDocumentFactory.java
+++ /dev/null
@@ -1,75 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Jens Lukowski/Innoopract - initial renaming/restructuring
- *
- *******************************************************************************/
-package org.eclipse.wst.sse.core.filebuffers;
-
-import org.eclipse.core.filebuffers.IDocumentFactory;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IConfigurationElement;
-import org.eclipse.core.runtime.IExecutableExtension;
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.core.runtime.content.IContentType;
-import org.eclipse.core.runtime.content.IContentTypeManager;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.IDocumentPartitioner;
-import org.eclipse.wst.sse.core.internal.document.NullStructuredDocumentPartitioner;
-import org.eclipse.wst.sse.core.internal.modelhandler.ModelHandlerRegistry;
-import org.eclipse.wst.sse.core.internal.text.JobSafeStructuredDocument;
-import org.eclipse.wst.sse.core.modelhandler.IModelHandler;
-
-
-public class BasicStructuredDocumentFactory implements IDocumentFactory, IExecutableExtension {
-
- // The content type ID used to declare this factory; it is used to find
- // the corresponding ModelHandler
- private String fContentTypeIdentifier = null;
-
- public BasicStructuredDocumentFactory() {
- super();
- }
-
- public IDocument createDocument() {
- IDocument document = null;
- IContentType contentType = Platform.getContentTypeManager().getContentType(getContentTypeIdentifier());
- IModelHandler handler = null;
- while (handler == null && !IContentTypeManager.CT_TEXT.equals(contentType.getId())) {
- handler = ModelHandlerRegistry.getInstance().getHandlerForContentTypeId(contentType.getId());
- contentType = contentType.getBaseType();
- }
- if (handler != null) {
- document = handler.getDocumentLoader().createNewStructuredDocument();
- }
- else {
- document = new JobSafeStructuredDocument();
- }
-
- if (document.getDocumentPartitioner() == null) {
- IDocumentPartitioner defaultPartitioner = new NullStructuredDocumentPartitioner();
- document.setDocumentPartitioner(defaultPartitioner);
- defaultPartitioner.connect(document);
- }
- return document;
- }
-
- protected String getContentTypeIdentifier() {
- return fContentTypeIdentifier;
- }
-
- public void setInitializationData(IConfigurationElement config, String propertyName, Object data) throws CoreException {
- fContentTypeIdentifier = config.getAttribute("contentTypeId");
- if (data != null) {
- if (data instanceof String && data.toString().length() > 0) {
- fContentTypeIdentifier = (String) data;
- }
- }
- }
-}
diff --git a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/format/AbstractStructuredFormatProcessor.java b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/format/AbstractStructuredFormatProcessor.java
deleted file mode 100644
index d2c990f4e9..0000000000
--- a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/format/AbstractStructuredFormatProcessor.java
+++ /dev/null
@@ -1,479 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Jens Lukowski/Innoopract - initial renaming/restructuring
- *
- *******************************************************************************/
-package org.eclipse.wst.sse.core.format;
-
-import java.io.ByteArrayInputStream;
-import java.io.FileInputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.util.Vector;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.wst.sse.core.IStructuredModel;
-import org.eclipse.wst.sse.core.StructuredModelManager;
-import org.eclipse.wst.sse.core.internal.Logger;
-import org.eclipse.wst.sse.core.util.Assert;
-import org.w3c.dom.Attr;
-import org.w3c.dom.Node;
-
-
-public abstract class AbstractStructuredFormatProcessor implements IStructuredFormatProcessor {
- protected IStructuredFormatContraints fFormatContraints = null;
- protected IProgressMonitor fProgressMonitor = null;
- public boolean refreshFormatPreferences = true; // special flag for JUnit
-
- protected void ensureClosed(OutputStream outputStream, InputStream inputStream) {
-
- try {
- if (inputStream != null) {
- inputStream.close();
- }
- } catch (IOException e) {
- Logger.logException(e); // hopeless
- }
- try {
- if (outputStream != null) {
- outputStream.close();
- }
- } catch (IOException e) {
- Logger.logException(e); // hopeless
- }
- }
-
- public String formatContent(String input) throws IOException, CoreException {
- if (input == null)
- return input;
-
- IStructuredModel structuredModel = null;
- InputStream inputStream = null;
- try {
- // setup structuredModel
- // Note: We are getting model for read. Will return formatted
- // string and NOT save model.
- inputStream = new ByteArrayInputStream(input.getBytes("UTF8")); //$NON-NLS-1$
- String id = inputStream.toString() + "." + getFileExtension(); //$NON-NLS-1$
- structuredModel = StructuredModelManager.getModelManager().getModelForRead(id, inputStream, null);
-
- // format
- formatModel(structuredModel);
-
- // return output
- return structuredModel.getStructuredDocument().get();
- } finally {
- ensureClosed(null, inputStream);
- // release from model manager
- if (structuredModel != null)
- structuredModel.releaseFromRead();
- }
- }
-
- public String formatContent(String input, int start, int length) throws IOException, CoreException {
- if (input == null)
- return input;
-
- if (start >= 0 && length >= 0 && start + length <= input.length()) {
- IStructuredModel structuredModel = null;
- InputStream inputStream = null;
- try {
- // setup structuredModel
- // Note: We are getting model for read. Will return formatted
- // string and NOT save model.
- inputStream = new ByteArrayInputStream(input.getBytes("UTF8")); //$NON-NLS-1$
- String id = inputStream.toString() + "." + getFileExtension(); //$NON-NLS-1$
- structuredModel = StructuredModelManager.getModelManager().getModelForRead(id, inputStream, null);
-
- // format
- formatModel(structuredModel, start, length);
-
- // return output
- return structuredModel.getStructuredDocument().get();
- } finally {
- ensureClosed(null, inputStream);
- // release from model manager
- if (structuredModel != null)
- structuredModel.releaseFromRead();
- }
- } else
- return input;
- }
-
- public void formatDocument(IDocument document) throws IOException, CoreException {
- if (document == null)
- return;
-
- IStructuredModel structuredModel = null;
- //OutputStream outputStream = null;
- try {
- // setup structuredModel
- // Note: We are getting model for edit. Will save model if model
- // changed.
- structuredModel = StructuredModelManager.getModelManager().getExistingModelForEdit(document);
-
- // format
- formatModel(structuredModel);
-
- // save model if needed
- if (!structuredModel.isSharedForEdit() && structuredModel.isSaveNeeded())
- structuredModel.save();
- } finally {
- //ensureClosed(outputStream, null);
- // release from model manager
- if (structuredModel != null)
- structuredModel.releaseFromEdit();
- }
- }
-
- public void formatDocument(IDocument document, int start, int length) throws IOException, CoreException {
- if (document == null)
- return;
-
- if (start >= 0 && length >= 0 && start + length <= document.getLength()) {
- IStructuredModel structuredModel = null;
- //OutputStream outputStream = null;
- try {
- // setup structuredModel
- // Note: We are getting model for edit. Will save model if
- // model changed.
- structuredModel = StructuredModelManager.getModelManager().getExistingModelForEdit(document);
-
- // format
- formatModel(structuredModel, start, length);
-
- // save model if needed
- if (!structuredModel.isSharedForEdit() && structuredModel.isSaveNeeded())
- structuredModel.save();
- } finally {
- //ensureClosed(outputStream, null);
- // release from model manager
- if (structuredModel != null)
- structuredModel.releaseFromEdit();
- }
- }
- }
-
- public void formatFile(IFile file) throws IOException, CoreException {
- if (file == null)
- return;
-
- IStructuredModel structuredModel = null;
- //OutputStream outputStream = null;
- try {
- // setup structuredModel
- // Note: We are getting model for edit. Will save model if model
- // changed.
- structuredModel = StructuredModelManager.getModelManager().getModelForEdit(file);
-
- structuredModel.aboutToChangeModel();
-
- // format
- formatModel(structuredModel);
-
- // save model if needed
- if (!structuredModel.isSharedForEdit() && structuredModel.isSaveNeeded())
- structuredModel.save();
- } finally {
- //ensureClosed(outputStream, null);
- // release from model manager
- structuredModel.changedModel();
- if (structuredModel != null) {
- structuredModel.releaseFromEdit();
- }
-
- }
- }
-
- public void formatFile(IFile file, int start, int length) throws IOException, CoreException {
- if (file == null)
- return;
-
- IStructuredModel structuredModel = null;
- //OutputStream outputStream = null;
- try {
- // setup structuredModel
- // Note: We are getting model for edit. Will save model if model
- // changed.
- structuredModel = StructuredModelManager.getModelManager().getModelForEdit(file);
-
- // format
- formatModel(structuredModel, start, length);
-
- // save model if needed
- if (!structuredModel.isSharedForEdit() && structuredModel.isSaveNeeded())
- structuredModel.save();
- } finally {
- //ensureClosed(outputStream, null);
- // release from model manager
- if (structuredModel != null)
- structuredModel.releaseFromEdit();
- }
- }
-
- public void formatFileName(String fileName) throws IOException, CoreException {
- if (fileName == null)
- return;
-
- IStructuredModel structuredModel = null;
- InputStream inputStream = null;
- //OutputStream outputStream = null;
- try {
- // setup structuredModel
- // Note: We are getting model for edit. Will save model if model
- // changed.
- inputStream = new FileInputStream(fileName);
- structuredModel = StructuredModelManager.getModelManager().getModelForEdit(fileName, inputStream, null);
-
- // format
- formatModel(structuredModel);
-
- // save model if needed
- if (!structuredModel.isSharedForEdit() && structuredModel.isSaveNeeded())
- structuredModel.save();
- } finally {
- //ensureClosed(outputStream, inputStream);
- // release from model manager
- if (structuredModel != null)
- structuredModel.releaseFromEdit();
- }
- }
-
- public void formatFileName(String fileName, int start, int length) throws IOException, CoreException {
- if (fileName == null)
- return;
-
- IStructuredModel structuredModel = null;
- InputStream inputStream = null;
- //OutputStream outputStream = null;
- try {
- // setup structuredModel
- // Note: We are getting model for edit. Will save model if model
- // changed.
- inputStream = new FileInputStream(fileName);
- structuredModel = StructuredModelManager.getModelManager().getModelForEdit(fileName, inputStream, null);
-
- // format
- formatModel(structuredModel, start, length);
-
- // save model if needed
- if (!structuredModel.isSharedForEdit() && structuredModel.isSaveNeeded())
- structuredModel.save();
- } finally {
- //ensureClosed(outputStream, inputStream);
- // release from model manager
- if (structuredModel != null)
- structuredModel.releaseFromEdit();
- }
- }
-
- public void formatModel(IStructuredModel structuredModel) {
- int start = 0;
- int length = structuredModel.getStructuredDocument().getLength();
-
- formatModel(structuredModel, start, length);
- }
-
- public void formatModel(IStructuredModel structuredModel, int start, int length) {
- if (structuredModel != null) {
- if (start == 0 && length == structuredModel.getStructuredDocument().getLength())
- setFormatWithSiblingIndent(structuredModel, false);
- else
- setFormatWithSiblingIndent(structuredModel, true);
-
- if (start >= 0 && length >= 0 && start + length <= structuredModel.getStructuredDocument().getLength()) {
- Vector activeNodes = getActiveNodes(structuredModel, start, length);
- if (activeNodes.size() > 0) {
- Node firstNode = (Node) activeNodes.firstElement();
- Node lastNode = (Node) activeNodes.lastElement();
-
- boolean done = false;
- Node eachNode = firstNode;
- Node nextNode = null;
- // TODO: we should be able to call something like
- // sequentialRewrite, but
- // doesn't work for
- // our case, since we do "gets" during reparsing, so makes
- // sequential rewrite
- // store actually
- // less efficient than gap store. Someday we need our own
- // gap store, that
- // handles
- // structured text more efficiently. I thought I'd leave
- // this commented out
- // code here
- // as a reminder.
- // try {
- // structuredModel.getStructuredDocument().startSequentialRewrite(false);
- while (!done) {
- // update "done"
- done = (eachNode == lastNode);
-
- // get next sibling before format because eachNode
- // may
- // be deleted,
- // for example when it's an empty text node
- nextNode = eachNode.getNextSibling();
-
- // format each node
- formatNode(eachNode);
-
- // update each node
- if (nextNode != null && nextNode.getParentNode() == null)
- // nextNode is deleted during format
- eachNode = eachNode.getNextSibling();
- else
- eachNode = nextNode;
-
- // This should not be needed, but just in case
- // something went wrong with with eachNode.
- // We don't want an infinite loop here.
- if (eachNode == null)
- done = true;
- }
- // }
- // finally {
- // structuredModel.getStructuredDocument().stopSequentialRewrite();
- // }
- }
- }
- }
- }
-
- public void formatNode(Node node) {
- if (node != null) {
- Node newNode = node;
-
- // format the owner node if it's an attribute node
- if (node.getNodeType() == Node.ATTRIBUTE_NODE)
- newNode = ((Attr) node).getOwnerElement();
-
- // refresh format preferences before getting formatter
- if (refreshFormatPreferences)
- refreshFormatPreferences();
-
- // get formatter and format contraints
- IStructuredFormatter formatter = getFormatter(newNode);
- // TODO_future: added assert to replace "redundant null check".
- // if formatter is ever null, we should provide some
- // default formatter to serve as place holder.
- Assert.isNotNull(formatter, "formatter was null for a node, "); //$NON-NLS-1$
- IStructuredFormatContraints formatContraints = formatter.getFormatContraints();
- formatContraints.setFormatWithSiblingIndent(true);
- // format each node
- formatter.format(newNode, formatContraints);
- }
- }
-
- protected Vector getActiveNodes(IStructuredModel structuredModel, int startNodeOffset, int length) {
- Vector activeNodes = new Vector();
-
- if (structuredModel != null) {
- Node startNode = (Node) structuredModel.getIndexedRegion(startNodeOffset);
- // see https://w3.opensource.ibm.com/bugzilla/show_bug.cgi?id=4711
- //
- // We have to watch for selection boundary conditions. Use this as
- // an example: <a>text</a><b>text</b>,
- // If the whole <a> node is selected, like:
- // |<a>text</a>|<b>text</b>, we need to substract the length by 1
- // to find
- // the node at the end of the selection:
- // structuredModel.getIndexedRegion(startNodeOffset + length - 1),
- // or else
- // we'd find the next adjacent node.
- //
- // However, when the selection length is 0 (meaning no text is
- // selected), the cursor is at the beginning
- // of the node we want to format: |<a>text</a><b>text</b>, the
- // node at the end of the selection is:
- // structuredModel.getIndexedRegion(startNodeOffset + length).
- int endNodeOffset = length > 0 ? startNodeOffset + length - 1 : startNodeOffset + length;
- Node endNode = (Node) structuredModel.getIndexedRegion(endNodeOffset);
-
- // make sure it's an non-empty document
- if (startNode != null) {
- while (isSiblingOf(startNode, endNode) == false) {
- if (endNode != null)
- endNode = endNode.getParentNode();
- if (endNode == null) {
- startNode = startNode.getParentNode();
- // see
- // https://w3.opensource.ibm.com/bugzilla/show_bug.cgi?id=4711
- // and notes above
- endNodeOffset = length > 0 ? startNodeOffset + length - 1 : startNodeOffset + length;
- endNode = (Node) structuredModel.getIndexedRegion(endNodeOffset);
- }
- }
-
- while (startNode != endNode) {
- activeNodes.addElement(startNode);
- startNode = startNode.getNextSibling();
- }
- if (startNode != null)
- activeNodes.addElement(startNode);
- }
- }
-
- return activeNodes;
- }
-
- abstract protected String getFileExtension();
-
- protected IStructuredFormatContraints getFormatContraints(IStructuredModel structuredModel) {
- // 262135 - NPE during format of empty document
- if (fFormatContraints == null && structuredModel != null) {
- Node node = (Node) structuredModel.getIndexedRegion(0);
-
- if (node != null) {
- IStructuredFormatter formatter = getFormatter(node);
- if (formatter != null) {
- fFormatContraints = formatter.getFormatContraints();
- }
- }
- }
-
- return fFormatContraints;
- }
-
- abstract protected IStructuredFormatter getFormatter(Node node);
-
- protected boolean isSiblingOf(Node node, Node endNode) {
- if (endNode == null) {
- return true;
- } else {
- Node siblingNode = node;
- while (siblingNode != null) {
- if (siblingNode == endNode)
- return true;
- else
- siblingNode = siblingNode.getNextSibling();
- }
- return false;
- }
- }
-
- abstract protected void refreshFormatPreferences();
-
- protected void setFormatWithSiblingIndent(IStructuredModel structuredModel, boolean formatWithSiblingIndent) {
- // 262135 - NPE during format of empty document
- IStructuredFormatContraints formatContraints = getFormatContraints(structuredModel);
-
- if (formatContraints != null)
- formatContraints.setFormatWithSiblingIndent(formatWithSiblingIndent);
- }
-
- public void setProgressMonitor(IProgressMonitor monitor) {
- fProgressMonitor = monitor;
- }
-}
diff --git a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/format/IStructuredContentFormatter.java b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/format/IStructuredContentFormatter.java
deleted file mode 100644
index 729b416971..0000000000
--- a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/format/IStructuredContentFormatter.java
+++ /dev/null
@@ -1,19 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Jens Lukowski/Innoopract - initial renaming/restructuring
- *
- *******************************************************************************/
-package org.eclipse.wst.sse.core.format;
-
-import org.eclipse.wst.sse.core.IStructuredModel;
-
-public interface IStructuredContentFormatter {
- void setModel(IStructuredModel model);
-}
diff --git a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/format/IStructuredFormatContraints.java b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/format/IStructuredFormatContraints.java
deleted file mode 100644
index f3bcbd6942..0000000000
--- a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/format/IStructuredFormatContraints.java
+++ /dev/null
@@ -1,27 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Jens Lukowski/Innoopract - initial renaming/restructuring
- *
- *******************************************************************************/
-package org.eclipse.wst.sse.core.format;
-
-public interface IStructuredFormatContraints {
- boolean getClearAllBlankLines();
-
- String getCurrentIndent();
-
- boolean getFormatWithSiblingIndent();
-
- void setClearAllBlankLines(boolean clearAllBlankLines);
-
- void setCurrentIndent(String currentIndent);
-
- void setFormatWithSiblingIndent(boolean formatWithSiblingIndent);
-}
diff --git a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/format/IStructuredFormatPreferences.java b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/format/IStructuredFormatPreferences.java
deleted file mode 100644
index 3329cb62ec..0000000000
--- a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/format/IStructuredFormatPreferences.java
+++ /dev/null
@@ -1,27 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Jens Lukowski/Innoopract - initial renaming/restructuring
- *
- *******************************************************************************/
-package org.eclipse.wst.sse.core.format;
-
-public interface IStructuredFormatPreferences {
- boolean getClearAllBlankLines();
-
- String getIndent();
-
- int getLineWidth();
-
- void setClearAllBlankLines(boolean clearAllBlankLines);
-
- void setIndent(String indent);
-
- void setLineWidth(int lineWidth);
-}
diff --git a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/format/IStructuredFormatProcessor.java b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/format/IStructuredFormatProcessor.java
deleted file mode 100644
index e279a676a8..0000000000
--- a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/format/IStructuredFormatProcessor.java
+++ /dev/null
@@ -1,107 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Jens Lukowski/Innoopract - initial renaming/restructuring
- *
- *******************************************************************************/
-package org.eclipse.wst.sse.core.format;
-
-import java.io.IOException;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.wst.sse.core.IStructuredModel;
-import org.w3c.dom.Node;
-
-
-public interface IStructuredFormatProcessor {
- /**
- * This form of the FormatProcessor takes an input string as input,
- * creates an InputStream from the input string, create a temporary model
- * of the content type specified, formats the whole model, then returns
- * the formatted input string.
- */
- String formatContent(String content) throws IOException, CoreException;
-
- /**
- * This form of the FormatProcessor takes an input string as input,
- * creates an InputStream from the input string, create a temporary model
- * of the content type specified, formats the model within start and
- * length, then returns the formatted input string.
- */
- String formatContent(String content, int start, int length) throws IOException, CoreException;
-
- /**
- * This form of the FormatProcessor takes an IDocument as input, creates a
- * temporary model of content type calculated using the IDocument's file
- * extension, formats the whole model, then releases the model.
- */
- void formatDocument(IDocument document) throws IOException, CoreException;
-
- /**
- * This form of the FormatProcessor takes an IDocument as input, creates a
- * temporary model of content type calculated using the IDocument's file
- * extension, formats the model within start and length, then releases the
- * model.
- */
- void formatDocument(IDocument document, int start, int length) throws IOException, CoreException;
-
- /**
- * This form of the FormatProcessor takes an IFile as input, creates a
- * temporary model of content type calculated using the IFile's file
- * extension, formats the whole model, then releases the model.
- */
- void formatFile(IFile file) throws IOException, CoreException;
-
- /**
- * This form of the FormatProcessor takes an IFile as input, creates a
- * temporary model of content type calculated using the IFile's file
- * extension, formats the model within start and length, then releases the
- * model.
- */
- void formatFile(IFile file, int start, int length) throws IOException, CoreException;
-
- /**
- * This form of the FormatProcessor takes a file name as input,creates an
- * InputStream from the file, create a temporary model of content type
- * calculated using the file name's file extension, formats the whole
- * model, then releases the model.
- */
- void formatFileName(String fileName) throws IOException, CoreException;
-
- /**
- * This form of the FormatProcessor takes a file name as input,creates an
- * InputStream from the file, create a temporary model of content type
- * calculated using the file name's file extension, formats the model
- * within start and length, then releases the model.
- */
- void formatFileName(String fileName, int start, int length) throws IOException, CoreException;
-
- /**
- * This form of the FormatProcessor takes a model as input, and formats
- * the whole model.
- */
- void formatModel(IStructuredModel structuredModel);
-
- /**
- * This form of the FormatProcessor takes a model as input, and formats
- * the model within start and length.
- */
- void formatModel(IStructuredModel structuredModel, int start, int length);
-
- /**
- * This form of the FormatProcessor takes a node as input, and formats the
- * node and all its children.
- */
- void formatNode(Node node);
-
- void setProgressMonitor(IProgressMonitor monitor);
-}
diff --git a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/format/IStructuredFormatter.java b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/format/IStructuredFormatter.java
deleted file mode 100644
index 59cb989ad6..0000000000
--- a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/format/IStructuredFormatter.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Jens Lukowski/Innoopract - initial renaming/restructuring
- *
- *******************************************************************************/
-package org.eclipse.wst.sse.core.format;
-
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.w3c.dom.Node;
-
-public interface IStructuredFormatter {
- void format(Node node);
-
- void format(Node node, IStructuredFormatContraints formatContraints);
-
- IStructuredFormatContraints getFormatContraints();
-
- IStructuredFormatPreferences getFormatPreferences();
-
- void setFormatPreferences(IStructuredFormatPreferences formatPreferences);
-
- void setProgressMonitor(IProgressMonitor monitor);
-}
diff --git a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/format/StructuredFormatContraints.java b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/format/StructuredFormatContraints.java
deleted file mode 100644
index 8dcf98c7d5..0000000000
--- a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/format/StructuredFormatContraints.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Jens Lukowski/Innoopract - initial renaming/restructuring
- *
- *******************************************************************************/
-package org.eclipse.wst.sse.core.format;
-
-public class StructuredFormatContraints implements IStructuredFormatContraints {
- protected int fAvailableLineWidth;
- protected boolean fClearAllBlankLines;
- protected String fCurrentIndent = ""; //$NON-NLS-1$
- protected boolean fFormatWithSiblingIndent = false;
-
- public boolean getClearAllBlankLines() {
- return fClearAllBlankLines;
- }
-
- public String getCurrentIndent() {
- return fCurrentIndent;
- }
-
- public boolean getFormatWithSiblingIndent() {
- return fFormatWithSiblingIndent;
- }
-
- public void setClearAllBlankLines(boolean clearAllBlankLines) {
- fClearAllBlankLines = clearAllBlankLines;
- }
-
- public void setCurrentIndent(String currentIndent) {
- fCurrentIndent = currentIndent;
- }
-
- public void setFormatWithSiblingIndent(boolean formatWithSiblingIndent) {
- fFormatWithSiblingIndent = formatWithSiblingIndent;
- }
-}
diff --git a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/format/StructuredFormatPreferences.java b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/format/StructuredFormatPreferences.java
deleted file mode 100644
index b41d11b0f7..0000000000
--- a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/format/StructuredFormatPreferences.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Jens Lukowski/Innoopract - initial renaming/restructuring
- *
- *******************************************************************************/
-package org.eclipse.wst.sse.core.format;
-
-public class StructuredFormatPreferences implements IStructuredFormatPreferences {
- private boolean fClearAllBlankLines;
- private String fIndent;
- private int fLineWidth;
-
- public boolean getClearAllBlankLines() {
- return fClearAllBlankLines;
- }
-
- public String getIndent() {
- return fIndent;
- }
-
- public int getLineWidth() {
- return fLineWidth;
- }
-
- public void setClearAllBlankLines(boolean clearAllBlankLines) {
- fClearAllBlankLines = clearAllBlankLines;
- }
-
- public void setIndent(String indent) {
- fIndent = indent;
- }
-
- public void setLineWidth(int lineWidth) {
- fLineWidth = lineWidth;
- }
-}
diff --git a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/FileBufferModelManager.java b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/FileBufferModelManager.java
deleted file mode 100644
index 1fb5deb23e..0000000000
--- a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/FileBufferModelManager.java
+++ /dev/null
@@ -1,513 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Jens Lukowski/Innoopract - initial renaming/restructuring
- *
- *******************************************************************************/
-package org.eclipse.wst.sse.core.internal;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.io.InputStream;
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.util.Hashtable;
-import java.util.Map;
-
-import org.eclipse.core.filebuffers.FileBuffers;
-import org.eclipse.core.filebuffers.IFileBuffer;
-import org.eclipse.core.filebuffers.IFileBufferListener;
-import org.eclipse.core.filebuffers.ITextFileBuffer;
-import org.eclipse.core.filebuffers.ITextFileBufferManager;
-import org.eclipse.core.resources.IContainer;
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.NullProgressMonitor;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.core.runtime.content.IContentDescription;
-import org.eclipse.core.runtime.content.IContentType;
-import org.eclipse.core.runtime.content.IContentTypeManager;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.wst.sse.core.AbstractStructuredModel;
-import org.eclipse.wst.sse.core.IModelLoaderExtension;
-import org.eclipse.wst.sse.core.IStructuredModel;
-import org.eclipse.wst.sse.core.ModelLoader;
-import org.eclipse.wst.sse.core.exceptions.ResourceInUse;
-import org.eclipse.wst.sse.core.internal.modelhandler.ModelHandlerRegistry;
-import org.eclipse.wst.sse.core.modelhandler.IModelHandler;
-import org.eclipse.wst.sse.core.text.IStructuredDocument;
-import org.eclipse.wst.sse.core.util.ProjectResolver;
-import org.eclipse.wst.sse.core.util.URIResolver;
-import org.eclipse.wst.xml.uriresolver.util.URIHelper;
-
-
-public class FileBufferModelManager {
-
- static class DocumentInfo {
- ITextFileBuffer buffer = null;
- String contentTypeID = null;
- IStructuredModel model = null;
- boolean selfConnected = false;
- int bufferReferenceCount = 0;
- int modelReferenceCount = 0;
- }
-
- /**
- * A URIResolver instance of models built on java.io.Files
- */
- class ExternalURIResolver implements URIResolver {
- IPath fLocation;
-
- ExternalURIResolver(IPath location) {
- fLocation = location;
- }
-
- public String getFileBaseLocation() {
- return fLocation.toString();
- }
-
- public String getLocationByURI(String uri) {
- return getLocationByURI(uri, getFileBaseLocation(), false);
- }
-
- public String getLocationByURI(String uri, boolean resolveCrossProjectLinks) {
- return getLocationByURI(uri, getFileBaseLocation(), resolveCrossProjectLinks);
- }
-
- public String getLocationByURI(String uri, String baseReference) {
- return getLocationByURI(uri, baseReference, false);
- }
-
- public String getLocationByURI(String uri, String baseReference, boolean resolveCrossProjectLinks) {
- // ignore resolveCrossProjectLinks value
- if (uri == null)
- return null;
- if (uri.startsWith("file:")) {
- try {
- URL url = new URL(uri);
- return url.getFile();
- }
- catch (MalformedURLException e) {
- }
- }
- return URIHelper.normalize(uri, baseReference, Path.ROOT.toString());
- }
-
- public IProject getProject() {
- return null;
- }
-
- public IContainer getRootLocation() {
- return ResourcesPlugin.getWorkspace().getRoot();
- }
-
- public InputStream getURIStream(String uri) {
- return null;
- }
-
- public void setFileBaseLocation(String newLocation) {
- }
-
- public void setProject(IProject newProject) {
- }
- }
-
- /**
- * Maps interesting documents in file buffers to those file buffers.
- * Required to allows us to go from documents to complete models.
- */
- class FileBufferMapper implements IFileBufferListener {
- public void bufferContentAboutToBeReplaced(IFileBuffer buffer) {
- }
-
- public void bufferContentReplaced(IFileBuffer buffer) {
- }
-
- public void bufferCreated(IFileBuffer buffer) {
- if (buffer instanceof ITextFileBuffer) {
- ITextFileBuffer textBuffer = (ITextFileBuffer) buffer;
- if (!(textBuffer.getDocument() instanceof IStructuredDocument))
- return;
- if (debugTextBufferLifeCycle) {
- System.out.println("Learned new buffer: " + buffer.getLocation().toString() + " " + buffer + " " + ((ITextFileBuffer) buffer).getDocument());
- }
- DocumentInfo info = new DocumentInfo();
- info.buffer = textBuffer;
- info.contentTypeID = detectContentType(buffer.getLocation()).getId();
- info.bufferReferenceCount++;
- fDocumentMap.put(textBuffer.getDocument(), info);
- }
- }
-
- public void bufferDisposed(IFileBuffer buffer) {
- if (buffer instanceof ITextFileBuffer) {
- ITextFileBuffer textBuffer = (ITextFileBuffer) buffer;
- if (!(textBuffer.getDocument() instanceof IStructuredDocument))
- return;
- if (debugTextBufferLifeCycle) {
- System.out.println("Discarded buffer: " + buffer.getLocation().toString() + " " + buffer + " " + ((ITextFileBuffer) buffer).getDocument());
- }
- DocumentInfo info = (DocumentInfo) fDocumentMap.get(textBuffer.getDocument());
- if (info != null) {
- info.bufferReferenceCount--;
- if (info.bufferReferenceCount == 0 && info.modelReferenceCount == 0)
- fDocumentMap.remove(textBuffer.getDocument());
- }
- }
- }
-
- public void dirtyStateChanged(IFileBuffer buffer, boolean isDirty) {
- if (buffer instanceof ITextFileBuffer) {
- if (debugTextBufferLifeCycle) {
- System.out.println("Buffer dirty state changed: (" + isDirty + ") " + buffer.getLocation().toString() + " " + buffer + " " + ((ITextFileBuffer) buffer).getDocument());
- }
- ITextFileBuffer textBuffer = (ITextFileBuffer) buffer;
- if (!(textBuffer.getDocument() instanceof IStructuredDocument))
- return;
- DocumentInfo info = (DocumentInfo) fDocumentMap.get(textBuffer.getDocument());
- if (info != null && info.model != null) {
- String msg = "Updating model dirty state for" + info.buffer.getLocation();
- if (debugFileBufferModelManagement || debugTextBufferLifeCycle) {
- System.out.println(msg);
- }
- info.model.setDirtyState(isDirty);
-
- IFile workspaceFile = FileBuffers.getWorkspaceFileAtLocation(info.buffer.getLocation());
- if (!isDirty && workspaceFile != null) {
- info.model.resetSynchronizationStamp(workspaceFile);
- }
- }
- }
- }
-
- public void stateChangeFailed(IFileBuffer buffer) {
- }
-
- public void stateChanging(IFileBuffer buffer) {
- }
-
- public void stateValidationChanged(IFileBuffer buffer, boolean isStateValidated) {
- }
-
- public void underlyingFileDeleted(IFileBuffer buffer) {
- if (buffer instanceof ITextFileBuffer) {
- if (debugTextBufferLifeCycle) {
- System.out.println("Deleted buffer: " + buffer.getLocation().toOSString() + " " + buffer);
- }
- }
- }
-
- public void underlyingFileMoved(IFileBuffer buffer, IPath path) {
- if (buffer instanceof ITextFileBuffer) {
- if (debugTextBufferLifeCycle) {
- System.out.println("Moved buffer from: " + buffer.getLocation().toOSString() + " " + buffer);
- System.out.println("Moved buffer to: " + path.toOSString() + " " + buffer);
- }
- }
- }
- }
-
- static final boolean debugFileBufferModelManagement = "true".equalsIgnoreCase(Platform.getDebugOption("org.eclipse.wst.sse.core/filebuffers/modelmanagement"));
-
- static final boolean debugTextBufferLifeCycle = "true".equalsIgnoreCase(Platform.getDebugOption("org.eclipse.wst.sse.core/filebuffers/lifecycle"));
-
- private static FileBufferModelManager instance;
-
- public static FileBufferModelManager getInstance() {
- if (instance == null) {
- instance = new FileBufferModelManager();
- }
- return instance;
- }
-
- static final void shutdown() {
- if (instance != null) {
- if (debugFileBufferModelManagement) {
- IDocument[] danglingDocuments = (IDocument[]) instance.fDocumentMap.keySet().toArray(new IDocument[0]);
- for (int i = 0; i < danglingDocuments.length; i++) {
- DocumentInfo info = (DocumentInfo) instance.fDocumentMap.get(danglingDocuments[i]);
- if (info.modelReferenceCount > 0)
- System.err.println("LEAKED MODEL: " + info.buffer.getLocation() + " " + (info.model != null ? info.model.getId() : null));
- if (info.bufferReferenceCount > 0)
- System.err.println("LEAKED BUFFER: " + info.buffer.getLocation() + " " + info.buffer.getDocument());
- }
- }
- FileBuffers.getTextFileBufferManager().removeFileBufferListener(instance.fFileBufferListener);
- instance = null;
- }
- }
-
- static final void startup() {
- getInstance();
- }
-
- // a map of IStructuredDocuments to DocumentInfo objects
- Map fDocumentMap = null;
-
- IFileBufferListener fFileBufferListener = null;
-
- FileBufferModelManager() {
- super();
- fDocumentMap = new Hashtable(4);
- FileBuffers.getTextFileBufferManager().addFileBufferListener(fFileBufferListener = new FileBufferMapper());
- }
-
- public String calculateId(IFile file) {
- String id = null;
- IPath path = file.getLocation();
- if (path != null) {
- /*
- * The ID of models must be the same as the normalized paths
- * stored in the underlying FileBuffers to retrieve them by common
- * ID later on. We chose the FileBuffer normalized path over the
- * previously used absolute IFile path because the buffers should
- * already exist before we build a model and we can't retrieve a
- * FileBuffer using the ID of a model that doesn't yet exist.
- */
- id = FileBuffers.normalizeLocation(path).toString();
- }
- return id;
-
- }
-
- public String calculateId(IStructuredDocument document) {
- String id = null;
- ITextFileBuffer buffer = getBuffer(document);
- if (buffer != null) {
- id = buffer.getLocation().toString();
- }
- return id;
- }
-
- URIResolver createURIResolver(ITextFileBuffer buffer) {
- IPath location = buffer.getLocation();
- IFile workspaceFile = FileBuffers.getWorkspaceFileAtLocation(location);
- URIResolver resolver = null;
- if (workspaceFile != null) {
- IProject project = workspaceFile.getProject();
- resolver = (URIResolver) project.getAdapter(URIResolver.class);
- if (resolver == null) {
- resolver = new ProjectResolver(project);
- }
- resolver.setFileBaseLocation(workspaceFile.getLocation().toString());
- }
- else {
- resolver = new ExternalURIResolver(location);
- }
- return resolver;
- }
-
-
- IContentType detectContentType(IPath location) {
- IContentType type = null;
-
- IResource resource = FileBuffers.getWorkspaceFileAtLocation(location);
- if (resource != null) {
- if (resource.getType() == IResource.FILE && resource.isAccessible()) {
- IContentDescription d = null;
- try {
- // Optimized description lookup, might not succeed
- d = ((IFile) resource).getContentDescription();
- if (d != null) {
- type = d.getContentType();
- }
- }
- catch (CoreException e) {
- // Should not be possible given the accessible and file
- // type check above
- }
- if (type == null) {
- type = Platform.getContentTypeManager().findContentTypeFor(resource.getName());
- }
- }
- }
- else {
- File file = FileBuffers.getSystemFileAtLocation(location);
- if (file != null) {
- InputStream input = null;
- try {
- input = new FileInputStream(file);
- type = Platform.getContentTypeManager().findContentTypeFor(input, location.toOSString());
- }
- catch (FileNotFoundException e) {
- }
- catch (IOException e) {
- }
- finally {
- if (input != null) {
- try {
- input.close();
- }
- catch (IOException e1) {
- }
- }
- }
- if (type == null) {
- type = Platform.getContentTypeManager().findContentTypeFor(file.getName());
- }
- }
- }
- if (type == null) {
- type = Platform.getContentTypeManager().getContentType(IContentTypeManager.CT_TEXT);
- }
- return type;
- }
-
- public ITextFileBuffer getBuffer(IDocument document) {
- DocumentInfo info = (DocumentInfo) fDocumentMap.get(document);
- if (info != null)
- return info.buffer;
- return null;
- }
-
- String getContentTypeID(IDocument document) {
- DocumentInfo info = (DocumentInfo) fDocumentMap.get(document);
- if (info != null)
- return info.contentTypeID;
- return null;
- }
-
- IStructuredModel getModel(File file) {
- IStructuredModel model = null;
- ITextFileBufferManager bufferManager = FileBuffers.getTextFileBufferManager();
- try {
- IPath location = new Path(file.getAbsolutePath());
- if (debugFileBufferModelManagement) {
- System.out.println("FileBufferModelManager connecting to File " + location);
- }
- bufferManager.connect(location, getProgressMonitor());
- ITextFileBuffer buffer = bufferManager.getTextFileBuffer(location);
- if (buffer != null) {
- DocumentInfo info = (DocumentInfo) fDocumentMap.get(buffer.getDocument());
- info.selfConnected = true;
- model = getModel((IStructuredDocument) buffer.getDocument());
- }
- }
- catch (CoreException e) {
- Logger.log(Logger.ERROR, "Error getting model for " + file.getPath(), e);
- }
- return model;
- }
-
- public IStructuredModel getModel(IFile file) {
- IStructuredModel model = null;
- ITextFileBufferManager bufferManager = FileBuffers.getTextFileBufferManager();
- try {
- if (debugFileBufferModelManagement) {
- System.out.println("FileBufferModelManager connecting to IFile " + file.getLocation());
- }
- bufferManager.connect(file.getLocation(), getProgressMonitor());
- ITextFileBuffer buffer = bufferManager.getTextFileBuffer(file.getLocation());
- if (buffer != null) {
- DocumentInfo info = (DocumentInfo) fDocumentMap.get(buffer.getDocument());
- info.selfConnected = true;
- model = getModel((IStructuredDocument) buffer.getDocument());
- }
- }
- catch (CoreException e) {
- Logger.log(Logger.ERROR, "Error getting model for " + file.getLocation(), e);
- }
- return model;
- }
-
- public IStructuredModel getModel(IStructuredDocument document) {
- if (document == null)
- return null;
-
- DocumentInfo info = (DocumentInfo) fDocumentMap.get(document);
- if (info != null && info.model == null) {
- if (debugFileBufferModelManagement) {
- System.out.println("FileBufferModelManager creating model for " + info.buffer.getLocation() + " " + info.buffer.getDocument());
- }
- info.modelReferenceCount++;
-
- IStructuredModel model = null;
- IModelHandler handler = ModelHandlerRegistry.getInstance().getHandlerForContentTypeId(info.contentTypeID);
- ModelLoader loader = handler.getModelLoader();
- boolean mustSetDocument = true;
- if (loader instanceof IModelLoaderExtension) {
- mustSetDocument = false;
- model = ((IModelLoaderExtension) loader).createModel(document, info.buffer.getLocation().toString());
- }
- else {
- model = loader.createModel();
- model.setBaseLocation(info.buffer.getLocation().toString());
- }
- try {
- info.model = model;
- model.setId(info.buffer.getLocation().toString());
- model.setModelHandler(handler);
- if (model instanceof AbstractStructuredModel) {
- ((AbstractStructuredModel) model).setContentTypeIdentifier(info.contentTypeID);
- }
- model.setResolver(createURIResolver(getBuffer(document)));
- if (mustSetDocument) {
- model.setStructuredDocument(document);
- }
- if (info.buffer.isDirty()) {
- model.setDirtyState(true);
- }
- }
- catch (ResourceInUse e) {
- Logger.log(Logger.ERROR, "attempted to create new model with existing ID", e);
- model = null;
- }
- }
- if (info != null) {
- return info.model;
- }
- return null;
- }
-
- /**
- * @return
- */
- private IProgressMonitor getProgressMonitor() {
- return new NullProgressMonitor();
- }
-
- public boolean isExistingBuffer(IDocument document) {
- if (document == null)
- return false;
-
- DocumentInfo info = (DocumentInfo) fDocumentMap.get(document);
- return info != null;
- }
-
- public void releaseModel(IStructuredDocument document) {
- DocumentInfo info = (DocumentInfo) fDocumentMap.get(document);
- if (info != null) {
- if (debugFileBufferModelManagement) {
- System.out.println("FileBufferModelManager noticed full release of model for " + info.buffer.getLocation() + " " + info.buffer.getDocument());
- }
- info.model = null;
- info.modelReferenceCount--;
- if (info.selfConnected) {
- if (debugFileBufferModelManagement) {
- System.out.println("FileBufferModelManager disconnecting from " + info.buffer.getLocation() + " " + info.buffer.getDocument());
- }
- IPath location = info.buffer.getLocation();
- try {
- FileBuffers.getTextFileBufferManager().disconnect(info.buffer.getLocation(), getProgressMonitor());
- }
- catch (CoreException e) {
- Logger.log(Logger.ERROR, "Error releasing model for " + location, e);
- }
- }
- }
- }
-}
diff --git a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/JSPAwareAdapterFactory.java b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/JSPAwareAdapterFactory.java
deleted file mode 100644
index 0f9efdbf2a..0000000000
--- a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/JSPAwareAdapterFactory.java
+++ /dev/null
@@ -1,22 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Jens Lukowski/Innoopract - initial renaming/restructuring
- *
- *******************************************************************************/
-package org.eclipse.wst.sse.core.internal;
-
-import org.eclipse.wst.sse.core.AdapterFactory;
-import org.eclipse.wst.sse.core.modelhandler.EmbeddedTypeHandler;
-
-
-public interface JSPAwareAdapterFactory extends AdapterFactory {
-
- void initializeWith(EmbeddedTypeHandler embeddedContentType);
-}
diff --git a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/Logger.java b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/Logger.java
deleted file mode 100644
index 064a37f789..0000000000
--- a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/Logger.java
+++ /dev/null
@@ -1,175 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Jens Lukowski/Innoopract - initial renaming/restructuring
- *
- *******************************************************************************/
-package org.eclipse.wst.sse.core.internal;
-
-
-
-import java.util.StringTokenizer;
-
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.core.runtime.Plugin;
-import org.eclipse.core.runtime.Status;
-import org.osgi.framework.Bundle;
-
-/**
- * Small convenience class to log messages to plugin's log file and also, if
- * desired, the console. This class should only be used by classes in this
- * plugin. Other plugins should make their own copy, with appropriate ID.
- */
-public class Logger {
- private static final String PLUGIN_ID = "org.eclipse.wst.sse.core"; //$NON-NLS-1$
- public static final int ERROR = IStatus.ERROR; // 4
- public static final int ERROR_DEBUG = 200 + ERROR;
- public static final int INFO = IStatus.INFO; // 1
- public static final int INFO_DEBUG = 200 + INFO;
-
- public static final int OK = IStatus.OK; // 0
-
- public static final int OK_DEBUG = 200 + OK;
-
- private static final String TRACEFILTER_LOCATION = "/debug/tracefilter"; //$NON-NLS-1$
- public static final int WARNING = IStatus.WARNING; // 2
- public static final int WARNING_DEBUG = 200 + WARNING;
-
- /**
- * Adds message to log.
- *
- * @param level
- * severity level of the message (OK, INFO, WARNING, ERROR,
- * OK_DEBUG, INFO_DEBUG, WARNING_DEBUG, ERROR_DEBUG)
- * @param message
- * text to add to the log
- * @param exception
- * exception thrown
- */
- protected static void _log(int level, String message, Throwable exception) {
- if (level == OK_DEBUG || level == INFO_DEBUG || level == WARNING_DEBUG || level == ERROR_DEBUG) {
- if (!isDebugging())
- return;
- }
-
- int severity = IStatus.OK;
- switch (level) {
- case INFO_DEBUG :
- case INFO :
- severity = IStatus.INFO;
- break;
- case WARNING_DEBUG :
- case WARNING :
- severity = IStatus.WARNING;
- break;
- case ERROR_DEBUG :
- case ERROR :
- severity = IStatus.ERROR;
- }
- message = (message != null) ? message : "null"; //$NON-NLS-1$
- Status statusObj = new Status(severity, PLUGIN_ID, severity, message, exception);
- Bundle bundle = Platform.getBundle(PLUGIN_ID);
- if (bundle != null)
- Platform.getLog(bundle).log(statusObj);
- }
-
- /**
- * Prints message to log if category matches /debug/tracefilter option.
- *
- * @param message
- * text to print
- * @param category
- * category of the message, to be compared with
- * /debug/tracefilter
- */
- protected static void _trace(String category, String message, Throwable exception) {
- if (isTracing(category)) {
- message = (message != null) ? message : "null"; //$NON-NLS-1$
- Status statusObj = new Status(IStatus.OK, PLUGIN_ID, IStatus.OK, message, exception);
- Bundle bundle = Platform.getBundle(PLUGIN_ID);
- if (bundle != null)
- Platform.getLog(bundle).log(statusObj);
- }
- }
-
- /**
- * @deprecated Logger is not responsible for returning plugin
- */
- public static Plugin getPlugin() {
- return SSECorePlugin.getDefault();
- }
-
- /**
- * @deprecated Logger is not responsible for returning plugin id
- * @return
- */
- public static String getPluginId() {
- return PLUGIN_ID;
- }
-
- /**
- * @return true if the platform is debugging
- */
- public static boolean isDebugging() {
- return Platform.inDebugMode();
- }
-
- /**
- * Determines if currently tracing a category
- *
- * @param category
- * @return true if tracing category, false otherwise
- */
- public static boolean isTracing(String category) {
- if (!isDebugging())
- return false;
-
- String traceFilter = Platform.getDebugOption(PLUGIN_ID + TRACEFILTER_LOCATION);
- if (traceFilter != null) {
- StringTokenizer tokenizer = new StringTokenizer(traceFilter, ","); //$NON-NLS-1$
- while (tokenizer.hasMoreTokens()) {
- String cat = tokenizer.nextToken().trim();
- if (category.equals(cat)) {
- return true;
- }
- }
- }
- return false;
- }
-
- public static void log(int level, String message) {
- _log(level, message, null);
- }
-
- public static void log(int level, String message, Throwable exception) {
- _log(level, message, exception);
- }
-
- public static void logException(String message, Throwable exception) {
- _log(ERROR, message, exception);
- }
-
- public static void logException(Throwable exception) {
- _log(ERROR, exception.getMessage(), exception);
- }
-
- public static void trace(String category, String message) {
- _trace(category, message, null);
- }
-
- public static void traceException(String category, String message, Throwable exception) {
- _trace(category, message, exception);
- }
-
- public static void traceException(String category, Throwable exception) {
- _trace(category, exception.getMessage(), exception);
- }
-
-}
diff --git a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/ModelManagerPluginRegistryReader.java b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/ModelManagerPluginRegistryReader.java
deleted file mode 100644
index da7d491f52..0000000000
--- a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/ModelManagerPluginRegistryReader.java
+++ /dev/null
@@ -1,170 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Jens Lukowski/Innoopract - initial renaming/restructuring
- *
- *******************************************************************************/
-package org.eclipse.wst.sse.core.internal;
-
-import java.lang.reflect.InvocationTargetException;
-import java.util.List;
-import java.util.Vector;
-
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IConfigurationElement;
-import org.eclipse.core.runtime.IExtensionPoint;
-import org.eclipse.core.runtime.IExtensionRegistry;
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.wst.sse.core.AdapterFactory;
-import org.eclipse.wst.sse.core.modelhandler.IDocumentTypeHandler;
-import org.osgi.framework.Bundle;
-
-
-public class ModelManagerPluginRegistryReader {
- private static ModelManagerPluginRegistryReader reader = null;
-
- public synchronized static ModelManagerPluginRegistryReader getInstance() {
- if (reader == null) {
- reader = new ModelManagerPluginRegistryReader();
- }
- return reader;
- }
-
- protected final String ATTR_ADAPTERKEY = "adapterKeyClass"; //$NON-NLS-1$
- protected final String ATTR_CLASS = "class"; //$NON-NLS-1$
- protected final String ATTR_CONTENTTYPE = "type"; //$NON-NLS-1$
- protected final String ATTR_REGISTERADAPTER = "registerAdapters"; //$NON-NLS-1$
-
- protected final String EXTENSION_POINT_ID = "adaptOnCreateFactory"; //$NON-NLS-1$
- protected final String TAG_NAME = "AdaptOnCreateFactory"; //$NON-NLS-1$
-
- /**
- * XMLEditorPluginRegistryReader constructor comment.
- */
- protected ModelManagerPluginRegistryReader() {
- super();
- }
-
- public List getFactories(IDocumentTypeHandler handler) {
- return loadRegistry(handler.getId());
- }
-
- public List getFactories(String type) {
- return loadRegistry(type);
- }
-
- protected AdapterFactory loadFactoryFromConfigurationElement(IConfigurationElement element, Object requesterType) {
- AdapterFactory factory = null;
- if (element.getName().equals(TAG_NAME)) {
- String contentType = element.getAttribute(ATTR_CONTENTTYPE);
- if (!contentType.equals(requesterType))
- return null;
- String className = element.getAttribute(ATTR_CLASS);
- String adapterKeyClass = element.getAttribute(ATTR_ADAPTERKEY);
- String registerAdapters = element.getAttribute(ATTR_REGISTERADAPTER);
-
- // if className is null, then no one defined the extension point
- // for adapter factories
- if (className != null) {
- String name = element.getDeclaringExtension().getNamespace();
- Bundle bundle = null;
- try {
- bundle = Platform.getBundle(name);
- } catch (Exception e) {
- // if an error occurs here, its probably that the plugin
- // could not be found/loaded
- Logger.logException("Could not find bundle: " + name, e); //$NON-NLS-1$
-
- }
- if (bundle != null) {
- boolean useExtendedConstructor = false;
- boolean doRegisterAdapters = false;
- Object adapterKey = null;
-
- if (registerAdapters != null && registerAdapters.length() > 0 && Boolean.valueOf(registerAdapters).booleanValue()) {
- doRegisterAdapters = true;
- }
- if (adapterKeyClass != null) {
- try {
- Class aClass = null;
-// aClass = classLoader != null ? classLoader.loadClass(adapterKeyClass) : Class.forName(adapterKeyClass);
- if (bundle.getState() != Bundle.UNINSTALLED) {
- aClass = bundle.loadClass(adapterKeyClass);
- } else {
- aClass = Class.forName(adapterKeyClass);
- }
- if (aClass != null) {
- useExtendedConstructor = true;
- adapterKey = aClass;
- } else {
- adapterKey = adapterKeyClass;
- }
- } catch (Exception anyErrors) {
- adapterKey = adapterKeyClass;
- }
- }
-
- try {
- Class theClass = null;
-// Class theClass = classLoader != null ? classLoader.loadClass(className) : Class.forName(className);
- if (bundle.getState() != Bundle.UNINSTALLED) {
- theClass = bundle.loadClass(className);
- } else {
- theClass = Class.forName(className);
- }
- if (useExtendedConstructor) {
- java.lang.reflect.Constructor[] ctors = theClass.getConstructors();
- for (int i = 0; i < ctors.length; i++) {
- Class[] paramTypes = ctors[i].getParameterTypes();
- if (ctors[i].isAccessible() && paramTypes.length == 2 && paramTypes[0].equals(Object.class) && paramTypes[1].equals(boolean.class)) {
- try {
- factory = (AdapterFactory) ctors[i].newInstance(new Object[]{adapterKey, new Boolean(doRegisterAdapters)});
- } catch (IllegalAccessException e) {
- throw new org.eclipse.wst.sse.core.exceptions.SourceEditingRuntimeException(e);
- } catch (IllegalArgumentException e) {
- throw new org.eclipse.wst.sse.core.exceptions.SourceEditingRuntimeException(e);
- } catch (InstantiationException e) {
- throw new org.eclipse.wst.sse.core.exceptions.SourceEditingRuntimeException(e);
- } catch (InvocationTargetException e) {
- throw new org.eclipse.wst.sse.core.exceptions.SourceEditingRuntimeException(e);
- } catch (ExceptionInInitializerError e) {
- throw new org.eclipse.wst.sse.core.exceptions.SourceEditingRuntimeException(e);
- }
- }
- }
- }
- if (factory == null) {
- factory = (AdapterFactory) element.createExecutableExtension(ATTR_CLASS);
- }
- } catch (ClassNotFoundException e) {
- throw new org.eclipse.wst.sse.core.exceptions.SourceEditingRuntimeException(e);
- } catch (CoreException e) {
- throw new org.eclipse.wst.sse.core.exceptions.SourceEditingRuntimeException(e);
- }
- }
- }
- }
- return factory;
- }
-
- protected List loadRegistry(Object contentType) {
- List factoryList = new Vector();
- IExtensionRegistry extensionRegistry = Platform.getExtensionRegistry();
- IExtensionPoint point = extensionRegistry.getExtensionPoint(SSECorePlugin.ID, EXTENSION_POINT_ID);
- if (point != null) {
- IConfigurationElement[] elements = point.getConfigurationElements();
- for (int i = 0; i < elements.length; i++) {
- AdapterFactory factory = loadFactoryFromConfigurationElement(elements[i], contentType);
- if (factory != null)
- factoryList.add(factory);
- }
- }
- return factoryList;
- }
-}
diff --git a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/NoCancelProgressMonitor.java b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/NoCancelProgressMonitor.java
deleted file mode 100644
index c9f129f5e6..0000000000
--- a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/NoCancelProgressMonitor.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Jens Lukowski/Innoopract - initial renaming/restructuring
- *
- *******************************************************************************/
-
-package org.eclipse.wst.sse.core.internal;
-
-import org.eclipse.core.runtime.NullProgressMonitor;
-
-
-public class NoCancelProgressMonitor extends NullProgressMonitor {
-
-
- public NoCancelProgressMonitor() {
- super();
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.core.runtime.IProgressMonitor#isCanceled()
- */
- public boolean isCanceled() {
-
- return false;
- }
-}
diff --git a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/NotImplementedException.java b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/NotImplementedException.java
deleted file mode 100644
index 3a0b985c13..0000000000
--- a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/NotImplementedException.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Jens Lukowski/Innoopract - initial renaming/restructuring
- *
- *******************************************************************************/
-package org.eclipse.wst.sse.core.internal;
-
-
-public class NotImplementedException extends RuntimeException {
- /**
- * Comment for <code>serialVersionUID</code>
- */
- private static final long serialVersionUID = 1L;
-
- public NotImplementedException() {
- super();
- }
-
- public NotImplementedException(String message) {
- super(message);
- }
-
- public NotImplementedException(String message, Throwable cause) {
- super(message, cause);
- }
-
- public NotImplementedException(Throwable cause) {
- super(cause);
- }
-}
diff --git a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/NullMemento.java b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/NullMemento.java
deleted file mode 100644
index 827f2a2f04..0000000000
--- a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/NullMemento.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Jens Lukowski/Innoopract - initial renaming/restructuring
- *
- *******************************************************************************/
-package org.eclipse.wst.sse.core.internal;
-
-import org.eclipse.wst.common.encoding.EncodingMemento;
-import org.eclipse.wst.common.encoding.NonContentBasedEncodingRules;
-
-
-
-/**
- * This class can be used in place of an EncodingMemento (its super class),
- * when there is not in fact ANY encoding information. For example, when a
- * structuredDocument is created directly from a String
- */
-public class NullMemento extends EncodingMemento {
- /**
- *
- */
- public NullMemento() {
- super();
- String defaultCharset = NonContentBasedEncodingRules.useDefaultNameRules(null);
- setJavaCharsetName(defaultCharset);
- setAppropriateDefault(defaultCharset);
- setDetectedCharsetName(null);
- addTrace(DEFAULTS_ASSUMED_FOR_EMPTY_INPUT);
- }
-
-}
diff --git a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/SSECorePlugin.java b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/SSECorePlugin.java
deleted file mode 100644
index cf9dae535a..0000000000
--- a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/SSECorePlugin.java
+++ /dev/null
@@ -1,192 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Jens Lukowski/Innoopract - initial renaming/restructuring
- *
- *******************************************************************************/
-package org.eclipse.wst.sse.core.internal;
-
-import java.text.MessageFormat;
-import java.util.MissingResourceException;
-import java.util.ResourceBundle;
-
-import org.eclipse.core.runtime.Plugin;
-import org.eclipse.core.runtime.Preferences;
-import org.eclipse.wst.common.encoding.CommonEncodingPreferenceNames;
-import org.eclipse.wst.sse.core.IModelManager;
-import org.eclipse.wst.sse.core.IModelManagerPlugin;
-import org.eclipse.wst.sse.core.StructuredModelManager;
-import org.eclipse.wst.sse.core.internal.builder.StructuredDocumentBuilder;
-import org.eclipse.wst.sse.core.internal.modelhandler.ModelHandlerRegistry;
-import org.eclipse.wst.sse.core.preferences.CommonModelPreferenceNames;
-import org.osgi.framework.BundleContext;
-
-
-/**
- * This model manager plugin helper is used to return the model manager
- * desired to be used for creating a new model manager, for managing (add or
- * remove) model loaders and model dumpers, and for managing (get, release,
- * save, and save as) models. Here is an example on on how to use it. Under
- * the subdirectory named after your package which contains your
- * implementation of the model manager (e.g. "org.eclipse.wst.sse.core") in
- * the "project_resources\plugins" directory, create a "plugin.xml" file. In
- * this file ("projectproject_resources\plugins\com.ibm.sed.model\plugin.xml")
- * enter: <?xml version="1.0"?> <plugin name="IBM Web Tooling Model Manager
- * Plugin" id="org.eclipse.wst.sse.core" version="1.0" vendor-name="RTP"
- * class="org.eclipse.wst.sse.core.ModelManagerPlugin"> <!-- The XML package:
- * com.ibm.etools.b2bxmlrt, is required before the others to give precedence
- * to DOM2 APIs, instead of the DOM1 (used by others, such as the desktop
- * ("com.ibm.eclipse.*")) --> <requires><import
- * plugin="com.ibm.etools.b2bxmlrt" export="true"/> <import
- * plugin="org.eclipse.wst.common.contentmodel" export="true"/> </requires>
- * <runtime><library name="runtime/sedmodel.jar"> <export name="*"/>
- * </library> </runtime> </plugin> to tell the workbench the model manager
- * plugin ID and where to find this model manager plugin class. Then in the
- * getModelManager method of this model manager plugin class, create and
- * return the model manager desired to be used. In the client code that
- * requests the model manager, the following code should be used to access the
- * model manager
- * // get the model manager from the StructuredModelManager
- * StructuredModelManager.getModelManager();
- */
-public class SSECorePlugin extends Plugin implements IModelManagerPlugin {
- static SSECorePlugin instance = null;
- //Resource bundle.
- private ResourceBundle resourceBundle;
- private static final String KEY_PREFIX = "%"; //$NON-NLS-1$
- private static final String KEY_DOUBLE_PREFIX = "%%"; //$NON-NLS-1$
-
- private static final String OFF = "off"; //$NON-NLS-1$
- public static final String STRUCTURED_BUILDER = "org.eclipse.wst.sse.core.structuredbuilder"; //$NON-NLS-1$
- public static final String ID = "org.eclipse.wst.sse.core"; //$NON-NLS-1$
-
- public static SSECorePlugin getDefault() {
- return instance;
- }
-
- public SSECorePlugin() {
- super();
- instance = this;
- }
-
- /**
- * Set default non-UI
- */
- protected void initializeDefaultPluginPreferences() {
- Preferences prefs = getDefault().getPluginPreferences();
- // set model preference defaults
- prefs.setDefault(CommonModelPreferenceNames.CLEANUP_TAG_NAME_CASE, CommonModelPreferenceNames.ASIS);
- prefs.setDefault(CommonModelPreferenceNames.CLEANUP_ATTR_NAME_CASE, CommonModelPreferenceNames.ASIS);
- prefs.setDefault(CommonModelPreferenceNames.COMPRESS_EMPTY_ELEMENT_TAGS, true);
- prefs.setDefault(CommonModelPreferenceNames.INSERT_REQUIRED_ATTRS, true);
- prefs.setDefault(CommonModelPreferenceNames.INSERT_MISSING_TAGS, true);
- prefs.setDefault(CommonModelPreferenceNames.QUOTE_ATTR_VALUES, true);
- prefs.setDefault(CommonModelPreferenceNames.FORMAT_SOURCE, true);
- prefs.setDefault(CommonModelPreferenceNames.CONVERT_EOL_CODES, false);
- prefs.setDefault(CommonEncodingPreferenceNames.INPUT_CODESET, ""); //$NON-NLS-1$
- prefs.setDefault(CommonEncodingPreferenceNames.OUTPUT_CODESET, CommonModelPreferenceNames.UTF_8);
- prefs.setDefault(CommonEncodingPreferenceNames.END_OF_LINE_CODE, ""); //$NON-NLS-1$
- prefs.setDefault(CommonModelPreferenceNames.TAB_WIDTH, CommonModelPreferenceNames.DEFAULT_TAB_WIDTH);
- prefs.setDefault(CommonModelPreferenceNames.FORMATTING_SUPPORTED, false);
- prefs.setDefault(CommonModelPreferenceNames.LINE_WIDTH, 72);
- prefs.setDefault(CommonModelPreferenceNames.SPLIT_MULTI_ATTRS, false);
- prefs.setDefault(CommonModelPreferenceNames.INDENT_USING_TABS, true);
- prefs.setDefault(CommonModelPreferenceNames.CLEAR_ALL_BLANK_LINES, false);
- prefs.setDefault(CommonModelPreferenceNames.PREFERRED_MARKUP_CASE_SUPPORTED, false);
- prefs.setDefault(CommonModelPreferenceNames.TAG_NAME_CASE, CommonModelPreferenceNames.UPPER);
- prefs.setDefault(CommonModelPreferenceNames.ATTR_NAME_CASE, CommonModelPreferenceNames.LOWER);
- prefs.setDefault(CommonModelPreferenceNames.TASK_TAG_ENABLE, false);
- prefs.setDefault(CommonModelPreferenceNames.TASK_TAG_TAGS, "TODO,FIXME,XXX"); //$NON-NLS-1$
- prefs.setDefault(CommonModelPreferenceNames.TASK_TAG_PRIORITIES, "1,2,1"); //$NON-NLS-1$
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.core.runtime.Plugin#stop(org.osgi.framework.BundleContext)
- */
- public void stop(BundleContext context) throws Exception {
- savePluginPreferences();
- StructuredDocumentBuilder.shutdown();
- FileBufferModelManager.shutdown();
-
- super.stop(context);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.core.runtime.Plugin#start(org.osgi.framework.BundleContext)
- */
- public void start(BundleContext context) throws Exception {
- super.start(context);
-
- String build = System.getProperty(STRUCTURED_BUILDER);
- if (build == null || !build.equalsIgnoreCase(OFF)) {
- StructuredDocumentBuilder.startup();
- }
- // initialize FileBuffer handling
- FileBufferModelManager.startup();
- }
-
- /**
- * @deprecated
- */
- public ModelHandlerRegistry getModelHandlerRegistry() {
- return ModelHandlerRegistry.getInstance();
- }
-
- /**
- * @deprecated - use StructuredModelManager.getModelManager();
- */
- public IModelManager getModelManager() {
- return StructuredModelManager.getModelManager();
- }
-
- /**
- * Returns the string from the plugin's resource bundle,
- * or 'key' if not found.
- */
- public static String getResourceString(String value) {
- String s = value.trim();
- if (!s.startsWith(KEY_PREFIX, 0))
- return s;
- if (s.startsWith(KEY_DOUBLE_PREFIX, 0))
- return s.substring(1);
-
- int ix = s.indexOf(' ');
- String key = ix == -1 ? s : s.substring(0, ix);
-
- ResourceBundle bundle = getDefault().getResourceBundle();
- try {
- return (bundle != null) ? bundle.getString(key.substring(1)) : key;
- } catch (MissingResourceException e) {
- return key;
- }
- }
-
- public static String getResourceString(String key, Object[] args) {
-
- try {
- return MessageFormat.format(getResourceString(key), args);
- } catch (IllegalArgumentException e) {
- return getResourceString(key);
- }
-
- }
-
- /**
- * Returns the plugin's resource bundle,
- */
- public ResourceBundle getResourceBundle() {
- try {
- if (resourceBundle == null)
- resourceBundle = ResourceBundle.getBundle("org.eclipse.wst.sse.core.internal.SSECorePluginResources");
- } catch (MissingResourceException x) {
- resourceBundle = null;
- }
- return resourceBundle;
- }
-}
diff --git a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/SSECorePluginResources.properties b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/SSECorePluginResources.properties
deleted file mode 100644
index a956704bdd..0000000000
--- a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/SSECorePluginResources.properties
+++ /dev/null
@@ -1,69 +0,0 @@
-###############################################################################
-# Copyright (c) 2001, 2004 IBM Corporation and others.
-# All rights reserved. This program and the accompanying materials
-# are made available under the terms of the Eclipse Public License v1.0
-# which accompanies this distribution, and is available at
-# http://www.eclipse.org/legal/epl-v10.html
-#
-# Contributors:
-# IBM Corporation - initial API and implementation
-# Jens Lukowski/Innoopract - initial renaming/restructuring
-#
-###############################################################################
-A_model's_id_can_not_be_nu_EXC_=A model's id can not be null
-Program_Error__ModelManage_EXC_=Program Error: ModelManagerImpl::saveModel. Model should be in the cache
-Original_Error__UI_=Original Error:
-ModelPlugin.0=Structured Builder
-StructuredDocumentBuilder.0=Updating builders
-Text_Change_UI_=Text Change
-###############################################################################
-Unkown_internal_scanner_er_ERROR_=Unkown internal scanner error
-Internal_error__unknown_st_ERROR_=Internal error: unknown state
-Error__could_not_match_inp_ERROR_=Error: could not match input
-Error__pushback_value_was__ERROR_=Error: pushback value was too large
-An_I/O_error_occured_while_EXC_=An I/O error occured while scanning :
-3concat=File not found : \"{0}\"
-5concat=Error opening file \"{0}\"
-ul_____(template)_UI_=ul (template)
-<ul>_n__<li>_Item_one_</li_UI_=<ul>\n <li> Item one </li>\n <li> Item two </li>\n</ul>\n
-dl_____(template)_UI_=dl (template)
-<dl>_n__<dt>_First_definit_UI_=<dl>\n <dt> First definition <dd> First explanation\n <dt> Second definition <dd> Second explanation\n</dl>\n
-table_____(template)_UI_=table (template)
-<table_border>_n__<tr>_n___UI_=<table border>\n <tr>\n <th>Column 1 Heading</th>\n <th>Column 2 Heading</th>\n </tr>\n <tr>\n <td>Row 1: Col 1</td>\n <td>Row 1: Col 2</td>\n </tr>\n</table>\n
-ol_____(template)_UI_=ol (template)
-<ol>_n__<li>_Item_one_</li_UI_=<ol>\n <li> Item one </li>\n <li> Item two </li>\n</ol>\n
-html____(template)_UI_=html (template)
-<html>_n<head>_n<title>Ins_UI_=<html>\n<head>\n<title>Insert title here</title>\n</head>\n<body>\n<|c>\n</body>\n</html>
-script_____(commented)_UI_=script (commented)
-style_____(commented)_UI_=style (commented)
-img_____(map)_UI=img (map)
-Usage___java_HTMLTokenizer_EXC_=Usage : java HTMLTokenizer <inputfile>
-## on the following line, just translate: "place title here" and "place content here"
-__>_n_t_t<TITLE><|c>place__UI_=\">\n\t\t<TITLE><|c>place title here</TITLE>\n\t</HEAD>\n\t<BODY>\n\t\tplace content here\n\t</BODY>\n</HTML>
-Flatmodel_constructor_doesn__t_know_how_to_deal_with_non-string_4=Flatmodel constructor doesn\'t know how to deal with non-string
-unexpected_ModelManager_Impl_1=unexpected ModelManager Impl
-continuous_1=continuous
-paged_2=paged
-visual_3=visual
-aural_4=aural
-tactile_5=tactile
-grid_6=grid
-bitmap_7=bitmap
-interactive_8=interactive
-static_9=static
-all_10=all
-Cleaning_up_element_{0}=Cleaning up element \"{0}\"
-Uppercasing_attribute_name_{0}=Uppercasing attribute name \"{0}\"
-Lowercasing_attribute_name_{0}=Lowercasing attribute name \"{0}\"
-Uppercasing_tag_name_{0}=Uppercasing tag name \"{0}\"
-Lowercasing_tag_name_{0}=Lowercasing tag name \"{0}\"
-Inserting_missing_end_tag_{0}=Inserting missing end tag \"{0}\"
-Inserting_missing_start_tag_{0}=Inserting missing start tag \"{0}\"
-Inserting_default_attribute_value_{0}=Inserting default attribute value \"{0}\"
-Quoting_attribute_value_{0}=Quoting attribute value \"{0}\"
-Formatting_start_tag_of_element_{0}=Formatting start tag of element \"{0}\"
-Formatting_end_tag_of_element_{0}=Formatting end tag of element \"{0}\"
-Formatting_element_{0}=Formatting element \"{0}\"
-Formatting_indentation_before_element_{0}=Formatting indentation before element \"{0}\"
-Formatting_indentation_after_element_{0}=Formatting indentation after element \"{0}\"
-Formatting_element_{0}=Formatting element \"{0}\"
diff --git a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/builder/BuilderModelProvider.java b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/builder/BuilderModelProvider.java
deleted file mode 100644
index d6f24e2eb3..0000000000
--- a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/builder/BuilderModelProvider.java
+++ /dev/null
@@ -1,179 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Jens Lukowski/Innoopract - initial renaming/restructuring
- *
- *******************************************************************************/
-package org.eclipse.wst.sse.core.internal.builder;
-
-import java.util.Map;
-import java.util.WeakHashMap;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.wst.sse.core.IModelManager;
-import org.eclipse.wst.sse.core.IStructuredModel;
-import org.eclipse.wst.sse.core.builder.IBuilderModelProvider;
-import org.eclipse.wst.sse.core.internal.Logger;
-import org.eclipse.wst.sse.core.text.IStructuredDocument;
-
-
-public class BuilderModelProvider implements IBuilderModelProvider {
- private static final boolean _debug = "true".equalsIgnoreCase(Platform.getDebugOption("org.eclipse.wst.sse.core/builder/modelprovider")); //$NON-NLS-1$ //$NON-NLS-2$
-
- private Map fDocuments = null;
- private IModelManager fModelManager;
- private Map fModels = null;
-
- public BuilderModelProvider(IModelManager manager) {
-
- super();
- fModelManager = manager;
- }
-
- /**
- * Creates the document for this file; current done by retrieving it from
- * an IStructuredModel
- *
- * @param file
- * @return
- * @todo Generated comment
- */
- private IStructuredDocument createDocument(IFile file) {
-
- // For now, we have to retrieve the IStructuredDocument from the
- // IStructuredModel.
- IStructuredModel model = getModel(file);
- if (model != null) {
- if (_debug) {
- System.out.println(getClass().getName() + " created IStructuredDocument for " + file.getFullPath().toString()); //$NON-NLS-1$
- }
- return model.getStructuredDocument();
- }
- return null;
- }
-
-
- /**
- * Creates the model for this file. Currently, does it using the
- * IModelManager from scratch. TODO: C4, create the model using the
- * document (creating the document if needed, first)
- *
- * @param file
- * @return
- * @todo Generated comment
- */
- private IStructuredModel createModel(IFile file) {
- try {
- IStructuredModel model = null;
- if (_debug) {
- System.out.println(getClass().getName() + " created IStructuredModel for " + file.getFullPath().toString()); //$NON-NLS-1$
- }
- model = getModelManager().getExistingModelForRead(file);
- if (model != null) {
- // we have our reference, allow the
- // IModelManager to dispose if needed
- model.releaseFromRead();
- } else {
- model = getModelManager().createUnManagedStructuredModelFor(file);
- }
- return model;
- }
- // catch 'em all
- catch (Exception t) {
- Logger.log(Logger.WARNING, "Exception caught creating IStructuredModel for file " + file.getFullPath().toOSString() + ":" + t); //$NON-NLS-1$ //$NON-NLS-2$
- }
- return null;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.wst.sse.core.builder.IBuilderModelProvider#getDocument(org.eclipse.core.resources.IFile)
- */
- public IStructuredDocument getDocument(IFile file) {
-
- if (file == null) {
- return null;
- }
- IStructuredDocument document = (IStructuredDocument) getDocuments().get(file);
- if (document == null) {
- document = createDocument(file);
- if (document != null) {
- getDocuments().put(file, document);
- }
- }
- return document;
- }
-
- /**
- * @return Returns the documents.
- */
- public Map getDocuments() {
-
- if (fDocuments == null) {
- fDocuments = new WeakHashMap();
- }
- return fDocuments;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.wst.sse.core.builder.IBuilderModelProvider#getModel(org.eclipse.core.resources.IFile)
- */
- public IStructuredModel getModel(IFile file) {
-
- if (file == null) {
- return null;
- }
- IStructuredModel model = (IStructuredModel) getModels().get(file);
- if (model == null) {
- model = createModel(file);
- if (model != null) {
- getModels().put(file, model);
- }
- }
- return model;
- }
-
- protected IModelManager getModelManager() {
-
- return fModelManager;
- }
-
- /**
- * @return Returns the models.
- */
- public Map getModels() {
-
- if (fModels == null) {
- fModels = new WeakHashMap();
- }
- return fModels;
- }
-
- public void release(IFile file) {
-
- if (_debug) {
- System.out.println(getClass().getName() + " released resources for " + file.getProjectRelativePath().toString()); //$NON-NLS-1$
- }
- getDocuments().remove(file);
- getModels().remove(file);
- }
-
- public void releaseAll() {
-
- if (_debug) {
- System.out.println(getClass().getName() + " released all resources"); //$NON-NLS-1$
- }
- getDocuments().clear();
- getModels().clear();
- }
-}
diff --git a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/builder/BuilderParticipantRegistryReader.java b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/builder/BuilderParticipantRegistryReader.java
deleted file mode 100644
index e4e19c163b..0000000000
--- a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/builder/BuilderParticipantRegistryReader.java
+++ /dev/null
@@ -1,150 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Jens Lukowski/Innoopract - initial renaming/restructuring
- *
- *******************************************************************************/
-package org.eclipse.wst.sse.core.internal.builder;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IConfigurationElement;
-import org.eclipse.core.runtime.IExtensionPoint;
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.wst.sse.core.builder.IBuilderDelegate;
-import org.eclipse.wst.sse.core.builder.IBuilderParticipant;
-import org.eclipse.wst.sse.core.internal.Logger;
-import org.eclipse.wst.sse.core.internal.SSECorePlugin;
-import org.eclipse.wst.sse.core.util.StringUtils;
-
-
-class BuilderParticipantRegistryReader {
-
- private static final boolean _debugReader = "true".equalsIgnoreCase(Platform.getDebugOption("org.eclipse.wst.sse.core/participantregistry")); //$NON-NLS-1$ //$NON-NLS-2$
-
- private final static String CONTENTTYPE_WILDCARD = "*"; //$NON-NLS-1$
- private String ATT_CLASS = "class"; //$NON-NLS-1$
- private String ATT_CONTENT_TYPE = "contentType"; //$NON-NLS-1$
-
- private String DELEGATE_EXTENSION_POINT_ID = SSECorePlugin.ID + ".builderdelegate"; //$NON-NLS-1$
- private IConfigurationElement[] fDelegateElements;
- // a mapping of content types to IBuilderDelegate instances
- private Map fDelegateMap = null;
-
- // all of the configuration elements for our extension point
- private IConfigurationElement[] fParticipantElements;
-
- // a mapping of content types to IBuilderParticipant instances
- private Map fParticipantMap = null;
-
- private String PARTICIPANT_EXTENSION_POINT_ID = SSECorePlugin.ID + ".builderparticipant"; //$NON-NLS-1$
-
- BuilderParticipantRegistryReader() {
- super();
- }
-
- public IBuilderDelegate[] getBuilderDelegates(Object contentTypeID) {
- if (fDelegateElements == null) {
- readRegistry();
- }
- IBuilderDelegate[] delegates = (IBuilderDelegate[]) fDelegateMap.get(contentTypeID);
- if (delegates == null) {
- // fine the relevant extensions
- List elements = new ArrayList(0);
- IConfigurationElement[] delegateElements = fDelegateElements;
- for (int j = 0; j < delegateElements.length; j++) {
- String contentTypes = delegateElements[j].getAttribute(ATT_CONTENT_TYPE);
- String[] contentType = StringUtils.unpack(contentTypes);
- for (int k = 0; k < contentType.length; k++) {
- // allow wildcards to be returned as well
- if (contentType[k].equals(contentTypeID)) {
- elements.add(delegateElements[j]);
- }
- }
- }
- // instantiate and save them
- List delegateList = new ArrayList(elements.size());
- for (int i = 0; i < elements.size(); i++) {
- try {
- IBuilderDelegate delegate = (IBuilderDelegate) ((IConfigurationElement) elements.get(i)).createExecutableExtension(ATT_CLASS);
- if (delegate != null) {
- delegateList.add(delegate);
- }
- } catch (CoreException e) {
- Logger.logException("Exception creating builder participant for " + contentTypeID, e); //$NON-NLS-1$
- }
- }
- delegates = (IBuilderDelegate[]) delegateList.toArray(new IBuilderDelegate[0]);
- fDelegateMap.put(contentTypeID, delegates);
- if (_debugReader) {
- System.out.println("Created " + delegates.length + " build participants for " + contentTypeID); //$NON-NLS-1$ //$NON-NLS-2$
- }
- }
- return delegates;
- }
-
- public IBuilderParticipant[] getBuildParticipants(Object contentTypeID) {
- if (fParticipantElements == null) {
- readRegistry();
- }
- IBuilderParticipant[] participants = (IBuilderParticipant[]) fParticipantMap.get(contentTypeID);
- if (participants == null) {
- // fine the relevant extensions
- List elements = new ArrayList(0);
- IConfigurationElement[] participantElements = fParticipantElements;
- for (int j = 0; j < participantElements.length; j++) {
- String participantContentTypes = participantElements[j].getAttribute(ATT_CONTENT_TYPE);
- String[] participantContentType = StringUtils.unpack(participantContentTypes);
- for (int k = 0; k < participantContentType.length; k++) {
- // allow wildcards to be returned as well
- if (participantContentType[k].equals(contentTypeID) || CONTENTTYPE_WILDCARD.equals(participantContentType[k])) {
- elements.add(participantElements[j]);
- }
- }
- }
- // instantiate and save them
- List participantsList = new ArrayList(elements.size());
- for (int i = 0; i < elements.size(); i++) {
- try {
- IBuilderParticipant participant = (IBuilderParticipant) ((IConfigurationElement) elements.get(i)).createExecutableExtension(ATT_CLASS);
- if (participant != null) {
- participantsList.add(participant);
- }
- } catch (CoreException e) {
- Logger.logException("Exception creating builder participant for " + contentTypeID, e); //$NON-NLS-1$
- }
- }
- participants = (IBuilderParticipant[]) participantsList.toArray(new IBuilderParticipant[0]);
- fParticipantMap.put(contentTypeID, participants);
- if (_debugReader) {
- System.out.println("Created " + participants.length + " build participants for " + contentTypeID); //$NON-NLS-1$ //$NON-NLS-2$
- }
- }
- return participants;
- }
-
- private void readRegistry() {
- fParticipantMap = new HashMap();
- fDelegateMap = new HashMap();
- // Just remember the elements, so plugins don't have to be activated,
- // unless extension attributes match those of interest
- IExtensionPoint point = Platform.getExtensionRegistry().getExtensionPoint(PARTICIPANT_EXTENSION_POINT_ID);
- if (point != null) {
- fParticipantElements = point.getConfigurationElements();
- }
- point = Platform.getExtensionRegistry().getExtensionPoint(DELEGATE_EXTENSION_POINT_ID);
- if (point != null) {
- fDelegateElements = point.getConfigurationElements();
- }
- }
-}
diff --git a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/builder/StructuredDocumentBuilder.java b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/builder/StructuredDocumentBuilder.java
deleted file mode 100644
index 84cd0e265e..0000000000
--- a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/builder/StructuredDocumentBuilder.java
+++ /dev/null
@@ -1,575 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Jens Lukowski/Innoopract - initial renaming/restructuring
- *
- *******************************************************************************/
-package org.eclipse.wst.sse.core.internal.builder;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import org.eclipse.core.resources.ICommand;
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IProjectDescription;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.resources.IResourceChangeEvent;
-import org.eclipse.core.resources.IResourceChangeListener;
-import org.eclipse.core.resources.IResourceDelta;
-import org.eclipse.core.resources.IResourceDeltaVisitor;
-import org.eclipse.core.resources.IResourceVisitor;
-import org.eclipse.core.resources.IWorkspace;
-import org.eclipse.core.resources.IWorkspaceRoot;
-import org.eclipse.core.resources.IncrementalProjectBuilder;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.resources.WorkspaceJob;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IConfigurationElement;
-import org.eclipse.core.runtime.IExecutableExtension;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.NullProgressMonitor;
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.core.runtime.SubProgressMonitor;
-import org.eclipse.core.runtime.content.IContentDescription;
-import org.eclipse.core.runtime.content.IContentType;
-import org.eclipse.core.runtime.jobs.ISchedulingRule;
-import org.eclipse.core.runtime.jobs.Job;
-import org.eclipse.wst.sse.core.builder.IBuilderDelegate;
-import org.eclipse.wst.sse.core.internal.Logger;
-import org.eclipse.wst.sse.core.internal.SSECorePlugin;
-import org.eclipse.wst.sse.core.preferences.CommonModelPreferenceNames;
-
-public class StructuredDocumentBuilder extends IncrementalProjectBuilder implements IExecutableExtension {
-
- protected static final boolean _debugBuilder = "true".equalsIgnoreCase(Platform.getDebugOption("org.eclipse.wst.sse.core/builder")); //$NON-NLS-1$ //$NON-NLS-2$
- protected static final boolean _debugBuilderContentTypeDetection = "true".equalsIgnoreCase(Platform.getDebugOption("org.eclipse.wst.sse.core/builder/detection")); //$NON-NLS-1$ //$NON-NLS-2$
- protected static final boolean _debugBuilderPerf = "true".equalsIgnoreCase(Platform.getDebugOption("org.eclipse.wst.sse.core/builder/time")); //$NON-NLS-1$ //$NON-NLS-2$
- private static final boolean performValidateEdit = false;
-
- private static boolean isGloballyEnabled = true;
- private static final String OFF = "off"; //$NON-NLS-1$
- static final boolean _debugResourceChangeListener = "true".equalsIgnoreCase(Platform.getDebugOption("org.eclipse.wst.sse.core/resourcechangehandling")); //$NON-NLS-1$ //$NON-NLS-2$
-
- protected static class ProjectChangeListener implements IResourceChangeListener, IResourceDeltaVisitor {
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.core.resources.IResourceChangeListener#resourceChanged(org.eclipse.core.resources.IResourceChangeEvent)
- */
- public void resourceChanged(IResourceChangeEvent event) {
- IResourceDelta delta = event.getDelta();
- if (delta.getResource() != null) {
- int resourceType = delta.getResource().getType();
- if (resourceType == IResource.PROJECT || resourceType == IResource.ROOT) {
- try {
- delta.accept(this);
- }
- catch (CoreException e) {
- Logger.logException("Exception managing buildspec list", e); //$NON-NLS-1$
- }
- }
- }
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.core.resources.IResourceDeltaVisitor#visit(org.eclipse.core.resources.IResourceDelta)
- */
- public boolean visit(IResourceDelta delta) throws CoreException {
- IResource resource = delta.getResource();
- if (resource != null) {
- if (resource.getType() == IResource.ROOT)
- return true;
- else if (resource.getType() == IResource.PROJECT) {
- if (delta.getKind() == IResourceDelta.ADDED) {
- if (_debugResourceChangeListener) {
- System.out.println("Project " + delta.getResource().getName() + " added to workspace and registering with SDMB");//$NON-NLS-2$//$NON-NLS-1$
- }
- add(new NullProgressMonitor(), (IProject) resource, null);
- }
- return false;
- }
- }
- return false;
- }
- }
-
- static {
- String build = System.getProperty(SSECorePlugin.STRUCTURED_BUILDER);
- isGloballyEnabled = (build == null || !build.equalsIgnoreCase(OFF));
- }
-
- /**
- * Add the StructuredBuilder to the build spec of a single IProject
- *
- * @param project -
- * the IProject to add to, when needed
- */
- public static void add(IProgressMonitor monitor, IProject project, Object validateEditContext) {
- if (project == null || !project.isAccessible()) {
- return;
- }
- boolean isBuilderPresent = false;
- try {
- IFile descriptionFile = project.getFile(IProjectDescription.DESCRIPTION_FILE_NAME);
- if (descriptionFile.exists() && descriptionFile.isAccessible()) {
- IProjectDescription description = project.getDescription();
- ICommand[] commands = description.getBuildSpec();
- if (commands != null) {
- for (int i = 0; i < commands.length; i++) {
- String builderName = commands[i].getBuilderName();
- // builder name will be null if it has not been set
- if (builderName != null && builderName.equals(getBuilderId())) {
- isBuilderPresent = true;
- break;
- }
- }
- }
- if (!isBuilderPresent && !monitor.isCanceled()) {
- // validate for edit
- IStatus status = null;
- if (performValidateEdit) {
- ISchedulingRule validateEditRule = null;
- try {
- if (_debugBuilder) {
- System.out.println("Attempting validateEdit for " + descriptionFile.getFullPath().toString()); //$NON-NLS-1$
- }
- IFile[] validateFiles = new IFile[]{descriptionFile};
- IWorkspace workspace = descriptionFile.getWorkspace();
- validateEditRule = workspace.getRuleFactory().validateEditRule(validateFiles);
- Platform.getJobManager().beginRule(validateEditRule, monitor);
- status = workspace.validateEdit(validateFiles, null);
- if (_debugBuilder) {
- if (status.isOK()) {
- System.out.println("ValidateEdit completed for " + descriptionFile.getFullPath().toString()); //$NON-NLS-1$
- }
- else {
- System.out.println("ValidateEdit failed for " + descriptionFile.getFullPath().toString() + " " + status.getMessage()); //$NON-NLS-2$//$NON-NLS-1$
- }
- }
- }
- finally {
- if (validateEditRule != null) {
- Platform.getJobManager().endRule(validateEditRule);
- }
- }
- }
- if (status == null || status.isOK()) {
- // add the builder
- ICommand newCommand = description.newCommand();
- newCommand.setBuilderName(getBuilderId());
- ICommand[] newCommands = null;
- if (commands != null) {
- newCommands = new ICommand[commands.length + 1];
- System.arraycopy(commands, 0, newCommands, 0, commands.length);
- newCommands[commands.length] = newCommand;
- }
- else {
- newCommands = new ICommand[1];
- newCommands[0] = newCommand;
- }
- description.setBuildSpec(newCommands);
- /*
- * This 'refresh' was added since unit tests were
- * throwing exceptions about being out of sync. That
- * may indicate a "deeper" problem such as needing to
- * use scheduling rules, (although there don't appear
- * to be examples of that) or something similar.
- */
- // project.refreshLocal(IResource.DEPTH_ZERO,
- // subMonitorFor(monitor, 1,
- // IProgressMonitor.UNKNOWN));
- try {
- project.setDescription(description, subMonitorFor(monitor, 1, IProgressMonitor.UNKNOWN));
- }
- catch (CoreException e) {
- if (_debugBuilder) {
- if (performValidateEdit) {
- System.out.println("Description for project \"" + project.getName() + "\" could not be updated despite successful validateEdit"); //$NON-NLS-2$//$NON-NLS-1$
- }
- else {
- System.out.println("Description for project \"" + project.getName() + "\" could not be updated"); //$NON-NLS-2$//$NON-NLS-1$
- }
- }
- if (performValidateEdit) {
- Logger.log(Logger.WARNING, "Description for project \"" + project.getName() + "\" could not be updated despite successful validateEdit"); //$NON-NLS-2$//$NON-NLS-1$
- }
- else {
- Logger.log(Logger.WARNING, "Description for project \"" + project.getName() + "\" could not be updated"); //$NON-NLS-2$//$NON-NLS-1$
- }
- }
- }
- }
- }
- else {
- if (_debugBuilder) {
- System.out.println("Description for project \"" + project.getName() + "\" could not be updated"); //$NON-NLS-2$//$NON-NLS-1$
- }
- Logger.log(Logger.WARNING, "Description for project \"" + project.getName() + "\" could not be updated"); //$NON-NLS-2$//$NON-NLS-1$
- }
- }
- catch (Exception e) {
- // if we can't read the information, the project isn't open,
- // so it can't run auto-validate
- Logger.logException("Exception caught when adding Model Builder", e); //$NON-NLS-1$
- }
- }
-
- /**
- * Adds the StructuredBuilder to every project in the Workspace
- *
- * @param root
- */
- public synchronized static void add(IProgressMonitor monitor, IWorkspaceRoot root, Object validateEditContext) {
- if (!isGloballyEnabled) {
- return;
- }
- IProject[] allProjects = root.getProjects();
- IProgressMonitor localMonitor = subMonitorFor(monitor, allProjects.length);
- localMonitor.beginTask(SSECorePlugin.getResourceString("%StructuredDocumentBuilder.0"), 1); //$NON-NLS-1$
- for (int i = 0; i < allProjects.length && !monitor.isCanceled(); i++) {
- add(localMonitor, allProjects[i], validateEditContext);
- localMonitor.worked(1);
- }
- localMonitor.done();
- }
-
- private static String getBuilderId() {
- return "org.eclipse.wst.sse.core.structuredbuilder"; //$NON-NLS-1$
- }
-
- public static IProgressMonitor monitorFor(IProgressMonitor monitor) {
- if (monitor == null)
- return new NullProgressMonitor();
- return monitor;
- }
-
- public static IProgressMonitor subMonitorFor(IProgressMonitor monitor, int ticks) {
- if (monitor == null)
- return new NullProgressMonitor();
- if (monitor instanceof NullProgressMonitor)
- return monitor;
- return new SubProgressMonitor(monitor, ticks);
- }
-
- public static IProgressMonitor subMonitorFor(IProgressMonitor monitor, int ticks, int style) {
- if (monitor == null)
- return new NullProgressMonitor();
- if (monitor instanceof NullProgressMonitor)
- return monitor;
- return new SubProgressMonitor(monitor, ticks, style);
- }
-
- protected List fActiveDelegates = null;
- private String fName = "Structured Document Builder"; //$NON-NLS-1$
- protected BuilderParticipantRegistryReader registry = null;
-
- private long time0;
- private IResourceChangeListener changeListener;
-
- /**
- *
- */
- public StructuredDocumentBuilder() {
- super();
- if (isGloballyEnabled) {
- registry = new BuilderParticipantRegistryReader();
- fActiveDelegates = new ArrayList();
- }
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.core.internal.events.InternalBuilder#build(int,
- * java.util.Map, org.eclipse.core.runtime.IProgressMonitor)
- */
- protected IProject[] build(int kind, Map args, IProgressMonitor monitor) throws CoreException {
- IProject currentProject = getProject();
- // Currently, just use the Task Tags preference
- boolean locallyEnabled = isGloballyEnabled && SSECorePlugin.getDefault().getPluginPreferences().getBoolean(CommonModelPreferenceNames.TASK_TAG_ENABLE);
- if (!locallyEnabled || currentProject == null || !currentProject.isAccessible()) {
- if (_debugBuilderPerf || _debugBuilder) {
- System.out.println(getClass().getName() + " skipping build of " + currentProject.getName()); //$NON-NLS-1$
- }
- return new IProject[]{currentProject};
- }
-
- if (_debugBuilderPerf || _debugBuilder) {
- time0 = System.currentTimeMillis();
- }
- IResourceDelta delta = getDelta(currentProject);
- IProgressMonitor localMonitor = subMonitorFor(monitor, 1);
- localMonitor.beginTask(getDisplayName(), 1);
-
- if (!localMonitor.isCanceled()) {
- // check the kind of delta if one was given
- if (kind == FULL_BUILD || kind == CLEAN_BUILD || delta == null) {
- doFullBuild(kind, args, localMonitor, getProject());
- }
- else {
- doIncrementalBuild(kind, args, localMonitor);
- }
- }
- localMonitor.worked(1);
- shutdownDelegates();
- localMonitor.done();
- if (_debugBuilderPerf || _debugBuilder) {
- if (kind == FULL_BUILD || delta == null) {
- System.out.println(getClass().getName() + " finished FULL build of " + currentProject.getName() //$NON-NLS-1$
- + " in " + (System.currentTimeMillis() - time0) + "ms"); //$NON-NLS-1$ //$NON-NLS-2$
- }
- else {
- System.out.println(getClass().getName() + " finished INCREMENTAL/CLEAN/AUTO build of " + currentProject.getName() //$NON-NLS-1$
- + " in " + (System.currentTimeMillis() - time0) + "ms"); //$NON-NLS-1$ //$NON-NLS-2$
- }
- }
- return new IProject[]{getProject()};
- }
-
- void build(int kind, Map args, IResource resource, IContentType[] types, IProgressMonitor monitor) {
- if (!monitor.isCanceled() && resource.getType() == IResource.FILE) {
- IBuilderDelegate[] delegates = null;
- List allDelegates = new ArrayList();
- for (int i = 0; i < types.length; i++) {
- IBuilderDelegate[] typeDelegates = registry.getBuilderDelegates(types[i].getId());
- if (typeDelegates != null && typeDelegates.length > 0) {
- allDelegates.addAll(Arrays.asList(typeDelegates));
- }
- }
- delegates = (IBuilderDelegate[]) allDelegates.toArray(new IBuilderDelegate[0]);
- for (int j = 0; delegates != null && j < delegates.length; j++) {
- if (kind != IncrementalProjectBuilder.CLEAN_BUILD) {
- monitor.subTask(getDisplayName() + " building " + resource.getFullPath()); //$NON-NLS-1$
- }
- try {
- if (!fActiveDelegates.contains(delegates[j]) && !monitor.isCanceled()) {
- delegates[j].startup(getProject(), kind, args);
- fActiveDelegates.add(delegates[j]);
- }
- delegates[j].build((IFile) resource, kind, args, subMonitorFor(monitor, 100));
- }
- catch (Exception e) {
- Logger.logException(e);
- }
- }
- }
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.core.resources.IncrementalProjectBuilder#clean(org.eclipse.core.runtime.IProgressMonitor)
- */
- protected void clean(IProgressMonitor monitor) throws CoreException {
- if (_debugBuilderPerf || _debugBuilder) {
- time0 = System.currentTimeMillis();
- }
- super.clean(monitor);
- IProject currentProject = getProject();
- if (!isGloballyEnabled || currentProject == null || !currentProject.isAccessible()) {
- return;
- }
- doFullBuild(IncrementalProjectBuilder.CLEAN_BUILD, new HashMap(0), monitor, getProject());
- if (_debugBuilderPerf || _debugBuilder) {
- System.out.println(getClass().getName() + " finished CLEAN build of " + currentProject.getName() //$NON-NLS-1$
- + " in " + (System.currentTimeMillis() - time0) + "ms"); //$NON-NLS-1$ //$NON-NLS-2$
- }
- }
-
- IContentType[] detectContentTypes(IResource resource) {
- IContentType[] types = null;
- if (resource.getType() == IResource.FILE && resource.isAccessible()) {
- IContentDescription d = null;
- try {
- // optimized description lookup, might not succeed
- d = ((IFile) resource).getContentDescription();
- if (d != null) {
- types = new IContentType[]{d.getContentType()};
- }
- }
- catch (CoreException e) {
- // should not be possible given the accessible and file type
- // check above
- }
- if (types == null) {
- types = Platform.getContentTypeManager().findContentTypesFor(resource.getName());
- }
- if (_debugBuilderContentTypeDetection) {
- if (types.length > 0) {
- if (types.length > 1) {
- System.out.println(resource.getFullPath() + ": " + "multiple based on name (probably hierarchical)"); //$NON-NLS-1$ //$NON-NLS-2$
- }
- for (int i = 0; i < types.length; i++) {
- System.out.println(resource.getFullPath() + " matched: " + types[i].getId()); //$NON-NLS-1$
- }
- }
- }
- }
- return types;
- }
-
- /**
- * Iterate through the list of resources and build each one
- *
- * @param monitor
- * @param resources
- */
- protected void doFullBuild(int kind, Map args, IProgressMonitor monitor, IProject project) {
- if (_debugBuilder) {
- System.out.println(getClass().getName() + " building project " + project.getName()); //$NON-NLS-1$
- }
-
- final IProgressMonitor subMonitor = subMonitorFor(monitor, IProgressMonitor.UNKNOWN);
- final int localKind = kind;
- final Map localArgs = args;
-
- final IProgressMonitor visitorMonitor = monitor;
- IResourceVisitor internalBuilder = new IResourceVisitor() {
- public boolean visit(IResource resource) throws CoreException {
- if (resource.getType() == IResource.FILE) {
- // for any supported file type, record the resource
- IContentType[] contentTypes = detectContentTypes(resource);
- if (contentTypes != null) {
- build(localKind, localArgs, resource, contentTypes, subMonitor);
- visitorMonitor.worked(1);
- }
- return false;
- }
- else {
- return true;
- }
- }
-
- };
- try {
- project.accept(internalBuilder);
- }
- catch (CoreException e) {
- Logger.logException(e);
- }
- }
-
- /**
- *
- */
- protected void doIncrementalBuild(int kind, Map args, IProgressMonitor monitor) {
- IResourceDelta projectDelta = getDelta(getProject());
- if (projectDelta == null) {
- throw new IllegalArgumentException("delta is null, should do a full build"); //$NON-NLS-1$
- }
- if (_debugBuilder) {
- if (projectDelta != null && projectDelta.getResource() != null) {
- System.out.println(getClass().getName() + " building " + projectDelta.getResource().getFullPath()); //$NON-NLS-1$
- }
- else {
- System.out.println(getClass().getName() + " building project " + getProject().getName()); //$NON-NLS-1$
- }
- }
-
- final Map localArgs = args;
- final int localKind = kind;
- final IProgressMonitor localMonitor = subMonitorFor(monitor, IProgressMonitor.UNKNOWN, SubProgressMonitor.PREPEND_MAIN_LABEL_TO_SUBTASK);
- IResourceDeltaVisitor participantVisitor = new IResourceDeltaVisitor() {
- public boolean visit(IResourceDelta delta) throws CoreException {
- if (!localMonitor.isCanceled() && delta.getResource().getType() == IResource.FILE) {
- IContentType[] contentTypes = detectContentTypes(delta.getResource());
- if (contentTypes != null)
- build(localKind, localArgs, delta.getResource(), contentTypes, localMonitor);
- }
- return delta.getAffectedChildren().length > 0;
- }
- };
- try {
- projectDelta.accept(participantVisitor);
- }
- catch (CoreException e) {
- Logger.logException(e);
- }
- monitor.worked(1);
- }
-
- private String getDisplayName() {
- return fName;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.core.runtime.IExecutableExtension#setInitializationData(org.eclipse.core.runtime.IConfigurationElement,
- * java.lang.String, java.lang.Object)
- */
- public void setInitializationData(IConfigurationElement config, String propertyName, Object data) throws CoreException {
- if (config != null) {
- fName = config.getDeclaringExtension().getLabel();
- }
- }
-
- /**
- *
- */
- private void shutdownDelegates() {
- for (int j = 0; j < fActiveDelegates.size(); j++) {
- try {
- ((IBuilderDelegate) fActiveDelegates.get(j)).shutdown(getProject());
- }
- catch (Exception e) {
- Logger.logException(e);
- }
- }
- fActiveDelegates = new ArrayList(1);
- }
-
- // make private if ever used again
- void doTaskTagProcessing() {
- // Must make sure the builder is registered for projects which may
- // have been created before this plugin was activated.
- Job adder = new WorkspaceJob(SSECorePlugin.getResourceString("%ModelPlugin.0")) { //$NON-NLS-1$
- public IStatus runInWorkspace(IProgressMonitor monitor) {
- add(monitor, ResourcesPlugin.getWorkspace().getRoot(), null);
- return Status.OK_STATUS;
- }
- };
- adder.setSystem(true);
- // use SHORT, since once executing, this job should be quick
- adder.setPriority(Job.SHORT);
- // since we have potential to change several .project files,
- // we should wait until we can get exclusive access to
- // whole workspace.
- // TODO: future re-design should not require this.
- adder.setRule(ResourcesPlugin.getWorkspace().getRoot());
- adder.schedule();
-
- // Register the ProjectChangeListener so that it can add the
- // builder
- // to projects as needed
- changeListener = new ProjectChangeListener();
- ResourcesPlugin.getWorkspace().addResourceChangeListener(changeListener, IResourceChangeEvent.PRE_BUILD);
- }
-
- /**
- * Only for use by ModelPlugin class
- */
- public static void shutdown() {
- }
-
- /**
- * Only for use by ModelPlugin class
- */
- public static void startup() {
- // TODO:disabled for now
- }
-}
diff --git a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/document/NullStructuredDocumentPartitioner.java b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/document/NullStructuredDocumentPartitioner.java
deleted file mode 100644
index 79a22b667f..0000000000
--- a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/document/NullStructuredDocumentPartitioner.java
+++ /dev/null
@@ -1,115 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Jens Lukowski/Innoopract - initial renaming/restructuring
- *
- *******************************************************************************/
-package org.eclipse.wst.sse.core.internal.document;
-
-import org.eclipse.jface.text.DocumentEvent;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.IDocumentPartitioner;
-import org.eclipse.jface.text.IRegion;
-import org.eclipse.jface.text.ITypedRegion;
-import org.eclipse.jface.text.TypedRegion;
-
-/**
- * To be used when no known partitioner is available. Always returns the
- * unknown type.
- */
-public class NullStructuredDocumentPartitioner implements IDocumentPartitioner {
-
- public class NullStructuredTypedRegion implements ITypedRegion {
-
- private int fLength;
-
- private int fOffset;
-
- private String fType;
-
- public int getLength() {
- return fLength;
- }
-
- public int getOffset() {
- return fOffset;
- }
-
- public String getType() {
- return fType;
- }
-
- public void setLength(int length) {
- fLength = length;
-
- }
-
- public void setOffset(int offset) {
- fOffset = offset;
- }
-
- public void setType(String type) {
- fType = type;
- }
-
- }
-
- public final static String ST_UNKNOWN_PARTITION = "org.eclipse.wst.sse.core.UNKNOWN_PARTITION_TYPE"; //$NON-NLS-1$
- private final String[] legalTypes = new String[]{ST_UNKNOWN_PARTITION};
-
- public NullStructuredDocumentPartitioner() {
- super();
- }
-
- public ITypedRegion[] computePartitioning(int offset, int length) {
- ITypedRegion[] alwaysOne = new ITypedRegion[]{createPartition(offset, length, ST_UNKNOWN_PARTITION)};
- return alwaysOne;
- }
-
- public void connect(IDocument document) {
- // nothing to do
- }
-
- public ITypedRegion createPartition(int offset, int length, String type) {
- ITypedRegion result = new TypedRegion(offset, length, type);
- return result;
- }
-
- public void disconnect() {
- // nothing to do
- }
-
- public void documentAboutToBeChanged(DocumentEvent event) {
- }
-
- public boolean documentChanged(DocumentEvent event) {
- return false;
- }
-
- public String getContentType(int offset) {
- return getDefault();
- }
-
- public String getDefault() {
- return ST_UNKNOWN_PARTITION;
- }
-
- public String[] getLegalContentTypes() {
- return legalTypes;
- }
-
- public ITypedRegion getPartition(int offset) {
- return createPartition(offset, 1, getDefault());
- }
-
- public String getPartitionType(IRegion region, int offset) {
- return ST_UNKNOWN_PARTITION;
- }
-
-}
diff --git a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/document/TextUtilities.java b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/document/TextUtilities.java
deleted file mode 100644
index 91ec59830d..0000000000
--- a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/document/TextUtilities.java
+++ /dev/null
@@ -1,73 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Jens Lukowski/Innoopract - initial renaming/restructuring
- *
- *******************************************************************************/
-package org.eclipse.wst.sse.core.internal.document;
-
-
-/**
- * Collection of text functions.
- *
- * @deprecated - marked as deprecated to remind us to phase this out (and/or
- * move to "finished" version).
- */
-public class TextUtilities {
-
- /**
- * @deprecated if possible, its best to use
- * IDocument.getLegalLineDelimiters()
- */
- public final static String[] fgDelimiters = new String[]{"\n", "\r", "\r\n"};//$NON-NLS-3$//$NON-NLS-2$//$NON-NLS-1$
-
- /**
- * Determines which one of fgDelimiters appears first in the text. If none
- * of them the hint is returned.
- */
- public static String determineLineDelimiter(StringBuffer textBuffer, String[] possibles, String hint) {
- try {
- // TODO: avoid use of String instance
- String text = textBuffer.toString();
- int[] info = indexOf(possibles, text, 0);
- return possibles[info[1]];
- } catch (ArrayIndexOutOfBoundsException x) {
- }
- return hint;
- }
-
- /**
- * Returns the position in the string greater than offset of the longest
- * matching search string.
- */
- private static int[] indexOf(String[] searchStrings, String text, int offset) {
-
- int[] result = {-1, -1};
-
- for (int i = 0; i < searchStrings.length; i++) {
- int index = text.indexOf(searchStrings[i], offset);
- if (index >= 0) {
-
- if (result[0] == -1) {
- result[0] = index;
- result[1] = i;
- } else if (index < result[0]) {
- result[0] = index;
- result[1] = i;
- } else if (index == result[0] && searchStrings[i].length() > searchStrings[result[1]].length()) {
- result[0] = index;
- result[1] = i;
- }
- }
- }
-
- return result;
-
- }
-}
diff --git a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/modelhandler/EmbeddedTypeRegistry.java b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/modelhandler/EmbeddedTypeRegistry.java
deleted file mode 100644
index 8fab43b686..0000000000
--- a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/modelhandler/EmbeddedTypeRegistry.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Jens Lukowski/Innoopract - initial renaming/restructuring
- *
- *******************************************************************************/
-package org.eclipse.wst.sse.core.internal.modelhandler;
-
-import org.eclipse.wst.sse.core.modelhandler.EmbeddedTypeHandler;
-
-/**
- * The entries in this registry are, conceptually, singleton's Since only one
- * instance is created in the registry, and then that instance returned when
- * required.
- *
- * Note that there is intentionally no 'remove' method, Since the registry
- * itself is read it when once, from the platform's plugin registry, and is
- * not intended to be modified after that. A change in an extenstion in a
- * plugin.xml will only take effect when the workbench is re-started.
- *
- */
-public interface EmbeddedTypeRegistry {
-
- /**
- * Method to return the specific type for the specific mimetype.
- */
- public EmbeddedTypeHandler getTypeFor(String mimeType);
-
-}
diff --git a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/modelhandler/EmbeddedTypeRegistryImpl.java b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/modelhandler/EmbeddedTypeRegistryImpl.java
deleted file mode 100644
index f8d642672e..0000000000
--- a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/modelhandler/EmbeddedTypeRegistryImpl.java
+++ /dev/null
@@ -1,120 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Jens Lukowski/Innoopract - initial renaming/restructuring
- *
- *******************************************************************************/
-package org.eclipse.wst.sse.core.internal.modelhandler;
-
-import java.util.HashSet;
-import java.util.Iterator;
-
-import org.eclipse.wst.sse.core.modelhandler.EmbeddedTypeHandler;
-import org.eclipse.wst.sse.core.modelhandler.IDocumentTypeHandler;
-
-
-/**
- *
- */
-public class EmbeddedTypeRegistryImpl implements EmbeddedTypeRegistry {
-
- private static EmbeddedTypeRegistry instance = null;
-
- public synchronized static EmbeddedTypeRegistry getInstance() {
- if (instance == null) {
- instance = new EmbeddedTypeRegistryImpl();
- }
- return instance;
- }
-
- private HashSet hashSet = null;
- private EmbeddedTypeHandler registryDefaultHandler = null;
-
- /*
- * @see ContentTypeRegistry#getTypeFor(String)
- */
- /**
- * Constructor for ContentTypeRegistryImpl.
- */
- private EmbeddedTypeRegistryImpl() {
- super();
- hashSet = new HashSet();
- new EmbeddedTypeRegistryReader().readRegistry(hashSet);
- }
-
- /**
- * @see ContentTypeRegistry#add(ContentTypeDescription)
- */
- void add(IDocumentTypeHandler contentTypeDescription) {
- hashSet.add(contentTypeDescription);
- }
-
- private EmbeddedTypeHandler getJSPDefaultEmbeddedType() {
- return getTypeFor("text/html"); //$NON-NLS-1$
- }
-
- /**
- * Method getRegistryDefault. We cache the default handler, since can't
- * change once plugin descriptors are loaded.
- *
- * @return EmbeddedTypeHandler
- */
- private EmbeddedTypeHandler getRegistryDefault() {
- if (registryDefaultHandler == null) {
- Iterator it = hashSet.iterator();
- while ((registryDefaultHandler == null) && (it.hasNext())) { // safe
- // cast
- // since
- // 'add'
- // requires
- // EmbeddedContentTypeDescription
- EmbeddedTypeHandler item = (EmbeddedTypeHandler) it.next();
- if ((item != null) && (item.isDefault())) {
- registryDefaultHandler = item;
- break;
- }
- }
- }
- return registryDefaultHandler;
- }
-
- /**
- * Finds the contentTypeDescription based on literal id. Its basically a
- * "first found first returned". Note the order is fairly unpredictable,
- * so non-unique ids would cause problems.
- */
- public EmbeddedTypeHandler getTypeFor(String mimeType) {
- // Note: the reason we have this precondition is that the
- // default is different inside the registry than when called,
- // for example, from the JSPLoader. For the JSPLoader, if there
- // is no mimetype, the default should be HTML. Here, if there is
- // some mimetype, but it is not recognized, we return a default
- // for XML. This is required for various voice xml types, etc.
- EmbeddedTypeHandler found = null;
- if (mimeType == null || mimeType.trim().length() == 0) {
- found = getJSPDefaultEmbeddedType();
- } else {
- Iterator it = hashSet.iterator();
- while ((found == null) && (it.hasNext())) { // safe cast since
- // 'add' requires
- // EmbeddedContentTypeDescription
- EmbeddedTypeHandler item = (EmbeddedTypeHandler) it.next();
- if ((item != null) && (item.getSupportedMimeTypes().contains(mimeType))) {
- found = item;
- break;
- }
- }
- }
- if (found == null) {
- found = getRegistryDefault();
- }
- return found;
- }
-
-}
diff --git a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/modelhandler/EmbeddedTypeRegistryReader.java b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/modelhandler/EmbeddedTypeRegistryReader.java
deleted file mode 100644
index 6d6c1f938f..0000000000
--- a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/modelhandler/EmbeddedTypeRegistryReader.java
+++ /dev/null
@@ -1,71 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Jens Lukowski/Innoopract - initial renaming/restructuring
- *
- *******************************************************************************/
-package org.eclipse.wst.sse.core.internal.modelhandler;
-
-import java.util.Set;
-
-import org.eclipse.core.runtime.IConfigurationElement;
-import org.eclipse.core.runtime.IExtensionPoint;
-import org.eclipse.core.runtime.IExtensionRegistry;
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.wst.sse.core.internal.Logger;
-import org.eclipse.wst.sse.core.modelhandler.EmbeddedTypeHandler;
-import org.eclipse.wst.sse.core.util.Assert;
-
-
-public class EmbeddedTypeRegistryReader {
- protected String ATT_CLASS = "class"; //$NON-NLS-1$
- protected String EXTENSION_POINT_ID = "embeddedTypeHandler"; //$NON-NLS-1$
-
-
- protected String PLUGIN_ID = "org.eclipse.wst.sse.core"; //$NON-NLS-1$
- protected String TAG_NAME = "embeddedTypeHandler"; //$NON-NLS-1$
-
- EmbeddedTypeRegistryReader() {
- super();
- }
-
- protected EmbeddedTypeHandler readElement(IConfigurationElement element) {
-
- EmbeddedTypeHandler contentTypeDescription = null;
- if (element.getName().equals(TAG_NAME)) {
- try {
- contentTypeDescription = (EmbeddedTypeHandler) element.createExecutableExtension(ATT_CLASS);
- } catch (Exception e) {
- Logger.logException(e);
- }
- }
- Assert.isNotNull(contentTypeDescription, "Error reading content type description"); //$NON-NLS-1$
- return contentTypeDescription;
- }
-
- /**
- * We simply require an 'add' method, of what ever it is we are to read
- * into
- */
- void readRegistry(Set set) {
- IExtensionRegistry extensionRegistry = Platform.getExtensionRegistry();
- IExtensionPoint point = extensionRegistry.getExtensionPoint(PLUGIN_ID, EXTENSION_POINT_ID);
- if (point != null) {
- IConfigurationElement[] elements = point.getConfigurationElements();
- for (int i = 0; i < elements.length; i++) {
- EmbeddedTypeHandler embeddedContentType = readElement(elements[i]);
- // null can be returned if there's an error reading the
- // element
- if (embeddedContentType != null) {
- set.add(embeddedContentType);
- }
- }
- }
- }
-}
diff --git a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/modelhandler/ModelHandlerRegistry.java b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/modelhandler/ModelHandlerRegistry.java
deleted file mode 100644
index 383af34d74..0000000000
--- a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/modelhandler/ModelHandlerRegistry.java
+++ /dev/null
@@ -1,279 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Jens Lukowski/Innoopract - initial renaming/restructuring
- *
- *******************************************************************************/
-package org.eclipse.wst.sse.core.internal.modelhandler;
-
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.io.InputStream;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IConfigurationElement;
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.core.runtime.content.IContentDescription;
-import org.eclipse.core.runtime.content.IContentType;
-import org.eclipse.core.runtime.content.IContentTypeManager;
-import org.eclipse.wst.common.encoding.CodedIO;
-import org.eclipse.wst.sse.core.internal.Logger;
-import org.eclipse.wst.sse.core.modelhandler.IModelHandler;
-import org.eclipse.wst.sse.core.util.Utilities;
-
-
-public class ModelHandlerRegistry {
- private static ModelHandlerRegistry instance = null;
-
- private static IContentTypeManager getContentTypeRegistry() {
- IContentTypeManager registry = Platform.getContentTypeManager();
- return registry;
- }
-
- /**
- */
- public synchronized static ModelHandlerRegistry getInstance() {
- if (instance == null) {
- instance = new ModelHandlerRegistry();
- }
- return instance;
- }
-
- private IModelHandler defaultHandler = null;
- private ModelHandlerRegistryReader reader = new ModelHandlerRegistryReader();
-
- /*
- * @see ContentTypeRegistry#getTypeFor(String)
- */
- /**
- * Constructor for ContentTypeRegistryImpl.
- */
- protected ModelHandlerRegistry() {
- super();
- reader = new ModelHandlerRegistryReader().readRegistry();
- }
-
- /**
- * Finds the default model handler. Note: we still go through the registry
- * to be sure to get the existing instance, but then we do remember it, so
- * subsequent requests will be faster. The first time through, we do check
- * the whole list, to be sure there is only one.
- *
- */
- final public IModelHandler getDefault() {
- if (defaultHandler == null) {
- IConfigurationElement[] elements = reader.elements;
- for (int i = 0; i < elements.length; i++) {
- boolean ofInterest = reader.isElementDefault(elements[i]);
- if (ofInterest) {
- // if, here within the search loop we've already found
- // one defaultHandler, then something is wrong!
- if (defaultHandler == null) {
- defaultHandler = reader.getInstance(elements[i]);
- } else {
- String errorString = "Program or configuration error. More than one default content handler found"; //$NON-NLS-1$
- Logger.log(Logger.ERROR, errorString);
- throw new IllegalStateException(errorString);
- }
- }
- }
- }
- if (defaultHandler == null) {
- String errorString = "Program or configuration error. No default content type handler found."; //$NON-NLS-1$
- Logger.log(Logger.ERROR, errorString);
- throw new IllegalStateException(errorString);
- }
- return defaultHandler;
- }
-
- /**
- * Finds the contentTypeDescription based on outcome of the
- * ContentTypeDescription's canHandle(IResource) method.
- *
- * @throws CoreException
- */
- public IModelHandler getHandlerFor(IFile iFile) throws CoreException {
- IModelHandler modelHandler = null;
- IContentDescription contentDescription = null;
- IContentType contentType = null;
- boolean exists = iFile.exists();
- if (exists) {
- // try the optimized method first as the description may be cached
- contentDescription = iFile.getContentDescription();
- if (contentDescription != null) {
- // use the provided description
- contentType = contentDescription.getContentType();
- } else {
- // use the more thorough discovery method to get a description
- InputStream contents = null;
- try {
- contents = iFile.getContents(true);
- contentDescription = Platform.getContentTypeManager().getDescriptionFor(contents, iFile.getName(), IContentDescription.ALL);
- if (contentDescription != null) {
- contentType = contentDescription.getContentType();
- }
- } catch (IOException e) {
- // nothing further can be done, but will log for debugging
- Logger.logException(e);
- } finally {
- if (contents != null) {
- try {
- contents.close();
- } catch (IOException e1) {
- // nothing can be done
- }
- }
- }
- }
- }
-
- // if we couldn't get the content type from a description, try basing
- // it on the filename
- if (contentType == null) {
- contentType = Platform.getContentTypeManager().findContentTypeFor(iFile.getName());
- }
-
- if (contentType != null) {
- modelHandler = getHandlerForContentType(contentType);
- } else {
- // temp hard coding for null content type
- modelHandler = getHandlerForID("org.eclipse.wst.sse.core.handler.xml"); //$NON-NLS-1$
- }
-
- return modelHandler;
- }
-
- /**
- * @see ContentTypeRegistry#add(ContentTypeDescription)
- */
- // void add(IModelHandler contentTypeDescription) {
- // arrayList.add(contentTypeDescription);
- // }
- /*
- * @see ContentTypeRegistry#getModelFor(String)
- */
- /**
- * @throws IOException
- * @see ContentTypeRegistry#getTypeFor(String, InputStream)
- */
- public IModelHandler getHandlerFor(String filename, InputStream inputStream) throws IOException {
- InputStream iStream = Utilities.getMarkSupportedStream(inputStream);
- IModelHandler modelHandler = null;
- IContentType contentType = null;
- if (inputStream != null) {
- try {
- iStream.mark(CodedIO.MAX_MARK_SIZE);
- contentType = getContentTypeRegistry().findContentTypeFor(Utilities.getLimitedStream(iStream), filename);
- }
- // XXX: Remove when we build with the fix for Eclipse bug #63625
- catch (FileNotFoundException fnfe) {
- Logger.logException(fnfe);
- } finally {
- if (iStream != null && iStream.markSupported()) {
- iStream.reset();
- }
- }
-
- }
- if (contentType == null) {
- contentType = getContentTypeRegistry().findContentTypeFor(filename);
- }
- // if all else failed, try to detect solely on contents; done last for performance reasons
- if (contentType == null) {
- contentType = getContentTypeRegistry().findContentTypeFor(Utilities.getLimitedStream(iStream), null);
- }
- modelHandler = getHandlerForContentType(contentType);
- return modelHandler;
- }
-
-
- /**
- * Gets registered modelHandlers for given content type. TODO: eventually
- * need to look at contentType's parent types to see if more general type
- * can handle (e.g. if we got xsl which was a subtype of xml).
- *
- * @param contentType
- * @return
- */
- private IModelHandler getHandlerForContentType(IContentType contentType) {
-
- IModelHandler found = null;
- // temp hard coding for null content type
- if (contentType == null) {
- found = getHandlerForID("org.eclipse.wst.sse.core.handler.xml"); //$NON-NLS-1$
- } else {
- //String associatedContentTypeId = contentType.getId();
- IConfigurationElement[] elements = reader.elements;
- if (elements != null) {
- for (int i = 0; i < elements.length; i++) {
- String currentId = reader.getAssociatedContentTypeId(elements[i]);
- IContentType modelContentType = Platform.getContentTypeManager().getContentType(currentId);
- if (contentType.isKindOf(modelContentType)) {
- IModelHandler item = reader.getInstance(elements[i]);
- found = item;
- }
- }
- } else {
- Logger.log(Logger.WARNING_DEBUG, "There were no Model Handler found in registry"); //$NON-NLS-1$
- }
- }
- return found;
- }
-
- /**
- * Finds the ModelHandler based on literal content type id. This should
- * not normally be needed, in is in cases when a model needs to be
- * created, and there is no resource. Its basically a "first found first
- * returned". Note the order is fairly unpredictable, so non-unique ids
- * would cause problems, and are not checked.
- */
- public IModelHandler getHandlerForContentTypeId(String contentTypeId) {
- IContentType contentType = Platform.getContentTypeManager().getContentType(contentTypeId);
- return getHandlerForContentType(contentType);
- // IModelHandler found = null;
- // IConfigurationElement[] elements = reader.elements;
- // if (elements != null) {
- // for (int i = 0; i < elements.length; i++) {
- // String currentId = reader.getAssociatedContentTypeId(elements[i]);
- // if (contentTypeId.equals(currentId)) {
- // IModelHandler item = reader.getInstance(elements[i]);
- // found = item;
- // }
- // }
- // }
- // else {
- // Logger.log(Logger.WARNING_DEBUG, "There were no Model Handler found
- // in registry");
- // }
- // return found;
- }
-
- /**
- * Finds the ModelHandler based on literal id. Its basically a "first
- * found first returned". Note the order is fairly unpredictable, so
- * non-unique ids would cause problems, and are not checked.
- */
- private IModelHandler getHandlerForID(String modelId) {
- IModelHandler found = null;
- IConfigurationElement[] elements = reader.elements;
- if (elements != null) {
- for (int i = 0; i < elements.length; i++) {
- String currentId = reader.getId(elements[i]);
- if (modelId.equals(currentId)) {
- IModelHandler item = reader.getInstance(elements[i]);
- found = item;
- }
- }
- } else {
- Logger.log(Logger.WARNING_DEBUG, "There were no Model Handler found in registry"); //$NON-NLS-1$
- }
- return found;
- }
-}
diff --git a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/modelhandler/ModelHandlerRegistryReader.java b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/modelhandler/ModelHandlerRegistryReader.java
deleted file mode 100644
index c2c49d57bf..0000000000
--- a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/modelhandler/ModelHandlerRegistryReader.java
+++ /dev/null
@@ -1,106 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Jens Lukowski/Innoopract - initial renaming/restructuring
- *
- *******************************************************************************/
-package org.eclipse.wst.sse.core.internal.modelhandler;
-
-import java.util.HashMap;
-
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IConfigurationElement;
-import org.eclipse.core.runtime.IExtensionPoint;
-import org.eclipse.core.runtime.IExtensionRegistry;
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.wst.sse.core.modelhandler.AbstractModelHandler;
-import org.eclipse.wst.sse.core.modelhandler.IModelHandler;
-
-
-/**
- * This class just converts what's in the plugins registry into a form more
- * easily useable by others, the ContentTypeRegistry.
- */
-class ModelHandlerRegistryReader {
- private HashMap allReadyCreateInstances = new HashMap();
- protected String ATT_ASSOCIATED_CONTENT_TYPE = "associatedContentTypeId"; //$NON-NLS-1$
- protected String ATT_CLASS = "class"; //$NON-NLS-1$
- protected String ATT_DEFAULT = "default"; //$NON-NLS-1$
- protected String ATT_ID = "id"; //$NON-NLS-1$
- IConfigurationElement[] elements;
- protected String EXTENSION_POINT_ID = "modelHandler"; //$NON-NLS-1$
- //
- protected String PLUGIN_ID = "org.eclipse.wst.sse.core"; //$NON-NLS-1$
- protected String TAG_NAME = "modelHandler"; //$NON-NLS-1$
-
- //
- /**
- * ContentTypeRegistryReader constructor comment.
- */
- ModelHandlerRegistryReader() {
- super();
- }
-
- String getAssociatedContentTypeId(IConfigurationElement element) {
- String value = element.getAttribute(ATT_ASSOCIATED_CONTENT_TYPE);
- return value;
- }
-
- String getId(IConfigurationElement element) {
- String idValue = element.getAttribute(ATT_ID);
- return idValue;
- }
-
- synchronized IModelHandler getInstance(IConfigurationElement element) {
- // May need to reconsider, but for now, we'll assume all clients must
- // subclass AbstractContentTypeIdentifier. Its easier and safer, for
- // this
- // low level "system" object. (That is, we can check and set "package
- // protected"
- // attributes.
- AbstractModelHandler modelHandler = (AbstractModelHandler) allReadyCreateInstances.get(getId(element));
- if (modelHandler == null) {
- try {
- modelHandler = (AbstractModelHandler) element.createExecutableExtension(ATT_CLASS);
- if (modelHandler != null) {
- allReadyCreateInstances.put(getId(element), modelHandler);
- String defaultValue = element.getAttribute(ATT_DEFAULT);
- if (defaultValue != null && "true".equals(defaultValue)) //$NON-NLS-1$
- modelHandler.setDefault(true);
- else
- modelHandler.setDefault(false);
- // TODO -- set and check attributes vs. created instance
- //contentTypeIdentifier.setOrCheckId(element.getAttribute(ATT_ID));
- }
- } catch (CoreException e) {
- org.eclipse.wst.sse.core.internal.Logger.logException(e);
- }
- }
- return modelHandler;
- }
-
- public boolean isElementDefault(IConfigurationElement element) {
- String defaultValue = element.getAttribute(ATT_DEFAULT);
- if (defaultValue != null && "true".equals(defaultValue)) //$NON-NLS-1$
- return true;
- else
- return false;
- }
-
- ModelHandlerRegistryReader readRegistry() {
- IExtensionRegistry extensionRegistry = Platform.getExtensionRegistry();
- IExtensionPoint point = extensionRegistry.getExtensionPoint(PLUGIN_ID, EXTENSION_POINT_ID);
- if (point != null) {
- // just remember the elements, so plugins don't have to
- // be activated, unless extension matches those "of interest".
- elements = point.getConfigurationElements();
- }
- return this;
- }
-}
diff --git a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/modelhandler/ModelHandlerUtility.java b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/modelhandler/ModelHandlerUtility.java
deleted file mode 100644
index 58fb94f3d2..0000000000
--- a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/modelhandler/ModelHandlerUtility.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Jens Lukowski/Innoopract - initial renaming/restructuring
- *
- *******************************************************************************/
-package org.eclipse.wst.sse.core.internal.modelhandler;
-
-import org.eclipse.wst.sse.core.modelhandler.EmbeddedTypeHandler;
-import org.eclipse.wst.sse.core.modelhandler.IDocumentTypeHandler;
-
-/**
- *
- * Likely a temporary class to be replaced by plugin, eventually.
- */
-public class ModelHandlerUtility {
-
- private static ModelHandlerRegistry contentTypeRegistry;
-
- public static IDocumentTypeHandler getContentTypeFor(String string) {
- return getContentTypeRegistry().getHandlerForContentTypeId(string);
- }
-
- private static ModelHandlerRegistry getContentTypeRegistry() {
- if (contentTypeRegistry == null) {
- contentTypeRegistry = ModelHandlerRegistry.getInstance();
- }
- return contentTypeRegistry;
- }
-
- public static EmbeddedTypeHandler getDefaultEmbeddedType() {
- return getEmbeddedContentTypeFor("text/html"); //$NON-NLS-1$
- }
-
- public static EmbeddedTypeHandler getEmbeddedContentTypeFor(String string) {
- EmbeddedTypeHandler instance = null;
- instance = EmbeddedTypeRegistryImpl.getInstance().getTypeFor(string);
- return instance;
- }
-
- public ModelHandlerUtility() {
- super();
- }
-}
diff --git a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/modelhandler/PluginContributedFactoryReader.java b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/modelhandler/PluginContributedFactoryReader.java
deleted file mode 100644
index 475cbd6643..0000000000
--- a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/modelhandler/PluginContributedFactoryReader.java
+++ /dev/null
@@ -1,126 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Jens Lukowski/Innoopract - initial renaming/restructuring
- *
- *******************************************************************************/
-package org.eclipse.wst.sse.core.internal.modelhandler;
-
-import java.util.List;
-import java.util.Vector;
-
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IConfigurationElement;
-import org.eclipse.core.runtime.IExtensionPoint;
-import org.eclipse.core.runtime.IExtensionRegistry;
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.wst.sse.core.AdapterFactory;
-import org.eclipse.wst.sse.core.internal.SSECorePlugin;
-import org.eclipse.wst.sse.core.modelhandler.IDocumentTypeHandler;
-
-
-/**
- *
- * Clients can make use of IExecutableExtension to handle the optional adapter
- * class and key. Typically, many clients use a typical pattern of providing
- * an adapter class and key in their null argument constructor anyway, so
- * they'd only have to use IExecutableExtension if the factory was for more
- * than one.
- */
-public class PluginContributedFactoryReader {
- // protected final String ATTR_ADAPTERKEY = "adapterKeyClass";
- // //$NON-NLS-1$
- // protected final String ATTR_REGISTERADAPTER = "registerAdapters";
- // //$NON-NLS-1$
- private static PluginContributedFactoryReader reader = null;
-
- public synchronized static PluginContributedFactoryReader getInstance() {
- if (reader == null) {
- reader = new PluginContributedFactoryReader();
- }
- return reader;
- }
-
- protected final String ATTR_CLASS = "class"; //$NON-NLS-1$
- protected final String ATTR_CONTENTTYPE = "contentTypeIdentiferId"; //$NON-NLS-1$
-
- protected final String EXTENSION_POINT_ID = "contentTypeFactoryContribution"; //$NON-NLS-1$
- protected final String TAG_NAME = "factory"; //$NON-NLS-1$
-
- protected PluginContributedFactoryReader() {
- super();
- }
-
- public List getFactories(IDocumentTypeHandler handler) {
- return loadRegistry(handler.getId());
- }
-
- public List getFactories(String type) {
- return loadRegistry(type);
- }
-
- protected AdapterFactory loadFactoryFromConfigurationElement(IConfigurationElement element, Object requesterType) {
- AdapterFactory factory = null;
- if (element.getName().equals(TAG_NAME)) {
- String contentType = element.getAttribute(ATTR_CONTENTTYPE);
- if (!requesterType.equals(contentType))
- return null;
- String className = element.getAttribute(ATTR_CLASS);
- // String adapterKeyClass = element.getAttribute(ATTR_ADAPTERKEY);
- // String registerAdapters =
- // element.getAttribute(ATTR_REGISTERADAPTER);
-
- // if className is null, then no one defined the extension point
- // for adapter factories
- if (className != null) {
- try {
- factory = (AdapterFactory) element.createExecutableExtension(ATTR_CLASS);
- } catch (CoreException e) {
- // if an error occurs here, its probably that the plugin
- // could not be found/loaded
- org.eclipse.wst.sse.core.internal.Logger.logException("Could not find class: " + className, e); //$NON-NLS-1$
- } catch (Exception e) {
- // if an error occurs here, its probably that the plugin
- // could not be found/loaded -- but in any case we just
- // want
- // to log the error and continue running and best we can.
- org.eclipse.wst.sse.core.internal.Logger.logException("Could not find class: " + className, e); //$NON-NLS-1$
- }
- // if (plugin != null) {
- // factory = oldAttributesCode(element, factory, className,
- // plugin);
- //
- }
- }
-
- return factory;
- }
-
- protected List loadRegistry(Object contentType) {
- List factoryList = null; // new Vector();
- IExtensionRegistry extensionRegistry = Platform.getExtensionRegistry();
- IExtensionPoint point = extensionRegistry.getExtensionPoint(SSECorePlugin.ID, EXTENSION_POINT_ID);
- if (point != null) {
- IConfigurationElement[] elements = point.getConfigurationElements();
- if (elements.length > 0) {
- // this is called a lot, so don't create vector unless really
- // needed
- // TODO: could eventually cache in a hashtable, or something,
- // to avoid repeat processing
- factoryList = new Vector();
- for (int i = 0; i < elements.length; i++) {
- AdapterFactory factory = loadFactoryFromConfigurationElement(elements[i], contentType);
- if (factory != null)
- factoryList.add(factory);
- }
- }
- }
- return factoryList;
- }
-}
diff --git a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/parser/ContextRegion.java b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/parser/ContextRegion.java
deleted file mode 100644
index 7fc2641e6f..0000000000
--- a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/parser/ContextRegion.java
+++ /dev/null
@@ -1,242 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Jens Lukowski/Innoopract - initial renaming/restructuring
- *
- *******************************************************************************/
-package org.eclipse.wst.sse.core.internal.parser;
-
-
-
-import org.eclipse.wst.sse.core.events.StructuredDocumentEvent;
-import org.eclipse.wst.sse.core.text.IStructuredDocumentRegion;
-import org.eclipse.wst.sse.core.text.ITextRegion;
-
-
-/**
- * Regions of this class are intended specifically for XML/HTML/JSPs. Other
- * languages may need their own subclasses. (See the updateModel method).
- */
-public class ContextRegion implements ITextRegion {
- protected int fLength;
-
- protected int fStart;
- protected int fTextLength;
- protected String fType;
-
- protected ContextRegion() {
- super();
- }
-
- public ContextRegion(String newContext, int newStart, int newTextLength, int newLength) {
- fType = newContext;
- fStart = newStart;
- fTextLength = newTextLength;
- fLength = newLength;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see com.ibm.sed.structured.text.core.ITextRegionCore#adjust(int)
- */
- public void adjust(int i) {
- fStart += i;
-
- }
-
- /*
- * (non-Javadoc)
- *
- * @see com.ibm.sed.structured.text.core.ITextRegionCore#adjustLengthWith(int)
- */
- public void adjustLengthWith(int i) {
- fLength += i;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see com.ibm.sed.structured.text.core.ITextRegionCore#adjustStart(int)
- */
- public void adjustStart(int i) {
- fStart += i;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see com.ibm.sed.structured.text.ITextRegion#adjustTextLength(int)
- */
- public void adjustTextLength(int i) {
- fTextLength += i;
-
- }
-
- protected boolean allLetterOrDigit(String changes) {
- boolean result = true;
- for (int i = 0; i < changes.length(); i++) {
- // TO_DO_FUTURE: check that a Java Letter or Digit is
- // the same thing as an XML letter or digit
- if (!(Character.isLetterOrDigit(changes.charAt(i)))) {
- result = false;
- break;
- }
- }
- return result;
- }
-
- protected boolean allWhiteSpace(String changes) {
- boolean result = true;
- for (int i = 0; i < changes.length(); i++) {
- if (!Character.isWhitespace(changes.charAt(i))) {
- result = false;
- break;
- }
- }
-
- return result;
- }
-
- protected boolean canHandleAsLetterOrDigit(String changes, int requestStart, int lengthToReplace) {
- boolean result = false;
- // Make sure we are in a non-white space area
- if ((requestStart <= (getTextEnd())) && (allLetterOrDigit(changes))) {
- result = true;
- }
- return result;
- }
-
- protected boolean canHandleAsWhiteSpace(String changes, int requestStart, int lengthToReplace) {
- boolean result = false;
- // if we are in the "white space" area of a region, then
- // we don't want to handle, a reparse is needed.
- // the white space region is consider anywhere that would
- // leave whitespace between this character and the text part.
- // and of course, we can insert whitespace in whitespace region
- //
- // if there is no whitespace in this region, no need to look further
- if (getEnd() > getTextEnd()) {
- // no need to add one to end of text, as we used to, since we
- // change definition of length to equate to offset plus one.
- if (requestStart > getTextEnd()) {
- // ok, we are in the whitespace region, so we can't handle,
- // unless
- // we are just inserting whitespace.
- if (allWhiteSpace(changes)) {
- result = true;
- } else {
- result = false;
- }
-
- }
- }
-
- return result;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see com.ibm.sed.structured.text.core.ITextRegionCore#contains(int)
- */
- public boolean contains(int position) {
-
- return fStart <= position && position < fStart + fLength;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see com.ibm.sed.structured.text.core.ITextRegionCore#equatePositions(com.ibm.sed.structured.text.ITextRegion)
- */
- public void equatePositions(ITextRegion region) {
- fStart = region.getStart();
- fLength = region.getLength();
- fTextLength = region.getTextLength();
- }
-
- /*
- * (non-Javadoc)
- *
- * @see com.ibm.sed.structured.text.ITextRegion#getEnd()
- */
- public int getEnd() {
- return fStart + fLength;
- }
-
- public int getLength() {
- return fLength;
- }
-
- public int getStart() {
- return fStart;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see com.ibm.sed.structured.text.ITextRegion#getTextEnd()
- */
- public int getTextEnd() {
- return fStart + fTextLength;
- }
-
- public int getTextLength() {
- return fTextLength;
- }
-
- public String getType() {
- return fType;
- }
-
- public void setLength(int i) {
- fLength = i;
- }
-
- public void setStart(int i) {
- fStart = i;
- }
-
- public void setTextLength(int i) {
- fTextLength = i;
- }
-
- public void setType(String string) {
- fType = string;
- }
-
- public String toString() {
- String className = getClass().getName();
- String shortClassName = className.substring(className.lastIndexOf(".") + 1); //$NON-NLS-1$
- // ==> // String resultText = null;
- String result = shortClassName + "--> " + getType() + ": " + getStart() + "-" + getTextEnd() + (getTextEnd() != getEnd() ? ("/" + getEnd()) : ""); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
- // NOTE: if the document held by any region has been updated and the
- // region offsets have not
- // yet been updated, the output from this method invalid.
- //return com.ibm.sed.util.StringUtils.escape("('"+(getFirstRegion()
- // == null || document == null? "" :
- // getText(getFirstRegion()))+"'"+getStart()+" -
- // "+getEnd()+"'"+(getClose() == null || document == null ||
- // getRegions().size()<2 ? "" : getText(getClose()))+"')
- // "+getRegions());
- return result;
- }
-
- public StructuredDocumentEvent updateModel(Object requester, IStructuredDocumentRegion parent, String changes, int requestStart, int lengthToReplace) {
- // the four types we used to handle here, have all been moved to
- // specific region classes.
- // XML_TAG_ATTRIBUTE_VALUE
- // XML_TAG_ATTRIBUTE_NAME
- // XML_CONTENT
- // XML_CDATA_TEXT
- return null;
- }
-
-}
diff --git a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/parser/ForeignRegion.java b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/parser/ForeignRegion.java
deleted file mode 100644
index 57233dc18a..0000000000
--- a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/parser/ForeignRegion.java
+++ /dev/null
@@ -1,88 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Jens Lukowski/Innoopract - initial renaming/restructuring
- *
- *******************************************************************************/
-package org.eclipse.wst.sse.core.internal.parser;
-
-
-
-import org.eclipse.wst.sse.core.events.RegionChangedEvent;
-import org.eclipse.wst.sse.core.events.StructuredDocumentEvent;
-import org.eclipse.wst.sse.core.text.IStructuredDocumentRegion;
-
-
-public class ForeignRegion extends ContextRegion {
-
- protected String language = null;
- protected String surroundingTag = null;
-
- /**
- * ForeignRegion constructor comment.
- */
- public ForeignRegion() {
- super();
- }
-
- public ForeignRegion(String newContext, int newStart, int newTextLength, int newLength) {
- super(newContext, newStart, newTextLength, newLength);
- }
-
- public ForeignRegion(String newContext, int newStart, int newTextLength, int newLength, String newLanguage) {
- super(newContext, newStart, newTextLength, newLength);
- setLanguage(newLanguage);
- }
-
- /**
- *
- * @return java.lang.String
- */
- public java.lang.String getLanguage() {
- return language;
- }
-
- /**
- * @return java.lang.String
- */
- public java.lang.String getSurroundingTag() {
- return surroundingTag;
- }
-
- /**
- *
- * @param newLanguage
- * java.lang.String
- */
- public void setLanguage(java.lang.String newLanguage) {
- language = newLanguage;
- }
-
- /**
- * @param newSurroundingTag
- * java.lang.String
- */
- public void setSurroundingTag(java.lang.String newSurroundingTag) {
- surroundingTag = newSurroundingTag;
- }
-
- public String toString() {
- return "FOREIGN: " + super.toString();//$NON-NLS-1$
- }
-
- public StructuredDocumentEvent updateModel(Object requester, IStructuredDocumentRegion flatnode, String changes, int requestStart, int lengthToReplace) {
- org.eclipse.wst.sse.core.events.RegionChangedEvent result = null;
- int lengthDifference = org.eclipse.wst.sse.core.util.Utilities.calculateLengthDifference(changes, lengthToReplace);
- fLength += lengthDifference;
- fTextLength += lengthDifference;
- result = new RegionChangedEvent(flatnode.getParentDocument(), requester, flatnode, this, changes, requestStart, lengthToReplace);
-
- return result;
- }
-}
diff --git a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/text/BasicStructuredDocument.java b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/text/BasicStructuredDocument.java
deleted file mode 100644
index bf8081a999..0000000000
--- a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/text/BasicStructuredDocument.java
+++ /dev/null
@@ -1,2614 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Jens Lukowski/Innoopract - initial renaming/restructuring
- *
- *******************************************************************************/
-package org.eclipse.wst.sse.core.internal.text;
-
-import java.io.Reader;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.jface.text.BadLocationException;
-import org.eclipse.jface.text.BadPartitioningException;
-import org.eclipse.jface.text.BadPositionCategoryException;
-import org.eclipse.jface.text.DefaultLineTracker;
-import org.eclipse.jface.text.DocumentEvent;
-import org.eclipse.jface.text.DocumentPartitioningChangedEvent;
-import org.eclipse.jface.text.FindReplaceDocumentAdapter;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.IDocumentExtension;
-import org.eclipse.jface.text.IDocumentExtension3;
-import org.eclipse.jface.text.IDocumentListener;
-import org.eclipse.jface.text.IDocumentPartitioner;
-import org.eclipse.jface.text.IDocumentPartitionerExtension2;
-import org.eclipse.jface.text.IDocumentPartitioningListener;
-import org.eclipse.jface.text.IDocumentPartitioningListenerExtension;
-import org.eclipse.jface.text.IDocumentPartitioningListenerExtension2;
-import org.eclipse.jface.text.ILineTracker;
-import org.eclipse.jface.text.IPositionUpdater;
-import org.eclipse.jface.text.IRegion;
-import org.eclipse.jface.text.ITextStore;
-import org.eclipse.jface.text.ITypedRegion;
-import org.eclipse.jface.text.Position;
-import org.eclipse.jface.text.SequentialRewriteTextStore;
-import org.eclipse.jface.text.TypedRegion;
-import org.eclipse.wst.common.encoding.EncodingMemento;
-import org.eclipse.wst.sse.core.document.StructuredDocumentFactory;
-import org.eclipse.wst.sse.core.events.AboutToBeChangeEvent;
-import org.eclipse.wst.sse.core.events.IModelAboutToBeChangedListener;
-import org.eclipse.wst.sse.core.events.IStructuredDocumentListener;
-import org.eclipse.wst.sse.core.events.NewDocumentEvent;
-import org.eclipse.wst.sse.core.events.NewModelEvent;
-import org.eclipse.wst.sse.core.events.NoChangeEvent;
-import org.eclipse.wst.sse.core.events.RegionChangedEvent;
-import org.eclipse.wst.sse.core.events.RegionsReplacedEvent;
-import org.eclipse.wst.sse.core.events.StructuredDocumentEvent;
-import org.eclipse.wst.sse.core.events.StructuredDocumentRegionsReplacedEvent;
-import org.eclipse.wst.sse.core.exceptions.SourceEditingRuntimeException;
-import org.eclipse.wst.sse.core.internal.Logger;
-import org.eclipse.wst.sse.core.internal.undo.StructuredTextUndoManager;
-import org.eclipse.wst.sse.core.parser.RegionParser;
-import org.eclipse.wst.sse.core.text.DeleteEqualPositionUpdater;
-import org.eclipse.wst.sse.core.text.IStructuredDocument;
-import org.eclipse.wst.sse.core.text.IStructuredDocumentRegion;
-import org.eclipse.wst.sse.core.text.IStructuredDocumentRegionList;
-import org.eclipse.wst.sse.core.text.IStructuredTextReParser;
-import org.eclipse.wst.sse.core.text.rules.StructuredTextPartitioner;
-import org.eclipse.wst.sse.core.undo.IStructuredTextUndoManager;
-import org.eclipse.wst.sse.core.util.Assert;
-import org.eclipse.wst.sse.core.util.Debug;
-import org.eclipse.wst.sse.core.util.Utilities;
-
-
-/**
- * The standard implementation of structured document.
- */
-public class BasicStructuredDocument implements IStructuredDocument, IDocumentExtension, IDocumentExtension3, CharSequence, IRegionComparible {
-
- /**
- * This ThreadLocal construct is used so each thread can maintain its only
- * pointer to the double linked list that manages the documents regions.
- * The only thing we "gaurd" for is that a previously cached region has
- * been deleted.
- *
- * The object that is kept in the thread local's map, is just a pointer to
- * an array position. That's because the object there needs to be "free"
- * from references to other objects, or it will not be garbage collected.
- */
- private class CurrentDocumentRegionCache {
- // I'm assuming for now there would never be so many threads that
- // this arrayList needs to be bounded, or 'cleaned up'.
- // this assumption should be tested in practice and long running
- // jobs -- found not to be a good assumption. See below.
- private List cachedRegionPositionArray = Collections.synchronizedList(new ArrayList());
- private final boolean DEBUG = false;
- private final int MAX_SIZE = 50;
-
-
- private ThreadLocal threadLocalCachePosition = new ThreadLocal();
-
- IStructuredDocumentRegion get() {
- IStructuredDocumentRegion region = null;
- int pos = getThreadLocalPosition();
- try {
- region = (IStructuredDocumentRegion) cachedRegionPositionArray.get(pos);
- } catch (IndexOutOfBoundsException e) {
- // even though the cachedRegionPosition is synchronized,
- // that just means each access is syncronized, its
- // still possible for another thread to cause it to
- // be cleared, after this thread gets it position.
- // So, if that happens, all we can do is reset to beginning.
- // This should be extremely rare (in other words, probably
- // not worth using synchronized blocks
- // to access cachedRegionPositionArray.
- reinitThreadLocalPosition();
- resetToInitialState();
- }
- if (region == null) {
- region = resetToInitialState();
- } else
- // region not null
- if (region.isDeleted()) {
- region = resetToInitialState();
- }
- return region;
- }
-
- private int getThreadLocalPosition() {
- Object threadLocalObject = threadLocalCachePosition.get();
- int pos = -1;
- if (threadLocalObject == null) {
-
- pos = reinitThreadLocalPosition();
- } else {
- pos = ((Integer) threadLocalObject).intValue();
- }
- return pos;
- }
-
- /**
- * @return
- */
- private int reinitThreadLocalPosition() {
- Integer position;
- int pos;
- // TODO_future: think of a better solution that doesn't
- // require this kludge. This is especially required because
- // some infrasture, such as reconciler, actually null out
- // their thread object and recreate it, 500 msecs later
- // (approximately).
- // Note: the likely solution in future is to clear after every
- // heavy use of getCachedRegion, such as in creating node
- // lists, or reparsing or partioning.
- if (cachedRegionPositionArray.size() > MAX_SIZE) {
- cachedRegionPositionArray.clear();
- if (DEBUG) {
- System.out.println("cachedRegionPositionArray cleared at size " + MAX_SIZE);
- }
- }
- position = new Integer(cachedRegionPositionArray.size());
- threadLocalCachePosition.set(position);
- cachedRegionPositionArray.add(position.intValue(), null);
- pos = position.intValue();
- return pos;
- }
-
- private IStructuredDocumentRegion resetToInitialState() {
- IStructuredDocumentRegion region;
- region = getFirstStructuredDocumentRegion();
- set(region);
- return region;
- }
-
- // TODO: make privite if used, else delete
- void set(int pos, IStructuredDocumentRegion region) {
- cachedRegionPositionArray.set(pos, region);
- }
-
- void set(IStructuredDocumentRegion region) {
- try {
- int pos = getThreadLocalPosition();
- cachedRegionPositionArray.set(pos, region);
- } catch (IndexOutOfBoundsException e) {
- // even though the cachedRegionPosition is synchronized,
- // that just means each access is syncronized, its
- // still possible for another thread to cause it to
- // be cleared, after this thread gets it position.
- // So, if that happens, all we can do is reset to beginning.
- // This should be extremely rare (in other words, probably
- // not worth using synchronized blocks
- // to access cachedRegionPositionArray.
- reinitThreadLocalPosition();
- resetToInitialState();
- }
- }
- }
-
- /**
- * This NullDocumentEvent is used to complete the "aboutToChange" and
- * "changed" cycle, when in fact the original change is no longer valid.
- * The only known (valid) case of this is when a model re-initialize takes
- * place, which causes setText to be called in the middle of some previous
- * change. [This architecture will be improved in future].
- */
- public class NullDocumentEvent extends DocumentEvent {
- public NullDocumentEvent() {
- this(BasicStructuredDocument.this, 0, 0, ""); //$NON-NLS-1$
- }
-
- private NullDocumentEvent(IDocument doc, int offset, int length, String text) {
- super(doc, offset, length, text);
- }
- }
-
- class RegisteredReplace {
- /** The owner of this replace operation. */
- IDocumentListener fOwner;
- /** The replace operation */
- IDocumentExtension.IReplace fReplace;
-
- /**
- * Creates a new bundle object.
- *
- * @param owner
- * the document listener owning the replace operation
- * @param replace
- * the replace operation
- */
- RegisteredReplace(IDocumentListener owner, IDocumentExtension.IReplace replace) {
- fOwner = owner;
- fReplace = replace;
- }
- }
-
- /**
- * these control variable isn't mark as 'final' since there's some unit
- * tests that manipulate it. For final product, it should be.
- */
-
- private static boolean USE_LOCAL_THREAD = true;
-
- /**
- * purely for debugging/performance measurements In practice, would always
- * be 'true'. (and should never be called by called by clients). Its not
- * 'final' or private just so it can be varied during
- * debugging/performance measurement runs.
- *
- * @param use_local_thread
- */
- public static void setUSE_LOCAL_THREAD(final boolean use_local_thread) {
- USE_LOCAL_THREAD = use_local_thread;
- }
-
- private IStructuredDocumentRegion cachedDocumentRegion;
- private EncodingMemento encodingMemento;
- private boolean fAcceptPostNotificationReplaces = true;
- private CurrentDocumentRegionCache fCurrentDocumnetRegionCache;
- private DocumentEvent fDocumentEvent;
- private IDocumentListener[] fDocumentListeners;
-
- /**
- * The registered document partitioners.
- *
- * @since 3.0
- */
- private Map fDocumentPartitioners;
- /** The registered document partitioning listeners */
- private List fDocumentPartitioningListeners;
- private IStructuredDocumentRegion firstDocumentRegion;
- private RegionParser fParser;
- private GenericPositionManager fPositionManager;
- private List fPostNotificationChanges;
- private IDocumentListener[] fPrenotifiedDocumentListeners;
- private int fReentranceCount = 0;
- private IStructuredTextReParser fReParser;
- private int fStoppedCount = 0;
-
- private ITextStore fStore;
- private Object[] fStructuredDocumentAboutToChangeListeners;
- private Object[] fStructuredDocumentChangedListeners;
- private Object[] fStructuredDocumentChangingListeners;
-
- private ILineTracker fTracker;
- private IStructuredTextUndoManager fUndoManager;
- private IStructuredDocumentRegion lastDocumentRegion;
-
- private byte[] listenerLock = new byte[0];
- private NullDocumentEvent NULL_DOCUMENT_EVENT;
-
- //
- /**
- * in case preferred delimiter is not set, we'll assume the platform
- * default Note: it is not final static to make sure it won't be inlined
- * by compiler.
- */
- private final String PlatformLineDelimiter = System.getProperty("line.separator"); //$NON-NLS-1$
- /**
- * theoretically, a document can contain mixed line delimiters
- */
- private String preferedDelimiter;
- private final String READ_ONLY_REGIONS_CATEGORY = "_READ_ONLY_REGIONS_CATEGORY_"; //$NON-NLS-1$
- /**
- * debug variable only
- *
- * @param parser
- */
- private long startStreamTime;
- /**
- * debug variable only
- *
- * @param parser
- */
- private long startTime;
-
- public BasicStructuredDocument() {
- super();
- fCurrentDocumnetRegionCache = new CurrentDocumentRegionCache();
- fStore = new StructuredDocumentTextStore(50, 300);
- setLineTracker(new DefaultLineTracker());
- NULL_DOCUMENT_EVENT = new NullDocumentEvent();
-
- internal_addPositionCategory(READ_ONLY_REGIONS_CATEGORY);
- internal_addPositionUpdater(new DeleteEqualPositionUpdater(READ_ONLY_REGIONS_CATEGORY));
-
- }
-
- /**
- * This is the primary way to get a new structuredDocument. Its best to
- * use the factory methods in ModelManger to create a new
- * IStructuredDocument, since it will get and initialize the parser
- * according to the desired content type.
- */
- public BasicStructuredDocument(RegionParser parser) {
- this();
- Assert.isNotNull(parser, "Program Error: IStructuredDocument can not be created with null parser"); //$NON-NLS-1$
- // go through setter in case there is side effects
- internal_setParser(parser);
- }
-
- private void _clearDocumentEvent() {
- // no hard and fast requirement to null out ... just seems like
- // a good idea, since we are done with it.
- fDocumentEvent = null;
- }
-
- private void _fireDocumentAboutToChange(Object[] listeners) {
- // most DocumentAboutToBeChanged listeners do not anticipate
- // DocumentEvent == null. So make sure documentEvent is not
- // null. (this should never happen, yet it does sometimes)
- if (fDocumentEvent == null) {
- fDocumentEvent = new NullDocumentEvent();
- }
- // we must assign listeners to local variable, since the add and
- // remove
- // listner
- // methods can change the actual instance of the listener array from
- // another thread
- if (listeners != null) {
- Object[] holdListeners = listeners;
- // Note: the docEvent is created in replaceText API
- // fire
- for (int i = 0; i < holdListeners.length; i++) {
- if (Debug.perfTest || Debug.perfTestStructuredDocumentEventOnly) {
- startTime = System.currentTimeMillis();
- }
- // safeguard from listeners that throw exceptions
- try {
- // this is a safe cast, since addListners requires a
- // IStructuredDocumentListener
- ((IDocumentListener) holdListeners[i]).documentAboutToBeChanged(fDocumentEvent);
- } catch (Exception exception) {
- Logger.logException(exception);
- }
- if (Debug.perfTest || Debug.perfTestStructuredDocumentEventOnly) {
- long stopTime = System.currentTimeMillis();
- System.out.println("\n\t\t\t\t IStructuredDocument::fireStructuredDocumentEvent. Time was " + (stopTime - startTime) + " msecs to fire NewModelEvent to instance of " + holdListeners[i].getClass()); //$NON-NLS-2$//$NON-NLS-1$
- }
- }
- }
- }
-
- private void notifyDocumentPartitionersAboutToChange(DocumentEvent documentEvent) {
- if (fDocumentPartitioners != null) {
- Iterator e = fDocumentPartitioners.values().iterator();
- while (e.hasNext()) {
- IDocumentPartitioner p = (IDocumentPartitioner) e.next();
- // safeguard from listeners that throw exceptions
- try {
- p.documentAboutToBeChanged(documentEvent);
- } catch (Exception exception) {
- Logger.logException(exception);
- }
- }
- }
- }
-
- private void _fireDocumentChanged(Object[] listeners, StructuredDocumentEvent event) {
-
- // we must assign listeners to local variable, since the add and
- // remove
- // listner
- // methods can change the actual instance of the listener array from
- // another thread
- if (listeners != null) {
- Object[] holdListeners = listeners;
- // NOTE: document event is created in replace Text API and setText
- // API
- // now fire
- for (int i = 0; i < holdListeners.length; i++) {
- if (Debug.perfTest || Debug.perfTestStructuredDocumentEventOnly) {
- startTime = System.currentTimeMillis();
- }
-
- // safeguard from listeners that throw exceptions
- try {
- // this is a safe cast, since addListners requires a
- // IStructuredDocumentListener
- // Notes: fDocumentEvent can be "suddenly" null, if one of
- // the
- // previous changes
- // caused a "setText" to be called. The only known case of
- // this
- // is a model reset
- // due to page directive changing. Eventually we should
- // change
- // archetecture to have
- // event que and be able to "cancel" pending events, but
- // for
- // now, we'll just pass a
- // NullDocumentEvent. By the way, it is important to send
- // something, since clients might
- // have indeterminant state due to "aboutToChange" being
- // sent
- // earlier.
- if (fDocumentEvent == null) {
- ((IDocumentListener) holdListeners[i]).documentChanged(NULL_DOCUMENT_EVENT);
- } else {
- ((IDocumentListener) holdListeners[i]).documentChanged(fDocumentEvent);
- }
- } catch (Exception exception) {
- Logger.logException(exception);
- }
- if (Debug.perfTest || Debug.perfTestStructuredDocumentEventOnly) {
- long stopTime = System.currentTimeMillis();
- System.out.println("\n\t\t\t\t IStructuredDocument::fireStructuredDocumentEvent. Time was " + (stopTime - startTime) + " msecs to fire NewModelEvent to instance of " + holdListeners[i].getClass()); //$NON-NLS-2$//$NON-NLS-1$
- }
- }
- }
- }
-
- private void notifyDocumentPartitionersDocumentChanged(DocumentEvent documentEvent) {
- if (fDocumentPartitioners != null) {
- Iterator e = fDocumentPartitioners.values().iterator();
- while (e.hasNext()) {
- IDocumentPartitioner p = (IDocumentPartitioner) e.next();
- // safeguard from listeners that throw exceptions
- try {
- p.documentChanged(documentEvent);
- } catch (Exception exception) {
- Logger.logException(exception);
- }
- }
- }
- }
-
- private void _fireEvent(Object[] listeners, NewDocumentEvent event) {
- // we must assign listeners to local variable, since the add and
- // remove
- // listner
- // methods can change the actual instance of the listener array from
- // another thread
- if (listeners != null) {
- Object[] holdListeners = listeners;
- for (int i = 0; i < holdListeners.length; i++) {
- if (Debug.perfTest || Debug.perfTestStructuredDocumentEventOnly) {
- startTime = System.currentTimeMillis();
- }
- // safeguard from listeners that throw exceptions
- try {
- // this is a safe cast, since addListners requires a
- // IStructuredDocumentListener
- ((IStructuredDocumentListener) holdListeners[i]).newModel(event);
- } catch (Exception exception) {
- Logger.logException(exception);
- }
- if (Debug.perfTest || Debug.perfTestStructuredDocumentEventOnly) {
- long stopTime = System.currentTimeMillis();
- System.out.println("\n\t\t\t\t IStructuredDocument::fireStructuredDocumentEvent. Time was " + (stopTime - startTime) + " msecs to fire NewModelEvent to instance of " + holdListeners[i].getClass()); //$NON-NLS-2$//$NON-NLS-1$
- }
- }
- }
- }
-
- private void _fireEvent(Object[] listeners, NoChangeEvent event) {
- // we must assign listeners to local variable, since the add and
- // remove
- // listner
- // methods can change the actual instance of the listener array from
- // another thread
- if (listeners != null) {
- Object[] holdListeners = listeners;
- for (int i = 0; i < holdListeners.length; i++) {
- if (Debug.perfTest || Debug.perfTestStructuredDocumentEventOnly) {
- startTime = System.currentTimeMillis();
- }
- // safeguard from listeners that throw exceptions
- try {
- // this is a safe cast, since addListners requires a
- // IStructuredDocumentListener
- ((IStructuredDocumentListener) holdListeners[i]).noChange(event);
- } catch (Exception exception) {
- Logger.logException(exception);
- }
- if (Debug.perfTest || Debug.perfTestStructuredDocumentEventOnly) {
- long stopTime = System.currentTimeMillis();
- System.out.println("\n\t\t\t\t IStructuredDocument::fireStructuredDocumentEvent. Time was " + (stopTime - startTime) + " msecs to fire NewModelEvent to instance of " + holdListeners[i].getClass()); //$NON-NLS-2$//$NON-NLS-1$
- }
- }
- }
- }
-
- private void _fireEvent(Object[] listeners, RegionChangedEvent event) {
- // we must assign listeners to local variable, since the add and
- // remove
- // listner
- // methods can change the actual instance of the listener array from
- // another thread
- if (listeners != null) {
- Object[] holdListeners = listeners;
- for (int i = 0; i < holdListeners.length; i++) {
- if (Debug.perfTest || Debug.perfTestStructuredDocumentEventOnly) {
- startTime = System.currentTimeMillis();
- }
- // safeguard from listeners that throw exceptions
- try {
- // this is a safe cast, since addListners requires a
- // IStructuredDocumentListener
- ((IStructuredDocumentListener) holdListeners[i]).regionChanged(event);
- } catch (Exception exception) {
- Logger.logException(exception);
- }
- if (Debug.perfTest || Debug.perfTestStructuredDocumentEventOnly) {
- long stopTime = System.currentTimeMillis();
- System.out.println("\n\t\t\t\t IStructuredDocument::fireStructuredDocumentEvent. Time was " + (stopTime - startTime) + " msecs to fire NewModelEvent to instance of " + holdListeners[i].getClass()); //$NON-NLS-2$//$NON-NLS-1$
- }
- }
- }
- }
-
- private void _fireEvent(Object[] listeners, RegionsReplacedEvent event) {
- // we must assign listeners to local variable, since the add and
- // remove
- // listner
- // methods can change the actual instance of the listener array from
- // another thread
- if (listeners != null) {
- Object[] holdListeners = listeners;
- for (int i = 0; i < holdListeners.length; i++) {
- if (Debug.perfTest || Debug.perfTestStructuredDocumentEventOnly) {
- startTime = System.currentTimeMillis();
- }
- // safeguard from listeners that throw exceptions
- try {
- // this is a safe cast, since addListners requires a
- // IStructuredDocumentListener
- ((IStructuredDocumentListener) holdListeners[i]).regionsReplaced(event);
- } catch (Exception exception) {
- Logger.logException(exception);
- }
- if (Debug.perfTest || Debug.perfTestStructuredDocumentEventOnly) {
- long stopTime = System.currentTimeMillis();
- System.out.println("\n\t\t\t\t IStructuredDocument::fireStructuredDocumentEvent. Time was " + (stopTime - startTime) + " msecs to fire NewModelEvent to instance of " + holdListeners[i].getClass()); //$NON-NLS-2$//$NON-NLS-1$
- }
- }
- }
- }
-
- private void _fireEvent(Object[] listeners, StructuredDocumentRegionsReplacedEvent event) {
- // we must assign listeners to local variable, since the add and
- // remove
- // listner
- // methods can change the actual instance of the listener array from
- // another thread
- if (listeners != null) {
- Object[] holdListeners = listeners;
- for (int i = 0; i < holdListeners.length; i++) {
- if (Debug.perfTest || Debug.perfTestStructuredDocumentEventOnly) {
- startTime = System.currentTimeMillis();
- }
- // safeguard from listeners that throw exceptions
- try {
- // this is a safe cast, since addListners requires a
- // IStructuredDocumentListener
- ((IStructuredDocumentListener) holdListeners[i]).nodesReplaced(event);
- } catch (Exception exception) {
- Logger.logException(exception);
- }
- if (Debug.perfTest || Debug.perfTestStructuredDocumentEventOnly) {
- long stopTime = System.currentTimeMillis();
- System.out.println("\n\t\t\t\t IStructuredDocument::fireStructuredDocumentEvent. Time was " + (stopTime - startTime) + " msecs to fire NewModelEvent to instance of " + holdListeners[i].getClass()); //$NON-NLS-2$//$NON-NLS-1$
- }
- }
- }
- }
-
- private void _fireStructuredDocumentAboutToChange(Object[] listeners) {
- // we must assign listeners to local variable, since the add and
- // remove
- // listner
- // methods can change the actual instance of the listener array from
- // another thread
- if (listeners != null) {
- Object[] holdListeners = listeners;
- // Note: the docEvent is created in replaceText API
- // fire
- for (int i = 0; i < holdListeners.length; i++) {
- if (Debug.perfTest || Debug.perfTestStructuredDocumentEventOnly) {
- startTime = System.currentTimeMillis();
- }
- // safeguard from listeners that throw exceptions
- try {
- // notice the AboutToBeChangedEvent is created from the
- // DocumentEvent, since it is (nearly)
- // the same information. ?What to do about
- // originalRequester?
- if (fDocumentEvent == null) {
- fDocumentEvent = new NullDocumentEvent();
- }
- AboutToBeChangeEvent aboutToBeChangedEvent = new AboutToBeChangeEvent(this, null, fDocumentEvent.getText(), fDocumentEvent.getOffset(), fDocumentEvent.getLength());
- // this is a safe cast, since addListners requires a
- // IStructuredDocumentListener
- ((IModelAboutToBeChangedListener) holdListeners[i]).modelAboutToBeChanged(aboutToBeChangedEvent);
- } catch (Exception exception) {
- Logger.logException(exception);
- }
- if (Debug.perfTest || Debug.perfTestStructuredDocumentEventOnly) {
- long stopTime = System.currentTimeMillis();
- System.out.println("\n\t\t\t\t IStructuredDocument::fireStructuredDocumentEvent. Time was " + (stopTime - startTime) + " msecs to fire NewModelEvent to instance of " + holdListeners[i].getClass()); //$NON-NLS-2$//$NON-NLS-1$
- }
- }
- }
- }
-
- protected void acquireLock() {
- // do nothing here in super class
- }
-
- /**
- * addModelAboutToBeChangedListener method comment.
- */
- public void addDocumentAboutToChangeListener(IModelAboutToBeChangedListener listener) {
- synchronized (listenerLock) {
-
- // make sure listener is not already in listening
- // (and if it is, print a warning to aid debugging, if needed)
- if (!Utilities.contains(fStructuredDocumentAboutToChangeListeners, listener)) {
- int oldSize = 0;
- if (fStructuredDocumentAboutToChangeListeners != null) {
- // normally won't be null, but we need to be sure, for
- // first
- // time through
- oldSize = fStructuredDocumentAboutToChangeListeners.length;
- }
- int newSize = oldSize + 1;
- Object[] newListeners = new Object[newSize];
- if (fStructuredDocumentAboutToChangeListeners != null) {
- System.arraycopy(fStructuredDocumentAboutToChangeListeners, 0, newListeners, 0, oldSize);
- }
- // add listener to last position
- newListeners[newSize - 1] = listener;
- //
- // now switch new for old
- fStructuredDocumentAboutToChangeListeners = newListeners;
- //
- }
- }
- }
-
- /**
- * The StructuredDocumentListners and ModelChagnedListeners are very
- * similar. They both receive identical events. The difference is the
- * timing. The "pure" StructuredDocumentListners are notified after the
- * structuredDocument has been changed, but before other, related models
- * may have been changed such as the Structural Model. The Structural
- * model is in fact itself a "pure" StructuredDocumentListner. The
- * ModelChangedListeners can rest assured that all models and data have
- * been updated from the change by the tiem they are notified. This is
- * especially important for the text widget, for example, which may rely
- * on both structuredDocument and structural model information.
- */
- public void addDocumentChangedListener(IStructuredDocumentListener listener) {
- synchronized (listenerLock) {
-
- if (Debug.debugStructuredDocument) {
- System.out.println("IStructuredDocument::addModelChangedListener. Request to add an instance of " + listener.getClass() + " as a listener on structuredDocument."); //$NON-NLS-2$//$NON-NLS-1$
- }
- // make sure listener is not already in listening
- // (and if it is, print a warning to aid debugging, if needed)
- if (Utilities.contains(fStructuredDocumentChangedListeners, listener)) {
- if (Debug.displayWarnings) {
- System.out.println("IStructuredDocument::addModelChangedListener. listener " + listener + " was addeded more than once. "); //$NON-NLS-2$//$NON-NLS-1$
- }
- } else {
- if (Debug.debugStructuredDocument) {
- System.out.println("IStructuredDocument::addModelChangedListener. Adding an instance of " + listener.getClass() + " as a listener on structuredDocument."); //$NON-NLS-2$//$NON-NLS-1$
- }
- int oldSize = 0;
- if (fStructuredDocumentChangedListeners != null) {
- // normally won't be null, but we need to be sure, for
- // first
- // time through
- oldSize = fStructuredDocumentChangedListeners.length;
- }
- int newSize = oldSize + 1;
- Object[] newListeners = new Object[newSize];
- if (fStructuredDocumentChangedListeners != null) {
- System.arraycopy(fStructuredDocumentChangedListeners, 0, newListeners, 0, oldSize);
- }
- // add listener to last position
- newListeners[newSize - 1] = listener;
- //
- // now switch new for old
- fStructuredDocumentChangedListeners = newListeners;
- //
- // when a listener is added,
- // send the new model event to that one particular listener,
- // so it
- // can initialize itself with the current state of the model
- // listener.newModel(new NewModelEvent(this, listener));
- }
- }
- }
-
- public void addDocumentChangingListener(IStructuredDocumentListener listener) {
- synchronized (listenerLock) {
-
- if (Debug.debugStructuredDocument) {
- System.out.println("IStructuredDocument::addStructuredDocumentListener. Request to add an instance of " + listener.getClass() + " as a listener on structuredDocument."); //$NON-NLS-2$//$NON-NLS-1$
- }
- // make sure listener is not already in listening
- // (and if it is, print a warning to aid debugging, if needed)
- if (Utilities.contains(fStructuredDocumentChangingListeners, listener)) {
- if (Debug.displayWarnings) {
- System.out.println("IStructuredDocument::addStructuredDocumentListener. listener " + listener + " was addeded more than once. "); //$NON-NLS-2$//$NON-NLS-1$
- }
- } else {
- if (Debug.debugStructuredDocument) {
- System.out.println("IStructuredDocument::addStructuredDocumentListener. Adding an instance of " + listener.getClass() + " as a listener on structuredDocument."); //$NON-NLS-2$//$NON-NLS-1$
- }
- int oldSize = 0;
- if (fStructuredDocumentChangingListeners != null) {
- // normally won't be null, but we need to be sure, for
- // first
- // time through
- oldSize = fStructuredDocumentChangingListeners.length;
- }
- int newSize = oldSize + 1;
- Object[] newListeners = new Object[newSize];
- if (fStructuredDocumentChangingListeners != null) {
- System.arraycopy(fStructuredDocumentChangingListeners, 0, newListeners, 0, oldSize);
- }
- // add listener to last position
- newListeners[newSize - 1] = listener;
- //
- // now switch new for old
- fStructuredDocumentChangingListeners = newListeners;
- //
- // when a listener is added,
- // send the new model event to that one particular listener,
- // so it
- // can initialize itself with the current state of the model
- // listener.newModel(new NewModelEvent(this, listener));
- }
- }
- }
-
- /**
- * We manage our own document listners, instead of delegating to our
- * parentDocument, so we can fire at very end (and not when the
- * parentDocument changes).
- *
- */
- public void addDocumentListener(IDocumentListener listener) {
- synchronized (listenerLock) {
-
- // make sure listener is not already in listening
- // (and if it is, print a warning to aid debugging, if needed)
- if (!Utilities.contains(fDocumentListeners, listener)) {
- int oldSize = 0;
- if (fDocumentListeners != null) {
- // normally won't be null, but we need to be sure, for
- // first
- // time through
- oldSize = fDocumentListeners.length;
- }
- int newSize = oldSize + 1;
- IDocumentListener[] newListeners = null;
- newListeners = new IDocumentListener[newSize];
- if (fDocumentListeners != null) {
- System.arraycopy(fDocumentListeners, 0, newListeners, 0, oldSize);
- }
- // add listener to last position
- newListeners[newSize - 1] = listener;
- // now switch new for old
- fDocumentListeners = newListeners;
- }
- }
- }
-
- /*
- * @see org.eclipse.jface.text.IDocument#addDocumentPartitioningListener(org.eclipse.jface.text.IDocumentPartitioningListener)
- *
- * Registers the document partitioning listener with the document. After
- * registration the IDocumentPartitioningListener is informed about each
- * partition change cause by a document manipulation. If a document
- * partitioning listener is also a document listener, the following
- * notification sequence is guaranteed if a document manipulation changes
- * the document partitioning: 1)
- * listener.documentAboutToBeChanged(DocumentEvent); 2)
- * listener.documentPartitioningChanged(); 3)
- * listener.documentChanged(DocumentEvent); If the listener is already
- * registered nothing happens.
- *
- * @see IDocumentPartitioningListener
- */
-
- public void addDocumentPartitioningListener(IDocumentPartitioningListener listener) {
- synchronized (listenerLock) {
-
- Assert.isNotNull(listener);
- if (fDocumentPartitioningListeners == null) {
- fDocumentPartitioningListeners = new ArrayList(1);
- }
- if (!fDocumentPartitioningListeners.contains(listener))
- fDocumentPartitioningListeners.add(listener);
- }
- }
-
- /**
- * Adds the position to the document's default position category. The
- * default category must be specified by the implementer. A position that
- * has been added to a position category is updated at each change applied
- * to the document.
- *
- * @exception BadLocationException
- * If position is not a valid range in the document
- */
- public void addPosition(Position position) throws BadLocationException {
- getPositionManager().addPosition(position);
- }
-
- /**
- * @see IDocument#addPosition
- * @exception BadLocationException
- * If position is not a valid range in the document
- * @exception BadPositionCategoryException
- * If the category is not defined for the document
- */
- public void addPosition(String category, Position position) throws BadLocationException, BadPositionCategoryException {
- getPositionManager().addPosition(category, position);
- }
-
- /**
- * @see IDocument#addPositionCategory
- */
- public void addPositionCategory(String category) {
- internal_addPositionCategory(category);
- }
-
- /**
- * @see IDocument#addPositionUpdater
- */
- public void addPositionUpdater(IPositionUpdater updater) {
- internal_addPositionUpdater(updater);
- }
-
- /**
- * Adds the given document listener as one which is notified before those
- * document listeners added with <code>addDocumentListener</code> are
- * notified. If the given listener is also registered using
- * <code>addDocumentListener</code> it will be notified twice. If the
- * listener is already registered nothing happens.
- * <p>
- *
- * This method is not for public use, it may only be called by
- * implementers of <code>IDocumentAdapter</code> and only if those
- * implementers need to implement <code>IDocumentListener</code>.
- *
- * @param documentAdapter
- * the listener to be added as prenotified document listener
- */
- public void addPrenotifiedDocumentListener(IDocumentListener documentAdapter) {
- synchronized (listenerLock) {
-
- if (fPrenotifiedDocumentListeners != null) {
- int previousSize = fPrenotifiedDocumentListeners.length;
- IDocumentListener[] listeners = new IDocumentListener[previousSize + 1];
- System.arraycopy(fPrenotifiedDocumentListeners, 0, listeners, 0, previousSize);
- listeners[previousSize] = documentAdapter;
- fPrenotifiedDocumentListeners = listeners;
- } else {
- fPrenotifiedDocumentListeners = new IDocumentListener[1];
- fPrenotifiedDocumentListeners[0] = documentAdapter;
- }
- }
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.lang.CharSequence#charAt(int)
- */
- public char charAt(int arg0) {
- try {
- return getChar(0);
- } catch (BadLocationException e) {
- throw new IndexOutOfBoundsException();
- }
- }
-
- /**
- * This form of the API removes all read only positions, as should be done
- * we 'setText' is called. Note: an alternative algorithm may simply
- * remove the category (and it would get added back in later, if/when
- * readonly regions added.
- */
- private void clearReadOnly() {
- Position[] positions = null;
- try {
- positions = getPositions(READ_ONLY_REGIONS_CATEGORY);
- } catch (BadPositionCategoryException e) {
- Logger.logException("program error: should never occur", e); //$NON-NLS-1$
- }
- for (int i = 0; i < positions.length; i++) {
- Position position = positions[i];
- // note we don't fire the "about to change" or "changed" events,
- // since presumably, text is all going away and being replaced
- // anyway.
- position.delete();
- }
- }
-
- /*
- * (non-Javadoc)
- *
- * @see com.ibm.sed.structured.text.IStructuredDocument#clearReadOnly(int,
- * int)
- */
- public void clearReadOnly(int startOffset, int length) {
- // TODO DW I still need to implement smarter algorithm that
- // adust existing RO regions, if needed. For now, I'll just
- // remove any that overlap.
- try {
- Position[] positions = getPositions(READ_ONLY_REGIONS_CATEGORY);
- for (int i = 0; i < positions.length; i++) {
- Position position = positions[i];
- if (position.overlapsWith(startOffset, length)) {
- String effectedText = this.get(startOffset, length);
- // fDocumentEvent = new DocumentEvent(this, startOffset,
- // length, effectedText);
- fireReadOnlyAboutToBeChanged();
- position.delete();
- NoChangeEvent noChangeEvent = new NoChangeEvent(this, null, effectedText, startOffset, length);
- noChangeEvent.reason = NoChangeEvent.READ_ONLY_STATE_CHANGE;
- fireReadOnlyStructuredDocumentEvent(noChangeEvent);
- }
- }
- } catch (BadPositionCategoryException e) {
- // just means no readonly regions been defined yet
- // so nothing to do.
- }
- }
-
- /**
- * Computes the index at which a <code>Position</code> with the
- * specified offset would be inserted into the given category. As the
- * ordering inside a category only depends on the offset, the index must
- * be choosen to be the first of all positions with the same offset.
- *
- * @param category
- * the category in which would be added
- * @param offset
- * the position offset to be considered
- * @return the index into the category
- * @exception BadLocationException
- * if offset is invalid in this document
- * @exception BadPositionCategoryException
- * if category is undefined in this document
- */
- public int computeIndexInCategory(String category, int offset) throws org.eclipse.jface.text.BadPositionCategoryException, org.eclipse.jface.text.BadLocationException {
- return getPositionManager().computeIndexInCategory(category, offset);
- }
-
- /**
- * Computes the number of lines in the given text. For a given implementer
- * of this interface this method returns the same result as
- * <code>set(text); getNumberOfLines()</code>.
- *
- * @param text
- * the text whose number of lines should be computed
- * @return the number of lines in the given text
- */
- public int computeNumberOfLines(String text) {
- return getTracker().computeNumberOfLines(text);
- }
-
- /**
- * Computes the partitioning of the given document range using the
- * document's partitioner.
- *
- * @param offset
- * the document offset at which the range starts
- * @param length
- * the length of the document range
- * @return a specification of the range's partitioning
- * @throws BadLocationException
- * @throws BadPartitioningException
- */
- public ITypedRegion[] computePartitioning(int offset, int length) throws BadLocationException {
- ITypedRegion[] typedRegions = null;
- try {
- typedRegions = computePartitioning(IStructuredDocument.DEFAULT_STRUCTURED_PARTITIONING, offset, length, false);
- } catch (BadPartitioningException e) {
- // impossible in this context
- throw new Error(e);
- }
- if (typedRegions == null) {
- typedRegions = new ITypedRegion[0];
- }
- return typedRegions;
- }
-
- /*
- * @see org.eclipse.jface.text.IDocumentExtension3#computeZeroLengthPartitioning(java.lang.String,
- * int, int)
- * @since 3.0
- */
- public ITypedRegion[] computePartitioning(String partitioning, int offset, int length, boolean includeZeroLengthPartitions) throws BadLocationException, BadPartitioningException {
- if ((0 > offset) || (0 > length) || (offset + length > getLength()))
- throw new BadLocationException();
-
- IDocumentPartitioner partitioner = getDocumentPartitioner(partitioning);
-
- if (partitioner instanceof IDocumentPartitionerExtension2)
- return ((IDocumentPartitionerExtension2) partitioner).computePartitioning(offset, length, includeZeroLengthPartitions);
- else if (partitioner != null)
- return partitioner.computePartitioning(offset, length);
- else if (IStructuredDocument.DEFAULT_STRUCTURED_PARTITIONING.equals(partitioning))
- return new TypedRegion[]{new TypedRegion(offset, length, DEFAULT_CONTENT_TYPE)};
- else
- throw new BadPartitioningException();
- }
-
- /**
- * @see IDocument#containsPosition
- */
- public boolean containsPosition(String category, int offset, int length) {
- return getPositionManager().containsPosition(category, offset, length);
- }
-
- /**
- * @see IDocument#containsPositionCategory
- */
- public boolean containsPositionCategory(String category) {
- return getPositionManager().containsPositionCategory(category);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see com.ibm.sed.structured.text.IStructuredDocument#containsReadOnly(int,
- * int)
- */
- public boolean containsReadOnly(int startOffset, int length) {
- boolean result = false;
- try {
- Position[] positions = getPositions(READ_ONLY_REGIONS_CATEGORY);
- for (int i = 0; i < positions.length; i++) {
- Position position = positions[i];
- if (position.overlapsWith(startOffset, length)) {
- result = true;
- break;
- }
- }
- } catch (BadPositionCategoryException e) {
- // just means no readonly regions been defined yet
- // so obviously false
- result = false;
- }
- return result;
- }
-
- private void executePostNotificationChanges() {
- if (fStoppedCount > 0)
- return;
- while (fPostNotificationChanges != null) {
- List changes = fPostNotificationChanges;
- fPostNotificationChanges = null;
- Iterator e = changes.iterator();
- while (e.hasNext()) {
- RegisteredReplace replace = (RegisteredReplace) e.next();
- replace.fReplace.perform(this, replace.fOwner);
- }
- }
- }
-
- private void fireDocumentAboutToChanged() {
- // most DocumentAboutToBeChanged listeners do not anticipate
- // DocumentEvent == null. So make sure documentEvent is not
- // null. (this should never happen, yet it does sometimes)
- if (fDocumentEvent == null) {
- fDocumentEvent = new NullDocumentEvent();
- }
-
- _fireStructuredDocumentAboutToChange(fStructuredDocumentAboutToChangeListeners);
- // Note: the docEvent is created in replaceText API! (or set Text)
- _fireDocumentAboutToChange(fPrenotifiedDocumentListeners);
- notifyDocumentPartitionersAboutToChange(fDocumentEvent);
- _fireDocumentAboutToChange(fDocumentListeners);
- }
-
- /**
- * Fires the document partitioning changed notification to all registered
- * document partitioning listeners. Uses a robust iterator.
- *
- * @param event
- * the document partitioning changed event
- *
- * @see IDocumentPartitioningListenerExtension2
- * @since 3.0
- */
- protected void fireDocumentPartitioningChanged(DocumentPartitioningChangedEvent event) {
- if (fDocumentPartitioningListeners == null || fDocumentPartitioningListeners.size() == 0)
- return;
-
- List list = new ArrayList(fDocumentPartitioningListeners);
- Iterator e = list.iterator();
- while (e.hasNext()) {
- IDocumentPartitioningListener l = (IDocumentPartitioningListener) e.next();
- if (l instanceof IDocumentPartitioningListenerExtension2) {
- IDocumentPartitioningListenerExtension2 extension2 = (IDocumentPartitioningListenerExtension2) l;
- extension2.documentPartitioningChanged(event);
- } else if (l instanceof IDocumentPartitioningListenerExtension) {
- IDocumentPartitioningListenerExtension extension = (IDocumentPartitioningListenerExtension) l;
- extension.documentPartitioningChanged(this, event.getCoverage());
- } else {
- l.documentPartitioningChanged(this);
- }
- }
-
- }
-
- private void fireReadOnlyAboutToBeChanged() {
- _fireStructuredDocumentAboutToChange(fStructuredDocumentAboutToChangeListeners);
- // Note: the docEvent is created in replaceText API! (or set Text)
- // _fireDocumentAboutToChange(fPrenotifiedDocumentListeners);
- // _fireDocumentAboutToChange(fDocumentListeners);
- }
-
- private void fireReadOnlyStructuredDocumentEvent(NoChangeEvent event) {
- _fireEvent(fStructuredDocumentChangingListeners, event);
- _fireEvent(fStructuredDocumentChangedListeners, event);
- // _fireDocumentChanged(fPrenotifiedDocumentListeners, event);
- // _fireDocumentChanged(fDocumentListeners, event);
- // _clearDocumentEvent();
- }
-
- private void fireStructuredDocumentEvent(NewDocumentEvent event) {
- _fireEvent(fStructuredDocumentChangingListeners, event);
- _fireEvent(fStructuredDocumentChangedListeners, event);
- _fireDocumentChanged(fPrenotifiedDocumentListeners, event);
- notifyDocumentPartitionersDocumentChanged(event);
- _fireDocumentChanged(fDocumentListeners, event);
- _clearDocumentEvent();
- }
-
- private void fireStructuredDocumentEvent(NoChangeEvent event) {
- _fireEvent(fStructuredDocumentChangingListeners, event);
- _fireEvent(fStructuredDocumentChangedListeners, event);
- _fireDocumentChanged(fPrenotifiedDocumentListeners, event);
- notifyDocumentPartitionersDocumentChanged(event);
- _fireDocumentChanged(fDocumentListeners, event);
- _clearDocumentEvent();
- }
-
- private void fireStructuredDocumentEvent(RegionChangedEvent event) {
- _fireEvent(fStructuredDocumentChangingListeners, event);
- _fireEvent(fStructuredDocumentChangedListeners, event);
- _fireDocumentChanged(fPrenotifiedDocumentListeners, event);
- notifyDocumentPartitionersDocumentChanged(event);
- _fireDocumentChanged(fDocumentListeners, event);
- _clearDocumentEvent();
- }
-
- private void fireStructuredDocumentEvent(RegionsReplacedEvent event) {
- _fireEvent(fStructuredDocumentChangingListeners, event);
- _fireEvent(fStructuredDocumentChangedListeners, event);
- _fireDocumentChanged(fPrenotifiedDocumentListeners, event);
- notifyDocumentPartitionersDocumentChanged(event);
- _fireDocumentChanged(fDocumentListeners, event);
- _clearDocumentEvent();
- }
-
- private void fireStructuredDocumentEvent(StructuredDocumentRegionsReplacedEvent event) {
- _fireEvent(fStructuredDocumentChangingListeners, event);
- _fireEvent(fStructuredDocumentChangedListeners, event);
- _fireDocumentChanged(fPrenotifiedDocumentListeners, event);
- notifyDocumentPartitionersDocumentChanged(event);
- _fireDocumentChanged(fDocumentListeners, event);
- _clearDocumentEvent();
- }
-
- /**
- * Returns the document's complete text.
- */
- public String get() {
- return getStore().get(0, getLength());
- }
-
- /**
- * Returns length characters from the document's text starting from the
- * specified position.
- *
- * @throws BadLocationException
- *
- * @exception BadLocationException
- * If the range is not valid in the document
- */
- public String get(int offset, int length) {
- String result = null;
- int myLength = getLength();
- if (0 > offset)
- offset = 0;
- if (0 > length)
- length = 0;
- if (offset + length > myLength) {
- // first try adjusting length to fit
- int lessLength = myLength - offset;
- if ((lessLength >= 0) && (offset + lessLength == myLength)) {
- length = lessLength;
- } else {
- // second, try offset
- int moreOffset = myLength - length;
- if ((moreOffset >= 0) && (moreOffset + length == myLength)) {
- offset = moreOffset;
- } else {
- // should never happen
- throw new Error();
- }
- }
-
- }
- // if ((0 > offset) || (0 > length) || (offset + length > myLength))
- // throw new BadLocationException();
- result = getStore().get(offset, length);
- return result;
- }
-
- public Object getAdapter(Class adapter) {
- return Platform.getAdapterManager().getAdapter(this, adapter);
- }
-
- /**
- * @return com.ibm.sed.structuredDocument.core.IStructuredDocumentRegion
- */
- IStructuredDocumentRegion getCachedDocumentRegion() {
- IStructuredDocumentRegion result = null;
- if (USE_LOCAL_THREAD) {
- result = fCurrentDocumnetRegionCache.get();
- } else {
- result = cachedDocumentRegion;
- }
- return result;
- }
-
- /**
- * @see IDocument#getChar
- * @exception BadLocationException
- * If position is not a valid range in the document
- */
- public char getChar(int pos) throws BadLocationException {
- char result = 0x00;
- try {
- result = getStore().get(pos);
- } catch (IndexOutOfBoundsException e) {
- throw new BadLocationException(e.getLocalizedMessage());
- }
- return result;
- }
-
- /**
- * Returns the type of the document partition containing the given
- * character position.
- */
- public String getContentType(int offset) throws BadLocationException {
- return getDocumentPartitioner().getContentType(offset);
- }
-
- /*
- * @see org.eclipse.jface.text.IDocumentExtension3#getZeroLengthContentType(java.lang.String,
- * int)
- * @since 3.0
- */
- public String getContentType(String partitioning, int offset, boolean preferOpenPartitions) throws BadLocationException, BadPartitioningException {
- if ((0 > offset) || (offset > getLength()))
- throw new BadLocationException();
-
- IDocumentPartitioner partitioner = getDocumentPartitioner(partitioning);
-
- if (partitioner instanceof IDocumentPartitionerExtension2)
- return ((IDocumentPartitionerExtension2) partitioner).getContentType(offset, preferOpenPartitions);
- else if (partitioner != null)
- return partitioner.getContentType(offset);
- else if (IStructuredDocument.DEFAULT_STRUCTURED_PARTITIONING.equals(partitioning))
- return DEFAULT_CONTENT_TYPE;
- else
- throw new BadPartitioningException();
- }
-
- /**
- * Returns the document's partitioner.
- *
- * @see IDocumentPartitioner
- */
- public IDocumentPartitioner getDocumentPartitioner() {
- return getDocumentPartitioner(IDocumentExtension3.DEFAULT_PARTITIONING);
- }
-
- /*
- * @see org.eclipse.jface.text.IDocumentExtension3#getDocumentPartitioner(java.lang.String)
- * @since 3.0
- */
- public IDocumentPartitioner getDocumentPartitioner(String partitioning) {
-
- IDocumentPartitioner documentPartitioner = null;
- if (fDocumentPartitioners != null) {
- documentPartitioner = (IDocumentPartitioner) fDocumentPartitioners.get(partitioning);
- }
- return documentPartitioner;
- }
-
- /**
- * @see com.ibm.sed.structuredDocument.IStructuredDocument#getEncodingMemento()
- */
- public EncodingMemento getEncodingMemento() {
- return encodingMemento;
- }
-
- public IStructuredDocumentRegion getFirstStructuredDocumentRegion() {
- // should we update cachedNode?
- // We should to keep consistent philosophy of remembering last
- // requested position,
- // for efficiency.
- setCachedDocumentRegion(firstDocumentRegion);
- return firstDocumentRegion;
- }
-
- public IStructuredDocumentRegion getLastStructuredDocumentRegion() {
- // should we update cachedNode?
- // We should to keep consistent philosophy of remembering last
- // requested position,
- // for efficiency.
- setCachedDocumentRegion(lastDocumentRegion);
- return lastDocumentRegion;
- }
-
- /*
- * -------------------------- partitions
- * ----------------------------------
- */
- public String[] getLegalContentTypes() {
- String[] result = null;
- try {
- result = getLegalContentTypes(IStructuredDocument.DEFAULT_STRUCTURED_PARTITIONING);
- } catch (BadPartitioningException e) {
- // impossible in this context
- throw new Error(e);
- }
- return result;
- }
-
- /*
- * @see org.eclipse.jface.text.IDocumentExtension3#getLegalContentTypes(java.lang.String)
- * @since 3.0
- */
- public String[] getLegalContentTypes(String partitioning) throws BadPartitioningException {
- IDocumentPartitioner partitioner = getDocumentPartitioner(partitioning);
- if (partitioner != null)
- return partitioner.getLegalContentTypes();
- if (IStructuredDocument.DEFAULT_STRUCTURED_PARTITIONING.equals(partitioning))
- return new String[]{DEFAULT_CONTENT_TYPE};
- throw new BadPartitioningException();
- }
-
- /*
- * ------------------ line delimiter conversion
- * ---------------------------
- */
- public String[] getLegalLineDelimiters() {
- return getTracker().getLegalLineDelimiters();
- }
-
- /**
- * @see IDocument#getLength
- */
- public int getLength() {
- return getStore().getLength();
- }
-
- public String getLineDelimiter() {
- if (preferedDelimiter == null) {
- preferedDelimiter = PlatformLineDelimiter;
- }
- return preferedDelimiter;
- }
-
- /**
- * Returns the line delimiter of that line
- *
- * @exception BadLocationException
- * If the line number is invalid in the document
- */
- public String getLineDelimiter(int line) throws org.eclipse.jface.text.BadLocationException {
- return getTracker().getLineDelimiter(line);
- }
-
- /**
- * Returns a description of the specified line. The line is described by
- * its offset and its length excluding the line's delimiter.
- *
- * @param line
- * the line of interest
- * @return a line description
- * @exception BadLocationException
- * if the line number is invalid in this document
- */
- public org.eclipse.jface.text.IRegion getLineInformation(int line) throws org.eclipse.jface.text.BadLocationException {
- return getTracker().getLineInformation(line);
- }
-
- /**
- * Returns a description of the line at the given offset. The description
- * contains the offset and the length of the line excluding the line's
- * delimiter.
- *
- * @param offset
- * the offset whose line should be described
- * @return a region describing the line
- * @exception BadLocationException
- * if offset is invalid in this document
- */
- public org.eclipse.jface.text.IRegion getLineInformationOfOffset(int offset) throws org.eclipse.jface.text.BadLocationException {
- return getTracker().getLineInformationOfOffset(offset);
- }
-
- /*
- * ---------------------- line information
- * --------------------------------
- */
- public int getLineLength(int line) throws org.eclipse.jface.text.BadLocationException {
- return getTracker().getLineLength(line);
- }
-
- /**
- * Determines the offset of the first character of the given line.
- *
- * @param line
- * the line of interest
- * @return the document offset
- * @exception BadLocationException
- * if the line number is invalid in this document
- */
- public int getLineOffset(int line) throws org.eclipse.jface.text.BadLocationException {
- return getTracker().getLineOffset(line);
- }
-
- public int getLineOfOffset(int offset) {
- int result = -1;
- try {
- result = getTracker().getLineNumberOfOffset(offset);
- } catch (BadLocationException e) {
- Logger.traceException("IStructuredDocument", "Dev. Program Info Only: IStructuredDocument::getLineOfOffset: offset out of range, zero assumed. offset = " + offset, e); //$NON-NLS-1$ //$NON-NLS-2$
- result = 0;
- }
- return result;
- }
-
- /**
- * Returns the number of lines in this document
- *
- * @return the number of lines in this document
- */
- public int getNumberOfLines() {
- return getTracker().getNumberOfLines();
- }
-
- /**
- * Returns the number of lines which are occupied by a given text range.
- *
- * @param offset
- * the offset of the specified text range
- * @param length
- * the length of the specified text range
- * @return the number of lines occupied by the specified range
- * @exception BadLocationException
- * if specified range is invalid in this tracker
- */
- public int getNumberOfLines(int offset, int length) throws org.eclipse.jface.text.BadLocationException {
- return getTracker().getNumberOfLines(offset, length);
- }
-
- /**
- * This is public, for use by tag lib classes.
- */
- public RegionParser getParser() {
- if (fParser == null) {
- throw new SourceEditingRuntimeException("IStructuredDocument::getParser. Parser needs to be set before use"); //$NON-NLS-1$
- // fParser = getParserFactory().createParser(fType);
- // System.out.println("Information:
- // IStructuredDocument::getParser.
- // XML Parser assumed.");
- // fParser = new XMLSourceParser();
- }
- return fParser;
- }
-
- /**
- * Returns the document partition in which the position is located. The
- * partition is specified as typed region.
- */
- public ITypedRegion getPartition(int offset) throws BadLocationException {
- ITypedRegion partition = null;
- try {
- partition = getPartition(IStructuredDocument.DEFAULT_STRUCTURED_PARTITIONING, offset, false);
- } catch (BadPartitioningException e) {
- throw new Error(e);
- }
- if (partition == null) {
- throw new Error();
- }
- return partition;
- }
-
- /*
- * @see org.eclipse.jface.text.IDocumentExtension3#getZeroLengthPartition(java.lang.String,
- * int)
- * @since 3.0
- */
- public ITypedRegion getPartition(String partitioning, int offset, boolean preferOpenPartitions) throws BadLocationException, BadPartitioningException {
- if ((0 > offset) || (offset > getLength()))
- throw new BadLocationException();
- ITypedRegion result = null;
-
- IDocumentPartitioner partitioner = getDocumentPartitioner(partitioning);
-
- if (partitioner instanceof IDocumentPartitionerExtension2) {
- result = ((IDocumentPartitionerExtension2) partitioner).getPartition(offset, preferOpenPartitions);
- } else if (partitioner != null) {
- result = partitioner.getPartition(offset);
- } else if (IStructuredDocument.DEFAULT_STRUCTURED_PARTITIONING.equals(partitioning)) {
- result = new TypedRegion(0, getLength(), DEFAULT_CONTENT_TYPE);
- } else
- throw new BadPartitioningException();
- return result;
- }
-
-
- /*
- * @see org.eclipse.jface.text.IDocumentExtension3#getPartitionings()
- * @since 3.0
- */
- public String[] getPartitionings() {
- if (fDocumentPartitioners == null)
- return new String[0];
- String[] partitionings = new String[fDocumentPartitioners.size()];
- fDocumentPartitioners.keySet().toArray(partitionings);
- return partitionings;
- }
-
- /**
- * Returns all position categories added to this document.
- */
- public String[] getPositionCategories() {
- return getPositionManager().getPositionCategories();
- }
-
- /**
- * @return Returns the positionManager.
- */
- private GenericPositionManager getPositionManager() {
- if (fPositionManager == null) {
- fPositionManager = new GenericPositionManager(this);
- }
- return fPositionManager;
- }
-
- /**
- * Returns all Positions of the given position category.
- *
- * @exception BadPositionCategoryException
- * If category is not defined for the document
- */
- public Position[] getPositions(String category) throws org.eclipse.jface.text.BadPositionCategoryException {
- return getPositionManager().getPositions(category);
- }
-
- /**
- * @see IDocument#getPositionUpdaters
- */
- public IPositionUpdater[] getPositionUpdaters() {
- return getPositionManager().getPositionUpdaters();
- }
-
- /**
- * This method can return null, which is the case if the offset is just
- * before or just after the existing text. Compare with
- * getNodeAtCharacterOffset.
- */
- public IStructuredDocumentRegion getRegionAtCharacterOffset(int offset) {
- IStructuredDocumentRegion result = null;
-
- // FIXME: need to synch on 'cachedRegion' (but since that's a
- // constantly changing object, we
- // can't, so need to add a "region_lock" object, and use it here, and
- // in re-parser.
- // Oh, and need to make sure, after synch, that the region is not
- // deleted, and if so, I guess go back
- // to the beginning!
-
- // cached node can be null when document is empty
- IStructuredDocumentRegion potentialCachedRegion = getCachedDocumentRegion();
- if (potentialCachedRegion != null) {
-
- //
-
- // if we already have the right node, return that.
- if (potentialCachedRegion.containsOffset(offset)) {
- result = potentialCachedRegion;
- } else {
- // first, find out what direction to go, relative to
- // cachedNode.
- // negative means "towards the front" of the file,
- // postitive
- // means
- // towards the end.
- int direction = offset - potentialCachedRegion.getStart();
- if (direction < 0) {
- // search towards beginning
- while (!potentialCachedRegion.containsOffset(offset)) {
- IStructuredDocumentRegion tempNode = potentialCachedRegion.getPrevious();
- if (tempNode == null) {
- break;
- } else {
- potentialCachedRegion = tempNode;
- }
- }
- } else {
- // search towards end
- // There is a legitamat condition where the
- // offset will not be contained in any node,
- // which is if the offset is just past the last
- // character of text.
- // And, we must gaurd against setting cachedNode to
- // null!
- while (!potentialCachedRegion.containsOffset(offset)) {
- IStructuredDocumentRegion tempNode = potentialCachedRegion.getNext();
- if (tempNode == null)
- break;
- else
- potentialCachedRegion = tempNode;
- }
- }
- }
- result = potentialCachedRegion;
- }
- // just to be doubly sure we never assign null to an already valid
- // cachedRegion.
- // I believe any time 'result' is null at this point, that just means
- // we have an
- // empty document, and the cachedRegion is already null, but we check
- // and print
- // warning, just so during development we be sure we never accidently
- // break this assumption.
- if (result != null)
- setCachedDocumentRegion(result);
- else if (getCachedDocumentRegion() != null) {
- throw new IllegalStateException("Program Error: no region could be found to cache, but cache was non null. Indicates corrupted model or region list"); //$NON-NLS-1$
- }
-
- return result;
- }
-
- public IStructuredDocumentRegionList getRegionList() {
- CoreNodeList result = null;
- if (getCachedDocumentRegion() == null)
- result = new CoreNodeList(null);
- else
- result = new CoreNodeList(getFirstStructuredDocumentRegion());
-
- return result;
- }
-
- /**
- * was made public for easier testing. Normally should never be used by
- * client codes.
- */
- public IStructuredTextReParser getReParser() {
- if (fReParser == null) {
- fReParser = new StructuredDocumentReParser();
- fReParser.setStructuredDocument(this);
- }
- return fReParser;
- }
-
- private ITextStore getStore() {
- Assert.isNotNull(fStore);
- return fStore;
- }
-
- public String getText() {
- String result = get();
- return result;
- }
-
- /**
- * Returns the document's line tracker. Assumes that the document has been
- * initialized with a line tracker.
- *
- * @return the document's line tracker
- */
- private ILineTracker getTracker() {
- Assert.isNotNull(fTracker);
- return fTracker;
- }
-
- public IStructuredTextUndoManager getUndoManager() {
- if (fUndoManager == null) {
- fUndoManager = new StructuredTextUndoManager();
- }
- return fUndoManager;
- }
-
- void initializeFirstAndLastDocumentRegion() {
- // cached Node must also be first, at the initial point. Only
- // valid
- // to call this method right after the first parse.
- //
- // when starting afresh, our cachedNode should be our firstNode,
- // so be sure to initialize the firstNode
- firstDocumentRegion = getCachedDocumentRegion();
- // be sure to use 'getNext' for this initial finding of the last
- // node,
- // since the implementation of node.getLastNode may simply call
- // structuredDocument.getLastStructuredDocumentRegion!
- IStructuredDocumentRegion aNode = firstDocumentRegion;
- if (aNode == null) {
- // defect 254607: to handle empty documents right, if
- // firstnode is
- // null, make sure last node is null too
- lastDocumentRegion = null;
- } else {
- while (aNode != null) {
- lastDocumentRegion = aNode;
- aNode = aNode.getNext();
- }
- }
- }
-
- /**
- * @see IDocument#insertPositionUpdater
- */
- public void insertPositionUpdater(IPositionUpdater updater, int index) {
- getPositionManager().insertPositionUpdater(updater, index);
- }
-
- private void internal_addPositionCategory(String category) {
- getPositionManager().addPositionCategory(category);
- }
-
- private void internal_addPositionUpdater(IPositionUpdater updater) {
- getPositionManager().addPositionUpdater(updater);
- }
-
- private void internal_setParser(RegionParser newParser) {
- fParser = newParser;
- }
-
- String internalGet(int offset, int length) {
- String result = null;
- int myLength = getLength();
- // if ((0 > offset) || (0 > length) || (offset + length > myLength))
- // throw new BadLocationException();
- result = getStore().get(offset, length);
- return result;
- }
-
- /**
- * @param requester
- * @param start
- * @param replacementLength
- * @param changes
- * @return
- */
- private StructuredDocumentEvent internalReplaceText(Object requester, int start, int replacementLength, String changes, boolean ignoreReadOnlySettings) {
- StructuredDocumentEvent result = null;
-
- stopPostNotificationProcessing();
- if (changes == null)
- changes = ""; //$NON-NLS-1$
- //
- if (Debug.debugStructuredDocument)
- System.out.println(getClass().getName() + "::replaceText(" + start + "," + replacementLength + "," + changes + ")"); //$NON-NLS-4$//$NON-NLS-3$//$NON-NLS-2$//$NON-NLS-1$
- if (Debug.perfTestStructuredDocumentOnly || Debug.perfTest || Debug.perfTestRawStructuredDocumentOnly) {
- startStreamTime = System.currentTimeMillis();
- }
- try {
- // Note: event must be computed before 'fire' method called
- fDocumentEvent = new DocumentEvent(this, start, replacementLength, changes);
- fireDocumentAboutToChanged();
-
- try {
- acquireLock();
-
- if (!ignoreReadOnlySettings && (containsReadOnly(start, replacementLength))) {
- NoChangeEvent noChangeEvent = new NoChangeEvent(this, requester, changes, start, replacementLength);
- noChangeEvent.reason = NoChangeEvent.READ_ONLY_STATE_CHANGE;
- result = noChangeEvent;
- } else {
- result = updateModel(requester, start, replacementLength, changes);
- }
- } finally {
- releaseLock();
- }
-
-
- if (Debug.perfTestRawStructuredDocumentOnly || Debug.perfTest) {
- long stopStreamTime = System.currentTimeMillis();
- System.out.println("\n\t\t\t\t Time for IStructuredDocument raw replaceText: " + (stopStreamTime - startStreamTime)); //$NON-NLS-1$
- }
- if (Debug.debugStructuredDocument) {
- System.out.println("event type returned by replaceTextWithNoDebuggingThread: " + result); //$NON-NLS-1$
- }
- } finally {
- // FUTURE_TO_DO: implement callback mechanism? to avoid instanceof
- // and casting
- // fireStructuredDocumentEvent must be called in order to end
- // documentAboutToBeChanged state
- if (result == null) {
- // result should not be null, but if an exception was thrown,
- // it will be
- // so send a noChangeEvent and log the problem
- NoChangeEvent noChangeEvent = new NoChangeEvent(this, requester, changes, start, replacementLength);
- noChangeEvent.reason = NoChangeEvent.NO_EVENT;
- fireStructuredDocumentEvent(noChangeEvent);
- Logger.log(Logger.ERROR, "Program Error: invalid structured document event"); //$NON-NLS-1$
- } else {
- if (result instanceof RegionChangedEvent) {
- fireStructuredDocumentEvent((RegionChangedEvent) result);
- } else {
- if (result instanceof RegionsReplacedEvent) {
- fireStructuredDocumentEvent((RegionsReplacedEvent) result);
- } else {
- if (result instanceof StructuredDocumentRegionsReplacedEvent) {
- // probably more efficient to mark old regions as
- // 'deleted' at the time
- // that are determined to be deleted, but I'll do
- // here
- // in then central spot
- // for programming ease.
- updateDeletedFields((StructuredDocumentRegionsReplacedEvent) result);
- fireStructuredDocumentEvent((StructuredDocumentRegionsReplacedEvent) result);
- } else {
- if (result instanceof NoChangeEvent) {
- fireStructuredDocumentEvent((NoChangeEvent) result);
- } else {
- // if here, this means a new event was created
- // and not handled here
- // just send a no event until this issue is
- // resolved.
- NoChangeEvent noChangeEvent = new NoChangeEvent(this, requester, changes, start, replacementLength);
- noChangeEvent.reason = NoChangeEvent.NO_EVENT;
- fireStructuredDocumentEvent(noChangeEvent);
- throw new SourceEditingRuntimeException("Program Error: unexpected structured document event: " + result); //$NON-NLS-1$
- }
- }
- }
- }
- }
- if (Debug.perfTest || Debug.perfTestStructuredDocumentOnly) {
- long stopStreamTime = System.currentTimeMillis();
- System.out.println("\n\t\t\t\t Total Time for IStructuredDocument event signaling/processing in replaceText: " + (stopStreamTime - startStreamTime)); //$NON-NLS-1$
- }
- resumePostNotificationProcessing();
- }
- return result;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.lang.CharSequence#length()
- */
- public int length() {
-
- return getLength();
- }
-
- /*
- * (non-Javadoc)
- *
- * @see com.ibm.sed.structured.text.IStructuredDocument#makeReadOnly(int,
- * int)
- */
- public void makeReadOnly(int startOffset, int length) {
-
- // doesn't make sense to have a readonly region of 0 length,
- // so we'll ignore those requests
- if (length <= 0)
- return;
- String affectedText = this.get(startOffset, length);
- // a document event for "read only" change ... must
- // be followed by "no change" structuredDocument event
- // fDocumentEvent = new DocumentEvent(this, startOffset, length,
- // affectedText);
- fireReadOnlyAboutToBeChanged();
- // if (containsReadOnly(startOffset, length)) {
- // adjustReadOnlyRegions(startOffset, length);
- // } else {
- // we can blindly add category, since no harm done if already
- // exists.
- addPositionCategory(READ_ONLY_REGIONS_CATEGORY);
- Position newPosition = new Position(startOffset, length);
- try {
- addPosition(READ_ONLY_REGIONS_CATEGORY, newPosition);
- // FIXME: need to change API to pass in requester, so this event
- // can be
- // created correctly, instead of using null.
- NoChangeEvent noChangeEvent = new NoChangeEvent(this, null, affectedText, startOffset, length);
- noChangeEvent.reason = NoChangeEvent.READ_ONLY_STATE_CHANGE;
- fireReadOnlyStructuredDocumentEvent(noChangeEvent);
- } catch (BadLocationException e) {
- // for now, log and ignore. Perhaps later we
- // could adjust to handle some cases?
- Logger.logException(("could not create readonly region at " + startOffset + " to " + length), e); //$NON-NLS-1$ //$NON-NLS-2$
- } catch (BadPositionCategoryException e) {
- // should never occur, since we add category
- Logger.logException(e);
- }
- }
-
- /**
- * @see com.ibm.sed.structuredDocument.IStructuredDocument#newInstance()
- */
- public IStructuredDocument newInstance() {
- IStructuredDocument newInstance = StructuredDocumentFactory.getNewStructuredDocumentInstance(getParser().newInstance());
- ((BasicStructuredDocument) newInstance).setReParser(getReParser().newInstance());
- if (getDocumentPartitioner() instanceof StructuredTextPartitioner) {
- newInstance.setDocumentPartitioner(((StructuredTextPartitioner) getDocumentPartitioner()).newInstance());
- newInstance.getDocumentPartitioner().connect(newInstance);
- }
- newInstance.setLineDelimiter(getLineDelimiter());
- if (getEncodingMemento() != null) {
- newInstance.setEncodingMemento((EncodingMemento) getEncodingMemento().clone());
- }
- return newInstance;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.wst.sse.core.internal.text.IRegionComparible#regionMatches(int,
- * int, java.lang.String)
- */
- public boolean regionMatches(int offset, int length, String stringToCompare) {
- boolean result = false;
- ITextStore store = getStore();
- if (store instanceof IRegionComparible) {
- result = ((IRegionComparible) store).regionMatches(offset, length, stringToCompare);
- } else {
- result = get(offset, length).equals(stringToCompare);
- }
- return result;
- }
-
- public boolean regionMatchesIgnoreCase(int offset, int length, String stringToCompare) {
- boolean result = false;
- ITextStore store = getStore();
- if (store instanceof IRegionComparible) {
- result = ((IRegionComparible) store).regionMatchesIgnoreCase(offset, length, stringToCompare);
- } else {
- result = get(offset, length).equalsIgnoreCase(stringToCompare);
- }
- return result;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jface.text.IDocumentExtension#registerPostNotificationReplace(org.eclipse.jface.text.IDocumentListener,
- * org.eclipse.jface.text.IDocumentExtension.IReplace)
- */
- public void registerPostNotificationReplace(IDocumentListener owner, IDocumentExtension.IReplace replace) {
- if (fAcceptPostNotificationReplaces) {
- if (fPostNotificationChanges == null)
- fPostNotificationChanges = new ArrayList(1);
- fPostNotificationChanges.add(new RegisteredReplace(owner, replace));
- }
- }
-
- protected void releaseLock() {
- // do nothing here in super class
- }
-
- public void removeDocumentAboutToChangeListener(IModelAboutToBeChangedListener listener) {
- synchronized (listenerLock) {
-
- if ((fStructuredDocumentAboutToChangeListeners != null) && (listener != null)) {
- // if its not in the listeners, we'll ignore the request
- if (Utilities.contains(fStructuredDocumentAboutToChangeListeners, listener)) {
- int oldSize = fStructuredDocumentAboutToChangeListeners.length;
- int newSize = oldSize - 1;
- Object[] newListeners = new Object[newSize];
- int index = 0;
- for (int i = 0; i < oldSize; i++) {
- if (fStructuredDocumentAboutToChangeListeners[i] == listener) { // ignore
- } else {
- // copy old to new if its not the one we are
- // removing
- newListeners[index++] = fStructuredDocumentAboutToChangeListeners[i];
- }
- }
- // now that we have a new array, let's switch it for the
- // old
- // one
- fStructuredDocumentAboutToChangeListeners = newListeners;
- }
- }
- }
- }
-
- /**
- * removeModelChangedListener method comment.
- */
- public void removeDocumentChangedListener(IStructuredDocumentListener listener) {
- synchronized (listenerLock) {
-
- if ((fStructuredDocumentChangedListeners != null) && (listener != null)) {
- // if its not in the listeners, we'll ignore the request
- if (Utilities.contains(fStructuredDocumentChangedListeners, listener)) {
- int oldSize = fStructuredDocumentChangedListeners.length;
- int newSize = oldSize - 1;
- Object[] newListeners = new Object[newSize];
- int index = 0;
- for (int i = 0; i < oldSize; i++) {
- if (fStructuredDocumentChangedListeners[i] == listener) { // ignore
- } else {
- // copy old to new if its not the one we are
- // removing
- newListeners[index++] = fStructuredDocumentChangedListeners[i];
- }
- }
- // now that we have a new array, let's switch it for the
- // old
- // one
- fStructuredDocumentChangedListeners = newListeners;
- }
- }
- }
- }
-
- public void removeDocumentChangingListener(IStructuredDocumentListener listener) {
- synchronized (listenerLock) {
-
- if ((fStructuredDocumentChangingListeners != null) && (listener != null)) {
- // if its not in the listeners, we'll ignore the request
- if (Utilities.contains(fStructuredDocumentChangingListeners, listener)) {
- int oldSize = fStructuredDocumentChangingListeners.length;
- int newSize = oldSize - 1;
- Object[] newListeners = new Object[newSize];
- int index = 0;
- for (int i = 0; i < oldSize; i++) {
- if (fStructuredDocumentChangingListeners[i] == listener) { // ignore
- } else {
- // copy old to new if its not the one we are
- // removing
- newListeners[index++] = fStructuredDocumentChangingListeners[i];
- }
- }
- // now that we have a new array, let's switch it for the
- // old
- // one
- fStructuredDocumentChangingListeners = newListeners;
- }
- }
- }
- }
-
- public void removeDocumentListener(IDocumentListener listener) {
- synchronized (listenerLock) {
-
- if ((fDocumentListeners != null) && (listener != null)) {
- // if its not in the listeners, we'll ignore the request
- if (Utilities.contains(fDocumentListeners, listener)) {
- int oldSize = fDocumentListeners.length;
- int newSize = oldSize - 1;
- IDocumentListener[] newListeners = new IDocumentListener[newSize];
- int index = 0;
- for (int i = 0; i < oldSize; i++) {
- if (fDocumentListeners[i] == listener) { // ignore
- } else {
- // copy old to new if its not the one we are
- // removing
- newListeners[index++] = fDocumentListeners[i];
- }
- }
- // now that we have a new array, let's switch it for the
- // old
- // one
- fDocumentListeners = newListeners;
- }
- }
- }
- }
-
- /*
- * @see org.eclipse.jface.text.IDocument#removeDocumentPartitioningListener(org.eclipse.jface.text.IDocumentPartitioningListener)
- */
- public void removeDocumentPartitioningListener(IDocumentPartitioningListener listener) {
- synchronized (listenerLock) {
-
- Assert.isNotNull(listener);
- if (fDocumentPartitioningListeners != null)
- fDocumentPartitioningListeners.remove(listener);
- }
- }
-
- /**
- * Removes the given <code>Position</code> from the document's default
- * position category. The default position category is to be defined by
- * the implementers. If the position is not part of the document's default
- * category nothing happens.
- */
- public void removePosition(Position position) {
- getPositionManager().removePosition(position);
- }
-
- /**
- * @see IDocument#removePosition
- * @exception BadPositionCategoryException
- * If the category is not defined for the document
- */
- public void removePosition(String category, Position position) throws BadPositionCategoryException {
- getPositionManager().removePosition(category, position);
- }
-
- /**
- * @see IDocument#removePositionCategory
- * @exception BadPositionCategoryException
- * If the category is not defined for the document
- */
- public void removePositionCategory(String category) throws BadPositionCategoryException {
- getPositionManager().removePositionCategory(category);
- }
-
- /**
- * @see IDocument#removePositionUpdater
- */
- public void removePositionUpdater(IPositionUpdater updater) {
- getPositionManager().removePositionUpdater(updater);
- }
-
- /**
- * Removes the given document listener from teh document's list of
- * prenotified document listeners. If the listener is not registered with
- * the document nothing happens.
- * <p>
- *
- * This method is not for public use, it may only be called by
- * implementers of <code>IDocumentAdapter</code> and only if those
- * implementers need to implement <code>IDocumentListener</code>.
- *
- * @param documentAdapter
- * the listener to be removed
- *
- * @see #addPrenotifiedDocumentListener(IDocumentListener)
- */
- public void removePrenotifiedDocumentListener(org.eclipse.jface.text.IDocumentListener documentAdapter) {
- synchronized (listenerLock) {
-
- if (Utilities.contains(fPrenotifiedDocumentListeners, documentAdapter)) {
- int previousSize = fPrenotifiedDocumentListeners.length;
- if (previousSize > 1) {
- IDocumentListener[] listeners = new IDocumentListener[previousSize - 1];
- int previousIndex = 0;
- int newIndex = 0;
- while (previousIndex < previousSize) {
- if (fPrenotifiedDocumentListeners[previousIndex] != documentAdapter)
- listeners[newIndex++] = fPrenotifiedDocumentListeners[previousIndex];
- previousIndex++;
- }
- fPrenotifiedDocumentListeners = listeners;
- } else {
- fPrenotifiedDocumentListeners = null;
- }
- }
- }
- }
-
- /**
- * This method is for INTERNAL USE ONLY and is NOT API.
- *
- * Rebuilds the StructuredDocumentRegion chain from the existing text.
- * FileBuffer support does not allow clients to know the document's
- * location before the text contents are set.
- *
- * @see set(String)
- */
- public void reparse(Object requester) {
- NewDocumentEvent result = null;
- stopPostNotificationProcessing();
- clearReadOnly();
-
- acquireLock();
- try {
- CharSequenceReader subSetTextStoreReader = new CharSequenceReader((CharSequence) getStore(), 0, getStore().getLength());
- resetParser(subSetTextStoreReader, 0);
- //
- setCachedDocumentRegion(getParser().getDocumentRegions());
- // when starting afresh, our cachedNode should be our firstNode,
- // so be sure to initialize the firstNode and lastNode
- initializeFirstAndLastDocumentRegion();
- StructuredDocumentRegionIterator.setParentDocument(getCachedDocumentRegion(), this);
- } finally {
- releaseLock();
- }
-
- resumePostNotificationProcessing();
- }
-
- /**
- * @see IDocument#replace
- * @exception BadLocationException
- * If position is not a valid range in the document
- */
- public void replace(int pos, int length, String string) throws BadLocationException {
- if (Debug.displayWarnings) {
- System.out.println("Note: IStructuredDocument::replace(int, int, String) .... its better to use replaceText(source, string, int, int) API for structuredDocument updates"); //$NON-NLS-1$
- }
- replaceText(this, pos, length, string);
- }
-
- /**
- * Replace the text with "newText" starting at position "start" for a
- * length of "replaceLength".
- * <p>
- *
- * @param start
- * start offset of text to replace None of the offsets include
- * delimiters of preceeding lines. Offset 0 is the first
- * character of the document.
- * @param replaceLength
- * start offset of text to replace
- * @param newText
- * start offset of text to replace
- * <p>
- * Implementors have to notify TextChanged listeners after the
- * content has been updated. The TextChangedEvent should be set
- * as follows:
- *
- * event.type = SWT.TextReplaced event.start = start of the replaced text
- * event.numReplacedLines = number of replaced lines event.numNewLines =
- * number of new lines event.replacedLength = length of the replaced text
- * event.newLength = length of the new text
- *
- * NOTE: numNewLines is the number of inserted lines and numReplacedLines
- * is the number of deleted lines based on the change that occurs
- * visually. For example:
- *
- * replacedText newText numReplacedLines numNewLines "" "\n" 0 1 "\n\n"
- * "a" 2 0 "a" "\n\n" 0 2
- */
- /**
- * One of the APIs to manipulate the IStructuredDocument in terms of text.
- */
- public StructuredDocumentEvent replaceText(Object requester, int start, int replacementLength, String changes) {
- return replaceText(requester, start, replacementLength, changes, false);
- }
-
- public StructuredDocumentEvent replaceText(Object requester, int start, int replacementLength, String changes, boolean ignoreReadOnlySettings) {
- return internalReplaceText(requester, start, replacementLength, changes, ignoreReadOnlySettings);
- }
-
- void resetParser(int startOffset, int endOffset) {
-
- RegionParser parser = getParser();
- ITextStore textStore = getStore();
- if (textStore instanceof CharSequence) {
- CharSequenceReader subSetTextStoreReader = new CharSequenceReader((CharSequence) textStore, startOffset, endOffset - startOffset);
- parser.reset(subSetTextStoreReader, startOffset);
- } else {
- String newNodeText = get(startOffset, endOffset - startOffset);
- parser.reset(newNodeText, startOffset);
-
- }
-
- }
-
- void resetParser(Reader reader, int startOffset) {
- RegionParser parser = getParser();
- parser.reset(reader, startOffset);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jface.text.IDocumentExtension#resumePostNotificationProcessing()
- */
- public void resumePostNotificationProcessing() {
- --fStoppedCount;
- if (fStoppedCount == 0 && fReentranceCount == 0)
- executePostNotificationChanges();
- }
-
- /**
- * @deprecated in superclass in 3.0 - use a FindReplaceDocumentAdapter
- * directly
- * @see IDocument#search
- */
- public int search(int startPosition, String findString, boolean forwardSearch, boolean caseSensitive, boolean wholeWord) throws BadLocationException {
- // (dmw) I added this warning, to know if still being used. I'm not
- // sure it
- // works as expected any longer.
- // but the warning should be removed, once know.
- Logger.log(Logger.INFO, "WARNING: using unsupported deprecated method 'search'"); //$NON-NLS-1$
- int offset = -1;
- IRegion match = new FindReplaceDocumentAdapter(this).find(startPosition, findString, forwardSearch, caseSensitive, wholeWord, false);
- if (match != null) {
- offset = match.getOffset();
- }
- return offset;
- }
-
- /**
- * @see IDocument#setText
- */
- public void set(String string) {
- if (Debug.displayInfo) {
- System.out.println("Note: IStructuredDocument::setText(String) .... its better to use setText(source, string) API for structuredDocument updates"); //$NON-NLS-1$
- }
- setText(null, string);
- }
-
- /**
- * This may be marked public, but should be packaged protected, once
- * refactoring is complete (in other words, not for client use).
- */
- public void setCachedDocumentRegion(IStructuredDocumentRegion structuredRegion) {
- if (USE_LOCAL_THREAD) {
- fCurrentDocumnetRegionCache.set(structuredRegion);
- } else {
- cachedDocumentRegion = structuredRegion;
- }
- }
-
- /**
- * Sets the document's partitioner.
- *
- * @see IDocumentPartitioner
- */
- public void setDocumentPartitioner(IDocumentPartitioner partitioner) {
- setDocumentPartitioner(IDocumentExtension3.DEFAULT_PARTITIONING, partitioner);
- }
-
- /*
- * @see org.eclipse.jface.text.IDocumentExtension3#setDocumentPartitioner(java.lang.String,
- * org.eclipse.jface.text.IDocumentPartitioner)
- * @since 3.0
- */
- public void setDocumentPartitioner(String partitioning, IDocumentPartitioner partitioner) {
- if (partitioner == null) {
- if (fDocumentPartitioners != null) {
- fDocumentPartitioners.remove(partitioning);
- if (fDocumentPartitioners.size() == 0)
- fDocumentPartitioners = null;
- }
- } else {
- if (fDocumentPartitioners == null)
- fDocumentPartitioners = new HashMap();
- fDocumentPartitioners.put(partitioning, partitioner);
- }
- DocumentPartitioningChangedEvent event = new DocumentPartitioningChangedEvent(this);
- event.setPartitionChange(partitioning, 0, getLength());
- fireDocumentPartitioningChanged(event);
- }
-
- /**
- * @see com.ibm.sed.structuredDocument.IStructuredDocument#setEncodingMemento(EncodingMemento)
- */
- public void setEncodingMemento(EncodingMemento encodingMemento) {
- this.encodingMemento = encodingMemento;
- }
-
- void setFirstDocumentRegion(IStructuredDocumentRegion region) {
- firstDocumentRegion = region;
-
- }
-
- void setLastDocumentRegion(IStructuredDocumentRegion region) {
- lastDocumentRegion = region;
-
- }
-
- /**
- * @see IStructuredDocument#setLineDelimiter(String)
- */
- public void setLineDelimiter(String delimiter) {
- // make sure our preferred delimiter is
- // one of the legal ones
- if (Utilities.containsString(getLegalLineDelimiters(), delimiter)) {
- preferedDelimiter = delimiter;
- } else {
- Logger.trace("IStructuredDocument", "Attempt to set linedelimiter to non-legal delimiter"); //$NON-NLS-1$ //$NON-NLS-2$
- preferedDelimiter = PlatformLineDelimiter;
- }
- }
-
- /**
- * Sets the document's line tracker. Must be called at the beginning of
- * the constructor.
- *
- * @param tracker
- * the document's line tracker
- */
- private void setLineTracker(ILineTracker tracker) {
- fTracker = tracker;
- }
-
- public void setParser(RegionParser newParser) {
- internal_setParser(newParser);
- }
-
- /**
- * @param positionManager
- * The positionManager to set.
- */
- // TODO: make private is needed, else remove
- void setPositionManager(GenericPositionManager positionManager) {
- fPositionManager = positionManager;
- }
-
- /**
- *
- */
- public void setReParser(IStructuredTextReParser newReParser) {
- fReParser = newReParser;
- if (fReParser != null) {
- fReParser.setStructuredDocument(this);
- }
- }
-
- /**
- * One of the APIs to manipulate the IStructuredDocument in terms of text.
- */
- public NewModelEvent setText(Object requester, String theString) {
-
- NewDocumentEvent result = null;
- stopPostNotificationProcessing();
- clearReadOnly();
- // Note: event must be computed before 'fire' method called
- // Note: judging from code in AbstractDocument, apparently the
- // length in this event is the current length of
- // the document.
- fDocumentEvent = new DocumentEvent(this, 0, length(), theString);
- fireDocumentAboutToChanged();
-
- acquireLock();
-
- try {
- getStore().set(theString);
- getTracker().set(theString);
- //
- CharSequenceReader subSetTextStoreReader = new CharSequenceReader((CharSequence) getStore(), 0, getStore().getLength());
- resetParser(subSetTextStoreReader, 0);
- //
- setCachedDocumentRegion(getParser().getDocumentRegions());
- // when starting afresh, our cachedNode should be our firstNode,
- // so be sure to initialize the firstNode and lastNode
- initializeFirstAndLastDocumentRegion();
- StructuredDocumentRegionIterator.setParentDocument(getCachedDocumentRegion(), this);
- } finally {
- releaseLock();
- }
-
- result = new NewDocumentEvent(this, requester);
- fireStructuredDocumentEvent(result);
- resumePostNotificationProcessing();
- return result;
- }
-
- /**
- * Sets the document's text store. Must be called at the beginning of the
- * constructor.
- *
- * @param store
- * the document's text store
- */
- private void setTextStore(ITextStore store) {
- fStore = store;
- }
-
- public void setUndoManager(IStructuredTextUndoManager undoManager) {
-
- // if the undo manager has already been set, then
- // fail fast, since changing the undo manager will lead
- // to unusual results (or at least loss of undo stack).
- if (fUndoManager != null && fUndoManager != undoManager) {
- throw new IllegalArgumentException("can not change undo manager once its been set"); //$NON-NLS-1$
- } else {
- fUndoManager = undoManager;
- }
- }
-
- /*
- * @see org.eclipse.jface.text.IDocumentExtension#startSequentialRewrite(boolean)
- * @since 2.0
- */
- public void startSequentialRewrite(boolean normalized) {
- ITextStore store = new SequentialRewriteTextStore(getStore());
- setTextStore(store);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jface.text.IDocumentExtension#stopPostNotificationProcessing()
- */
- public void stopPostNotificationProcessing() {
- ++fStoppedCount;
- }
-
- /*
- * @see org.eclipse.jface.text.IDocumentExtension#stopSequentialRewrite()
- * @since 2.0
- */
- public void stopSequentialRewrite() {
- if (getStore() instanceof SequentialRewriteTextStore) {
- SequentialRewriteTextStore srws = (SequentialRewriteTextStore) getStore();
- ITextStore source = srws.getSourceStore();
- setTextStore(source);
- srws.dispose();
- }
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.lang.CharSequence#subSequence(int, int)
- */
- public CharSequence subSequence(int arg0, int arg1) {
- return get(arg0, arg1);
- }
-
- /**
- * @param result
- */
- private void updateDeletedFields(StructuredDocumentRegionsReplacedEvent event) {
- IStructuredDocumentRegionList oldRegions = event.getOldStructuredDocumentRegions();
- for (int i = 0; i < oldRegions.getLength(); i++) {
- IStructuredDocumentRegion structuredDocumentRegion = oldRegions.item(i);
- structuredDocumentRegion.setDeleted(true);
- }
-
- }
-
- /**
- * Called by re-parser. Note: this method may be "public" but should only
- * be called by re-parsers in the right circumstances.
- */
- public void updateDocumentData(int start, int lengthToReplace, String changes) {
- stopPostNotificationProcessing();
- getStore().replace(start, lengthToReplace, changes);
- try {
- getTracker().replace(start, lengthToReplace, changes);
- }
-
- catch (BadLocationException e) {
- // should be impossible here, but will log for now
- Logger.logException(e);
- }
- if (fPositionManager != null) {
- fPositionManager.updatePositions(new DocumentEvent(this, start, lengthToReplace, changes));
- }
- resumePostNotificationProcessing();
- }
-
- private StructuredDocumentEvent updateModel(Object requester, int start, int lengthToReplace, String changes) {
- StructuredDocumentEvent result = null;
- IStructuredTextReParser reParser = getReParser();
- // initialize the IStructuredTextReParser with the standard data
- // that's
- // always needed
- reParser.initialize(requester, start, lengthToReplace, changes);
- result = reParser.reparse();
- // if result is null at this point, then there must be an error, since
- // even if there
- // was no change (either disallow due to readonly, or a person pasted
- // the same thing
- // they had selected) then a "NoChange" event should have been fired.
- Assert.isNotNull(result, "no structuredDocument event was created in IStructuredDocument::updateStructuredDocument"); //$NON-NLS-1$
- return result;
- }
-}
diff --git a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/text/BasicStructuredDocumentRegion.java b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/text/BasicStructuredDocumentRegion.java
deleted file mode 100644
index a31192c51a..0000000000
--- a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/text/BasicStructuredDocumentRegion.java
+++ /dev/null
@@ -1,688 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Jens Lukowski/Innoopract - initial renaming/restructuring
- *
- *******************************************************************************/
-package org.eclipse.wst.sse.core.internal.text;
-
-
-
-import org.eclipse.jface.text.BadLocationException;
-import org.eclipse.wst.sse.core.events.RegionChangedEvent;
-import org.eclipse.wst.sse.core.events.StructuredDocumentEvent;
-import org.eclipse.wst.sse.core.exceptions.SourceEditingRuntimeException;
-import org.eclipse.wst.sse.core.internal.Logger;
-import org.eclipse.wst.sse.core.text.IStructuredDocument;
-import org.eclipse.wst.sse.core.text.IStructuredDocumentRegion;
-import org.eclipse.wst.sse.core.text.ITextRegion;
-import org.eclipse.wst.sse.core.text.ITextRegionList;
-import org.eclipse.wst.sse.core.util.Assert;
-import org.eclipse.wst.sse.core.util.Debug;
-import org.eclipse.wst.sse.core.util.Utilities;
-
-
-public class BasicStructuredDocumentRegion extends Object implements IStructuredDocumentRegion {
- private static final String TEXT_STORE_NOT_ASSIGNED = "text store not assigned yet"; //$NON-NLS-1$
- private static final String UNDEFINED = "org.eclipse.wst.sse.core.structuredDocument.UNDEFINED"; //$NON-NLS-1$
-
- private ITextRegionList _regions;
- private boolean fIsDeleted = false;
- //private String fType;
- /**
- * allow a pointer back to this nodes model
- */
- private IStructuredDocument fParentDocument;
- /**
- * was this node terminated normally
- */
- // 0 == false, 1 == true
- private byte hasEnd = 0;
- protected int length;
- private IStructuredDocumentRegion next = null;
- private IStructuredDocumentRegion previous = null;
- protected int start;
-
- public BasicStructuredDocumentRegion() {
- super();
- _regions = new TextRegionListImpl();
-
- }
-
- /**
- * Even inside-this class uses of 'regions' should use this method, as
- * this is where (soft) memory management/reparsing, etc., will be
- * centralized.
- */
- private ITextRegionList _getRegions() {
-
- return _regions;
- }
-
- public void addRegion(ITextRegion aRegion) {
- _getRegions().add(aRegion);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see com.ibm.sed.structured.text.ITextRegion#adjust(int)
- */
- public void adjust(int i) {
- start += i;
- }
-
- public void adjustLengthWith(int i) {
- length += i;
- }
-
- public void adjustStart(int i) {
- start += i;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see com.ibm.sed.structured.text.ITextRegion#adjustTextLength(int)
- */
- public void adjustTextLength(int i) {
- // not supported
-
- }
-
- /*
- * (non-Javadoc)
- *
- * @see com.ibm.sed.structured.text.ITextRegionCollection#containsOffset(int)
- */
- public boolean containsOffset(int i) {
-
- return getStartOffset() <= i && i < getEndOffset();
- }
-
- /*
- * (non-Javadoc)
- *
- * @see com.ibm.sed.structured.text.ITextRegionCollection#containsOffset(com.ibm.sed.structured.text.ITextRegion,
- * int)
- */
- public boolean containsOffset(ITextRegion containedRegion, int offset) {
- return getStartOffset(containedRegion) <= offset && offset < getEndOffset(containedRegion);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see com.ibm.sed.structured.text.ITextRegion#equatePositions(com.ibm.sed.structured.text.ITextRegion)
- */
- public void equatePositions(ITextRegion region) {
- start = region.getStart();
- length = region.getLength();
- //textLength = region.getTextLength();
-
- }
-
- /**
- * getEnd and getEndOffset are the same only for
- * IStructuredDocumentRegions
- */
- public int getEnd() {
- return start + length;
- }
-
- /**
- * getEnd and getEndOffset are the same only for
- * IStructuredDocumentRegions
- */
- public int getEndOffset() {
- return getEnd();
- }
-
- /*
- * (non-Javadoc)
- *
- * @see com.ibm.sed.structured.text.ITextRegionCollection#getEndOffset(com.ibm.sed.structured.text.ITextRegion)
- */
- public int getEndOffset(ITextRegion containedRegion) {
- return getStartOffset(containedRegion) + containedRegion.getLength();
- }
-
- // public IStructuredDocumentRegion getFirstNode() {
- // IStructuredDocumentRegion aNode = (IStructuredDocumentRegion)
- // fOwningDocument.getFirstStructuredDocumentRegion();
- // return aNode;
- // }
- public ITextRegion getFirstRegion() {
- if (_getRegions() == null)
- return null;
- return _getRegions().get(0);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see com.ibm.sed.structured.text.ITextRegionCollection#getFullText()
- */
- public String getFullText() {
- try {
- return getParentDocument().get(start, length);
- } catch (BadLocationException e) {
- // program error
- throw new SourceEditingRuntimeException(e);
- }
- }
-
- public String getFullText(ITextRegion aRegion) {
- String result = null;
- try {
- int regionStart = aRegion.getStart();
- int regionLength = aRegion.getLength();
- result = fParentDocument.get(start + regionStart, regionLength);
- } catch (BadLocationException e) {
- throw new SourceEditingRuntimeException(e);
- }
- return result;
- }
-
- public String getFullText(String context) {
- // DMW: looping is faster than enumeration,
- // so switched around 2/12/03
- //Enumeration e = getRegions().elements();
- ITextRegion region = null;
- String result = ""; //$NON-NLS-1$
- int length = getRegions().size();
- for (int i = 0; i < length; i++) {
- region = getRegions().get(i);
- if (region.getType() == context)
- result += getFullText(region);
- }
- return result;
- }
-
- public ITextRegion getLastRegion() {
- if (_getRegions() == null)
- return null;
- return _getRegions().get(_getRegions().size() - 1);
- }
-
- public int getLength() {
- return length;
- }
-
- public IStructuredDocumentRegion getNext() {
- return next;
- }
-
- public int getNumberOfRegions() {
- return _getRegions().size();
- }
-
- /*
- * (non-Javadoc)
- *
- * @see com.ibm.sed.structured.text.IStructuredDocumentRegion#getDocument()
- */
- public IStructuredDocument getParentDocument() {
-
- return fParentDocument;
- }
-
- public IStructuredDocumentRegion getPrevious() {
- return previous;
- }
-
- /**
- * The parameter offset refers to the overall offset in the document.
- */
- public ITextRegion getRegionAtCharacterOffset(int offset) {
- ITextRegion result = null;
- if (_getRegions() != null) {
- // transform the requested offset to the "scale" that
- // regions are stored in, which are all relative to the
- // start point.
- //int transformedOffset = offset - getStartOffset();
- //
- int length = getRegions().size();
- for (int i = 0; i < length; i++) {
- ITextRegion region = getRegions().get(i);
- if (Debug.debugStructuredDocument) {
- System.out.println("region(s) in IStructuredDocumentRegion::getRegionAtCharacterOffset: " + region); //$NON-NLS-1$
- System.out.println(" requested offset: " + offset); //$NON-NLS-1$
- //System.out.println(" transformedOffset: " +
- // transformedOffset); //$NON-NLS-1$
- System.out.println(" region start: " + region.getStart()); //$NON-NLS-1$
- System.out.println(" region end: " + region.getEnd()); //$NON-NLS-1$
- System.out.println(" region type: " + region.getType()); //$NON-NLS-1$
- System.out.println(" region class: " + region.getClass()); //$NON-NLS-1$
-
- }
- if ((getStartOffset(region) <= offset) && (offset < getEndOffset(region))) {
- result = region;
- break;
- }
- }
- }
- return result;
- }
-
- public ITextRegionList getRegions() {
- return _getRegions();
- }
-
- /**
- * getStart and getStartOffset are the same only for
- * IStrucutredDocumentRegions
- */
- public int getStart() {
- return start;
- }
-
- /**
- * getStart and getStartOffset are the same only for
- * IStrucutredDocumentRegions
- */
- public int getStartOffset() {
- return getStart();
- }
-
- /*
- * (non-Javadoc)
- *
- * @see com.ibm.sed.structured.text.ITextRegionCollection#getStartOffset(com.ibm.sed.structured.text.ITextRegion)
- */
- public int getStartOffset(ITextRegion containedRegion) {
- // assert: containedRegion can not be null
- // (might be performance hit if literally put in assert call,
- // but containedRegion can not be null). Needs to be checked
- // by calling code.
- return getStartOffset() + containedRegion.getStart();
- }
-
- public String getText() {
- String result = null;
- try {
- if (fParentDocument == null) {
- // likely to happen during inspecting
- result = TEXT_STORE_NOT_ASSIGNED;
- } else {
- result = fParentDocument.get(start, length);
- }
- } catch (BadLocationException e) {
- throw new SourceEditingRuntimeException(e);
- }
- return result;
- }
-
- public String getText(ITextRegion aRegion) {
- // assert: aRegion can not be null
- // (might be performance hit if literally put in assert call,
- // but aRegion can not be null). Needs to be checked
- // by calling code.
- try {
- return fParentDocument.get(this.getStartOffset(aRegion), aRegion.getTextLength());
- } catch (BadLocationException e) {
- Logger.logException(e);
- }
- return ""; //$NON-NLS-1$
- }
-
- /**
- * Returns the text of the first region with the matching context type
- */
- public String getText(String context) {
- // DMW: looping is faster than enumeration,
- // so switched around 2/12/03
- //Enumeration e = getRegions().elements();
- ITextRegion region = null;
- String result = ""; //$NON-NLS-1$
- int length = getRegions().size();
- for (int i = 0; i < length; i++) {
- region = getRegions().get(i);
- if (region.getType() == context) {
- result = getText(region);
- break;
- }
- }
- return result;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see com.ibm.sed.structured.text.ITextRegion#getTextEnd()
- */
- public int getTextEnd() {
-
- //return start + textLength;
- return start + length;
- }
-
- /**
- * @return int
- */
- public int getTextEndOffset() {
- ITextRegion region = _getRegions().get(_getRegions().size() - 1);
- return getStartOffset() + region.getTextEnd();
- }
-
- /*
- * (non-Javadoc)
- *
- * @see com.ibm.sed.structured.text.ITextRegionCollection#getTextEndOffset(com.ibm.sed.structured.text.ITextRegion)
- */
- public int getTextEndOffset(ITextRegion containedRegion) {
- return getStartOffset(containedRegion) + containedRegion.getTextLength();
- }
-
- /*
- * (non-Javadoc)
- *
- * @see com.ibm.sed.structured.text.ITextRegion#getTextLength()
- */
- public int getTextLength() {
- //return textLength;
- return length;
- }
-
- /**
- * Provides the type of IStructuredDocumentRegion ... not to be confused
- * with type of XML node!
- */
- // For now return a String.
- public String getType() {
- // for a "named" XML node (e.g. start tag), but type of
- // flatnode is "named xml node" (which is always the second region).
- // Therefore, if there's two or more regions, the type for the
- // flatnode
- // will be the type of the second region. Otherwise it will be the
- // type
- // of the first region.
- // Note: this can be refined as needed.
- String result = UNDEFINED; //"IStructuredDocumentRegion.UNDEFINED";
- // //$NON-NLS-1$
- // we are assume there is always at least one region in a flatnode!
- result = getRegions().get(0).getType();
- // typcially subclassed, if something other than first region is
- // desired
- return result;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.wst.sse.core.text.IStructuredDocumentRegion#isDeleted()
- */
- public boolean isDeleted() {
- return fIsDeleted;
- }
-
- /**
- *
- * @return boolean
- */
- public boolean isEnded() {
- return (hasEnd == 1);
- }
-
- public boolean sameAs(IStructuredDocumentRegion region, int shift) {
- boolean result = false;
- // if region == null, we return false;
- if (region != null) {
- // if the regions are the same instance, they are equal
- if (this == region) {
- result = true;
- } else {
- // this is the non-trivial part
- // note: we change for type first, then start offset and end
- // offset,
- // since that would decide many cases right away and avoid the
- // text comparison
- if (getType() == region.getType()) {
- if (sameOffsetsAs(region, shift) && sameTextAs(region, shift)) {
- result = true;
- }
- }
-
- }
- }
- return result;
- }
-
- public boolean sameAs(ITextRegion oldRegion, IStructuredDocumentRegion newDocumentRegion, ITextRegion newRegion, int shift) {
- boolean result = false;
- // if any region is null, we return false (even if both are!)
- if ((oldRegion != null) && (newRegion != null)) {
- // if the regions are the same instance, they are equal
- if (oldRegion == newRegion) {
- result = true;
- } else {
- // this is the non-trivial part
- // note: we change for type first, then start offset and end
- // offset,
- // since that would decide many cases right away and avoid the
- // text comparison
- if (oldRegion.getType() == newRegion.getType()) {
- if (sameOffsetsAs(oldRegion, newDocumentRegion, newRegion, shift)) {
- if (sameTextAs(oldRegion, newDocumentRegion, newRegion, shift)) {
- result = true;
- }
- }
- }
- }
-
- }
-
- return result;
- }
-
- private boolean sameOffsetsAs(IStructuredDocumentRegion region, int shift) {
- if (getStartOffset() == region.getStartOffset() - shift) {
- if (getEndOffset() == region.getEndOffset() - shift) {
- return true;
- }
- }
- return false;
- }
-
- private boolean sameOffsetsAs(ITextRegion oldRegion, IStructuredDocumentRegion documentRegion, ITextRegion newRegion, int shift) {
- if (getStartOffset(oldRegion) == documentRegion.getStartOffset(newRegion) - shift) {
- if (getEndOffset(oldRegion) == documentRegion.getEndOffset(newRegion) - shift) {
- return true;
- }
- }
- return false;
- }
-
- private boolean sameTextAs(IStructuredDocumentRegion region, int shift) {
- boolean result = false;
- try {
- if (getText().equals(region.getText())) {
- result = true;
- }
- } catch (SourceEditingRuntimeException e) {
- if (e.getOriginalException() instanceof BadLocationException || e.getOriginalException() instanceof StringIndexOutOfBoundsException) {
- // this happens normally if document has been deleted from
- // and therefore regions are not equal
- result = false;
- } else {
- throw e;
- }
- }
-
- return result;
- }
-
- private boolean sameTextAs(ITextRegion oldRegion, IStructuredDocumentRegion documentRegion, ITextRegion newRegion, int shift) {
- boolean result = false;
- try {
- if (getText(oldRegion).equals(documentRegion.getText(newRegion))) {
- result = true;
- }
- } catch (SourceEditingRuntimeException e) {
- if (e.getOriginalException() instanceof BadLocationException) {
- // this happens normally if document has been deleted from
- // and therefore regions are not equal
- result = false;
- } else {
- throw e;
- }
- }
-
- return result;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.wst.sse.core.text.IStructuredDocumentRegion#setDelete(boolean)
- */
- public void setDeleted(boolean isDeleted) {
- fIsDeleted = isDeleted;
-
- }
-
- /**
- *
- * @param newHasEnd
- * boolean
- */
- public void setEnded(boolean newHasEnd) {
- if (newHasEnd) {
- hasEnd = 1;
- } else {
- hasEnd = 0;
- }
- }
-
- public void setLength(int newLength) {
- //textLength = newLength;
- length = newLength;
- }
-
- public void setNext(IStructuredDocumentRegion newNext) {
- next = newNext;
- }
-
- public void setParentDocument(IStructuredDocument document) {
- fParentDocument = document;
-
- }
-
- public void setPrevious(IStructuredDocumentRegion newPrevious) {
- previous = newPrevious;
- }
-
- public void setRegions(ITextRegionList containedRegions) {
- _regions = containedRegions;
- }
-
- public void setStart(int newStart) {
- start = newStart;
- }
-
- public String toString() {
- // NOTE: if the document held by any region has been updated and the
- // region offsets have not
- // yet been updated, the output from this method invalid.
- // Also note, this method can not be changed, without "breaking"
- // unit tests, since some of them compare current results to previous
- // results.
- String result = null;
- result = "[" + getStart() + ", " + getEnd() + "] (" + getText() + ")"; //$NON-NLS-4$//$NON-NLS-3$//$NON-NLS-2$//$NON-NLS-1$
- return result;
- }
-
- private void updateDownStreamRegions(ITextRegion changedRegion, int lengthDifference) {
- int listLength = _getRegions().size();
- int startIndex = 0;
- // first, loop through to find index of where to start
- for (int i = 0; i < listLength; i++) {
- ITextRegion region = _getRegions().get(i);
- if (region == changedRegion) {
- startIndex = i;
- break;
- }
- }
- // now, beginning one past the one that was changed, loop
- // through to end of list, adjusting the start postions.
- startIndex++;
- for (int j = startIndex; j < listLength; j++) {
- ITextRegion region = _getRegions().get(j);
- region.adjustStart(lengthDifference);
- }
- }
-
- // This is a language specific method (e.g. HTML, Java, Prolog, etc.) so
- // could/should be made configurable.
- /*
- * (non-Javadoc)
- *
- * @see com.ibm.sed.structured.text.ITextRegion#updateModel(java.lang.Object,
- * com.ibm.sed.structured.text.IStructuredDocumentRegion,
- * java.lang.String, int, int)
- */
- // public StructuredDocumentEvent updateModel(Object requester, String
- // changes, int start, int end, IStructuredDocumentRegion flatnode) {
- public StructuredDocumentEvent updateModel(Object requester, IStructuredDocumentRegion structuredDocumentRegion, String changes, int requestStart, int lengthToReplace) {
- StructuredDocumentEvent result = null;
- int lengthDifference = Utilities.calculateLengthDifference(changes, lengthToReplace);
- // Get the region pointed to by the requestStart postion, and give
- // that region a chance to effect
- // the update.
- ITextRegion region = getRegionAtCharacterOffset(requestStart);
- // if there is no region, then the requested changes must come right
- // after the
- // node (and right after the last region). This happens, for example,
- // when someone
- // types something at the end of the document, or more commonly, when
- // they are right
- // at the beginning of one node, and the dirty start is therefore
- // calculated to be the
- // previous node.
- // So, in this case, we'll give the last region a chance to see if it
- // wants to
- // swallow the requested changes -- but only for inserts -- deletes
- // and "replaces"
- // should be reparsed if they are in these border regions, and only if
- // the
- if ((region == null) && (lengthToReplace == 0)) {
- region = _getRegions().get(_getRegions().size() - 1);
- // make sure the region is contiguous
- if (getEndOffset(region) == requestStart) {
- result = region.updateModel(requester, this, changes, requestStart, lengthToReplace);
- }
- } else {
- if (region != null) {
- //
- // If the requested change spans more than one region, then
- // we don't give the region a chance to update.
- if ((containsOffset(region, requestStart)) && (containsOffset(region, requestStart + lengthToReplace))) {
- result = region.updateModel(requester, this, changes, requestStart, lengthToReplace);
- }
- }
- }
- // if result is not null, then we need to update the start and end
- // postions of the regions that follow this one
- // if result is null, then apply the flatnode specific checks on what
- // it can change
- // (i.e. more than one region, but no change to the node itself)
- if (result != null) {
- // That is, a region decided it could handle the change and
- // created
- // a region changed event.
- Assert.isTrue(result instanceof RegionChangedEvent, "Program Error"); //$NON-NLS-1$
- updateDownStreamRegions(((RegionChangedEvent) result).getRegion(), lengthDifference);
- // PLUS, we need to update our own node end point (length)
- setLength(getLength() + lengthDifference);
- }
-
- return result;
- }
-
-}
diff --git a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/text/CharSequenceReader.java b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/text/CharSequenceReader.java
deleted file mode 100644
index 081f630609..0000000000
--- a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/text/CharSequenceReader.java
+++ /dev/null
@@ -1,127 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Jens Lukowski/Innoopract - initial renaming/restructuring
- *
- *******************************************************************************/
-package org.eclipse.wst.sse.core.internal.text;
-
-import java.io.IOException;
-import java.io.Reader;
-
-public class CharSequenceReader extends Reader {
- private int fCurrentPosition;
- private int fMaximumReadOffset;
-
- private CharSequence fOriginalSource;
-
- /**
- *
- */
- CharSequenceReader() {
- super();
- }
-
-
- public CharSequenceReader(CharSequence originalSource, int offset, int length) {
- // ISSUE: should we "fail fast" if requested length is more than there
- // is?
- fOriginalSource = originalSource;
- int startOffset = offset;
- int maxRequestedOffset = startOffset + length;
- int maxPossibleOffset = 0 + originalSource.length();
- fMaximumReadOffset = Math.min(maxRequestedOffset, maxPossibleOffset);
-
- fCurrentPosition = startOffset;
-
- }
-
- /**
- * @param lock
- */
- CharSequenceReader(Object lock) {
- super(lock);
- // for thread safety, may need to add back locking mechanism
- // in our custom constructor. This constructor left here just
- // for a reminder.
- }
-
- public void close() throws IOException {
- // nothing to do when we close
- // (may be to eventually "unlock" or null out some varibles
- // just for hygene.
- // or, perhaps if already closed once throw IOException? for
- // consistency?
- }
-
- /**
- * @return Returns the originalSource.
- * @deprecated - only temporarily public, should be 'default' eventually
- * or go away altogether.
- */
- public CharSequence getOriginalSource() {
- return fOriginalSource;
- }
-
- public int read() {
- int result = -1;
- if (fCurrentPosition < fMaximumReadOffset) {
- result = fOriginalSource.charAt(fCurrentPosition++);
- }
- return result;
- }
-
- /**
- * Read characters into a portion of an array. This method will block
- * until some input is available, an I/O error occurs, or the end of the
- * stream is reached.
- *
- * @param cbuf
- * Destination buffer
- * @param off
- * Offset at which to start storing characters
- * @param len
- * Maximum number of characters to read
- *
- * @return The number of characters read, or -1 if the end of the stream
- * has been reached
- *
- * @exception IOException
- * If an I/O error occurs
- */
-
- public int read(char[] cbuf, int off, int len) throws IOException {
- int charsToRead = -1;
- // if already over max, just return -1
- // remember, currentPosition is what is getting ready to be read
- // (that is, its already been incremented in read()).
- if (fCurrentPosition < fMaximumReadOffset) {
-
-
- int buffMaxToRead = cbuf.length - off;
- int minRequested = Math.min(buffMaxToRead, len);
- int lengthRemaining = fMaximumReadOffset - fCurrentPosition;
- charsToRead = Math.min(minRequested, lengthRemaining);
-
-
- CharSequence seq = fOriginalSource.subSequence(fCurrentPosition, fCurrentPosition + charsToRead);
- // for now, hard assumption that original is a String since source
- // is assumed to be document, or text store
- String seqString = (String) seq;
- seqString.getChars(0, seqString.length(), cbuf, off);
-
-
-
- fCurrentPosition = fCurrentPosition + charsToRead;
-
-
- }
- return charsToRead;
- }
-}
diff --git a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/text/CoreNodeList.java b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/text/CoreNodeList.java
deleted file mode 100644
index c7b40e6361..0000000000
--- a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/text/CoreNodeList.java
+++ /dev/null
@@ -1,132 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Jens Lukowski/Innoopract - initial renaming/restructuring
- *
- *******************************************************************************/
-package org.eclipse.wst.sse.core.internal.text;
-
-
-
-import java.util.Enumeration;
-
-import org.eclipse.wst.sse.core.text.IStructuredDocumentRegion;
-import org.eclipse.wst.sse.core.text.IStructuredDocumentRegionList;
-
-
-public class CoreNodeList implements IStructuredDocumentRegionList {
- int countedLength;
- int currentIndex = -1;
-
- //com.ibm.sed.interfaces.core.Core
- IStructuredDocumentRegion[] flatNodes;
- //com.ibm.sed.interfaces.core.Core
- IStructuredDocumentRegion head;
-
- /**
- * CoreNodeList constructor comment.
- */
- public CoreNodeList() {
- super();
- // create an array, even if zero length
- flatNodes = new IStructuredDocumentRegion[0];
- }
-
- public CoreNodeList(IStructuredDocumentRegion newHead) {
- super();
- // save head
- head = newHead;
- int count = 0;
- IStructuredDocumentRegion countNode = newHead;
- // we have to go through the list once, to get its
- // length in order to create the array
- while (countNode != null) {
- count++;
- countNode = countNode.getNext();
- }
- // create an array, even if zero length
- flatNodes = new IStructuredDocumentRegion[count];
- // start countNode over again, so to speak.
- countNode = newHead;
- count = 0;
- while (countNode != null) {
- flatNodes[count++] = countNode;
- countNode = countNode.getNext();
- }
- if (count > 0) {
- currentIndex = 0;
- // else it stays at -1 initialized at object creation
- //
- // save length
- countedLength = count;
- }
- }
-
- public CoreNodeList(IStructuredDocumentRegion start, IStructuredDocumentRegion end) {
- super();
- // save head
- head = start;
- int count = 0;
- IStructuredDocumentRegion countNode = start;
- if ((start == null) || (end == null)) {
- // error condition
- //throw new IllegalArgumentException("Must provide start and end
- // nodes to construct CoreNodeList");
- } else {
- count = 1;
- while ((countNode != null) && (countNode != end)) {
- count++;
- countNode = countNode.getNext();
- }
- }
- // if we ended because the last one was null,
- // backup one.
- if (countNode == null)
- count--;
- if (count < 0) {
- count = 0;
- }
- flatNodes = new IStructuredDocumentRegion[count];
- if (count > 0) {
- flatNodes[0] = countNode = start;
- for (int i = 1; i < count; i++) {
- flatNodes[i] = flatNodes[i - 1].getNext();
- }
-
- }
- currentIndex = 0;
- countedLength = count;
- }
-
- public Enumeration elements() {
- StructuredDocumentRegionEnumeration result = null;
- if ((flatNodes != null) && (flatNodes.length > 0))
- result = new StructuredDocumentRegionEnumeration(flatNodes[0], flatNodes[flatNodes.length - 1]);
- else
- result = new StructuredDocumentRegionEnumeration(null);
- return result;
- }
-
- public int getLength() {
- return flatNodes.length;
- }
-
- public boolean includes(Object o) {
- if (flatNodes == null)
- return false;
- for (int i = 0; i < flatNodes.length; i++)
- if (flatNodes[i] == o)
- return true;
- return false;
- }
-
- public IStructuredDocumentRegion item(int i) {
- return flatNodes[i];
- }
-}
diff --git a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/text/DocumentInternalStateRule.java b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/text/DocumentInternalStateRule.java
deleted file mode 100644
index 76c4759414..0000000000
--- a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/text/DocumentInternalStateRule.java
+++ /dev/null
@@ -1,56 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Jens Lukowski/Innoopract - initial renaming/restructuring
- *
- *******************************************************************************/
-
-package org.eclipse.wst.sse.core.internal.text;
-
-import org.eclipse.core.runtime.jobs.ISchedulingRule;
-
-
-public class DocumentInternalStateRule implements ISchedulingRule {
-
- private final static int READ_STATE = 2;
- public final static DocumentInternalStateRule READ_RULE = new DocumentInternalStateRule(READ_STATE);
-
- private final static int WRITE_STATE = 1;
- public final static DocumentInternalStateRule WRITE_RULE = new DocumentInternalStateRule(WRITE_STATE);
- private int fState;
-
- /**
- *
- */
- public DocumentInternalStateRule(int state) {
- super();
- fState = state;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.core.runtime.jobs.ISchedulingRule#contains(org.eclipse.core.runtime.jobs.ISchedulingRule)
- */
- public boolean contains(ISchedulingRule rule) {
- boolean result = (rule instanceof DocumentInternalStateRule);
- return result;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.core.runtime.jobs.ISchedulingRule#isConflicting(org.eclipse.core.runtime.jobs.ISchedulingRule)
- */
- public boolean isConflicting(ISchedulingRule rule) {
- boolean result = (fState == WRITE_STATE) && (rule instanceof DocumentInternalStateRule);
- return result;
- }
-
-}
diff --git a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/text/GenericPositionManager.java b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/text/GenericPositionManager.java
deleted file mode 100644
index da26c4c7ed..0000000000
--- a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/text/GenericPositionManager.java
+++ /dev/null
@@ -1,401 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Jens Lukowski/Innoopract - initial renaming/restructuring
- *
- *******************************************************************************/
-
-package org.eclipse.wst.sse.core.internal.text;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-
-import org.eclipse.jface.text.BadLocationException;
-import org.eclipse.jface.text.BadPositionCategoryException;
-import org.eclipse.jface.text.DefaultPositionUpdater;
-import org.eclipse.jface.text.DocumentEvent;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.IPositionUpdater;
-import org.eclipse.jface.text.Position;
-import org.eclipse.wst.sse.core.util.Assert;
-
-
-
-public class GenericPositionManager {
- private CharSequence fCharSequence;
-
-
-
- private Map fPositions;
- /** All registered document position updaters */
- private List fPositionUpdaters;
-
- /**
- * don't allow instantiation with out document pointer
- *
- */
- private GenericPositionManager() {
- super();
- }
-
- /**
- *
- */
- public GenericPositionManager(CharSequence charSequence) {
- this();
- // we only use charSequence for "length", to
- // made more generic than "document" even "text store"
- fCharSequence = charSequence;
- completeInitialization();
- }
-
- /*
- * @see org.eclipse.jface.text.IDocument#addPosition(org.eclipse.jface.text.Position)
- */
- public void addPosition(Position position) throws BadLocationException {
- try {
- addPosition(IDocument.DEFAULT_CATEGORY, position);
- } catch (BadPositionCategoryException e) {
- }
- }
-
-
-
- /*
- * @see org.eclipse.jface.text.IDocument#addPosition(java.lang.String,
- * org.eclipse.jface.text.Position)
- */
- public void addPosition(String category, Position position) throws BadLocationException, BadPositionCategoryException {
-
- if ((0 > position.offset) || (0 > position.length) || (position.offset + position.length > getDocumentLength()))
- throw new BadLocationException();
-
- if (category == null)
- throw new BadPositionCategoryException();
-
- List list = (List) fPositions.get(category);
- if (list == null)
- throw new BadPositionCategoryException();
-
- list.add(computeIndexInPositionList(list, position.offset), position);
- }
-
- /*
- * @see org.eclipse.jface.text.IDocument#addPositionCategory(java.lang.String)
- */
- public void addPositionCategory(String category) {
-
- if (category == null)
- return;
-
- if (!containsPositionCategory(category))
- fPositions.put(category, new ArrayList());
- }
-
- /*
- * @see org.eclipse.jface.text.IDocument#addPositionUpdater(org.eclipse.jface.text.IPositionUpdater)
- */
- public void addPositionUpdater(IPositionUpdater updater) {
- insertPositionUpdater(updater, fPositionUpdaters.size());
- }
-
-
- /**
- * Initializes document listeners, positions, and position updaters. Must
- * be called inside the constructor after the implementation plug-ins have
- * been set.
- */
- protected void completeInitialization() {
-
- fPositions = new HashMap();
- fPositionUpdaters = new ArrayList();
-
- addPositionCategory(IDocument.DEFAULT_CATEGORY);
- addPositionUpdater(new DefaultPositionUpdater(IDocument.DEFAULT_CATEGORY));
- }
-
- /*
- * @see org.eclipse.jface.text.IDocument#computeIndexInCategory(java.lang.String,
- * int)
- */
- public int computeIndexInCategory(String category, int offset) throws BadLocationException, BadPositionCategoryException {
-
- if (0 > offset || offset > getDocumentLength())
- throw new BadLocationException();
-
- List c = (List) fPositions.get(category);
- if (c == null)
- throw new BadPositionCategoryException();
-
- return computeIndexInPositionList(c, offset);
- }
-
-
- /**
- * Computes the index in the list of positions at which a position with
- * the given offset would be inserted. The position is supposed to become
- * the first in this list of all positions with the same offset.
- *
- * @param positions
- * the list in which the index is computed
- * @param offset
- * the offset for which the index is computed
- * @return the computed index
- *
- * @see IDocument#computeIndexInCategory(String, int)
- */
- protected int computeIndexInPositionList(List positions, int offset) {
-
- if (positions.size() == 0)
- return 0;
-
- int left = 0;
- int right = positions.size() - 1;
- int mid = 0;
- Position p = null;
-
- while (left < right) {
-
- mid = (left + right) / 2;
-
- p = (Position) positions.get(mid);
- if (offset < p.getOffset()) {
- if (left == mid)
- right = left;
- else
- right = mid - 1;
- } else if (offset > p.getOffset()) {
- if (right == mid)
- left = right;
- else
- left = mid + 1;
- } else if (offset == p.getOffset()) {
- left = right = mid;
- }
-
- }
-
- int pos = left;
- p = (Position) positions.get(pos);
- if (offset > p.getOffset()) {
- // append to the end
- pos++;
- } else {
- // entry will became the first of all entries with the same
- // offset
- do {
- --pos;
- if (pos < 0)
- break;
- p = (Position) positions.get(pos);
- } while (offset == p.getOffset());
- ++pos;
- }
-
- Assert.isTrue(0 <= pos && pos <= positions.size());
-
- return pos;
- }
-
- /*
- * @see org.eclipse.jface.text.IDocument#containsPosition(java.lang.String,
- * int, int)
- */
- public boolean containsPosition(String category, int offset, int length) {
-
- if (category == null)
- return false;
-
- List list = (List) fPositions.get(category);
- if (list == null)
- return false;
-
- int size = list.size();
- if (size == 0)
- return false;
-
- int index = computeIndexInPositionList(list, offset);
- if (index < size) {
- Position p = (Position) list.get(index);
- while (p != null && p.offset == offset) {
- if (p.length == length)
- return true;
- ++index;
- p = (index < size) ? (Position) list.get(index) : null;
- }
- }
-
- return false;
- }
-
- /*
- * @see org.eclipse.jface.text.IDocument#containsPositionCategory(java.lang.String)
- */
- public boolean containsPositionCategory(String category) {
- if (category != null)
- return fPositions.containsKey(category);
- return false;
- }
-
-
-
- public int getDocumentLength() {
- return fCharSequence.length();
- }
-
- /**
- * Returns all positions managed by the document grouped by category.
- *
- * @return the document's positions
- */
- protected Map getDocumentManagedPositions() {
- return fPositions;
- }
-
- /*
- * @see org.eclipse.jface.text.IDocument#getPositionCategories()
- */
- public String[] getPositionCategories() {
- String[] categories = new String[fPositions.size()];
- Iterator keys = fPositions.keySet().iterator();
- for (int i = 0; i < categories.length; i++)
- categories[i] = (String) keys.next();
- return categories;
- }
-
-
- public Position[] getPositions(String category) throws BadPositionCategoryException {
-
- if (category == null)
- throw new BadPositionCategoryException();
-
- List c = (List) fPositions.get(category);
- if (c == null)
- throw new BadPositionCategoryException();
-
- Position[] positions = new Position[c.size()];
- c.toArray(positions);
- return positions;
- }
-
- /*
- * @see org.eclipse.jface.text.IDocument#getPositionUpdaters()
- */
- public IPositionUpdater[] getPositionUpdaters() {
- IPositionUpdater[] updaters = new IPositionUpdater[fPositionUpdaters.size()];
- fPositionUpdaters.toArray(updaters);
- return updaters;
- }
-
-
-
- /*
- * @see org.eclipse.jface.text.IDocument#insertPositionUpdater(org.eclipse.jface.text.IPositionUpdater,
- * int)
- */
- public void insertPositionUpdater(IPositionUpdater updater, int index) {
-
- for (int i = fPositionUpdaters.size() - 1; i >= 0; i--) {
- if (fPositionUpdaters.get(i) == updater)
- return;
- }
-
- if (index == fPositionUpdaters.size())
- fPositionUpdaters.add(updater);
- else
- fPositionUpdaters.add(index, updater);
- }
-
- /*
- * @see org.eclipse.jface.text.IDocument#removePosition(org.eclipse.jface.text.Position)
- */
- public void removePosition(Position position) {
- try {
- removePosition(IDocument.DEFAULT_CATEGORY, position);
- } catch (BadPositionCategoryException e) {
- }
- }
-
- /*
- * @see org.eclipse.jface.text.IDocument#removePosition(java.lang.String,
- * org.eclipse.jface.text.Position)
- */
- public void removePosition(String category, Position position) throws BadPositionCategoryException {
-
- if (position == null)
- return;
-
- if (category == null)
- throw new BadPositionCategoryException();
-
- List c = (List) fPositions.get(category);
- if (c == null)
- throw new BadPositionCategoryException();
-
- // remove based on identity not equality
- int size = c.size();
- for (int i = 0; i < size; i++) {
- if (position == c.get(i)) {
- c.remove(i);
- return;
- }
- }
- }
-
- /*
- * @see org.eclipse.jface.text.IDocument#removePositionCategory(java.lang.String)
- */
- public void removePositionCategory(String category) throws BadPositionCategoryException {
-
- if (category == null)
- return;
-
- if (!containsPositionCategory(category))
- throw new BadPositionCategoryException();
-
- fPositions.remove(category);
- }
-
- /*
- * @see org.eclipse.jface.text.IDocument#removePositionUpdater(org.eclipse.jface.text.IPositionUpdater)
- */
- public void removePositionUpdater(IPositionUpdater updater) {
- for (int i = fPositionUpdaters.size() - 1; i >= 0; i--) {
- if (fPositionUpdaters.get(i) == updater) {
- fPositionUpdaters.remove(i);
- return;
- }
- }
- }
-
-
- /**
- * Updates all positions of all categories to the change described by the
- * document event. All registered document updaters are called in the
- * sequence they have been arranged. Uses a robust iterator.
- *
- * @param event
- * the document event describing the change to which to adapt
- * the positions
- */
- protected void updatePositions(DocumentEvent event) {
- List list = new ArrayList(fPositionUpdaters);
- Iterator e = list.iterator();
- while (e.hasNext()) {
- IPositionUpdater u = (IPositionUpdater) e.next();
- u.update(event);
- }
- }
-
-
-}
-
diff --git a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/text/IExecutionDelegatable.java b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/text/IExecutionDelegatable.java
deleted file mode 100644
index 5e314101e3..0000000000
--- a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/text/IExecutionDelegatable.java
+++ /dev/null
@@ -1,20 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Jens Lukowski/Innoopract - initial renaming/restructuring
- *
- *******************************************************************************/
-package org.eclipse.wst.sse.core.internal.text;
-
-import org.eclipse.wst.sse.core.document.IExecutionDelegate;
-
-public interface IExecutionDelegatable {
-
- void setExecutionDelegate(IExecutionDelegate executionDelegate);
-}
diff --git a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/text/IRegionComparible.java b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/text/IRegionComparible.java
deleted file mode 100644
index 3230439abb..0000000000
--- a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/text/IRegionComparible.java
+++ /dev/null
@@ -1,20 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Jens Lukowski/Innoopract - initial renaming/restructuring
- *
- *******************************************************************************/
-package org.eclipse.wst.sse.core.internal.text;
-
-public interface IRegionComparible {
- boolean regionMatches(int offset, int length, String stringToCompare);
-
- boolean regionMatchesIgnoreCase(int offset, int length, String stringToCompare);
-
-}
diff --git a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/text/JobSafeStructuredDocument.java b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/text/JobSafeStructuredDocument.java
deleted file mode 100644
index 18bc4d2759..0000000000
--- a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/text/JobSafeStructuredDocument.java
+++ /dev/null
@@ -1,179 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Jens Lukowski/Innoopract - initial renaming/restructuring
- *
- *******************************************************************************/
-package org.eclipse.wst.sse.core.internal.text;
-
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.core.runtime.jobs.ILock;
-import org.eclipse.wst.sse.core.document.IExecutionDelegate;
-import org.eclipse.wst.sse.core.document.ILockable;
-import org.eclipse.wst.sse.core.events.NewModelEvent;
-import org.eclipse.wst.sse.core.events.StructuredDocumentEvent;
-import org.eclipse.wst.sse.core.parser.RegionParser;
-
-
-
-public class JobSafeStructuredDocument extends BasicStructuredDocument implements IExecutionDelegatable, ILockable {
-
- private IExecutionDelegate fExecutionDelegate;
- private ILock fLockable = null;
-
- public JobSafeStructuredDocument() {
- super();
- }
-
-
- public JobSafeStructuredDocument(RegionParser parser) {
- super(parser);
- }
-
-
- /**
- *
- */
- protected final void acquireLock() {
- getLockObject().acquire();
- }
-
- private IExecutionDelegate getExecutionDelegate() {
- return fExecutionDelegate;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.wst.sse.core.ILockable#getLock()
- */
-
- public ILock getLockObject() {
- if (fLockable == null) {
- fLockable = Platform.getJobManager().newLock();
- }
- return fLockable;
- }
-
-
- /**
- *
- */
- protected final void releaseLock() {
- getLockObject().release();
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.wst.sse.core.text.IStructuredDocument#replaceText(java.lang.Object,
- * int, int, java.lang.String, boolean)
- */
- public StructuredDocumentEvent replaceText(final Object requester, final int start, final int replacementLength, final String changes, final boolean ignoreReadOnlySettings) {
- Object threadResult = null;
- StructuredDocumentEvent event = null;
- if (getExecutionDelegate() == null) {
- // if the delegate has not been set, we execute on current
- // thread, like "normal". This is the case for normal
- // non-editor
- // use (which should still, ultimately, be protected by
- // a scheduling rule).
- event = super.replaceText(requester, start, replacementLength, changes, ignoreReadOnlySettings);
- } else {
- // If document is being used by an editor, a runnable is
- // created,
- // even if later (in the execution delegate instance) it is
- // decided
- // nothing special is needed (that is, in fact being called
- // from
- // editor's display thread, in which case its just executed)
- final Object[] resultSlot = new Object[1];
- Runnable runnable = new Runnable() {
- public void run() {
- try {
- resultSlot[0] = JobSafeStructuredDocument.super.replaceText(requester, start, replacementLength, changes, ignoreReadOnlySettings);
- } catch (Throwable e) {
- resultSlot[0] = e;
- }
- }
- };
- // strongly assumes synchronous call, to "wait" for
- // results
- // basically just routes to Display.synchExec(runnable),
- // if not already running on display thread.
- getExecutionDelegate().execute(runnable);
-
- // this remembering and re-throwing of exception is just to
- // get an
- // exception that occurred on one thread, to be thrown on
- // callers
- // thread.
- if (resultSlot[0] instanceof Throwable) {
- throw new RuntimeException((Throwable) resultSlot[0]);
- } else {
- event = (StructuredDocumentEvent) resultSlot[0];
- }
- }
- return event;
- }
-
- public void setExecutionDelegate(IExecutionDelegate delegate) {
- fExecutionDelegate = delegate;
- }
-
-
- public NewModelEvent setText(final Object requester, final String theString) {
- NewModelEvent event = null;
- Object threadResult = null;
- if (getExecutionDelegate() == null) {
- // if the delegate has not been set, we execute on current
- // thread, like "normal". This is the case for normal
- // non-editor
- // use (which should still, ultimately, be protected by
- // a scheduling rule).
- event = super.setText(requester, theString);
- } else {
- // If document is being used by an editor, a runnable is
- // created,
- // even if later (in the execution delegate instance) it is
- // decided
- // nothing special is needed (that is, in fact being called
- // from
- // editor's display thread, in which case its just executed)
- final Object[] resultSlot = new Object[1];
- Runnable runnable = new Runnable() {
- public void run() {
- try {
- resultSlot[0] = JobSafeStructuredDocument.super.setText(requester, theString);
- } catch (Throwable e) {
- resultSlot[0] = e;
- }
- }
- };
- // strongly assumes synchronous call, to "wait" for
- // results
- // basically just routes to Display.synchExec(runnable),
- // if not already running on display thread.
- getExecutionDelegate().execute(runnable);
-
- // this remembering and re-throwing of exception is just to
- // get an
- // exception that occurred on one thread, to be thrown on
- // callers
- // thread.
- if (resultSlot[0] instanceof Throwable) {
- throw new RuntimeException((Throwable) resultSlot[0]);
- } else {
- event = (NewModelEvent) resultSlot[0];
- }
- }
- return event;
- }
-
-}
diff --git a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/text/MinimalDocument.java b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/text/MinimalDocument.java
deleted file mode 100644
index 87a1fe830d..0000000000
--- a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/text/MinimalDocument.java
+++ /dev/null
@@ -1,427 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Jens Lukowski/Innoopract - initial renaming/restructuring
- *
- *******************************************************************************/
-package org.eclipse.wst.sse.core.internal.text;
-
-import org.eclipse.jface.text.BadLocationException;
-import org.eclipse.jface.text.BadPositionCategoryException;
-import org.eclipse.jface.text.IDocumentListener;
-import org.eclipse.jface.text.IDocumentPartitioner;
-import org.eclipse.jface.text.IDocumentPartitioningListener;
-import org.eclipse.jface.text.IPositionUpdater;
-import org.eclipse.jface.text.IRegion;
-import org.eclipse.jface.text.ITypedRegion;
-import org.eclipse.jface.text.Position;
-import org.eclipse.jface.text.TypedRegion;
-import org.eclipse.wst.common.encoding.EncodingMemento;
-import org.eclipse.wst.sse.core.events.IModelAboutToBeChangedListener;
-import org.eclipse.wst.sse.core.events.IStructuredDocumentListener;
-import org.eclipse.wst.sse.core.events.NewModelEvent;
-import org.eclipse.wst.sse.core.events.StructuredDocumentEvent;
-import org.eclipse.wst.sse.core.internal.Logger;
-import org.eclipse.wst.sse.core.internal.NotImplementedException;
-import org.eclipse.wst.sse.core.internal.document.NullStructuredDocumentPartitioner;
-import org.eclipse.wst.sse.core.parser.RegionParser;
-import org.eclipse.wst.sse.core.text.IStructuredDocument;
-import org.eclipse.wst.sse.core.text.IStructuredDocumentRegion;
-import org.eclipse.wst.sse.core.text.IStructuredDocumentRegionList;
-import org.eclipse.wst.sse.core.text.IStructuredTextReParser;
-import org.eclipse.wst.sse.core.undo.IStructuredTextUndoManager;
-
-
-/**
- * Purely a dummy "marker" instance for StructuredDocumentRegions which are
- * created temorarily in the course of re-parsing. Primarily a place holder,
- * but can be needed to get text from.
- */
-public class MinimalDocument implements IStructuredDocument {
- private SubSetTextStore data;
-
- /**
- * Marked private to be sure never created without data being initialized.
- *
- */
- private MinimalDocument() {
- super();
- }
-
- public MinimalDocument(SubSetTextStore initialContents) {
- this();
- data = initialContents;
- }
-
- public void addDocumentAboutToChangeListener(IModelAboutToBeChangedListener listener) {
- throw new NotImplementedException("intentionally not implemented"); //$NON-NLS-1$
- }
-
- public void addDocumentChangedListener(IStructuredDocumentListener listener) {
- throw new NotImplementedException("intentionally not implemented"); //$NON-NLS-1$
- }
-
- public void addDocumentChangingListener(IStructuredDocumentListener listener) {
- throw new NotImplementedException("intentionally not implemented"); //$NON-NLS-1$
- }
-
- public void addDocumentListener(IDocumentListener listener) {
- throw new NotImplementedException("intentionally not implemented"); //$NON-NLS-1$
- }
-
- public void addDocumentPartitioningListener(IDocumentPartitioningListener listener) {
- throw new NotImplementedException("intentionally not implemented"); //$NON-NLS-1$
- }
-
- public void addPosition(Position position) throws BadLocationException {
- throw new NotImplementedException("intentionally not implemented"); //$NON-NLS-1$
- }
-
- public void addPosition(String category, Position position) throws BadLocationException, BadPositionCategoryException {
- throw new NotImplementedException("intentionally not implemented"); //$NON-NLS-1$
- }
-
- public void addPositionCategory(String category) {
- throw new NotImplementedException("intentionally not implemented"); //$NON-NLS-1$
- }
-
- public void addPositionUpdater(IPositionUpdater updater) {
- throw new NotImplementedException("intentionally not implemented"); //$NON-NLS-1$
- }
-
- public void addPrenotifiedDocumentListener(IDocumentListener documentAdapter) {
- throw new NotImplementedException("intentionally not implemented"); //$NON-NLS-1$
- }
-
- public void clearReadOnly(int startOffset, int length) {
- // TODO: this is called from notifier loop inappropriately
- // throw new NotImplementedException("intentionally not implemented");
- }
-
- public int computeIndexInCategory(String category, int offset) throws BadLocationException, BadPositionCategoryException {
- throw new NotImplementedException("intentionally not implemented"); //$NON-NLS-1$
- }
-
- public int computeNumberOfLines(String text) {
- throw new NotImplementedException("intentionally not implemented"); //$NON-NLS-1$
- }
-
- public ITypedRegion[] computePartitioning(int offset, int length) throws BadLocationException {
- throw new NotImplementedException("intentionally not implemented"); //$NON-NLS-1$
- }
-
- public boolean containsPosition(String category, int offset, int length) {
- throw new NotImplementedException("intentionally not implemented"); //$NON-NLS-1$
- }
-
- public boolean containsPositionCategory(String category) {
- throw new NotImplementedException("intentionally not implemented"); //$NON-NLS-1$
- }
-
- public boolean containsReadOnly(int startOffset, int length) {
- throw new NotImplementedException("intentionally not implemented"); //$NON-NLS-1$
- }
-
- public void fireNewDocument(Object requester) {
- throw new NotImplementedException("intentionally not implemented"); //$NON-NLS-1$
- }
-
- public String get() {
- String result = null;
- result = data.get(0, data.getLength());
- return result;
- }
-
- public String get(int offset, int length) throws BadLocationException {
- String result = null;
- try {
- result = data.get(offset, length);
- } catch (StringIndexOutOfBoundsException e) {
- throw new BadLocationException();
- }
- return result;
- }
-
- public Object getAdapter(Class adapter) {
- throw new NotImplementedException("intentionally not implemented"); //$NON-NLS-1$
- }
-
- public char getChar(int offset) throws BadLocationException {
- return data.get(offset);
- }
-
- public String getContentType(int offset) throws BadLocationException {
- throw new NotImplementedException("intentionally not implemented"); //$NON-NLS-1$
- }
-
- public IDocumentPartitioner getDocumentPartitioner() {
- // temp fix
- return new NullStructuredDocumentPartitioner();
- // throw new NotImplementedException("intentionally not implemented");
- }
-
- public EncodingMemento getEncodingMemento() {
- throw new NotImplementedException("intentionally not implemented"); //$NON-NLS-1$
- }
-
- public IStructuredDocumentRegion getFirstStructuredDocumentRegion() {
- throw new NotImplementedException("intentionally not implemented"); //$NON-NLS-1$
- }
-
- public IStructuredDocumentRegion getLastStructuredDocumentRegion() {
- throw new NotImplementedException("intentionally not implemented"); //$NON-NLS-1$
- }
-
- public String[] getLegalContentTypes() {
- throw new NotImplementedException("intentionally not implemented"); //$NON-NLS-1$
- }
-
- public String[] getLegalLineDelimiters() {
- throw new NotImplementedException("intentionally not implemented"); //$NON-NLS-1$
- }
-
- public int getLength() {
- return data.getLength();
- }
-
- public String getLineDelimiter() {
- throw new NotImplementedException("intentionally not implemented"); //$NON-NLS-1$
- }
-
- public String getLineDelimiter(int line) throws BadLocationException {
- throw new NotImplementedException("intentionally not implemented"); //$NON-NLS-1$
- }
-
- public IRegion getLineInformation(int line) throws BadLocationException {
- throw new NotImplementedException("intentionally not implemented"); //$NON-NLS-1$
- }
-
- public IRegion getLineInformationOfOffset(int offset) throws BadLocationException {
- throw new NotImplementedException("intentionally not implemented"); //$NON-NLS-1$
- }
-
- public int getLineLength(int line) throws BadLocationException {
- throw new NotImplementedException("intentionally not implemented"); //$NON-NLS-1$
- }
-
- public int getLineOffset(int line) throws BadLocationException {
- throw new NotImplementedException("intentionally not implemented"); //$NON-NLS-1$
- }
-
- public int getLineOfOffset(int offset) {
- throw new NotImplementedException("intentionally not implemented"); //$NON-NLS-1$
- }
-
- public int getNumberOfLines() {
- throw new NotImplementedException("intentionally not implemented"); //$NON-NLS-1$
- }
-
- public int getNumberOfLines(int offset, int length) throws BadLocationException {
- throw new NotImplementedException("intentionally not implemented"); //$NON-NLS-1$
- }
-
- public RegionParser getParser() {
- throw new NotImplementedException("intentionally not implemented"); //$NON-NLS-1$
- }
-
- public ITypedRegion getPartition(int offset) throws BadLocationException {
- Logger.log(Logger.WARNING, "An instance of MinimalDocument was asked for its partition, sometime indicating a deleted region was being accessed.");
- return new TypedRegion(0,0, "undefined");
- //throw new NotImplementedException("intentionally not implemented"); //$NON-NLS-1$
- }
-
- public String[] getPositionCategories() {
- throw new NotImplementedException("intentionally not implemented"); //$NON-NLS-1$
- }
-
- public Position[] getPositions(String category) throws BadPositionCategoryException {
- throw new NotImplementedException("intentionally not implemented"); //$NON-NLS-1$
- }
-
- public IPositionUpdater[] getPositionUpdaters() {
- throw new NotImplementedException("intentionally not implemented"); //$NON-NLS-1$
- }
-
- public IStructuredDocumentRegion getRegionAtCharacterOffset(int offset) {
- throw new NotImplementedException("intentionally not implemented"); //$NON-NLS-1$
- }
-
- public IStructuredDocumentRegionList getRegionList() {
- throw new NotImplementedException("intentionally not implemented"); //$NON-NLS-1$
- }
-
- public IStructuredTextReParser getReParser() {
- throw new NotImplementedException("intentionally not implemented"); //$NON-NLS-1$
- }
-
- public String getText() {
- return data.get(0, data.getLength());
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.wst.sse.core.text.IStructuredDocument#getUndoManager()
- */
- public IStructuredTextUndoManager getUndoManager() {
- throw new NotImplementedException("intentionally not implemented"); //$NON-NLS-1$
- }
-
- public void insertPositionUpdater(IPositionUpdater updater, int index) {
- throw new NotImplementedException("intentionally not implemented"); //$NON-NLS-1$
- }
-
- public void makeReadOnly(int startOffset, int length) {
- // TODO: this is called from notifier loop inappropriately
- // throw new NotImplementedException("intentionally not implemented");
- }
-
- public IStructuredDocument newInstance() {
- throw new NotImplementedException("intentionally not implemented"); //$NON-NLS-1$
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jface.text.IDocumentExtension#registerPostNotificationReplace(org.eclipse.jface.text.IDocumentListener,
- * org.eclipse.jface.text.IDocumentExtension.IReplace)
- */
- public void registerPostNotificationReplace(IDocumentListener owner, IReplace replace) throws UnsupportedOperationException {
- throw new NotImplementedException("intentionally not implemented"); //$NON-NLS-1$
- }
-
- public void removeDocumentAboutToChangeListener(IModelAboutToBeChangedListener listener) {
- throw new NotImplementedException("intentionally not implemented"); //$NON-NLS-1$
- }
-
- public void removeDocumentChangedListener(IStructuredDocumentListener listener) {
- throw new NotImplementedException("intentionally not implemented"); //$NON-NLS-1$
- }
-
- public void removeDocumentChangingListener(IStructuredDocumentListener listener) {
- throw new NotImplementedException("intentionally not implemented"); //$NON-NLS-1$
- }
-
- public void removeDocumentListener(IDocumentListener listener) {
- throw new NotImplementedException("intentionally not implemented"); //$NON-NLS-1$
- }
-
- public void removeDocumentPartitioningListener(IDocumentPartitioningListener listener) {
- throw new NotImplementedException("intentionally not implemented"); //$NON-NLS-1$
- }
-
- public void removePosition(Position position) {
- throw new NotImplementedException("intentionally not implemented"); //$NON-NLS-1$
- }
-
- public void removePosition(String category, Position position) throws BadPositionCategoryException {
- throw new NotImplementedException("intentionally not implemented"); //$NON-NLS-1$
- }
-
- public void removePositionCategory(String category) throws BadPositionCategoryException {
- throw new NotImplementedException("intentionally not implemented"); //$NON-NLS-1$
- }
-
- public void removePositionUpdater(IPositionUpdater updater) {
- throw new NotImplementedException("intentionally not implemented"); //$NON-NLS-1$
- }
-
- public void removePrenotifiedDocumentListener(IDocumentListener documentAdapter) {
- throw new NotImplementedException("intentionally not implemented"); //$NON-NLS-1$
- }
-
- public void replace(int offset, int length, String text) throws BadLocationException {
- throw new NotImplementedException("intentionally not implemented"); //$NON-NLS-1$
- // data.replace(offset, length, text);
- }
-
- public StructuredDocumentEvent replaceText(Object source, int oldStart, int replacementLength, String requestedChange) {
- throw new NotImplementedException("intentionally not implemented"); //$NON-NLS-1$
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.wst.sse.core.text.IStructuredDocument#replaceText(java.lang.Object,
- * int, int, java.lang.String, boolean)
- */
- public StructuredDocumentEvent replaceText(Object source, int oldStart, int replacementLength, String requestedChange, boolean ignoreReadOnlySetting) {
- throw new NotImplementedException("intentionally not implemented"); //$NON-NLS-1$
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jface.text.IDocumentExtension#resumePostNotificationProcessing()
- */
- public void resumePostNotificationProcessing() {
- throw new NotImplementedException("intentionally not implemented"); //$NON-NLS-1$
- }
-
- public int search(int startOffset, String findString, boolean forwardSearch, boolean caseSensitive, boolean wholeWord) throws BadLocationException {
- throw new NotImplementedException("intentionally not implemented"); //$NON-NLS-1$
- }
-
- public void set(String text) {
- throw new NotImplementedException("intentionally not implemented"); //$NON-NLS-1$
- // data.set(text);
- }
-
- public void setDocumentPartitioner(IDocumentPartitioner partitioner) {
- throw new NotImplementedException("intentionally not implemented"); //$NON-NLS-1$
- }
-
- public void setEncodingMemento(EncodingMemento encodingMemento) {
- throw new NotImplementedException("intentionally not implemented"); //$NON-NLS-1$
- }
-
- public void setLineDelimiter(String delimiter) {
- throw new NotImplementedException("intentionally not implemented"); //$NON-NLS-1$
- }
-
- public NewModelEvent setText(Object requester, String allText) {
- throw new NotImplementedException("intentionally not implemented"); //$NON-NLS-1$
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.wst.sse.core.text.IStructuredDocument#setUndoManager(org.eclipse.wst.sse.core.undo.StructuredTextUndoManager)
- */
- public void setUndoManager(IStructuredTextUndoManager undoManager) {
- throw new NotImplementedException("intentionally not implemented"); //$NON-NLS-1$
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jface.text.IDocumentExtension#startSequentialRewrite(boolean)
- */
- public void startSequentialRewrite(boolean normalize) {
- throw new NotImplementedException("intentionally not implemented"); //$NON-NLS-1$
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jface.text.IDocumentExtension#stopPostNotificationProcessing()
- */
- public void stopPostNotificationProcessing() {
- throw new NotImplementedException("intentionally not implemented"); //$NON-NLS-1$
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jface.text.IDocumentExtension#stopSequentialRewrite()
- */
- public void stopSequentialRewrite() {
- throw new NotImplementedException("intentionally not implemented"); //$NON-NLS-1$
- }
-}
diff --git a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/text/StructuredDocumentReParser.java b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/text/StructuredDocumentReParser.java
deleted file mode 100644
index fba1d08295..0000000000
--- a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/text/StructuredDocumentReParser.java
+++ /dev/null
@@ -1,1660 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Jens Lukowski/Innoopract - initial renaming/restructuring
- *
- *******************************************************************************/
-package org.eclipse.wst.sse.core.internal.text;
-
-import java.util.Iterator;
-import java.util.List;
-
-import org.eclipse.jface.text.BadLocationException;
-import org.eclipse.jface.text.FindReplaceDocumentAdapter;
-import org.eclipse.jface.text.IRegion;
-import org.eclipse.wst.sse.core.events.NoChangeEvent;
-import org.eclipse.wst.sse.core.events.RegionChangedEvent;
-import org.eclipse.wst.sse.core.events.RegionsReplacedEvent;
-import org.eclipse.wst.sse.core.events.StructuredDocumentEvent;
-import org.eclipse.wst.sse.core.events.StructuredDocumentRegionsReplacedEvent;
-import org.eclipse.wst.sse.core.internal.Logger;
-import org.eclipse.wst.sse.core.parser.BlockTagParser;
-import org.eclipse.wst.sse.core.text.IStructuredDocument;
-import org.eclipse.wst.sse.core.text.IStructuredDocumentRegion;
-import org.eclipse.wst.sse.core.text.IStructuredTextReParser;
-import org.eclipse.wst.sse.core.text.ITextRegion;
-import org.eclipse.wst.sse.core.text.ITextRegionCollection;
-import org.eclipse.wst.sse.core.text.ITextRegionContainer;
-import org.eclipse.wst.sse.core.text.ITextRegionList;
-import org.eclipse.wst.sse.core.util.Debug;
-import org.eclipse.wst.sse.core.util.StringUtils;
-import org.eclipse.wst.sse.core.util.Utilities;
-
-
-/**
- * This class provides a centralized place to put "reparsing" logic. This is
- * the logic that reparses the text incrementally, as a user types in new
- * characters, or DOM nodes are inserted or deleted. Note: it is not a thread
- * safe class.
- */
-public class StructuredDocumentReParser implements IStructuredTextReParser {
- protected IStructuredDocumentRegion dirtyEnd = null;
- protected IStructuredDocumentRegion dirtyStart = null;
- final private String doubleQuote = new String(new char[]{'\"'});
- protected final CoreNodeList EMPTY_LIST = new CoreNodeList();
- protected String fChanges;
- protected String fDeletedText;
-
- private FindReplaceDocumentAdapter fFindReplaceDocumentAdapter = null;
- protected int fLengthDifference;
- protected int fLengthToReplace;
- protected Object fRequester;
- protected int fStart;
- // note: this is the impl class of IStructuredDocument, not the interface
- // FUTURE_TO_DO: I believe some of these can be made private now.?
- protected BasicStructuredDocument fStructuredDocument;
-
- /**
- * variable used in anticiapation of multithreading
- */
- protected boolean isParsing;
- final private String singleQuote = new String(new char[]{'\''});
-
- public StructuredDocumentReParser() {
- super();
- }
-
- public StructuredDocumentEvent _checkBlockNodeList(List blockTagList) {
- StructuredDocumentEvent result = null;
- if (blockTagList != null) {
- for (int i = 0; i < blockTagList.size(); i++) {
- org.eclipse.wst.sse.core.parser.BlockMarker blockTag = (org.eclipse.wst.sse.core.parser.BlockMarker) blockTagList.get(i);
- String tagName = blockTag.getTagName();
- result = checkForCriticalName("<" + tagName); //$NON-NLS-1$
- if (result != null)
- break;
- result = checkForCriticalName("</" + tagName); //$NON-NLS-1$
- if (result != null)
- break;
- }
- }
- return result;
- }
-
- /**
- * Common utility for checking for critical word such as " <SCRIPT>"
- */
- private StructuredDocumentEvent _checkForCriticalWord(String criticalTarget, boolean checkEnd) {
- StructuredDocumentEvent result = null;
- int documentLength = fStructuredDocument.getLength();
- int propLen = fLengthToReplace;
- if (propLen > documentLength)
- propLen = documentLength;
- int startNeighborhood = fStart - criticalTarget.length();
- int adjustInsert = 0;
- if (startNeighborhood < 0) {
- adjustInsert = 0 - startNeighborhood;
- startNeighborhood = 0;
- }
- int endNeighborhood = fStart + fLengthToReplace + criticalTarget.length() - 1;
- if (endNeighborhood > documentLength)
- endNeighborhood = documentLength - 1;
- int oldlen = endNeighborhood - startNeighborhood; // + 1;
- if (oldlen + startNeighborhood > documentLength) {
- oldlen = documentLength - startNeighborhood;
- }
- String oldText = fStructuredDocument.get(startNeighborhood, oldlen);
- String peek = StringUtils.paste(oldText, fChanges, criticalTarget.length() - adjustInsert, fLengthToReplace);
- boolean isCriticalString = checkTagNames(oldText, criticalTarget, checkEnd);
- boolean toBeCriticalString = checkTagNames(peek, criticalTarget, checkEnd);
- if ((isCriticalString != toBeCriticalString) || // OR if both are
- // critical and there's
- // a change in the end
- // tag ('>')
- ((isCriticalString && toBeCriticalString) && (changeInIsEndedState(oldText, peek)))) {
- // if it involves a change of a critical string (making one where
- // there wasn't, or removing
- // one where there was one) then reparse everthing.
- result = reparse(0, documentLength - 1);
- }
- return result;
- }
-
- private int _computeStartOfDifferences(CoreNodeList oldNodes, CoreNodeList newNodes) {
- int startOfDifferences = -1;
- int newNodesLength = newNodes.getLength();
- boolean foundDifference = false;
- boolean done = false;
- // we'll control our loop based on the old List length
- int oldNodesLength = oldNodes.getLength();
- // be sure to check 'done' first, so startOfDifferences isn't
- // icremented if done is true
- done : while ((!done) && (++startOfDifferences < oldNodesLength)) {
- IStructuredDocumentRegion oldNode = oldNodes.item(startOfDifferences);
- // this lessThanEffectedRegion is to check to be sure the node is
- // infact a candidate
- // to be considered as "old". This check is important for the case
- // where some
- // text is replaceing text that
- // appears identical, but is a different instance. For example, if
- // the text
- // is <P><B></B></P> and <B></B> is inserted at postion 3,
- // resulting in <P><B></B><B></B></P>
- // we do not want the
- // first <B> to be considered old ... it is the new one, the
- // second
- // <B> is the old one.
- if (_lessThanEffectedRegion(oldNode)) {
- // be sure to check that we have new nodes to compare against.
- if (startOfDifferences > newNodesLength) {
- foundDifference = false;
- done = true;
- continue done;
- } else {
- //
- IStructuredDocumentRegion newNode = newNodes.item(startOfDifferences);
- // note: shift is 0 while at beginning of list, before the
- // insertion (or deletion) point. After that, it is
- // fStart+fLengthDifference
- if (!(oldNode.sameAs(newNode, 0))) {
- foundDifference = true;
- done = true;
- continue done;
- } else { // if they are equal, then we will be keeping the
- // old one, so
- // we need to be sure its parentDocument is set back
- // to
- // the right instance
- oldNode.setParentDocument(fStructuredDocument);
- }
- }
- } else {
- // we didn't literally find a difference, but we count it as
- // such by implication
- foundDifference = true;
- done = true;
- continue done;
- }
- }
- // if we literally found a difference, then all is ok and we can
- // return
- // it.
- // if we did not literally find one, then we have to decide why.
- if (!foundDifference) {
- if (newNodesLength == oldNodesLength) { // then lists are
- // identical
- // (and may be of zero
- // length)
- startOfDifferences = -1;
- } else {
- if (newNodesLength > oldNodesLength) { // then lists are
- // identical except for
- // newNodes added
- startOfDifferences = oldNodesLength;
- } else {
- if (newNodesLength < oldNodesLength) { // then lists are
- // identical except
- // for old Nodes
- // deleted
- startOfDifferences = newNodesLength;
- }
- }
- }
- }
- return startOfDifferences;
- }
-
- private int _computeStartOfDifferences(IStructuredDocumentRegion oldNodeParam, ITextRegionList oldRegions, IStructuredDocumentRegion newNodeParam, ITextRegionList newRegions) {
- int startOfDifferences = -1;
- int newRegionsLength = newRegions.size();
- boolean foundDifference = false;
- boolean done = false;
- // we'll control our loop based on the old List length
- int oldRegionsLength = oldRegions.size();
- // be sure to check 'done' first, so startOfDifferences isn't
- // icremented if done is true
- done : while ((!done) && (++startOfDifferences < oldRegionsLength)) {
- ITextRegion oldRegion = oldRegions.get(startOfDifferences);
- // this lessThanEffectedRegion is to check to be sure the node is
- // infact a candidate
- // to be considered as "old". This check is important for the case
- // where some
- // text is replaceing text that
- // appears identical, but is a different instance. For example, if
- // the text
- // is <P><B></B></P> and <B></B> is inserted at postion 3,
- // resulting in <P><B></B><B></B></P>
- // we do not want the
- // first <B> to be considered old ... it is the new one, the
- // second
- // <B> is the old one.
- if (_lessThanEffectedRegion(oldNodeParam, oldRegion)) {
- // be sure to check that we have new nodes to compare against.
- if (startOfDifferences > newRegionsLength) {
- foundDifference = false;
- done = true;
- continue done;
- } else {
- //
- ITextRegion newRegion = newRegions.get(startOfDifferences);
- // note: shift is 0 while at beginning of list, before the
- // insertion (or deletion) point. After that, it is
- // fStart+fLengthDifference
- if (!(oldNodeParam.sameAs(oldRegion, newNodeParam, newRegion, 0))) {
- foundDifference = true;
- done = true;
- continue done;
- } else {
- // if they are equal, then we will be keeping the old
- // one.
- // unlike the flatnode case, there is no reason to
- // update
- // the textstore, since its the same text store in
- // either case
- // (since its the same flatnode)
- //oldRegion.setTextStore(fStructuredDocument.parentDocument);
- }
- }
- } else {
- // we didn't literally find a difference, but we count it as
- // such by implication
- foundDifference = true;
- done = true;
- continue done;
- }
- }
- // if we literally found a difference, then all is ok and we can
- // return
- // it.
- // if we did not literally find one, then we have to decide why.
- if (!foundDifference) {
- if (newRegionsLength == oldRegionsLength) { // then lists are
- // identical (and may
- // be of zero length)
- startOfDifferences = -1;
- } else {
- if (newRegionsLength > oldRegionsLength) { // then lists are
- // identical except
- // for newRegions
- // added
- startOfDifferences = oldRegionsLength;
- } else {
- if (newRegionsLength < oldRegionsLength) { // then lists
- // are identical
- // except for
- // old Nodes
- // deleted
- startOfDifferences = newRegionsLength;
- }
- }
- }
- }
- return startOfDifferences;
- }
-
- /**
- * Part 1 of 2 steps to do a core_reparse
- *
- * Parses a portion of the current text in the IStructuredDocument and
- * returns the raw result
- */
- private IStructuredDocumentRegion _core_reparse_text(int rescanStart, int rescanEnd) {
- fStructuredDocument.resetParser(rescanStart, rescanEnd);
- return fStructuredDocument.getParser().getDocumentRegions();
- }
-
- /**
- * Part 2 of 2 steps to do a core_reparse
- *
- * Integrates a list of StructuredDocumentRegions based on the current
- * text contents of the IStructuredDocument into the IStructuredDocument
- * data structure
- */
- private StructuredDocumentEvent _core_reparse_update_model(IStructuredDocumentRegion newNodesHead, int rescanStart, int rescanEnd, CoreNodeList oldNodes, boolean firstTime) {
- StructuredDocumentEvent result = null;
- CoreNodeList newNodes = null;
- // rescan
- newNodes = new CoreNodeList(newNodesHead);
- // adjust our newNode chain so the offset positions match
- // our text store (not the simple string of text reparsed)
- StructuredDocumentRegionIterator.adjustStart(newNodesHead, rescanStart);
- // initialize the parentDocument variable of each instance in the new
- // chain
- StructuredDocumentRegionIterator.setParentDocument(newNodesHead, fStructuredDocument);
- // initialize the structuredDocument variable of each instance in the
- // new chain
- //StructuredDocumentRegionIterator.setStructuredDocument(newNodesHead,
- // fStructuredDocument);
- //
- if (firstTime) {
- fStructuredDocument.setCachedDocumentRegion(newNodesHead);
- fStructuredDocument.initializeFirstAndLastDocumentRegion();
- // note: since we are inserting nodes, for the first time, there
- // is
- // no adjustments
- // to downstream stuff necessary.
- result = new StructuredDocumentRegionsReplacedEvent(fStructuredDocument, fRequester, oldNodes, newNodes, fChanges, fStart, fLengthToReplace);
- } else {
- // note: integrates changes into model as a side effect
- result = minimumEvent(oldNodes, newNodes);
- }
- result.setDeletedText(fDeletedText);
- return result;
- }
-
- private CoreNodeList _formMinimumList(CoreNodeList flatnodes, int startOfDifferences, int endOfDifferences) {
- CoreNodeList minimalNodes = null;
- // if startOfDifferces is still its initial value, then we have an
- // empty document
- if (startOfDifferences == -1) {
- minimalNodes = EMPTY_LIST;
- } else {
- // if we do not have any flatnode in our flatnode list, then
- // simply
- // return our standard empty list
- if (flatnodes.getLength() == 0) {
- minimalNodes = EMPTY_LIST;
- } else {
- // if startOfDifferences is greater than endOfDifferences,
- // then
- // that means the calculations "crossed" each other, and
- // hence,
- // there really is no differences, so, again, return the empty
- // list
- if (startOfDifferences > endOfDifferences) {
- minimalNodes = EMPTY_LIST;
- } else {
- // the last check be sure we have some differnces
- if ((endOfDifferences > -1)) {
- minimalNodes = new CoreNodeList(flatnodes.item(startOfDifferences), flatnodes.item(endOfDifferences));
- } else {
- // there were no differences, the list wasn't
- // minimized, so simply return it.
- minimalNodes = flatnodes;
- }
- }
- }
- }
- return minimalNodes;
- }
-
- private boolean _greaterThanEffectedRegion(IStructuredDocumentRegion oldNode) {
- boolean result = false;
- int nodeStart = oldNode.getStartOffset();
- int changedRegionEnd = fStart + fLengthToReplace - 1;
- result = nodeStart > changedRegionEnd;
- return result;
- }
-
- private boolean _greaterThanEffectedRegion(IStructuredDocumentRegion oldNode, ITextRegion oldRegion) {
- boolean result = false;
- int regionStartOffset = oldNode.getStartOffset(oldRegion);
- int effectedRegionEnd = fStart + fLengthToReplace - 1;
- result = regionStartOffset > effectedRegionEnd;
- return result;
- }
-
- private boolean _lessThanEffectedRegion(IStructuredDocumentRegion oldNode) {
- boolean result = false;
- int nodeEnd = oldNode.getEndOffset() - 1;
- result = nodeEnd < fStart;
- return result;
- }
-
- private boolean _lessThanEffectedRegion(IStructuredDocumentRegion oldNode, ITextRegion oldRegion) {
- boolean result = false;
- int nodeEnd = oldNode.getEndOffset(oldRegion) - 1;
- result = nodeEnd < fStart;
- return result;
- }
-
- private boolean _regionsSameKind(ITextRegion newRegion, ITextRegion oldRegion) {
- boolean result = false;
- // if one region is a container region, and the other not, always
- // return false
- // else, just check their type.
- // DW druing refactoring, looks like a "typo" here, using 'old' in
- // both.
- // if (isContainerRegion(oldRegion) != isContainerRegion(oldRegion))
- if (isCollectionRegion(oldRegion) != isCollectionRegion(newRegion))
- result = false;
- else if (oldRegion.getType() == newRegion.getType())
- result = true;
- return result;
- }
-
- // private boolean hasCollectionRegions(ITextRegion aRegion) {
- // boolean result = false;
- // if (aRegion instanceof ITextRegionCollection) {
- // ITextRegionCollection regionContainter = (ITextRegionCollection)
- // aRegion;
- // ITextRegionList regions = regionContainter.getRegions();
- // Iterator iterator = regions.iterator();
- // while (iterator.hasNext()) {
- // if (aRegion instanceof ITextRegionCollection) {
- // result = true;
- // break;
- // }
- // }
- // }
- // return result;
- // }
- /**
- * This method is specifically to detect changes in 'isEnded' state,
- * although it still does so with heuristics. If number of '>' changes,
- * assume the isEnded state has changed.
- */
- private boolean changeInIsEndedState(String oldText, String newText) {
- int nOld = StringUtils.occurrencesOf(oldText, '>');
- int nNew = StringUtils.occurrencesOf(newText, '>');
- return !(nOld == nNew);
- }
-
- private void checkAndAssignParent(IStructuredDocumentRegion oldNode, ITextRegion region) {
- if (region instanceof ITextRegionContainer) {
- ((ITextRegionContainer) region).setParent(oldNode);
- return;
- }
- if (region instanceof ITextRegionCollection) {
- ITextRegionCollection textRegionCollection = (ITextRegionCollection) region;
- ITextRegionList regionList = textRegionCollection.getRegions();
- for (int i = 0; i < regionList.size(); i++) {
- ITextRegion innerRegion = regionList.get(i);
- checkAndAssignParent(oldNode, innerRegion);
- }
- }
- }
-
- /**
- * A change to a CDATA tag can result in all being reparsed.
- */
- private StructuredDocumentEvent checkForCDATA() {
- StructuredDocumentEvent result = null;
- result = checkForCriticalKey("<![CDATA["); //$NON-NLS-1$
- if (result == null)
- result = checkForCriticalKey("]]>"); //$NON-NLS-1$
- return result;
- }
-
- /**
- * If a comment start or end tag is being added or deleted, we'll rescan
- * the whole document. The reason is that content that is revealed or
- * commented out can effect the interpretation of the rest of the
- * document. Note: for now this is very XML specific, can refactor/improve
- * later.
- */
- protected StructuredDocumentEvent checkForComments() {
- StructuredDocumentEvent result = null;
- result = checkForCriticalKey("<!--"); //$NON-NLS-1$
- if (result == null)
- result = checkForCriticalKey("-->"); //$NON-NLS-1$
- // we'll also check for these degenerate cases
- if (result == null)
- result = checkForCriticalKey("<!--->"); //$NON-NLS-1$
- return result;
- }
-
- /**
- * Common utility for checking for critical word such as " <SCRIPT>"
- */
- protected StructuredDocumentEvent checkForCriticalKey(String criticalTarget) {
- return _checkForCriticalWord(criticalTarget, false);
- }
-
- /**
- * Common utility for checking for critical word such as " <SCRIPT>"
- */
- private StructuredDocumentEvent checkForCriticalName(String criticalTarget) {
- return _checkForCriticalWord(criticalTarget, true);
- }
-
- // /**
- // * Currently this method is pretty specific to ?ML
- // * @deprecated - not really deprecated, but plan to make
- // * protected ... I'm not sure why its public or misspelled?
- // */
- protected StructuredDocumentEvent checkForCrossStructuredDocumentRegionBoundryCases() {
- StructuredDocumentEvent result = null;
- // Case 1: See if the language's syntax requires that multiple
- // StructuredDocumentRegions be rescanned
- if (result == null) {
- result = checkForCrossStructuredDocumentRegionSyntax();
- }
- // Case 2: "block tags" whose content is left unparsed
- if (result == null) {
- Object parser = fStructuredDocument.getParser();
- if (parser instanceof BlockTagParser) {
- List blockTags = ((BlockTagParser) parser).getBlockMarkers();
- result = _checkBlockNodeList(blockTags);
- }
- }
- // FUTURE_TO_DO: is there a better place to do this?
- // or! do we already do it some other more central place?
- if (result != null) {
- result.setDeletedText(fDeletedText);
- }
- return result;
- }
-
- /**
- * Allow a reparser to check for extra syntactic cases that require
- * parsing beyond the flatNode boundary.
- *
- * This implementation is very XML-centric.
- */
- protected StructuredDocumentEvent checkForCrossStructuredDocumentRegionSyntax() {
- StructuredDocumentEvent result;
- // Case 1: Quote characters are involved
- result = checkForQuotes();
- if (result == null) {
- // Case 2: The input forms or undoes a comment beginning or
- // comment
- // end
- result = checkForComments();
- }
- if (result == null) {
- // Case 3: The input forms or undoes a processing instruction
- result = checkForPI();
- }
- if (result == null) {
- // Case 4: The input forms or undoes a CDATA section
- result = checkForCDATA();
- }
- return result;
- }
-
- /**
- * Checks to see if change request exactly matches the text it would be
- * replacing. (In future, this, or similar method is where to check for
- * "read only" attempted change.)
- */
- private StructuredDocumentEvent checkForNoChange() {
- StructuredDocumentEvent result = null;
- // don't check equals unless lengths match
- // should be a tiny bit faster, since usually not
- // of equal lengths (I'm surprised String's equals method
- // doesn't do this.)
- if ((fChanges != null) && (fDeletedText != null) && (fChanges.length() == fDeletedText.length()) && (fChanges.equals(fDeletedText))) {
- result = new NoChangeEvent(fStructuredDocument, fRequester, fChanges, fStart, fLengthToReplace);
- }
- return result;
- }
-
- /**
- * A change to a PI tag can result in all being reparsed.
- */
- private StructuredDocumentEvent checkForPI() {
- StructuredDocumentEvent result = null;
- result = checkForCriticalKey("<?"); //$NON-NLS-1$
- if (result == null)
- result = checkForCriticalKey("?>"); //$NON-NLS-1$
- return result;
- }
-
- // For simplicity, if either text to be deleted, or text to be inserted
- // contains at least
- // one quote, we'll search for previous quote in document, if any, and use
- // that flatnode as
- // a dirty start, and we'll use end of document as dirty end. We need to
- // assume either \" or
- // \' is an exceptable quote. (NOTE: this is, loosely, an XML assumption
- // --
- // other languages
- // would differ, but we'll "hard code" for XML for now.
- // future_TODO: this is a really bad heuristic ... we should be looking
- // for
- // odd number of quotes
- // within a structuredDocumentRegion (or something!) This causes way too
- // much reparsing on
- // simple cases, like deleting a tag with a quoted attribute!
- private StructuredDocumentEvent checkForQuotes() {
- // routine is supported with null or empty string meaning the same
- // thing: deletion
- if (fChanges == null)
- fChanges = ""; //$NON-NLS-1$
- //
- StructuredDocumentEvent result = null;
- try {
- int dirtyStartPos = -1;
- String proposedDeletion = fStructuredDocument.get(fStart, fLengthToReplace);
- if (fStart < fStructuredDocument.getLength()) {
- if ((fChanges.indexOf(singleQuote) > -1) || (proposedDeletion.indexOf(singleQuote) > -1)) {
- IRegion singleQuoteRegion = getFindReplaceDocumentAdapter().find(fStart, singleQuote, false, false, false, false);
- if (singleQuoteRegion != null) {
- dirtyStartPos = singleQuoteRegion.getOffset();
- }
- } else if ((fChanges.indexOf(doubleQuote) > -1) || (proposedDeletion.indexOf(doubleQuote) > -1)) {
- IRegion doubleQuoteRegion = getFindReplaceDocumentAdapter().find(fStart, doubleQuote, false, false, false, false);
- if (doubleQuoteRegion != null) {
- dirtyStartPos = doubleQuoteRegion.getOffset();
- }
- }
- }
- if (dirtyStartPos > -1) {
- // then we found one, do create new structuredDocument event
- // based on the previous quote to end of document
- // except, we need to be positive that the previous quote is
- // in a "safe start" region (e.g. if in JSP content, we need
- // to
- // backup till we include the whole JSP region, in order for
- // it
- // to be correctly re-parsed. The backing up is done in the
- // reparse/find dirty start from hint
- // method.
- result = reparse(dirtyStartPos, fStructuredDocument.getLength() - 1);
- }
- } catch (BadLocationException e) {
- Logger.logException(e);
- }
- if (result != null) {
- result.setDeletedText(fDeletedText);
- }
- return result;
- }
-
- private StructuredDocumentEvent checkHeuristics() {
- StructuredDocumentEvent result = null;
- result = checkForNoChange();
- if (result == null) {
- result = checkForCrossStructuredDocumentRegionBoundryCases();
- if (result == null) {
- result = quickCheck();
- }
- }
- return result;
- }
-
- /**
- * Takes into account "tag name" rules for comparisons; case-insensitive.
- */
- private boolean checkTagNames(String compareText, String criticalTarget, boolean checkEnd) {
- boolean result = false;
- if ((compareText == null) || (criticalTarget == null))
- return false;
- int posOfCriticalWord = compareText.toLowerCase().indexOf(criticalTarget.toLowerCase());
- result = posOfCriticalWord > -1;
- if (checkEnd && result) {
- // instead of returning true right away, we'll only return true
- // the
- // potentially matched tag is indeed a tag, for example, if
- // <SCRIPT
- // becomes <SCRIPTS we don't want to say the latter is a critical
- // tag
- int lastPos = posOfCriticalWord + criticalTarget.length();
- if (lastPos < compareText.length()) {
- char lastChar = compareText.charAt(lastPos);
- // Future: check formal definition of this java method, vs.
- // XML
- // parsing rules
- result = (!Character.isLetterOrDigit(lastChar));
- }
- }
- return result;
- }
-
- /**
- * The core reparsing method ... after the dirty start and dirty end have
- * been calculated elsewhere, and the text updated.
- */
- protected StructuredDocumentEvent core_reparse(int rescanStart, int rescanEnd, CoreNodeList oldNodes, boolean firstTime) {
- IStructuredDocumentRegion newNodesHead = null;
- StructuredDocumentEvent result = null;
- newNodesHead = _core_reparse_text(rescanStart, rescanEnd);
- result = _core_reparse_update_model(newNodesHead, rescanStart, rescanEnd, oldNodes, firstTime);
- return result;
- }
-
- /**
- * Resets state to "not parsing"
- */
- private synchronized void endReParse() {
- isParsing = false;
- dirtyStart = null;
- dirtyEnd = null;
- }
-
- protected IStructuredDocumentRegion findDirtyEnd(int end) {
- // Caution: here's one place we have to cast
- IStructuredDocumentRegion result = fStructuredDocument.getRegionAtCharacterOffset(end);
- // if not well formed, get one past, if there is something there
- if ((result != null) && (!result.isEnded())) {
- if (result.getNext() != null) {
- result = result.getNext();
- }
- }
- // also, get one past if exactly equal to the end (this was needed
- // as a simple fix to when a whole exact region is deleted.
- // there's probably a better way.
- if ((result != null) && (end == result.getEnd())) {
- if (result.getNext() != null) {
- result = result.getNext();
- }
- }
- // moved to subclass for quick transition
- // 12/6/2001 - Since we've changed the parser/scanner to allow a lone
- // '<' without
- // always interpretting it as start of a tag name, we need to be a
- // little fancier, in order
- // to "skip" over any plain 'ol content between the lone '<' and any
- // potential meating
- // regions past plain 'ol content.
- // if (isLoneOpenFollowedByContent(result) && (result.getNext() !=
- // null)) {
- // result = result.getNext();
- // }
- if (result != null)
- fStructuredDocument.setCachedDocumentRegion(result);
- dirtyEnd = result;
- return dirtyEnd;
- }
-
- protected void findDirtyStart(int start) {
- IStructuredDocumentRegion result = fStructuredDocument.getRegionAtCharacterOffset(start);
- // heuristic: if the postion is exactly equal to the start, then
- // go back one more, if it exists. This prevents problems with
- // insertions
- // of text that should be merged with the previous node instead of
- // simply hung
- // off of it as a separate node (ex.: XML content inserted right
- // before
- // an open
- // bracket should become part of the previous content node)
- if (result != null) {
- IStructuredDocumentRegion previous = result.getPrevious();
- if ((previous != null) && ((!(previous.isEnded())) || (start == result.getStart()))) {
- result = previous;
- }
- // If we are now at the end of a "tag dependent" content area (or
- // JSP area)
- // then we need to back up all the way to the beginning of that.
- IStructuredDocumentRegion potential = result;
- // moved to subclass to speed transition
- // while (isPartOfBlockRegion(potential)) {
- // potential = potential.getPrevious();
- // }
- if (potential != null) {
- result = potential;
- fStructuredDocument.setCachedDocumentRegion(result);
- }
- }
- dirtyStart = result;
- }
-
- protected CoreNodeList formOldNodes(IStructuredDocumentRegion dirtyStart, IStructuredDocumentRegion dirtyEnd) {
- CoreNodeList oldNodes = new CoreNodeList(dirtyStart, dirtyEnd);
- // Now save the old text, that "goes with" the old nodes and regions.
- // Notice we are getting it directly from the text store
- String oldText = null;
- int oldStart = -1;
- int oldEnd = -1;
- // make sure there is some text, if not, use empty string
- // (if one node is not null, the other should ALWAYS be not null too,
- // since it
- // would at least be equal to it.)
- if (dirtyStart != null) {
- oldStart = dirtyStart.getStart();
- oldEnd = dirtyEnd.getEnd();
- oldText = fStructuredDocument.get(oldStart, oldEnd - oldStart);
- } else {
- oldStart = 0;
- oldEnd = 0;
- oldText = ""; //$NON-NLS-1$
- }
- // create a temporary text store for this text
- SubSetTextStore subTextStore = new SubSetTextStore(oldText, oldStart, oldEnd, fStructuredDocument.getLength());
- // Now update the text store of the oldNodes
- StructuredDocumentRegionIterator.setParentDocument(oldNodes, new MinimalDocument(subTextStore));
- return oldNodes;
- }
-
- /**
- * @return Returns the findReplaceDocumentAdapter.
- */
- public FindReplaceDocumentAdapter getFindReplaceDocumentAdapter() {
- if (fFindReplaceDocumentAdapter == null) {
- fFindReplaceDocumentAdapter = new FindReplaceDocumentAdapter(fStructuredDocument);
- }
- return fFindReplaceDocumentAdapter;
- }
-
- // Note: if thead safety is needed, this and all the other public methods
- // of this class
- // should be synchronized.
- public void initialize(Object requester, int start, int lengthToReplace, String changes) {
- isParsing = true;
- fRequester = requester;
- fStart = start;
- fLengthToReplace = lengthToReplace;
- fChanges = changes;
- // notice this one is derived
- fLengthDifference = Utilities.calculateLengthDifference(fChanges, fLengthToReplace);
- fDeletedText = fStructuredDocument.get(fStart, fLengthToReplace);
- }
-
- protected void insertNodes(IStructuredDocumentRegion previousOldNode, IStructuredDocumentRegion nextOldNode, CoreNodeList newNodes) {
- //
- IStructuredDocumentRegion firstNew = null;
- IStructuredDocumentRegion lastNew = null;
- //
- IStructuredDocumentRegion oldPrevious = previousOldNode;
- IStructuredDocumentRegion oldNext = nextOldNode;
- //
- if (newNodes.getLength() > 0) {
- // get pointers
- firstNew = newNodes.item(0);
- lastNew = newNodes.item(newNodes.getLength() - 1);
- // switch surrounding StructuredDocumentRegions' references to
- // lists
- if (oldPrevious != null)
- oldPrevious.setNext(firstNew);
- if (oldNext != null) {
- oldNext.setPrevious(lastNew);
- } else {
- // SIDE EFFECT
- // if oldNext is null, that means we are replaceing the
- // lastNode in the chain,
- // so we need to update the structuredDocuments lastNode as
- // the
- // last of the new nodes.
- fStructuredDocument.setLastDocumentRegion(newNodes.item(newNodes.getLength() - 1));
- }
- if (firstNew != null)
- firstNew.setPrevious(oldPrevious);
- if (lastNew != null)
- lastNew.setNext(oldNext);
- }
- // else nothing to insert
- }
-
- /**
- * @param oldRegion
- */
- private boolean isCollectionRegion(ITextRegion aRegion) {
- return (aRegion instanceof ITextRegionCollection);
- }
-
- /**
- * @return boolean
- */
- public boolean isParsing() {
- return isParsing;
- }
-
- /**
- * The minimization algorithm simply checks the old nodes to see if any of
- * them "survived" the rescan and are unchanged. If so, the instance of
- * the old node is used instead of the new node. Before the requested
- * change, need to check type, offsets, and text to determine if the same.
- * After the requested change, need to check type and text, but adjust the
- * offsets to what ever the change was.
- */
- protected StructuredDocumentEvent minimumEvent(CoreNodeList oldNodes, CoreNodeList newNodes) {
- StructuredDocumentEvent event = null;
- CoreNodeList minimalOldNodes = null;
- CoreNodeList minimalNewNodes = null;
- // To minimize nodes, we'll collect all those
- // that are not equal into old and new lists
- // Note: we assume that old and new nodes
- // are basically contiguous -- and we force it to be so,
- // by starting at the beginning to
- // find first difference, and then starting at the end to find
- // last difference. Everything in between we assume is different.
- //
- //
- //
- // startOfDifferences is the index into the core node list where the
- // first difference
- // occurs. But it may point into the old or the new list.
- int startOfDifferences = _computeStartOfDifferences(oldNodes, newNodes);
- int endOfDifferencesOld = -1;
- int endOfDifferencesNew = -1;
- // if one of the lists are shorter than where the differences start,
- // then
- // then some portion of the lists are identical
- if ((startOfDifferences >= oldNodes.getLength()) || (startOfDifferences >= newNodes.getLength())) {
- if (oldNodes.getLength() < newNodes.getLength()) {
- // Then there are new regions to add
- // these lengths will cause the vector of old ones to not
- // have any elements, and the vector of new regions to have
- // just the new ones not in common with the old ones
- //startOfDifferences should equal oldNodes.getLength(),
- // calculated above on _computeStartOfDifferences
- minimalOldNodes = EMPTY_LIST;
- endOfDifferencesNew = newNodes.getLength() - 1;
- minimalNewNodes = _formMinimumList(newNodes, startOfDifferences, endOfDifferencesNew);
- } else {
- if (oldNodes.getLength() > newNodes.getLength()) {
- // delete old
- // then there are old regions to delete
- // these lengths will cause the vector of old regions to
- // contain the ones to delete, and the vector of new
- // regions
- // not have any elements
- //startOfDifferences should equal newNodes.getLength(),
- // calculated above on _computeStartOfDifferences
- endOfDifferencesOld = oldNodes.getLength() - 1;
- minimalOldNodes = _formMinimumList(oldNodes, startOfDifferences, endOfDifferencesOld);
- minimalNewNodes = EMPTY_LIST;
- } else
- // unlikely event
- event = new NoChangeEvent(fStructuredDocument, fRequester, fChanges, fStart, fLengthToReplace);
- }
- } else {
- // We found a normal startOfDiffernces, but have not yet found the
- // ends.
- // We'll look for the end of differences by going backwards down
- // the two lists.
- // Here we need a seperate index for each array, since they may be
- // (and
- // probably are) of different lengths.
- int indexOld = oldNodes.getLength() - 1;
- int indexNew = newNodes.getLength() - 1;
- // The greaterThanEffectedRegion is important to gaurd against
- // incorrect counting
- // when something identical is inserted to what's already there
- // (see minimization test case 5)
- // Note: the indexOld > startOfDifferences keeps indexOld from
- // getting too small,
- // so that the subsequent oldNodes.item(indexOld) is always valid.
- while ((indexOld >= startOfDifferences) && (_greaterThanEffectedRegion(oldNodes.item(indexOld)))) {
- if (!(oldNodes.item(indexOld).sameAs(newNodes.item(indexNew), fLengthDifference))) {
- break;
- } else {
- // if they are equal, then we will be keeping the old one,
- // so
- // we need to be sure its parentDocument is set back to
- // the
- // right instance
- oldNodes.item(indexOld).setParentDocument(fStructuredDocument);
- }
- indexOld--;
- indexNew--;
- }
- endOfDifferencesOld = indexOld;
- endOfDifferencesNew = indexNew;
- minimalOldNodes = _formMinimumList(oldNodes, startOfDifferences, endOfDifferencesOld);
- minimalNewNodes = _formMinimumList(newNodes, startOfDifferences, endOfDifferencesNew);
- } /////////////////////////////////////////
- //
- IStructuredDocumentRegion firstDownStreamNode = null;
- event = regionCheck(minimalOldNodes, minimalNewNodes);
- if (event != null) {
- firstDownStreamNode = minimalOldNodes.item(0).getNext();
- if (firstDownStreamNode != null && fLengthDifference != 0) { // if
- // firstDownStream
- // is
- // null,
- // then
- // we're
- // at
- // the
- // end
- // of
- // the
- // document
- StructuredDocumentRegionIterator.adjustStart(firstDownStreamNode, fLengthDifference);
- } //
- } else {
- event = nodesReplacedCheck(minimalOldNodes, minimalNewNodes);
- // now splice the new chain of nodes to where the old chain is (or
- // was)
- // the firstDownStreamNode (the first of those after the new
- // nodes)
- // is
- // remembered as a tiny optimization.
- if (minimalOldNodes.getLength() == 0 && minimalNewNodes.getLength() > 0) {
- // if no old nodes are being deleted, then use the
- // the newNodes offset (minus one) to find the point to
- // update downstream nodes, and after updating downstream
- // nodes postions, insert the new ones.
- int insertOffset = minimalNewNodes.item(0).getStartOffset();
- IStructuredDocumentRegion lastOldUnchangedNode = null;
- if (insertOffset > 0) {
- lastOldUnchangedNode = fStructuredDocument.getRegionAtCharacterOffset(insertOffset - 1);
- firstDownStreamNode = lastOldUnchangedNode.getNext();
- } else {
- // we're inserting at very beginning
- firstDownStreamNode = fStructuredDocument.getFirstStructuredDocumentRegion();
- // SIDE EFFECT: change the firstNode pointer if we're
- // inserting at beginning
- fStructuredDocument.setFirstDocumentRegion(minimalNewNodes.item(0));
- }
- StructuredDocumentRegionIterator.adjustStart(firstDownStreamNode, fLengthDifference);
- insertNodes(lastOldUnchangedNode, firstDownStreamNode, minimalNewNodes);
- // this (nodes replaced) is the only case where we need to
- // update the cached Node
- reSetCachedNode(minimalOldNodes, minimalNewNodes);
- } else {
- firstDownStreamNode = switchNodeLists(minimalOldNodes, minimalNewNodes);
- // no need to adjust the length of the new nodes themselves,
- // they
- // are already correct, but we do need to
- // adjust all "down stream" nodes with the length of the
- // insertion or deletion
- // --- adjustment moved to calling method.
- if (firstDownStreamNode != null) {
- // && event != null
- StructuredDocumentRegionIterator.adjustStart(firstDownStreamNode, fLengthDifference);
- } //
- // this (nodes replaced) is the only case where we need to
- // update the cached Node
- reSetCachedNode(minimalOldNodes, minimalNewNodes);
- }
- }
- return event;
- }
-
- // TODO: This should be abstract.
- public IStructuredTextReParser newInstance() {
- return new StructuredDocumentReParser();
- }
-
- protected StructuredDocumentEvent nodesReplacedCheck(CoreNodeList oldNodes, CoreNodeList newNodes) {
- // actually, nothing to check here, since (and assuming) we've already
- // minimized the number of nodes, and ruled out mere region changes
- StructuredDocumentEvent result = new StructuredDocumentRegionsReplacedEvent(fStructuredDocument, fRequester, oldNodes, newNodes, fChanges, fStart, fLengthToReplace);
- return result;
- }
-
- /**
- * A method to allow any heuristic "quick checks" that might cover many
- * many cases, before expending the time on a full reparse.
- *
- */
- public StructuredDocumentEvent quickCheck() {
- StructuredDocumentEvent result = null;
- // if the dirty start is null, then we have an empty document.
- // in which case we'll return null so everything can be
- // reparsed "from scratch" . If its not null, we'll give the flatnode
- // a
- // chance
- // to handle, but only if there is one flatnode involved.
- if (dirtyStart != null && dirtyStart == dirtyEnd) {
- IStructuredDocumentRegion targetNode = dirtyStart;
- result = dirtyStart.updateModel(fRequester, targetNode, fChanges, fStart, fLengthToReplace);
- if (result != null) {
- // at this point only, we need to update the text store and
- // and downstream nodes.
- // FUTURE_TO_DO: can this dependency on structuredDocument
- // method be eliminated?
- fStructuredDocument.updateDocumentData(fStart, fLengthToReplace, fChanges);
- IStructuredDocumentRegion firstDownStreamNode = targetNode.getNext();
- // then flatnode must have been the last one, so need to
- // update
- // any downstream ones
- if (firstDownStreamNode != null) {
- StructuredDocumentRegionIterator.adjustStart(firstDownStreamNode, fLengthDifference);
- }
- }
- }
- if (result != null) {
- result.setDeletedText(fDeletedText);
- }
- return result;
- }
-
- /**
- * If only one node is involved, sees how many regions are changed. If
- * only one, then its a 'regionChanged' event ... if more than one, its a
- * 'regionsReplaced' event.
- */
- protected StructuredDocumentEvent regionCheck(CoreNodeList oldNodes, CoreNodeList newNodes) {
- if (Debug.debugStructuredDocument)
- System.out.println("IStructuredDocument::regionsReplacedCheck"); //$NON-NLS-1$
- //$NON-NLS-1$
- //$NON-NLS-1$
- // the "regionsReplaced" event could only be true if and only if the
- // nodelists
- // are each only "1" in length.
- StructuredDocumentEvent result = null;
- int oldLength = oldNodes.getLength();
- int newLength = newNodes.getLength();
- if ((oldLength != 1) || (newLength != 1)) {
- result = null;
- } else {
- IStructuredDocumentRegion oldNode = oldNodes.item(0);
- IStructuredDocumentRegion newNode = newNodes.item(0);
- result = regionCheck(oldNode, newNode);
- }
- return result;
- }
-
- /**
- * If only one node is involved, sees how many regions are changed. If
- * only one, then its a 'regionChanged' event ... if more than one, its a
- * 'regionsReplaced' event.
- */
- protected StructuredDocumentEvent regionCheck(IStructuredDocumentRegion oldNode, IStructuredDocumentRegion newNode) {
- //
- StructuredDocumentEvent result = null;
- ITextRegionList oldRegions = oldNode.getRegions();
- ITextRegionList newRegions = newNode.getRegions();
- // Also causes ArrayStoreExceptions when we encounter a container
- // ITextRegion[] oldRegionsArray = new
- // com.ibm.sed.parser.ContextRegion[oldRegions.size()];
- // ITextRegion[] newRegionsArray = new
- // com.ibm.sed.parser.ContextRegion[newRegions.size()];
- ITextRegion[] oldRegionsArray = oldRegions.toArray();
- ITextRegion[] newRegionsArray = newRegions.toArray();
- //
- // for the 'regionsReplaced' event, we don't care if
- // the regions changed due to type, or text,
- // we'll just collect all those that are not equal
- // into the old and new region lists.
- // Note: we, of course, assume that old and new regions
- // are basically contiguous -- and we force it to be so,
- // even if not literally so, by starting at beginning to
- // find first difference, and then starting at end to find
- // last difference. Everything in between we assume is different.
- //
- // going up is easy, we start at zero in each, and continue
- // till regions are not the same.
- int startOfDifferences = _computeStartOfDifferences(oldNode, oldRegions, newNode, newRegions);
- int endOfDifferencesOld = -1;
- int endOfDifferencesNew = -1;
- //
- //
- // if one of the lists are shorter than where the differences start,
- // then
- // then some portion of the lists are identical
- if ((startOfDifferences >= oldRegions.size()) || (startOfDifferences >= newRegions.size())) {
- if (oldRegions.size() < newRegions.size()) {
- // INSERT CASE
- // then there are new regions to add
- // these lengths will cause the vector of old ones to not
- // have any elements, and the vector of new regions to have
- // just the new ones.
- startOfDifferences = oldRegionsArray.length;
- endOfDifferencesOld = oldRegionsArray.length - 1;
- endOfDifferencesNew = newRegionsArray.length - 1;
- } else {
- if (oldRegions.size() > newRegions.size()) {
- // DELETE CASE
- // then there are old regions to delete
- // these lengths will cause the vector of old regions to
- // contain the ones to delete, and the vector of new
- // regions
- // not have any elements
- startOfDifferences = newRegionsArray.length;
- endOfDifferencesOld = oldRegionsArray.length - 1;
- endOfDifferencesNew = newRegionsArray.length - 1;
- } else {
- // else the lists are identical!
- // unlikely event, probably error in current design, since
- // we check for identity at the very beginning of
- // reparsing.
- result = new NoChangeEvent(fStructuredDocument, fRequester, fChanges, fStart, fLengthToReplace);
- }
- }
- } else {
- if ((startOfDifferences > -1) && (endOfDifferencesOld < 0) && (endOfDifferencesNew < 0)) {
- // We found a normal startOfDiffernces, but have not yet found
- // the ends.
- // We'll look for the end of differences by going backwards
- // down the two lists.
- // Here we need a seperate index for each array, since they
- // may
- // be (and
- // probably are) of different lengths.
- int indexOld = oldRegionsArray.length - 1;
- int indexNew = newRegionsArray.length - 1;
- while ((indexOld >= startOfDifferences) && (_greaterThanEffectedRegion(oldNode, oldRegionsArray[indexOld]))) {
- if ((!(oldNode.sameAs(oldRegionsArray[indexOld], newNode, newRegionsArray[indexNew], fLengthDifference)))) {
- //endOfDifferencesOld = indexOne;
- //endOfDifferencesNew = indexTwo;
- break;
- }
- indexOld--;
- indexNew--;
- }
- endOfDifferencesOld = indexOld;
- endOfDifferencesNew = indexNew;
- }
- }
- //
- // result != null means the impossible case above occurred
- if (result == null) {
- // Now form the two vectors of different regions
- ITextRegionList holdOldRegions = new TextRegionListImpl();
- ITextRegionList holdNewRegions = new TextRegionListImpl();
- if (startOfDifferences > -1 && endOfDifferencesOld > -1) {
- for (int i = startOfDifferences; i <= endOfDifferencesOld; i++) {
- holdOldRegions.add(oldRegionsArray[i]);
- }
- }
- if (startOfDifferences > -1 && endOfDifferencesNew > -1) {
- for (int i = startOfDifferences; i <= endOfDifferencesNew; i++) {
- holdNewRegions.add(newRegionsArray[i]);
- }
- }
- if (holdOldRegions.size() == 0 && holdNewRegions.size() == 0) {
- // then this means the regions were identical, which means
- // someone
- // pasted exactly the same thing they had selected, or !!!
- // someone deleted the end bracket of the tag. !!!?
- result = new NoChangeEvent(fStructuredDocument, fRequester, fChanges, fStart, fLengthToReplace);
- } else {
- //If both holdOldRegions and holdNewRegions are of length 1,
- // then its
- // a "region changed" event, else a "regions replaced" event.
- // so we want the new instance of region to become part of the
- // old instance of old node
- if ((holdOldRegions.size() == 1) && (holdNewRegions.size() == 1) && _regionsSameKind((holdNewRegions.get(0)), (holdOldRegions.get(0)))) {
- ITextRegion newOldRegion = swapNewForOldRegion(oldNode, holdOldRegions.get(0), newNode, holdNewRegions.get(0));
- // -- need to update any down stream regions, within this
- // 'oldNode'
- updateDownStreamRegions(oldNode, newOldRegion);
- result = new RegionChangedEvent(fStructuredDocument, fRequester, oldNode, newOldRegion, fChanges, fStart, fLengthToReplace);
- } else {
- replaceRegions(oldNode, holdOldRegions, newNode, holdNewRegions);
- // -- need to update any down stream regions, within this
- // 'oldNode'
- // don't need with the way replaceRegions is implemented.
- // It handles.
- //if(holdNewRegions.size() > 0)
- //updateDownStreamRegions(oldNode, (ITextRegion)
- // holdNewRegions.lastElement());
- result = new RegionsReplacedEvent(fStructuredDocument, fRequester, oldNode, holdOldRegions, holdNewRegions, fChanges, fStart, fLengthToReplace);
- }
- }
- }
- return result;
- }
-
- /**
- * An entry point for reparsing. It calculates the dirty start and dirty
- * end flatnodes based on the start point and length of the changes.
- *
- */
- public StructuredDocumentEvent reparse() {
- StructuredDocumentEvent result = null;
- // if we do not have a cachedNode, then the document
- // must be empty, so simply use 'null' as the dirtyStart and dirtyEnd
- // otherwise, find them.
- if (fStructuredDocument.getCachedDocumentRegion() != null) {
- findDirtyStart(fStart);
- int end = fStart + fLengthToReplace;
- findDirtyEnd(end);
- }
- if (fStructuredDocument.getCachedDocumentRegion() != null) {
- result = checkHeuristics();
- }
- if (result == null) {
- result = reparse(dirtyStart, dirtyEnd);
- }
- endReParse();
- return result;
- }
-
- /**
- * An entry point for reparsing. It calculates the dirty start and dirty
- * end flatnodes based on suggested positions to begin and end. This is
- * needed for cases where parsing must go beyond the immediate node and
- * its direct neighbors.
- *
- */
- protected StructuredDocumentEvent reparse(int reScanStartHint, int reScanEndHint) {
- StructuredDocumentEvent result = null;
- // if we do not have a cachedNode, then the document
- // must be empty, so simply use 'null' as the dirtyStart and dirtyEnd
- if (fStructuredDocument.getCachedDocumentRegion() != null) {
- findDirtyStart(reScanStartHint);
- findDirtyEnd(reScanEndHint);
- }
- result = reparse(dirtyStart, dirtyEnd);
- isParsing = false;
- // debug
- //verifyStructured(result);
- return result;
- }
-
- /**
- * The core reparsing method ... after the dirty start and dirty end have
- * been calculated elsewhere.
- */
- protected StructuredDocumentEvent reparse(IStructuredDocumentRegion dirtyStart, IStructuredDocumentRegion dirtyEnd) {
- StructuredDocumentEvent result = null;
- int rescanStart = -1;
- int rescanEnd = -1;
- boolean firstTime = false;
- //
- // "save" the oldNodes (that may be replaced) in a list
- CoreNodeList oldNodes = formOldNodes(dirtyStart, dirtyEnd);
- if (dirtyStart == null || dirtyEnd == null) {
- // dirtyStart or dirty end are null, then that means we didn't
- // have
- // a
- // cached node, which means we have an empty document, so we
- // just need to rescan the changes
- rescanStart = 0;
- rescanEnd = fChanges.length();
- firstTime = true;
- } else {
- // set the start of the text to rescan
- rescanStart = dirtyStart.getStart();
- //
- // set the end of the text to rescan
- // notice we use the same rationale as for the rescanStart,
- // with the added caveat that length has to be added to it,
- // to compensate for the new text which has been added or deleted.
- // If changes has zero length, then "length" will be negative,
- // since
- // we are deleting text. Otherwise, use the difference between
- // what's selected to be replaced and the length of the new text.
- rescanEnd = dirtyEnd.getEnd() + fLengthDifference;
- }
- // now that we have the old stuff "saved" away, update the document
- // with the changes.
- // FUTURE_TO_DO -- don't fire "document changed" event till later
- fStructuredDocument.updateDocumentData(fStart, fLengthToReplace, fChanges);
- // ------------------ now the real work
- result = core_reparse(rescanStart, rescanEnd, oldNodes, firstTime);
- //
- // event is returned to the caller, incase there is
- // some opitmization they can do
- return result;
- }
-
- protected void replaceRegions(IStructuredDocumentRegion oldNode, ITextRegionList oldRegions, IStructuredDocumentRegion newNode, ITextRegionList newRegions) {
- int insertPos = -1;
- ITextRegionList regions = oldNode.getRegions();
- // make a fake flatnode to be new parent of oldRegions, so their text
- // will be right.
- //IStructuredDocumentRegion holdOldStructuredDocumentRegion = new
- // BasicStructuredDocumentRegion(oldNode);
- //
- // need to reset the parent of the new to-be-inserted regions to be
- // the
- // same oldNode that is the one having its regions changed
- // DW, 4/16/2003, removed since ITextRegion no longer has parent.
- // ITextRegionContainer oldParent = oldNode;
- // for (int i = 0; i < newRegions.size(); i++) {
- // AbstractRegion region = (AbstractRegion) newRegions.elementAt(i);
- // region.setParent(oldParent);
- // }
- // if there are no old regions, insert the new regions according to
- // offset
- if (oldRegions.size() == 0) {
- ITextRegion firstNewRegion = newRegions.get(0);
- int firstOffset = newNode.getStartOffset(firstNewRegion);
- // if at beginning, insert there
- if (firstOffset == 0) {
- insertPos = 0;
- } else {
- //
- ITextRegion regionAtOffset = oldNode.getRegionAtCharacterOffset(firstOffset);
- if (regionAtOffset == null)
- insertPos = regions.size();
- else
- insertPos = regions.indexOf(regionAtOffset);
- }
- } else {
- // else, delete old ones before inserting new ones in their place
- ITextRegion firstOldRegion = oldRegions.get(0);
- insertPos = regions.indexOf(firstOldRegion);
- regions.removeAll(oldRegions);
- }
- regions.addAll(insertPos, newRegions);
- // now regions vector of each node should be of equal length,
- // so go through each, and make sure the old regions
- // offsets matches the new regions offsets
- // (we'll just assign them all, but could be slightly more effiecient)
- ITextRegionList allNewRegions = newNode.getRegions();
- for (int i = 0; i < regions.size(); i++) {
- ITextRegion nextOldishRegion = regions.get(i);
- ITextRegion nextNewRegion = allNewRegions.get(i);
- nextOldishRegion.equatePositions(nextNewRegion);
- checkAndAssignParent(oldNode, nextOldishRegion);
- }
- oldNode.setLength(newNode.getLength());
- oldNode.setEnded(newNode.isEnded());
- oldNode.setParentDocument(newNode.getParentDocument());
- // removed concept of part of these regions, so no longer need to do.
- // for (int i = 0; i < oldRegions.size(); i++) {
- // ITextRegion region = (ITextRegion) oldRegions.elementAt(i);
- // region.setParent(holdOldStructuredDocumentRegion);
- // }
- }
-
- private void reSetCachedNode(CoreNodeList oldNodes, CoreNodeList newNodes) {
- // use the last newNode as the new cachedNode postion, unless its null
- // (e.g. when nodes are deleted) in which case, assign
- // it to a "safe" node so we don't lose reference to the
- // structuredDocument!
- if (newNodes.getLength() > 0) {
- // use last new node as the cache
- fStructuredDocument.setCachedDocumentRegion(newNodes.item(newNodes.getLength() - 1));
- } else {
- // if cachedNode is an old node, then we're in trouble:
- // we can't leave it as the cached node! and its already
- // been disconnected from the model, so we can't do getNext
- // or getPrevious, so we'll get one that is right before
- // (or right after) the offset of the old nodes that are being
- // deleted.
- //
- // if newNodesHead and cachedNode are both null, then
- // it means we were asked to insert an empty string into
- // an empty document. So we have nothing to do here
- // (that is, we have no node to cache)
- // similarly if there are no new nodes and no old nodes then
- // nothing to do (but that should never happen ... we shouldn't
- // get there if there is no event to generate).
- if ((fStructuredDocument.getCachedDocumentRegion() != null) && (oldNodes.getLength() > 0)) {
- // note: we can't simple use nodeAtCharacterOffset, since it
- // depends on cachedNode.
- if (oldNodes.includes(fStructuredDocument.getCachedDocumentRegion()))
- fStructuredDocument.setCachedDocumentRegion(fStructuredDocument.getFirstStructuredDocumentRegion());
- }
- if ((fStructuredDocument.getCachedDocumentRegion() == null) && (Debug.displayWarnings)) {
- // this will happen now legitamately when all text is deleted
- // from a document
- System.out.println("Warning: StructuredDocumentReParser::reSetCachedNode: could not find a node to cache! (its ok if all text deleted)"); //$NON-NLS-1$
- }
- }
- }
-
- /**
- * @param newstructuredDocument
- * com.ibm.sed.structuredDocument.impl.IStructuredDocument
- */
- public void setStructuredDocument(IStructuredDocument newStructuredDocument) {
- // NOTE: this method (and class) depend on being able to
- // do the following cast (i.e. references some fields directly)
- fStructuredDocument = (BasicStructuredDocument) newStructuredDocument;
- fFindReplaceDocumentAdapter = null;
- }
-
- private IStructuredDocumentRegion splice(CoreNodeList oldNodes, CoreNodeList newNodes) {
- //
- IStructuredDocumentRegion firstOld = null;
- IStructuredDocumentRegion firstNew = null;
- IStructuredDocumentRegion lastOld = null;
- IStructuredDocumentRegion lastNew = null;
- //
- IStructuredDocumentRegion oldPrevious = null;
- IStructuredDocumentRegion oldNext = null;
- IStructuredDocumentRegion newPrevious = null;
- IStructuredDocumentRegion newNext = null;
- //
- // if called with both arguments empty lists, we can disregard.
- // this happens, for example, when some text is replaced with the
- // identical text.
- if ((oldNodes.getLength() == 0) && (newNodes.getLength() == 0)) {
- return null;
- }
- // get pointers
- if (newNodes.getLength() > 0) {
- firstNew = newNodes.item(0);
- lastNew = newNodes.item(newNodes.getLength() - 1);
- }
- //
- if (oldNodes.getLength() > 0) {
- firstOld = oldNodes.item(0);
- lastOld = oldNodes.item(oldNodes.getLength() - 1);
- if (firstOld != null)
- oldPrevious = firstOld.getPrevious();
- if (lastOld != null)
- oldNext = lastOld.getNext();
- }
- // handle switch
- if (newNodes.getLength() > 0) {
- // switch surrounding StructuredDocumentRegions' references to
- // lists
- if (oldPrevious != null)
- oldPrevious.setNext(firstNew);
- if (newPrevious != null)
- newPrevious.setNext(firstOld);
- if (oldNext != null)
- oldNext.setPrevious(lastNew);
- if (newNext != null)
- newNext.setPrevious(lastOld);
- // switch list pointers to surrounding StructuredDocumentRegions
- if (firstOld != null)
- firstOld.setPrevious(newPrevious);
- if (lastOld != null)
- lastOld.setNext(newNext);
- if (firstNew != null)
- firstNew.setPrevious(oldPrevious);
- if (lastNew != null)
- lastNew.setNext(oldNext);
- } else {
- // short circuit when there are no new nodes
- if (oldPrevious != null)
- oldPrevious.setNext(oldNext);
- if (oldNext != null)
- oldNext.setPrevious(oldPrevious);
- }
- //
- // SIDE EFFECTs
- // if we have oldNodes, and if oldNext or oldPrevious is null,
- // that means we are replacing
- // the lastNode or firstNode the structuredDocuments's chain of nodes,
- // so we need to update the structuredDocuments last or first Node
- // as the last or first of the new nodes.
- // (and sometimes even these will be null! such as when deleting all
- // text in a document).
- if ((oldNext == null) && (oldNodes.getLength() > 0)) {
- if (newNodes.getLength() > 0) {
- fStructuredDocument.setLastDocumentRegion(lastNew);
- } else {
- // in this case, the last node is being deleted, but not
- // replaced
- // with anything. In this case, we can just back up one
- // from the first old node
- fStructuredDocument.setLastDocumentRegion(firstOld.getPrevious());
- }
- }
- if ((oldPrevious == null) && (oldNodes.getLength() > 0)) {
- if (newNodes.getLength() > 0) {
- fStructuredDocument.setFirstDocumentRegion(firstNew);
- } else {
- // in this case the first node is being deleted, but not
- // replaced
- // with anything. So, we just go one forward past the last old
- // node.
- fStructuredDocument.setFirstDocumentRegion(lastOld.getNext());
- }
- }
- // as a tiny optimization, we return the first of the downstream
- // nodes,
- // if any
- return oldNext;
- }
-
- /**
- * The purpose of this method is to "reuse" the old container region, when
- * found to be same (so same instance doesn't change). The goal is to
- * "transform" the old region, so its equivelent to the newly parsed one.
- *
- */
- private ITextRegion swapNewForOldRegion(IStructuredDocumentRegion oldNode, ITextRegion oldRegion, IStructuredDocumentRegion newNode, ITextRegion newRegion) {
- // makes the old region instance the correct size.
- oldRegion.equatePositions(newRegion);
- // adjusts old node instance appropriately
- oldNode.setLength(newNode.getLength());
- oldNode.setEnded(newNode.isEnded());
- // we do have to set the parent document, since the oldNode's
- // were set to a temporary one, then newNode's have the
- // right one.
- oldNode.setParentDocument(newNode.getParentDocument());
- // if we're transforming a container region, we need to be sure to
- // transfer the new embedded regions, to the old parent
- // Note: if oldRegion hasEmbeddedRegions, then we know the
- // newRegion does too, since we got here because they were the
- // same type.
- if (isCollectionRegion(oldRegion)) { // ||
- // hasContainerRegions(oldRegion))
- // {
- transferEmbeddedRegions(oldNode, (ITextRegionContainer) oldRegion, (ITextRegionContainer) newRegion);
- }
- return oldRegion;
- }
-
- private IStructuredDocumentRegion switchNodeLists(CoreNodeList oldNodes, CoreNodeList newNodes) {
- IStructuredDocumentRegion result = splice(oldNodes, newNodes);
- // ensure that the old nodes hold no references to the existing model
- if (oldNodes.getLength() > 0) {
- IStructuredDocumentRegion firstItem = oldNodes.item(0);
- firstItem.setPrevious(null);
- IStructuredDocumentRegion lastItem = oldNodes.item(oldNodes.getLength() - 1);
- lastItem.setNext(null);
- }
- return result;
- }
-
- /**
- * The purpose of this method is to "reuse" the old container region, when
- * found to be same (so same instance doesn't change). The goal is to
- * "transform" the old region, so its equivelent to the newly parsed one.
- *
- */
- private void transferEmbeddedRegions(IStructuredDocumentRegion oldNode, ITextRegionContainer oldRegion, ITextRegionContainer newRegion) {
- // the oldRegion should already have the right parent, since
- // we got here because all's equivelent except the region
- // postions have changed.
- //oldRegion.setParent(newRegion.getParent());
- // but we should check if there's "nested" embedded regions, and if
- // so, we can just move them over. setting their parent as this old
- // region.
- ITextRegionList newRegionsToTransfer = newRegion.getRegions();
- oldRegion.setRegions(newRegionsToTransfer);
- Iterator newRegionsInOldOne = newRegionsToTransfer.iterator();
- while (newRegionsInOldOne.hasNext()) {
- ITextRegion newOne = (ITextRegion) newRegionsInOldOne.next();
- if (isCollectionRegion(newOne)) { // ||
- // hasContainerRegions(newOne)) {
- //((ITextRegionContainer) newOne).setParent(oldRegion);
- oldRegion.setRegions(newRegion.getRegions());
- }
- }
- }
-
- private void updateDownStreamRegions(IStructuredDocumentRegion flatNode, ITextRegion lastKnownRegion) {
- // so all regions after the last known region (last known to be ok)
- // have to have their start and end values adjusted.
- ITextRegionList regions = flatNode.getRegions();
- int listLength = regions.size();
- int startIndex = 0;
- // first, loop through to find where to start
- for (int i = 0; i < listLength; i++) {
- ITextRegion region = regions.get(i);
- if (region == lastKnownRegion) {
- startIndex = i;
- break;
- }
- }
- // now, beginning one past the last known one, loop
- // through to end of list, adjusting the start and end postions.
- startIndex++;
- for (int j = startIndex; j < listLength; j++) {
- ITextRegion region = regions.get(j);
- region.adjustStart(fLengthDifference);
- }
- }
-}
diff --git a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/text/StructuredDocumentRegionEnumeration.java b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/text/StructuredDocumentRegionEnumeration.java
deleted file mode 100644
index ee75e6a262..0000000000
--- a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/text/StructuredDocumentRegionEnumeration.java
+++ /dev/null
@@ -1,87 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Jens Lukowski/Innoopract - initial renaming/restructuring
- *
- *******************************************************************************/
-package org.eclipse.wst.sse.core.internal.text;
-
-
-
-import java.util.Enumeration;
-import java.util.NoSuchElementException;
-
-import org.eclipse.wst.sse.core.text.IStructuredDocumentRegion;
-import org.eclipse.wst.sse.core.util.Debug;
-
-
-public class StructuredDocumentRegionEnumeration implements Enumeration {
-
- private int count;
- private IStructuredDocumentRegion head;
- private IStructuredDocumentRegion oldHead;
-
- /**
- * StructuredDocumentRegionEnumeration constructor comment.
- */
- public StructuredDocumentRegionEnumeration(IStructuredDocumentRegion newHead) {
- super();
- IStructuredDocumentRegion countNode = head = newHead;
- while (countNode != null) {
- count++;
- countNode = countNode.getNext();
- }
- if (Debug.DEBUG > 5) {
- System.out.println("N Nodes in StructuredDocumentRegionEnumeration Contructor: " + count); //$NON-NLS-1$
- }
- }
-
- /**
- * StructuredDocumentRegionEnumeration constructor comment.
- */
- public StructuredDocumentRegionEnumeration(IStructuredDocumentRegion start, IStructuredDocumentRegion end) {
- super();
- IStructuredDocumentRegion countNode = head = start;
- if ((start == null) || (end == null)) {
- // error condition
- count = 0;
- return;
- }
- //If both nodes are non-null, we assume there is always at least one
- // item
- count = 1;
- while (countNode != end) {
- count++;
- countNode = countNode.getNext();
- }
- if (org.eclipse.wst.sse.core.util.Debug.DEBUG > 5) {
- System.out.println("N Nodes in StructuredDocumentRegionEnumeration Contructor: " + count); //$NON-NLS-1$
- }
- }
-
- /**
- * hasMoreElements method comment.
- */
- public synchronized boolean hasMoreElements() {
- return count > 0;
- }
-
- /**
- * nextElement method comment.
- */
- public synchronized Object nextElement() {
- if (count > 0) {
- count--;
- oldHead = head;
- head = head.getNext();
- return oldHead;
- }
- throw new NoSuchElementException("StructuredDocumentRegionEnumeration"); //$NON-NLS-1$
- }
-}
diff --git a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/text/StructuredDocumentRegionIterator.java b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/text/StructuredDocumentRegionIterator.java
deleted file mode 100644
index 6f1707eab0..0000000000
--- a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/text/StructuredDocumentRegionIterator.java
+++ /dev/null
@@ -1,115 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Jens Lukowski/Innoopract - initial renaming/restructuring
- *
- *******************************************************************************/
-package org.eclipse.wst.sse.core.internal.text;
-
-
-
-import java.util.Vector;
-
-import org.eclipse.wst.sse.core.text.IStructuredDocument;
-import org.eclipse.wst.sse.core.text.IStructuredDocumentRegion;
-import org.eclipse.wst.sse.core.text.IStructuredDocumentRegionList;
-import org.eclipse.wst.sse.core.util.Assert;
-
-
-public class StructuredDocumentRegionIterator {
-
- public final static IStructuredDocumentRegion adjustStart(IStructuredDocumentRegion headNode, int adjustment) {
- IStructuredDocumentRegion aNode = headNode;
- while (aNode != null) {
- aNode.adjustStart(adjustment);
- aNode = aNode.getNext();
- }
- return headNode;
- }
-
- public final static int countRegions(IStructuredDocumentRegionList flatNodes) {
- int result = 0;
- if (flatNodes != null) {
- int length = flatNodes.getLength();
- for (int i = 0; i < length; i++) {
- IStructuredDocumentRegion node = flatNodes.item(i);
- // don't know why, but we're getting null pointer exceptions
- // in this method
- if (node != null) {
- result = result + node.getNumberOfRegions();
- }
- }
- }
- return result;
- }
-
- public final static String getText(CoreNodeList flatNodes) {
- String result = null;
- if (flatNodes == null) {
- result = ""; //$NON-NLS-1$
- } else {
- StringBuffer buff = new StringBuffer();
- //IStructuredDocumentRegion aNode = null;
- int length = flatNodes.getLength();
- for (int i = 0; i < length; i++) {
- buff.append(flatNodes.item(i).getText());
- }
- result = buff.toString();
- }
- return result;
- }
-
- public final static CoreNodeList setParentDocument(CoreNodeList nodelist, IStructuredDocument textStore) {
- Assert.isNotNull(nodelist, "nodelist was null in CoreNodeList::setTextStore(CoreNodeList, StructuredTextStore)"); //$NON-NLS-1$
- int len = nodelist.getLength();
- for (int i = 0; i < len; i++) {
- IStructuredDocumentRegion node = nodelist.item(i);
- //Assert.isNotNull(node, "who's putting null in the node list? in
- // CoreNodeList::setTextStore(CoreNodeList,
- // StructuredTextStore)"); //$NON-NLS-1$
- node.setParentDocument(textStore);
- }
- return nodelist;
- }
-
- // public final static IStructuredDocumentRegion
- // setStructuredDocument(IStructuredDocumentRegion headNode,
- // BasicStructuredDocument structuredDocument) {
- // IStructuredDocumentRegion aNode = headNode;
- // while (aNode != null) {
- // aNode.setParentDocument(structuredDocument);
- // aNode = (IStructuredDocumentRegion) aNode.getNext();
- // }
- // return headNode;
- // }
- public final static IStructuredDocumentRegion setParentDocument(IStructuredDocumentRegion headNode, IStructuredDocument document) {
- IStructuredDocumentRegion aNode = headNode;
- while (aNode != null) {
- aNode.setParentDocument(document);
- aNode = aNode.getNext();
- }
- return headNode;
- }
-
- public final static Vector toVector(IStructuredDocumentRegion headNode) {
- IStructuredDocumentRegion aNode = headNode;
- Vector v = new Vector();
- while (aNode != null) {
- v.addElement(aNode);
- aNode = aNode.getNext();
- }
- return v;
- }
-
- /**
- *
- */
- private StructuredDocumentRegionIterator() {
- }
-}
diff --git a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/text/StructuredDocumentSequentialRewriteTextStore.java b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/text/StructuredDocumentSequentialRewriteTextStore.java
deleted file mode 100644
index 5c31aa8094..0000000000
--- a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/text/StructuredDocumentSequentialRewriteTextStore.java
+++ /dev/null
@@ -1,132 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Jens Lukowski/Innoopract - initial renaming/restructuring
- *
- *******************************************************************************/
-package org.eclipse.wst.sse.core.internal.text;
-
-import org.eclipse.jface.text.ITextStore;
-import org.eclipse.jface.text.SequentialRewriteTextStore;
-
-public class StructuredDocumentSequentialRewriteTextStore extends SequentialRewriteTextStore implements CharSequence, IRegionComparible {
-
- /**
- * @param source
- */
- public StructuredDocumentSequentialRewriteTextStore(ITextStore source) {
- super(source);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.lang.CharSequence#charAt(int)
- */
- public char charAt(int index) {
- return get(index);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.lang.CharSequence#length()
- */
- public int length() {
- return getLength();
- }
-
- /**
- * @param c
- * @param d
- * @return
- */
- private boolean matchesIgnoreCase(char c1, char c2) {
- // we check both case conversions to handle those few cases,
- // in languages such as Turkish, which have some characters
- // which sort of have 3 cases.
- boolean result = false;
- if (Character.toUpperCase(c1) == Character.toUpperCase(c2))
- result = true;
- else if (Character.toLowerCase(c1) == Character.toLowerCase(c2))
- result = true;
- return result;
- }
-
- public boolean regionMatches(int offset, int length, String stringToCompare) {
- boolean result = false;
- int compareLength = stringToCompare.length();
- if (compareLength == length) {
- int endOffset = offset + length;
- if (endOffset <= length()) {
- result = regionMatches(offset, stringToCompare);
- }
- }
-
- return result;
- }
-
- /**
- * This method assumes all lengths have been checked and fall withint
- * exceptable limits
- *
- * @param offset
- * @param stringToCompare
- * @return
- */
- private boolean regionMatches(int offset, String stringToCompare) {
- boolean result = true;
- int stringOffset = 0;
- int len = stringToCompare.length();
- for (int i = offset; i < len; i++) {
- if (charAt(i) != stringToCompare.charAt(stringOffset++)) {
- result = false;
- break;
- }
- }
- return result;
- }
-
- public boolean regionMatchesIgnoreCase(int offset, int length, String stringToCompare) {
- boolean result = false;
- int compareLength = stringToCompare.length();
- if (compareLength == length) {
- int endOffset = offset + length;
- if (endOffset <= length()) {
- result = regionMatchesIgnoreCase(offset, stringToCompare);
- }
- }
-
- return result;
- }
-
- private boolean regionMatchesIgnoreCase(int offset, String stringToCompare) {
- boolean result = true;
- int stringOffset = 0;
- int len = stringToCompare.length();
- for (int i = offset; i < len; i++) {
- if (!matchesIgnoreCase(charAt(i), stringToCompare.charAt(stringOffset++))) {
- result = false;
- break;
- }
- }
- return result;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.lang.CharSequence#subSequence(int, int)
- */
- public CharSequence subSequence(int start, int end) {
-
- return get(start, end - start);
- }
-
-}
diff --git a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/text/StructuredDocumentTextStore.java b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/text/StructuredDocumentTextStore.java
deleted file mode 100644
index 2751caeff0..0000000000
--- a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/text/StructuredDocumentTextStore.java
+++ /dev/null
@@ -1,189 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Jens Lukowski/Innoopract - initial renaming/restructuring
- *
- *******************************************************************************/
-package org.eclipse.wst.sse.core.internal.text;
-
-import org.eclipse.jface.text.GapTextStore;
-import org.eclipse.jface.text.ITextStore;
-
-public class StructuredDocumentTextStore implements ITextStore, CharSequence, IRegionComparible {
-
- private GapTextStore fInternalStore;
-
- /**
- *
- */
- public StructuredDocumentTextStore() {
- this(50, 300);
- }
-
- /**
- * @param lowWatermark
- * @param highWatermark
- */
- public StructuredDocumentTextStore(int lowWatermark, int highWatermark) {
- super();
- fInternalStore = new GapTextStore(lowWatermark, highWatermark);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.lang.CharSequence#charAt(int)
- */
- public char charAt(int index) {
- return fInternalStore.get(index);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jface.text.ITextStore#get(int)
- */
- public char get(int offset) {
-
- return fInternalStore.get(offset);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jface.text.ITextStore#get(int, int)
- */
- public String get(int offset, int length) {
-
- return fInternalStore.get(offset, length);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jface.text.ITextStore#getLength()
- */
- public int getLength() {
-
- return fInternalStore.getLength();
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.lang.CharSequence#length()
- */
- public int length() {
-
- return fInternalStore.getLength();
- }
-
- private boolean matchesIgnoreCase(char c1, char c2) {
- // we check both case conversions to handle those few cases,
- // in languages such as Turkish, which have some characters
- // which sort of have 3 cases.
- boolean result = false;
- if (Character.toUpperCase(c1) == Character.toUpperCase(c2))
- result = true;
- else if (Character.toLowerCase(c1) == Character.toLowerCase(c2))
- result = true;
- return result;
- }
-
- public boolean regionMatches(int offset, int length, String stringToCompare) {
- boolean result = false;
- int compareLength = stringToCompare.length();
- if (compareLength == length) {
- int endOffset = offset + length;
- if (endOffset <= length()) {
- result = regionMatches(offset, stringToCompare);
- }
- }
-
- return result;
- }
-
- /**
- * This method assumes all lengths have been checked and fall withint
- * exceptable limits
- *
- * @param offset
- * @param stringToCompare
- * @return
- */
- private boolean regionMatches(int offset, String stringToCompare) {
- boolean result = true;
- int stringOffset = 0;
- int len = stringToCompare.length();
- for (int i = offset; i < len; i++) {
- if (charAt(i) != stringToCompare.charAt(stringOffset++)) {
- result = false;
- break;
- }
- }
- return result;
- }
-
- public boolean regionMatchesIgnoreCase(int offset, int length, String stringToCompare) {
- boolean result = false;
- int compareLength = stringToCompare.length();
- if (compareLength == length) {
- int endOffset = offset + length;
- if (endOffset <= length()) {
- result = regionMatchesIgnoreCase(offset, stringToCompare);
- }
- }
-
- return result;
- }
-
- private boolean regionMatchesIgnoreCase(int offset, String stringToCompare) {
- boolean result = true;
- int stringOffset = 0;
- int len = stringToCompare.length();
- for (int i = offset; i < len; i++) {
- if (!matchesIgnoreCase(charAt(i), stringToCompare.charAt(stringOffset++))) {
- result = false;
- break;
- }
- }
- return result;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jface.text.ITextStore#replace(int, int,
- * java.lang.String)
- */
- public void replace(int offset, int length, String text) {
- fInternalStore.replace(offset, length, text);
-
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jface.text.ITextStore#set(java.lang.String)
- */
- public void set(String text) {
- fInternalStore.set(text);
-
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.lang.CharSequence#subSequence(int, int)
- */
- public CharSequence subSequence(int start, int end) {
- // convert 'end' to 'length'
- return fInternalStore.get(start, end - start);
- }
-}
diff --git a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/text/SubSetTextStore.java b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/text/SubSetTextStore.java
deleted file mode 100644
index caca8b9284..0000000000
--- a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/text/SubSetTextStore.java
+++ /dev/null
@@ -1,127 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Jens Lukowski/Innoopract - initial renaming/restructuring
- *
- *******************************************************************************/
-package org.eclipse.wst.sse.core.internal.text;
-
-/**
- * This is a convience or utility class that allows you to make a copy of a
- * part of a larger text store, but have the copy behave as if it was the
- * larger text store.
- *
- * In other words, it provides a subset of a larger document, that "looks like"
- * the orginal document. That is, "looks like" in terms of offsets and lengths.
- * Valid access can only be made to data between the orignal offsets, even
- * though those offsets are in the same units at the original, and even though
- * the length appears to be long.
- *
- * For example, if a subsettext store is created for the def part of abcdefgh,
- * then get(3,5) is valid, getLength is 8. Any other access, such as
- * getChar(2), would be invalid.
- */
-import org.eclipse.jface.text.ITextStore;
-
-/**
- * Similar to basics of IDocument, but the offsets are mapped from coordinates
- * of underlying storage to a "virtual" document.
- */
-public class SubSetTextStore implements ITextStore {
- private int pseudoBeginOffset; // maps to "zero" postion of new text
- //private int pseudoEndOffset;
- private int pseudoLength; // length of old/original document
- private StringBuffer stringBuffer = new StringBuffer();
-
- /**
- * SubSetTextStore constructor comment.
- *
- * @param initialContent
- * java.lang.String
- */
- public SubSetTextStore(String initialContent, int beginOffset, int endOffset, int originalDocumentLength) {
- super();
- pseudoBeginOffset = beginOffset;
- //pseudoEndOffset = endOffset;
- // used to be originalDocument.getLength ... not sure if used, or
- // which
- // is right
- pseudoLength = originalDocumentLength;
- stringBuffer = new StringBuffer(initialContent);
- //set(initialContent);
- }
-
- // this is our "private" get, which methods in this class should
- // use to get using "real" coordinates of underlying representation.
- private String _get(int begin, int length) {
- char[] chars = new char[length];
- int srcEnd = begin + length;
- stringBuffer.getChars(begin, srcEnd, chars, 0);
- return new String(chars);
- }
-
- public char get(int offset) {
- return stringBuffer.charAt(offset - pseudoBeginOffset);
- }
-
- /**
- * @return java.lang.String
- * @param begin
- * int
- * @param end
- * int
- */
- public String get(int begin, int length) {
- // remap the begin and end to "appear" to be in the
- // same coordinates of the original parentDocument
- return _get(begin - pseudoBeginOffset, length);
- }
-
- /**
- * @return java.lang.String
- * @param begin
- * int
- * @param end
- * int
- */
- public char getChar(int pos) {
- // remap the begin and end to "appear" to be in the
- // same coordinates of the original parentDocument
- return get(pos - pseudoBeginOffset);
- }
-
- /**
- * We redefine getLength so its not the true length of this sub-set
- * document, but the length of the original. This is needed, as a simple
- * example, if you want to see if the pseudo end is equal the last
- * position of the original document.
- */
- public int getLength() {
- return pseudoLength;
- }
-
- /**
- * Returns the length as if considered a true, standalone document
- */
- public int getTrueLength() {
- return stringBuffer.length();
- }
-
- public void replace(int begin, int length, String changes) {
- // remap the begin and end to "appear" to be in the
- // same coordinates of the original parentDocument
- int end = begin + length;
- stringBuffer.replace(begin - pseudoBeginOffset, end, changes);
- }
-
- public void set(String text) {
- stringBuffer.setLength(0);
- stringBuffer.append(text);
- }
-}
diff --git a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/text/TextRegionListImpl.java b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/text/TextRegionListImpl.java
deleted file mode 100644
index 1985edeffa..0000000000
--- a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/text/TextRegionListImpl.java
+++ /dev/null
@@ -1,223 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Jens Lukowski/Innoopract - initial renaming/restructuring
- *
- *******************************************************************************/
-package org.eclipse.wst.sse.core.internal.text;
-
-import java.util.Iterator;
-import java.util.NoSuchElementException;
-
-import org.eclipse.wst.sse.core.text.ITextRegion;
-import org.eclipse.wst.sse.core.text.ITextRegionList;
-
-
-public class TextRegionListImpl implements ITextRegionList {
-
- private class NullIterator implements Iterator {
- public NullIterator() {
- }
-
- public boolean hasNext() {
- return false;
- }
-
- public Object next() {
- throw new NoSuchElementException();
- }
-
- public void remove() {
- throw new UnsupportedOperationException("can not remove regions via iterator"); //$NON-NLS-1$
-
- }
-
- }
-
- private class RegionIterator implements Iterator {
- private ITextRegion[] fIteratorRegions;
- private int index = -1;
- private int maxindex = -1;
-
- public RegionIterator() {
- fIteratorRegions = toArray();
- maxindex = fIteratorRegions.length - 1;
- }
-
- public boolean hasNext() {
- return index < maxindex;
- }
-
- public Object next() {
- if (!(index < maxindex))
- throw new NoSuchElementException();
- return fIteratorRegions[++index];
- }
-
- public void remove() {
- throw new UnsupportedOperationException("can not remove regions via iterator"); //$NON-NLS-1$
-
- }
-
- }
-
- private final static int growthConstant = 2;
-
- private ITextRegion[] fRegions;
- private int fRegionsCount = 0;
-
- public TextRegionListImpl() {
- super();
- }
-
- public TextRegionListImpl(ITextRegionList regionList) {
- this();
- fRegions = (ITextRegion[]) regionList.toArray().clone();
- fRegionsCount = fRegions.length;
- }
-
- public boolean add(ITextRegion region) {
-
- if (region == null)
- return false;
- ensureCapacity(fRegionsCount + 1);
- fRegions[fRegionsCount++] = region;
- return true;
- }
-
- public boolean addAll(int insertPos, ITextRegionList newRegions) {
- // beginning of list is 0 to insertPos-1
- // remainder of list is insertPos to fRegionsCount
- // resulting total will be be fRegionsCount + newRegions.size()
- if (insertPos < 0 || insertPos > fRegionsCount) {
- throw new ArrayIndexOutOfBoundsException(insertPos);
- }
-
- int newRegionsSize = newRegions.size();
-
- ensureCapacity(fRegionsCount + newRegionsSize);
-
- int numMoved = fRegionsCount - insertPos;
- if (numMoved > 0)
- System.arraycopy(fRegions, insertPos, fRegions, insertPos + newRegionsSize, numMoved);
-
- for (int i = 0; i < newRegionsSize; i++)
- fRegions[insertPos++] = newRegions.get(i);
-
- fRegionsCount += newRegionsSize;
- return newRegionsSize != 0;
-
- }
-
- public void clear() {
- // note: size of array is not reduced!
- fRegionsCount = 0;
- }
-
- private void ensureCapacity(int needed) {
- if (fRegions == null) {
- // first time
- fRegions = new ITextRegion[needed];
- return;
- }
- int oldLength = fRegions.length;
- if (oldLength < needed) {
- ITextRegion[] oldAdapters = fRegions;
- ITextRegion[] newAdapters = new ITextRegion[needed + growthConstant];
- System.arraycopy(oldAdapters, 0, newAdapters, 0, fRegionsCount);
- fRegions = newAdapters;
- }
- }
-
- public ITextRegion get(int index) {
- if (index < 0 || index > fRegionsCount) {
- throw new ArrayIndexOutOfBoundsException(index);
- }
- ITextRegion result = fRegions[index];
- return result;
- }
-
- public int indexOf(ITextRegion region) {
-
- int result = -1;
- if (region != null) {
- if (fRegions != null) {
- for (int i = 0; i < fRegions.length; i++) {
- if (region.equals(fRegions[i])) {
- result = i;
- break;
- }
- }
- }
- }
- return result;
- }
-
- public boolean isEmpty() {
- return fRegionsCount == 0;
- }
-
- public Iterator iterator() {
- if (size() == 0) {
- return new NullIterator();
- } else {
- return new RegionIterator();
- }
- }
-
- public ITextRegion remove(int index) {
- // much more efficient ways to implement this, but
- // I doubt if called often
- ITextRegion oneToRemove = get(index);
- remove(oneToRemove);
- return oneToRemove;
- }
-
- public void remove(ITextRegion a) {
- if (fRegions == null || a == null)
- return;
- int newIndex = 0;
- ITextRegion[] newRegions = new ITextRegion[fRegionsCount];
- int oldRegionCount = fRegionsCount;
- boolean found = false;
- for (int oldIndex = 0; oldIndex < oldRegionCount; oldIndex++) {
- ITextRegion candidate = fRegions[oldIndex];
- if (a == candidate) {
- fRegionsCount--;
- found = true;
- } else
- newRegions[newIndex++] = fRegions[oldIndex];
- }
- if (found)
- fRegions = newRegions;
- }
-
- public void removeAll(ITextRegionList regionList) {
- // much more efficient ways to implement this, but
- // I doubt if called often
- if (regionList != null) {
- for (int i = 0; i < regionList.size(); i++) {
- this.remove(regionList.get(i));
- }
- }
-
- }
-
- public int size() {
- return fRegionsCount;
- }
-
- public ITextRegion[] toArray() {
- // return "clone" of internal array
- ITextRegion[] newArray = new ITextRegion[fRegionsCount];
- System.arraycopy(fRegions, 0, newArray, 0, fRegionsCount);
- return newArray;
- }
-
-}
diff --git a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/undo/StructuredTextCommandImpl.java b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/undo/StructuredTextCommandImpl.java
deleted file mode 100644
index 00e0f4e514..0000000000
--- a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/undo/StructuredTextCommandImpl.java
+++ /dev/null
@@ -1,138 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Jens Lukowski/Innoopract - initial renaming/restructuring
- *
- *******************************************************************************/
-package org.eclipse.wst.sse.core.internal.undo;
-
-
-
-import org.eclipse.emf.common.command.AbstractCommand;
-import org.eclipse.jface.text.BadLocationException;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.wst.sse.core.internal.Logger;
-import org.eclipse.wst.sse.core.text.IStructuredDocument;
-import org.eclipse.wst.sse.core.undo.StructuredTextCommand;
-
-
-public class StructuredTextCommandImpl extends AbstractCommand implements StructuredTextCommand {
-
- protected IDocument fDocument = null; // needed for updating the text
- protected String fTextDeleted = null;
- protected int fTextEnd = -1;
- protected String fTextInserted = null;
- protected int fTextStart = -1;
-
- /**
- * We have no-arg constructor non-public to force document to be specfied.
- *
- */
- protected StructuredTextCommandImpl() {
- super();
- }
-
- public StructuredTextCommandImpl(IDocument document) {
- this();
- fDocument = document; // needed for updating the text
- }
-
- public void execute() {
- }
-
- /**
- * getTextDeleted method comment.
- */
- public java.lang.String getTextDeleted() {
- return fTextDeleted;
- }
-
- /**
- * textEnd is the same as (textStart + textInserted.length())
- */
- public int getTextEnd() {
- return fTextEnd;
- }
-
- /**
- * getTextInserted method comment.
- */
- public java.lang.String getTextInserted() {
- return fTextInserted;
- }
-
- /**
- * getTextStart method comment.
- */
- public int getTextStart() {
- return fTextStart;
- }
-
- protected boolean prepare() {
- return true;
- }
-
- public void redo() {
- if (fDocument instanceof IStructuredDocument) {
- // note: one of the few places we programatically ignore read-only
- // settings
- ((IStructuredDocument) fDocument).replaceText(this, fTextStart, fTextDeleted.length(), fTextInserted, true);
- } else {
- try {
- fDocument.replace(fTextStart, fTextDeleted.length(), fTextInserted);
- } catch (BadLocationException e) {
- // assumed impossible, for now
- Logger.logException(e);
- }
- }
- }
-
- /**
- * setTextDeleted method comment.
- */
- public void setTextDeleted(java.lang.String textDeleted) {
- fTextDeleted = textDeleted;
- }
-
- /**
- * setTextEnd method comment.
- */
- public void setTextEnd(int textEnd) {
- fTextEnd = textEnd;
- }
-
- /**
- * setTextInserted method comment.
- */
- public void setTextInserted(java.lang.String textInserted) {
- fTextInserted = textInserted;
- }
-
- /**
- * setTextStart method comment.
- */
- public void setTextStart(int textStart) {
- fTextStart = textStart;
- }
-
- public void undo() {
- if (fDocument instanceof IStructuredDocument) {
- // note: one of the few places we programatically ignore read-only
- // settings
- ((IStructuredDocument) fDocument).replaceText(this, fTextStart, fTextInserted.length(), fTextDeleted, true);
- } else {
- try {
- fDocument.replace(fTextStart, fTextInserted.length(), fTextDeleted);
- } catch (BadLocationException e) {
- // assumed impossible, for now
- Logger.logException(e);
- }
- }
- }
-}
diff --git a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/undo/StructuredTextCompoundCommandImpl.java b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/undo/StructuredTextCompoundCommandImpl.java
deleted file mode 100644
index bb8856a8b4..0000000000
--- a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/undo/StructuredTextCompoundCommandImpl.java
+++ /dev/null
@@ -1,261 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Jens Lukowski/Innoopract - initial renaming/restructuring
- *
- *******************************************************************************/
-package org.eclipse.wst.sse.core.internal.undo;
-
-
-
-import org.eclipse.emf.common.command.Command;
-import org.eclipse.emf.common.command.CompoundCommand;
-import org.eclipse.wst.sse.core.undo.CommandCursorPosition;
-
-
-
-public class StructuredTextCompoundCommandImpl extends CompoundCommand implements CommandCursorPosition {
- protected int fRedoCursorPosition = -1;
- protected int fRedoSelectionLength = 0;
-
- protected int fUndoCursorPosition = -1;
- protected int fUndoSelectionLength = 0;
-
- /**
- * StructuredTextCompoundCommandImpl constructor comment.
- */
- public StructuredTextCompoundCommandImpl() {
- super();
- }
-
- /**
- * StructuredTextCompoundCommandImpl constructor comment.
- *
- * @param resultIndex
- * int
- */
- public StructuredTextCompoundCommandImpl(int resultIndex) {
- super(resultIndex);
- }
-
- /**
- * StructuredTextCompoundCommandImpl constructor comment.
- *
- * @param resultIndex
- * int
- * @param commandList
- * java.util.List
- */
- public StructuredTextCompoundCommandImpl(int resultIndex, java.util.List commandList) {
- super(resultIndex, commandList);
- }
-
- /**
- * StructuredTextCompoundCommandImpl constructor comment.
- *
- * @param resultIndex
- * int
- * @param label
- * java.lang.String
- */
- public StructuredTextCompoundCommandImpl(int resultIndex, String label) {
- super(resultIndex, label);
- }
-
- /**
- * StructuredTextCompoundCommandImpl constructor comment.
- *
- * @param resultIndex
- * int
- * @param label
- * java.lang.String
- * @param commandList
- * java.util.List
- */
- public StructuredTextCompoundCommandImpl(int resultIndex, String label, java.util.List commandList) {
- super(resultIndex, label, commandList);
- }
-
- /**
- * StructuredTextCompoundCommandImpl constructor comment.
- *
- * @param resultIndex
- * int
- * @param label
- * java.lang.String
- * @param description
- * java.lang.String
- */
- public StructuredTextCompoundCommandImpl(int resultIndex, String label, String description) {
- super(resultIndex, label, description);
- }
-
- /**
- * StructuredTextCompoundCommandImpl constructor comment.
- *
- * @param resultIndex
- * int
- * @param label
- * java.lang.String
- * @param description
- * java.lang.String
- * @param commandList
- * java.util.List
- */
- public StructuredTextCompoundCommandImpl(int resultIndex, String label, String description, java.util.List commandList) {
- super(resultIndex, label, description, commandList);
- }
-
- /**
- * StructuredTextCompoundCommandImpl constructor comment.
- *
- * @param commandList
- * java.util.List
- */
- public StructuredTextCompoundCommandImpl(java.util.List commandList) {
- super(commandList);
- }
-
- /**
- * StructuredTextCompoundCommandImpl constructor comment.
- *
- * @param label
- * java.lang.String
- */
- public StructuredTextCompoundCommandImpl(String label) {
- super(label);
- }
-
- /**
- * StructuredTextCompoundCommandImpl constructor comment.
- *
- * @param label
- * java.lang.String
- * @param commandList
- * java.util.List
- */
- public StructuredTextCompoundCommandImpl(String label, java.util.List commandList) {
- super(label, commandList);
- }
-
- /**
- * StructuredTextCompoundCommandImpl constructor comment.
- *
- * @param label
- * java.lang.String
- * @param description
- * java.lang.String
- */
- public StructuredTextCompoundCommandImpl(String label, String description) {
- super(label, description);
- }
-
- /**
- * StructuredTextCompoundCommandImpl constructor comment.
- *
- * @param label
- * java.lang.String
- * @param description
- * java.lang.String
- * @param commandList
- * java.util.List
- */
- public StructuredTextCompoundCommandImpl(String label, String description, java.util.List commandList) {
- super(label, description, commandList);
- }
-
- /**
- * Returns the cursor position to be set to after this command is redone.
- *
- * @return int
- */
- public int getRedoCursorPosition() {
- int cursorPosition = -1;
-
- if (fRedoCursorPosition != -1)
- cursorPosition = fRedoCursorPosition;
- else if (!commandList.isEmpty()) {
- int commandListSize = commandList.size();
- Command lastCommand = (Command) commandList.get(commandListSize - 1);
-
- if (lastCommand instanceof CommandCursorPosition)
- cursorPosition = ((CommandCursorPosition) lastCommand).getRedoCursorPosition();
- }
-
- return cursorPosition;
- }
-
- /**
- * Returns the length of text to be selected after this command is redone.
- *
- * @return int
- */
- public int getRedoSelectionLength() {
- return fRedoSelectionLength;
- }
-
- /**
- * Returns the cursor position to be set to after this command is undone.
- *
- * @return int
- */
- public int getUndoCursorPosition() {
- int cursorPosition = -1;
-
- if (fUndoCursorPosition != -1)
- cursorPosition = fUndoCursorPosition;
- else if (!commandList.isEmpty()) {
- // never used
- //int commandListSize = commandList.size();
- Command firstCommand = (Command) commandList.get(0);
-
- if (firstCommand instanceof CommandCursorPosition)
- cursorPosition = ((CommandCursorPosition) firstCommand).getUndoCursorPosition();
- }
-
- return cursorPosition;
- }
-
- /**
- * Returns the length of text to be selected after this command is undone.
- *
- * @return int
- */
- public int getUndoSelectionLength() {
- return fUndoSelectionLength;
- }
-
- /**
- * Sets the cursor position to be used after this command is redone.
- */
- public void setRedoCursorPosition(int cursorPosition) {
- fRedoCursorPosition = cursorPosition;
- }
-
- /**
- * Sets the length of text to be selected after this command is redone.
- */
- public void setRedoSelectionLength(int selectionLength) {
- fRedoSelectionLength = selectionLength;
- }
-
- /**
- * Sets the cursor position to be used after this command is undone.
- */
- public void setUndoCursorPosition(int cursorPosition) {
- fUndoCursorPosition = cursorPosition;
- }
-
- /**
- * Sets the length of text to be selected after this command is undone.
- */
- public void setUndoSelectionLength(int selectionLength) {
- fUndoSelectionLength = selectionLength;
- }
-}
diff --git a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/undo/StructuredTextUndoManager.java b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/undo/StructuredTextUndoManager.java
deleted file mode 100644
index 04df924f1f..0000000000
--- a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/undo/StructuredTextUndoManager.java
+++ /dev/null
@@ -1,617 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Jens Lukowski/Innoopract - initial renaming/restructuring
- *
- *******************************************************************************/
-package org.eclipse.wst.sse.core.internal.undo;
-
-import java.util.EventObject;
-
-import org.eclipse.emf.common.command.BasicCommandStack;
-import org.eclipse.emf.common.command.Command;
-import org.eclipse.emf.common.command.CommandStack;
-import org.eclipse.emf.common.command.CommandStackListener;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.wst.sse.core.IModelManager;
-import org.eclipse.wst.sse.core.IStructuredModel;
-import org.eclipse.wst.sse.core.StructuredModelManager;
-import org.eclipse.wst.sse.core.events.IStructuredDocumentListener;
-import org.eclipse.wst.sse.core.events.NewDocumentEvent;
-import org.eclipse.wst.sse.core.events.NoChangeEvent;
-import org.eclipse.wst.sse.core.events.RegionChangedEvent;
-import org.eclipse.wst.sse.core.events.RegionsReplacedEvent;
-import org.eclipse.wst.sse.core.events.StructuredDocumentEvent;
-import org.eclipse.wst.sse.core.events.StructuredDocumentRegionsReplacedEvent;
-import org.eclipse.wst.sse.core.internal.SSECorePlugin;
-import org.eclipse.wst.sse.core.text.IStructuredDocument;
-import org.eclipse.wst.sse.core.undo.CommandCursorPosition;
-import org.eclipse.wst.sse.core.undo.IDocumentSelectionMediator;
-import org.eclipse.wst.sse.core.undo.IStructuredTextUndoManager;
-import org.eclipse.wst.sse.core.undo.StructuredTextCommand;
-import org.eclipse.wst.sse.core.undo.UndoDocumentEvent;
-import org.eclipse.wst.sse.core.util.Assert;
-import org.eclipse.wst.sse.core.util.Utilities;
-
-public class StructuredTextUndoManager implements IStructuredTextUndoManager {
-
- class InternalCommandStackListener implements CommandStackListener {
- public void commandStackChanged(EventObject event) {
- resetInternalCommands();
- }
- }
-
- class InternalStructuredDocumentListener implements IStructuredDocumentListener {
-
- public void newModel(NewDocumentEvent structuredDocumentEvent) {
- // Do nothing. Do not push the new model's structuredDocument
- // changes
- // onto the undo command stack, or else the user may be able to
- // undo
- // an existing file to an empty file.
- }
-
- public void noChange(NoChangeEvent structuredDocumentEvent) {
- // Since "no change", do nothing.
- }
-
- public void nodesReplaced(StructuredDocumentRegionsReplacedEvent structuredDocumentEvent) {
- processStructuredDocumentEvent(structuredDocumentEvent);
- }
-
- private void processStructuredDocumentEvent(String textDeleted, String textInserted, int textStart, int textEnd) {
- if (fTextCommand != null && textStart == fTextCommand.getTextEnd()) {
- // append to the text command
- fTextCommand.setTextDeleted(fTextCommand.getTextDeleted().concat(textDeleted));
- fTextCommand.setTextInserted(fTextCommand.getTextInserted().concat(textInserted));
- fTextCommand.setTextEnd(textEnd);
- } else if (fTextCommand != null && textStart == fTextCommand.getTextStart() - (textEnd - textStart + 1) && textEnd <= fTextCommand.getTextEnd() - (textEnd - textStart + 1) && textDeleted.length() == 1 && textInserted.length() == 0) {
- // backspace pressed
-
- // erase a character just inserted
- if (fTextCommand.getTextInserted().length() > 0) {
- fTextCommand.setTextInserted(fTextCommand.getTextInserted().substring(0, fTextCommand.getTextEnd() - fTextCommand.getTextStart() - 1));
- fTextCommand.setTextEnd(textEnd);
- }
- // erase a character in the file
- else {
- fTextCommand.setTextDeleted(textDeleted.concat(fTextCommand.getTextDeleted()));
- fTextCommand.setTextStart(textStart);
- }
- } else {
- createNewTextCommand(textDeleted, textInserted, textStart, textEnd);
- }
-
- // save cursor position
- fCursorPosition = textEnd;
- }
-
- private void processStructuredDocumentEvent(StructuredDocumentEvent structuredDocumentEvent) {
- // Note: fListening tells us if we should listen to the
- // StructuredDocumentEvent.
- // fListening is set to false right before the undo/redo process
- // and
- // then set to true again
- // right after the undo/redo process to block out and ignore all
- // StructuredDocumentEvents generated
- // by the undo/redo process.
-
- // Process StructuredDocumentEvent if fListening is true.
- //
- // We are executing a command from the command stack if the
- // requester
- // is a command (for example, undo/redo).
- // We should not process the flat model event when we are
- // executing a
- // command from the command stack.
- if (fUndoManagementEnabled && !(structuredDocumentEvent.getOriginalSource() instanceof Command)) {
- // check requester if not recording
- if (!fRecording)
- checkRequester(structuredDocumentEvent.getOriginalSource());
-
- // process the structuredDocumentEvent
- String textDeleted = structuredDocumentEvent.getDeletedText();
- String textInserted = structuredDocumentEvent.getText();
- int textStart = structuredDocumentEvent.getOriginalStart();
- int textEnd = textStart + textInserted.length();
- processStructuredDocumentEvent(textDeleted, textInserted, textStart, textEnd);
- }
- }
-
- public void regionChanged(RegionChangedEvent structuredDocumentEvent) {
- processStructuredDocumentEvent(structuredDocumentEvent);
- }
-
- public void regionsReplaced(RegionsReplacedEvent structuredDocumentEvent) {
- processStructuredDocumentEvent(structuredDocumentEvent);
- }
-
- }
-
- private static final String TEXT_CHANGE_TEXT = SSECorePlugin.getResourceString("%Text_Change_UI_"); //$NON-NLS-1$
- private CommandStack fCommandStack = null;
- private StructuredTextCompoundCommandImpl fCompoundCommand = null;
- private String fCompoundCommandDescription = null;
- private String fCompoundCommandLabel = null;
- int fCursorPosition = 0;
- //private IStructuredModel fStructuredModel = null;
- private IDocument fDocument;
- private InternalCommandStackListener fInternalCommandStackListener;
- //private Map fTextViewerToListenerMap = new HashMap();
- private IStructuredDocumentListener fInternalStructuredDocumentListener;
- private IDocumentSelectionMediator[] fMediators = null;
- private boolean fRecording = false;
- private int fRecordingCount = 0;
- private Object fRequester;
- StructuredTextCommandImpl fTextCommand = null;
- private int fUndoCursorPosition = -1;
- boolean fUndoManagementEnabled = true;
- private int fUndoSelectionLength = 0;
-
- public StructuredTextUndoManager() {
- this(new BasicCommandStack());
- }
-
- public StructuredTextUndoManager(CommandStack commandStack) {
- setCommandStack(commandStack);
- }
-
- private void addDocumentSelectionMediator(IDocumentSelectionMediator mediator) {
- if (!Utilities.contains(fMediators, mediator)) {
- int oldSize = 0;
-
- if (fMediators != null) {
- // normally won't be null, but we need to be sure, for first
- // time through
- oldSize = fMediators.length;
- }
-
- int newSize = oldSize + 1;
- IDocumentSelectionMediator[] newMediators = new IDocumentSelectionMediator[newSize];
- if (fMediators != null) {
- System.arraycopy(fMediators, 0, newMediators, 0, oldSize);
- }
-
- // add the new undo mediator to last position
- newMediators[newSize - 1] = mediator;
-
- // now switch new for old
- fMediators = newMediators;
- } else {
- removeDocumentSelectionMediator(mediator);
- addDocumentSelectionMediator(mediator);
- }
- }
-
- public void beginRecording(Object requester) {
- beginRecording(requester, null, null);
- }
-
- public void beginRecording(Object requester, int cursorPosition, int selectionLength) {
- beginRecording(requester, null, null);
-
- fUndoCursorPosition = cursorPosition;
- fUndoSelectionLength = selectionLength;
- }
-
- public void beginRecording(Object requester, String label) {
- beginRecording(requester, label, null);
- }
-
- public void beginRecording(Object requester, String label, int cursorPosition, int selectionLength) {
- beginRecording(requester, label, null);
-
- fUndoCursorPosition = cursorPosition;
- fUndoSelectionLength = selectionLength;
- }
-
- public void beginRecording(Object requester, String label, String description) {
- // save the requester
- fRequester = requester;
-
- // update label and desc only on the first level when recording is
- // nested
- if (fRecordingCount == 0) {
- fCompoundCommandLabel = label;
- if (fCompoundCommandLabel == null)
- fCompoundCommandLabel = TEXT_CHANGE_TEXT;
-
- fCompoundCommandDescription = description;
- if (fCompoundCommandDescription == null)
- fCompoundCommandDescription = TEXT_CHANGE_TEXT;
-
- // clear commands
- fTextCommand = null;
- fCompoundCommand = null;
- }
-
- // update counter and flag
- fRecordingCount++;
- fRecording = true;
-
- // no undo cursor position and undo selection length specified
- // reset undo cursor position and undo selection length
- fUndoCursorPosition = -1;
- fUndoSelectionLength = 0;
- }
-
- public void beginRecording(Object requester, String label, String description, int cursorPosition, int selectionLength) {
- beginRecording(requester, label, description);
-
- fUndoCursorPosition = cursorPosition;
- fUndoSelectionLength = selectionLength;
- }
-
- void checkRequester(Object requester) {
- if (fRequester != null && !fRequester.equals(requester)) {
- // Force restart of recording so the last compound command is
- // closed.
- //
- // However, we should not force restart of recording when the
- // request came from StructuredDocumentToTextAdapter or
- // XMLModelImpl
- // because cut/paste requests and character inserts to the
- // textViewer are from StructuredDocumentToTextAdapter,
- // and requests to delete a node in the XMLTableTreeViewer are
- // from XMLModelImpl (which implements IStructuredModel).
-
- if (!(requester instanceof IStructuredModel || requester instanceof IStructuredDocument)) {
- resetInternalCommands();
- }
- }
- }
-
-
-
- public void connect(IDocumentSelectionMediator mediator) {
- Assert.isNotNull(mediator);
- if (fDocument == null) {
- // add this undo manager as structured document listener
- fDocument = mediator.getDocument();
- // future_TODO: eventually we want to refactor or allow either
- // type of document, but for now, we'll do instanceof check, and
- // fail
- // if not right type
- if (fDocument instanceof IStructuredDocument) {
- ((IStructuredDocument) fDocument).addDocumentChangedListener(getInternalStructuredDocumentListener());
- } else {
- throw new IllegalArgumentException("only meditator with structured documents currently handled"); //$NON-NLS-1$
- }
- } else {
- // if we've already had our document set, we'll just do this fail
- // fast integrity check
- if (!fDocument.equals(mediator.getDocument()))
- throw new IllegalStateException("Connection to undo manager failed. Document for document selection mediator inconistent with undo manager."); //$NON-NLS-1$
- }
-
- addDocumentSelectionMediator(mediator);
- }
-
- void createNewTextCommand(String textDeleted, String textInserted, int textStart, int textEnd) {
- StructuredTextCommandImpl textCommand = new StructuredTextCommandImpl(fDocument);
- textCommand.setLabel(TEXT_CHANGE_TEXT);
- textCommand.setDescription(TEXT_CHANGE_TEXT);
- textCommand.setTextStart(textStart);
- textCommand.setTextEnd(textEnd);
- textCommand.setTextDeleted(textDeleted);
- textCommand.setTextInserted(textInserted);
-
- if (fRecording) {
- if (fCompoundCommand == null) {
- StructuredTextCompoundCommandImpl compoundCommand = new StructuredTextCompoundCommandImpl();
- compoundCommand.setUndoCursorPosition(fUndoCursorPosition);
- compoundCommand.setUndoSelectionLength(fUndoSelectionLength);
-
- compoundCommand.setLabel(fCompoundCommandLabel);
- compoundCommand.setDescription(fCompoundCommandDescription);
- compoundCommand.append(textCommand);
- fCommandStack.execute(compoundCommand);
-
- fCompoundCommand = compoundCommand;
- } else {
- fCompoundCommand.append(textCommand);
- }
- } else {
- fCommandStack.execute(textCommand);
- }
-
- fTextCommand = textCommand;
- }
-
- /**
- * Disable undo management.
- */
- public void disableUndoManagement() {
- fUndoManagementEnabled = false;
- }
-
- public void disconnect(IDocumentSelectionMediator mediator) {
- removeDocumentSelectionMediator(mediator);
-
- if (fMediators != null && fMediators.length == 0 && fDocument != null) {
- // remove this undo manager as structured document listener
- // future_TODO: eventually we want to refactor or allow either
- // type of document, but for now, we'll do instanceof check, and
- // fail
- // if not right type
- if (fDocument instanceof IStructuredDocument) {
- ((IStructuredDocument) fDocument).removeDocumentChangedListener(getInternalStructuredDocumentListener());
- } else {
- throw new IllegalArgumentException("only meditator with structured documents currently handled"); //$NON-NLS-1$
- }
- // if no longer listening to document, then dont even track it
- // anymore
- // (this allows connect to reconnect to document again)
- fDocument = null;
- }
- }
-
- public void enableUndoManagement() {
- fUndoManagementEnabled = true;
- }
-
- public void endRecording(Object requester) {
- int cursorPosition = (fTextCommand != null) ? fTextCommand.getTextEnd() : -1;
- int selectionLength = 0;
-
- endRecording(requester, cursorPosition, selectionLength);
- }
-
- public void endRecording(Object requester, int cursorPosition, int selectionLength) {
- // Recording could be stopped by forceEndOfPendingCommand(). Make sure
- // we are still recording before proceeding, or else fRecordingCount
- // may not be balanced.
- if (fRecording) {
- if (fCompoundCommand != null) {
- fCompoundCommand.setRedoCursorPosition(cursorPosition);
- fCompoundCommand.setRedoSelectionLength(selectionLength);
- }
-
- // end recording is a logical stopping point for text command,
- // even when fRecordingCount > 0 (in nested beginRecording)
- fTextCommand = null;
-
- // update counter and flag
- if (fRecordingCount > 0)
- fRecordingCount--;
- if (fRecordingCount == 0) {
- fRecording = false;
-
- // reset compound command only when fRecordingCount ==
- // 0
- fCompoundCommand = null;
- fCompoundCommandLabel = null;
- fCompoundCommandDescription = null;
-
- // Also reset fRequester
- fRequester = null;
- }
- }
- }
-
- /**
- * Utility method to find model given document
- */
- private IStructuredModel findStructuredModel(IDocument document) {
- IModelManager modelManager = StructuredModelManager.getModelManager();
- IStructuredModel structuredModel = modelManager.getExistingModelForRead(document);
- return structuredModel;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.wst.sse.core.undo.IStructuredTextUndoManager#forceEndOfPendingCommand(java.lang.Object,
- * int, int)
- */
- public void forceEndOfPendingCommand(Object requester, int currentPosition, int length) {
- if (fRecording)
- endRecording(requester, currentPosition, length);
- else
- resetInternalCommands();
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.wst.sse.core.undo.IStructuredTextUndoManager#getCommandStack()
- */
- public CommandStack getCommandStack() {
- return fCommandStack;
- }
-
- /**
- * @return
- */
- private CommandStackListener getInternalCommandStackListener() {
- if (fInternalCommandStackListener == null) {
- fInternalCommandStackListener = new InternalCommandStackListener();
- }
- return fInternalCommandStackListener;
- }
-
- /**
- * @return
- */
- private IStructuredDocumentListener getInternalStructuredDocumentListener() {
- if (fInternalStructuredDocumentListener == null) {
- fInternalStructuredDocumentListener = new InternalStructuredDocumentListener();
- }
- return fInternalStructuredDocumentListener;
- }
-
- public Command getRedoCommand() {
- return fCommandStack.getRedoCommand();
- }
-
- public Command getUndoCommand() {
- return fCommandStack.getUndoCommand();
- }
-
- public void redo() {
- redo(null);
- }
-
- public void redo(IDocumentSelectionMediator requester) {
- IStructuredModel model = findStructuredModel(fDocument);
- if (redoable()) {
- try {
- if (model != null)
- model.aboutToChangeModel();
-
- Command redoCommand = getRedoCommand();
-
- // make sure to redo before setting document selection
- fCommandStack.redo();
-
- // set document selection
- setRedoDocumentSelection(requester, redoCommand);
- } finally {
- if (model != null) {
- model.changedModel();
- model.releaseFromRead();
- }
- }
- }
- }
-
- public boolean redoable() {
- return fCommandStack.canRedo();
- }
-
- private void removeDocumentSelectionMediator(IDocumentSelectionMediator mediator) {
- if (fMediators != null && mediator != null) {
- // if its not in the array, we'll ignore the request
- if (Utilities.contains(fMediators, mediator)) {
- int oldSize = fMediators.length;
- int newSize = oldSize - 1;
- IDocumentSelectionMediator[] newMediators = new IDocumentSelectionMediator[newSize];
- int index = 0;
- for (int i = 0; i < oldSize; i++) {
- if (fMediators[i] == mediator) { // ignore
- } else {
- // copy old to new if its not the one we are removing
- newMediators[index++] = fMediators[i];
- }
- }
- // now that we have a new array, let's switch it for the old
- // one
- fMediators = newMediators;
- }
- }
- }
-
- void resetInternalCommands() {
- // Either the requester of the structured document change event is
- // changed, or the command stack is changed. Need to reset internal
- // commands so we won't continue to append changes.
- fCompoundCommand = null;
- fTextCommand = null;
-
- // Also reset fRequester
- fRequester = null;
- }
-
- public void setCommandStack(CommandStack commandStack) {
- if (fCommandStack != null)
- fCommandStack.removeCommandStackListener(getInternalCommandStackListener());
-
- fCommandStack = commandStack;
-
- if (fCommandStack != null)
- fCommandStack.addCommandStackListener(getInternalCommandStackListener());
- }
-
- private void setRedoDocumentSelection(IDocumentSelectionMediator requester, Command command) {
- int cursorPosition = -1;
- int selectionLength = 0;
-
- if (command instanceof CommandCursorPosition) {
- CommandCursorPosition commandCursorPosition = (CommandCursorPosition) command;
- cursorPosition = commandCursorPosition.getRedoCursorPosition();
- selectionLength = commandCursorPosition.getRedoSelectionLength();
- } else if (command instanceof StructuredTextCommand) {
- StructuredTextCommand structuredTextCommand = (StructuredTextCommand) command;
- cursorPosition = structuredTextCommand.getTextStart();
- selectionLength = structuredTextCommand.getTextInserted().length();
- }
-
- if (cursorPosition > -1 && fMediators != null && fMediators.length > 0) {
- for (int i = 0; i < fMediators.length; i++) {
- IDocument document = fMediators[i].getDocument();
- fMediators[i].undoOperationSelectionChanged(new UndoDocumentEvent(requester, document, cursorPosition, selectionLength));
- }
- }
- }
-
- private void setUndoDocumentSelection(IDocumentSelectionMediator requester, Command command) {
- int cursorPosition = -1;
- int selectionLength = 0;
-
- if (command instanceof CommandCursorPosition) {
- CommandCursorPosition commandCursorPosition = (CommandCursorPosition) command;
- cursorPosition = commandCursorPosition.getUndoCursorPosition();
- selectionLength = commandCursorPosition.getUndoSelectionLength();
- } else if (command instanceof StructuredTextCommand) {
- StructuredTextCommand structuredTextCommand = (StructuredTextCommand) command;
- cursorPosition = structuredTextCommand.getTextStart();
- selectionLength = structuredTextCommand.getTextDeleted().length();
- }
-
- if (cursorPosition > -1 && fMediators != null && fMediators.length > 0) {
- for (int i = 0; i < fMediators.length; i++) {
- IDocument document = fMediators[i].getDocument();
- fMediators[i].undoOperationSelectionChanged(new UndoDocumentEvent(requester, document, cursorPosition, selectionLength));
- }
- }
- }
-
- public void undo() {
- undo(null);
- }
-
- public void undo(IDocumentSelectionMediator requester) {
- // Force an endRecording before undo.
- //
- // For example, recording was turned on on the Design Page of
- // PageDesigner.
- // Then undo is invoked on the Source Page. Recording should be
- // stopped before we undo.
- // Note that redo should not be available when we switch to the Source
- // Page.
- // Therefore, this force ending of recording is not needed in redo.
- if (fRecording)
- endRecording(this);
-
- if (undoable()) {
- IStructuredModel model = findStructuredModel(fDocument);
- try {
- if (model != null)
- model.aboutToChangeModel();
-
- Command undoCommand = getUndoCommand();
-
- // make sure to undo before setting document selection
- fCommandStack.undo();
-
- // set document selection
- setUndoDocumentSelection(requester, undoCommand);
- } finally {
- if (model != null) {
- model.changedModel();
- model.releaseFromRead();
- }
- }
- }
- }
-
- public boolean undoable() {
- return fCommandStack.canUndo();
- }
-}
diff --git a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/modelhandler/AbstractModelHandler.java b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/modelhandler/AbstractModelHandler.java
deleted file mode 100644
index b5faa21c10..0000000000
--- a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/modelhandler/AbstractModelHandler.java
+++ /dev/null
@@ -1,72 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Jens Lukowski/Innoopract - initial renaming/restructuring
- *
- *******************************************************************************/
-package org.eclipse.wst.sse.core.modelhandler;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.List;
-
-import org.eclipse.wst.sse.core.document.IDocumentCharsetDetector;
-import org.eclipse.wst.sse.core.internal.modelhandler.PluginContributedFactoryReader;
-
-
-public abstract class AbstractModelHandler implements IModelHandler {
- private String associatedContentTypeId;
- private boolean defaultSetting;
- private String modelHandlerID;
-
- // XXX: can be removed once we transition completely
- protected boolean USE_FILE_BUFFERS = false;
-
- public AbstractModelHandler() {
- super();
- }
-
- /**
- * These factories are added automatically by model manager
- */
- public List getAdapterFactories() {
- List result = new ArrayList();
- Collection holdFactories = PluginContributedFactoryReader.getInstance().getFactories(this);
- if (holdFactories != null) {
- result.addAll(holdFactories);
- }
- return result;
- }
-
- public String getAssociatedContentTypeId() {
- return associatedContentTypeId;
- }
-
- public abstract IDocumentCharsetDetector getEncodingDetector();
-
- public String getId() {
- return modelHandlerID;
- }
-
- public boolean isDefault() {
- return defaultSetting;
- }
-
- protected void setAssociatedContentTypeId(String contentTypeId) {
- associatedContentTypeId = contentTypeId;
- }
-
- public void setDefault(boolean defaultParam) {
- defaultSetting = defaultParam;
- }
-
- protected void setId(String id) {
- modelHandlerID = id;
- }
-}
diff --git a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/modelhandler/EmbeddedTypeHandler.java b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/modelhandler/EmbeddedTypeHandler.java
deleted file mode 100644
index a71c586269..0000000000
--- a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/modelhandler/EmbeddedTypeHandler.java
+++ /dev/null
@@ -1,63 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Jens Lukowski/Innoopract - initial renaming/restructuring
- *
- *******************************************************************************/
-package org.eclipse.wst.sse.core.modelhandler;
-
-import java.util.List;
-
-import org.eclipse.wst.sse.core.IFactoryRegistry;
-import org.eclipse.wst.sse.core.parser.JSPCapableParser;
-
-
-/**
- */
-public interface EmbeddedTypeHandler {
-
- /**
- * These AdapterFactories are NOT added to IStructuredModel's
- * AdapterFactory Registry ... they are for use by "JSP Aware
- * AdapterFactories" The are added to the "registry" in the
- * PageDirectiveAdapter.
- */
- List getAdapterFactories();
-
- /**
- * Returns the unique identifier for the content type family this
- * ContentTypeDescription belongs to.
- */
- public String getFamilyId();
-
- /**
- * Returns a list of mime tyeps (as Strings) this handler is appropriate
- * for
- */
- List getSupportedMimeTypes();
-
- /**
- * This method is to give the EmbeddedContentType an opportunity to add
- * factories directly to the IStructuredModel's AdapterFactory registry.
- */
- void initializeFactoryRegistry(IFactoryRegistry registry);
-
- /**
- * initializeParser Its purpose is to setBlockTags
- */
- void initializeParser(JSPCapableParser parser);
-
- boolean isDefault();
-
- public EmbeddedTypeHandler newInstance();
-
- void uninitializeFactoryRegistry(IFactoryRegistry registry);
-
- void uninitializeParser(JSPCapableParser parser);
-}
diff --git a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/modelhandler/IDocumentTypeHandler.java b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/modelhandler/IDocumentTypeHandler.java
deleted file mode 100644
index 9958966a6c..0000000000
--- a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/modelhandler/IDocumentTypeHandler.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Jens Lukowski/Innoopract - initial renaming/restructuring
- *
- *******************************************************************************/
-package org.eclipse.wst.sse.core.modelhandler;
-
-import org.eclipse.wst.sse.core.document.IDocumentCharsetDetector;
-import org.eclipse.wst.sse.core.document.IDocumentLoader;
-
-/**
- * Interface to allow custom content types to be defined as extension points
- * in plugins.
- */
-public interface IDocumentTypeHandler {
-
- /**
- * The Loader is reponsible for decoding the Resource,
- */
- IDocumentLoader getDocumentLoader();
-
- /**
- * @deprecated - likely to go away, so I marked as deprecated to
- * discoursage use
- */
- IDocumentCharsetDetector getEncodingDetector();
-
- /**
- * Must return unique ID that is the same as identified in plugin registry
- */
- String getId();
-
-
-
-}
diff --git a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/modelhandler/IModelHandler.java b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/modelhandler/IModelHandler.java
deleted file mode 100644
index 0b41cae826..0000000000
--- a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/modelhandler/IModelHandler.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Jens Lukowski/Innoopract - initial renaming/restructuring
- *
- *******************************************************************************/
-package org.eclipse.wst.sse.core.modelhandler;
-
-import java.util.List;
-
-import org.eclipse.wst.sse.core.ModelLoader;
-
-
-public interface IModelHandler extends IDocumentTypeHandler {
- /**
- * This method should return Factories which are added automatically by
- * IModelManager. This can and will often be an empty List (or null),
- * since some AdapterFactories must be added by Loader directly, and most
- * should be added by Editors. FormatAdapterFactory is an example of one
- * that can be returned here, since the timing of adding it is not
- * critical, but it may be needed even when an editor is not being used.
- */
- List getAdapterFactories();
-
- /**
- * Returns the ID for the associated ContentTypeHandler But is needed for
- * now.
- */
- String getAssociatedContentTypeId();
-
- /**
- * The Loader is reponsible for decoding the Resource,
- */
- ModelLoader getModelLoader();
-
- boolean isDefault();
-}
diff --git a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/modelquery/ModelQueryAdapter.java b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/modelquery/ModelQueryAdapter.java
deleted file mode 100644
index 76339f275c..0000000000
--- a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/modelquery/ModelQueryAdapter.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Jens Lukowski/Innoopract - initial renaming/restructuring
- *
- *******************************************************************************/
-package org.eclipse.wst.sse.core.modelquery;
-
-import org.eclipse.wst.common.contentmodel.modelquery.ModelQuery;
-import org.eclipse.wst.common.contentmodel.util.CMDocumentCache;
-import org.eclipse.wst.sse.core.INodeAdapter;
-import org.eclipse.wst.xml.uriresolver.util.IdResolver;
-
-
-public interface ModelQueryAdapter extends INodeAdapter {
-
- public CMDocumentCache getCMDocumentCache();
-
- public IdResolver getIdResolver();
-
- public ModelQuery getModelQuery();
-
- void release();
-
- void setIdResolver(IdResolver newIdResolver);
-}
diff --git a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/modelquery/ModelQueryAdapterImpl.java b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/modelquery/ModelQueryAdapterImpl.java
deleted file mode 100644
index d42c55974a..0000000000
--- a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/modelquery/ModelQueryAdapterImpl.java
+++ /dev/null
@@ -1,76 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Jens Lukowski/Innoopract - initial renaming/restructuring
- *
- *******************************************************************************/
-package org.eclipse.wst.sse.core.modelquery;
-
-
-
-import org.eclipse.wst.common.contentmodel.modelquery.ModelQuery;
-import org.eclipse.wst.common.contentmodel.util.CMDocumentCache;
-import org.eclipse.wst.sse.core.INodeNotifier;
-import org.eclipse.wst.xml.uriresolver.util.IdResolver;
-
-
-public class ModelQueryAdapterImpl implements ModelQueryAdapter {
- protected CMDocumentCache cmDocumentCache;
- protected IdResolver idResolver;
-
- protected ModelQuery modelQuery;
-
- public ModelQueryAdapterImpl(CMDocumentCache cmDocumentCache, ModelQuery modelQuery, IdResolver idResolver) {
- this.cmDocumentCache = cmDocumentCache;
- this.modelQuery = modelQuery;
- this.idResolver = idResolver;
- }
-
- public CMDocumentCache getCMDocumentCache() {
- return cmDocumentCache;
- }
-
- public IdResolver getIdResolver() {
- return idResolver;
- }
-
- public ModelQuery getModelQuery() {
- return modelQuery;
- }
-
- /**
- * Allowing the INodeAdapter to compare itself against the type allows it
- * to return true in more than one case.
- */
- public boolean isAdapterForType(Object type) {
- return type.equals(ModelQueryAdapter.class);
- }
-
- /**
- */
-
- public void notifyChanged(INodeNotifier notifier, int eventType, Object changedFeature, Object oldValue, Object newValue, int pos) {
- }
-
- /**
- * @see ModelQueryAdapter#release()
- */
- public void release() {
- }
-
- /**
- * @see ModelQueryAdapter#setIdResolver(IdResolver)
- */
-
- public void setIdResolver(IdResolver newIdResolver) {
- idResolver = newIdResolver;
- if (modelQuery instanceof MovableModelQuery)
- ((MovableModelQuery) modelQuery).setIdResolver(newIdResolver);
- }
-}
diff --git a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/modelquery/MovableModelQuery.java b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/modelquery/MovableModelQuery.java
deleted file mode 100644
index c713c5eed6..0000000000
--- a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/modelquery/MovableModelQuery.java
+++ /dev/null
@@ -1,23 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Jens Lukowski/Innoopract - initial renaming/restructuring
- *
- *******************************************************************************/
-package org.eclipse.wst.sse.core.modelquery;
-
-
-
-import org.eclipse.wst.common.contentmodel.modelquery.ModelQuery;
-import org.eclipse.wst.xml.uriresolver.util.IdResolver;
-
-public interface MovableModelQuery extends ModelQuery {
-
- void setIdResolver(IdResolver newIdResolver);
-}
diff --git a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/parser/BlockMarker.java b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/parser/BlockMarker.java
deleted file mode 100644
index e63adbfa10..0000000000
--- a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/parser/BlockMarker.java
+++ /dev/null
@@ -1,107 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Jens Lukowski/Innoopract - initial renaming/restructuring
- *
- *******************************************************************************/
-package org.eclipse.wst.sse.core.parser;
-
-
-
-import org.eclipse.wst.sse.core.text.ITextRegion;
-
-public class BlockMarker extends TagMarker {
-
- // allow for JSP expressions within the block
- protected boolean fAllowJSP = true;
-
- protected boolean fCaseSensitive = false;
-
- // the context for the contents of this tag (BLOCK_TEXT, JSP_CONTENT,
- // etc.)
- protected String fContext;
-
- /**
- * It's not appropriate to make "empty" BlockMarker, so we'll mark as
- * private.
- */
- private BlockMarker() {
- super();
- }
-
- public BlockMarker(String tagName, ITextRegion marker, String context) {
- this(tagName, marker, context, true);
- }
-
- public BlockMarker(String tagName, ITextRegion marker, String context, boolean caseSensitive) {
- this(tagName, marker, context, caseSensitive, true);
- }
-
- public BlockMarker(String tagName, ITextRegion marker, String context, boolean caseSensitive, boolean allowJSP) {
- super(tagName, marker);
- setContext(context);
- setCaseSensitive(caseSensitive);
- setAllowJSP(allowJSP);
- }
-
- public BlockMarker(String tagName, String regionContext, boolean caseSensitive) {
- this(tagName, null, regionContext, caseSensitive, false);
- }
-
- /**
- * Gets the allowJSP.
- *
- * @return Returns a boolean
- */
- public boolean allowsJSP() {
- return fAllowJSP;
- }
-
- /**
- * Gets the context.
- *
- * @return Returns a String
- */
- public String getContext() {
- return fContext;
- }
-
- /**
- *
- * @return boolean
- */
- public final boolean isCaseSensitive() {
- return fCaseSensitive;
- }
-
- /**
- * Sets the allowJSP.
- *
- * @param allowJSP
- * The allowJSP to set
- */
- public void setAllowJSP(boolean allowJSP) {
- fAllowJSP = allowJSP;
- }
-
- public final void setCaseSensitive(boolean sensitive) {
- fCaseSensitive = sensitive;
- }
-
- /**
- * Sets the context.
- *
- * @param context
- * The context to set
- */
- public void setContext(String context) {
- fContext = context;
- }
-
-}
diff --git a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/parser/BlockTagParser.java b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/parser/BlockTagParser.java
deleted file mode 100644
index 205323fff5..0000000000
--- a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/parser/BlockTagParser.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Jens Lukowski/Innoopract - initial renaming/restructuring
- *
- *******************************************************************************/
-package org.eclipse.wst.sse.core.parser;
-
-
-
-import java.util.List;
-
-public interface BlockTagParser {
-
- void addBlockMarker(BlockMarker marker);
-
- void beginBlockScan(String tagName);
-
- BlockMarker getBlockMarker(String tagName);
-
- List getBlockMarkers();
-
- void removeBlockMarker(BlockMarker marker);
-
- void removeBlockMarker(String tagName);
-}
diff --git a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/parser/BlockTokenizer.java b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/parser/BlockTokenizer.java
deleted file mode 100644
index 048f9fe5c6..0000000000
--- a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/parser/BlockTokenizer.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Jens Lukowski/Innoopract - initial renaming/restructuring
- *
- *******************************************************************************/
-package org.eclipse.wst.sse.core.parser;
-
-
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.Reader;
-import java.util.List;
-
-import org.eclipse.wst.sse.core.text.ITextRegion;
-
-
-public interface BlockTokenizer {
-
- void addBlockMarker(BlockMarker marker);
-
- void beginBlockMarkerScan(String newTagName, String context);
-
- void beginBlockTagScan(String newTagName);
-
- List getBlockMarkers();
-
- ITextRegion getNextToken() throws IOException;
-
- int getOffset();
-
- boolean isEOF();
-
- BlockTokenizer newInstance();
-
- void removeBlockMarker(BlockMarker marker);
-
- void removeBlockMarker(String tagname);
-
- void reset(char[] charArray);
-
- void reset(char[] charArray, int newOffset);
-
- void reset(InputStream in);
-
- void reset(InputStream in, int newOffset);
-
- void reset(Reader in);
-
- void reset(Reader in, int newOffset);
-}
diff --git a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/parser/IBlockedStructuredDocumentRegion.java b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/parser/IBlockedStructuredDocumentRegion.java
deleted file mode 100644
index df2bc6e254..0000000000
--- a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/parser/IBlockedStructuredDocumentRegion.java
+++ /dev/null
@@ -1,24 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Jens Lukowski/Innoopract - initial renaming/restructuring
- *
- *******************************************************************************/
-package org.eclipse.wst.sse.core.parser;
-
-import org.eclipse.wst.sse.core.text.IStructuredDocumentRegion;
-
-/**
- *
- */
-public interface IBlockedStructuredDocumentRegion extends IStructuredDocumentRegion {
- String getPartitionType();
-
- void setPartitionType(String partitionType);
-}
diff --git a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/parser/JSPCapableParser.java b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/parser/JSPCapableParser.java
deleted file mode 100644
index 048394fe6e..0000000000
--- a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/parser/JSPCapableParser.java
+++ /dev/null
@@ -1,28 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Jens Lukowski/Innoopract - initial renaming/restructuring
- *
- *******************************************************************************/
-package org.eclipse.wst.sse.core.parser;
-
-import java.util.List;
-
-public interface JSPCapableParser extends RegionParser, BlockTagParser {
- void addNestablePrefix(TagMarker marker);
-
- /**
- * returns the TagMarkers for prefixes that are allowed to be nestable
- *
- * @return
- */
- List getNestablePrefixes();
-
- void removeNestablePrefix(String tagName);
-}
diff --git a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/parser/RegionParser.java b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/parser/RegionParser.java
deleted file mode 100644
index 935fba19cf..0000000000
--- a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/parser/RegionParser.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Jens Lukowski/Innoopract - initial renaming/restructuring
- *
- *******************************************************************************/
-package org.eclipse.wst.sse.core.parser;
-
-
-
-import java.io.Reader;
-import java.util.List;
-
-import org.eclipse.wst.sse.core.text.IStructuredDocumentRegion;
-
-
-public interface RegionParser {
-
- IStructuredDocumentRegion getDocumentRegions();
-
- List getRegions();
-
- /**
- * The 'newInstance' method is similar to 'clone', but does not include
- * the copying of any content. For a pure RegionParser itself, there would
- * be little state to "clone", but for some subtypes, such as
- * StructuredDocumentRegionParser and JSPCapableParser, there could the
- * more internal data to "clone", such as the internal tokenizer should be
- * cloned (including block tags, etc).
- */
- RegionParser newInstance();
-
- void reset(Reader reader);
-
- /**
- * An additional offset for use with any position-dependant parsing rules
- */
- void reset(Reader reader, int offset);
-
- void reset(String input);
-
- /**
- * An additional offset for use with any position-dependant parsing rules
- */
- void reset(String input, int offset);
-}
diff --git a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/parser/StructuredDocumentRegionHandler.java b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/parser/StructuredDocumentRegionHandler.java
deleted file mode 100644
index b9f098ce84..0000000000
--- a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/parser/StructuredDocumentRegionHandler.java
+++ /dev/null
@@ -1,28 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Jens Lukowski/Innoopract - initial renaming/restructuring
- *
- *******************************************************************************/
-package org.eclipse.wst.sse.core.parser;
-
-
-
-import org.eclipse.wst.sse.core.text.IStructuredDocumentRegion;
-
-public interface StructuredDocumentRegionHandler {
-
- // Sent when a IStructuredDocumentRegion is first parsed
- public void nodeParsed(IStructuredDocumentRegion aCoreStructuredDocumentRegion);
-
- // Sent when the calling parser's model undergoes a full reset
- // and any information based upon the old model should be
- // cleared
- public void resetNodes();
-}
diff --git a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/parser/StructuredDocumentRegionHandlerExtension.java b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/parser/StructuredDocumentRegionHandlerExtension.java
deleted file mode 100644
index 0e6b9bb423..0000000000
--- a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/parser/StructuredDocumentRegionHandlerExtension.java
+++ /dev/null
@@ -1,20 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Jens Lukowski/Innoopract - initial renaming/restructuring
- *
- *******************************************************************************/
-package org.eclipse.wst.sse.core.parser;
-
-import org.eclipse.wst.sse.core.text.IStructuredDocument;
-
-
-public interface StructuredDocumentRegionHandlerExtension extends StructuredDocumentRegionHandler {
- void setStructuredDocument(IStructuredDocument newDocument);
-}
diff --git a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/parser/StructuredDocumentRegionParser.java b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/parser/StructuredDocumentRegionParser.java
deleted file mode 100644
index d8e280d37d..0000000000
--- a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/parser/StructuredDocumentRegionParser.java
+++ /dev/null
@@ -1,24 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Jens Lukowski/Innoopract - initial renaming/restructuring
- *
- *******************************************************************************/
-package org.eclipse.wst.sse.core.parser;
-
-
-
-public interface StructuredDocumentRegionParser extends RegionParser {
-
- void addStructuredDocumentRegionHandler(StructuredDocumentRegionHandler handler);
-
- void removeStructuredDocumentRegionHandler(StructuredDocumentRegionHandler handler);
-
- void resetHandlers();
-}
diff --git a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/parser/StructuredDocumentRegionParserExtension.java b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/parser/StructuredDocumentRegionParserExtension.java
deleted file mode 100644
index 561b64d061..0000000000
--- a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/parser/StructuredDocumentRegionParserExtension.java
+++ /dev/null
@@ -1,28 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Jens Lukowski/Innoopract - initial renaming/restructuring
- *
- *******************************************************************************/
-package org.eclipse.wst.sse.core.parser;
-
-import java.util.List;
-
-
-
-public interface StructuredDocumentRegionParserExtension extends StructuredDocumentRegionParser {
- /**
- * Returns the current list of StructuredDocumentRegionHandlers listening
- * to this parser.
- *
- * @return List - the list of listeners, the list may not be null and each
- * element in it must implement StructuredDocumentRegionHandler
- */
- List getStructuredDocumentRegionHandlers();
-}
diff --git a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/parser/TagMarker.java b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/parser/TagMarker.java
deleted file mode 100644
index f5dca4f39d..0000000000
--- a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/parser/TagMarker.java
+++ /dev/null
@@ -1,80 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Jens Lukowski/Innoopract - initial renaming/restructuring
- *
- *******************************************************************************/
-package org.eclipse.wst.sse.core.parser;
-
-import org.eclipse.wst.sse.core.text.ITextRegion;
-
-public class TagMarker {
-
- // a ITextRegion (meant to be updated with the model) marking the position
- // where this tagname becomes effective
- protected ITextRegion fMarker = null;
-
- // the tagname
- protected String fTagName = null;
-
- /**
- *
- */
- public TagMarker() {
- super();
- }
-
- public TagMarker(String tagname) {
- super();
- setTagName(tagname);
- }
-
- public TagMarker(String tagname, ITextRegion marker) {
- super();
- setTagName(tagname);
- setMarker(marker);
- }
-
- /**
- * @return com.ibm.sed.structuredDocument.ITextRegion
- */
- public final ITextRegion getMarker() {
- return fMarker;
- }
-
- /**
- * @return java.lang.String
- */
- public final String getTagName() {
- return fTagName;
- }
-
- /**
- * @return boolean
- */
- public boolean isGlobal() {
- return fMarker == null;
- }
-
- /**
- * @param newMarker
- * com.ibm.sed.structuredDocument.ITextRegion
- */
- public final void setMarker(ITextRegion newMarker) {
- fMarker = newMarker;
- }
-
- /**
- * @param newTagname
- * java.lang.String
- */
- public final void setTagName(String newTagName) {
- fTagName = newTagName;
- }
-}
diff --git a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/participants/AbstractBuilderParticipant.java b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/participants/AbstractBuilderParticipant.java
deleted file mode 100644
index e6c68ed16e..0000000000
--- a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/participants/AbstractBuilderParticipant.java
+++ /dev/null
@@ -1,183 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Jens Lukowski/Innoopract - initial renaming/restructuring
- *
- *******************************************************************************/
-package org.eclipse.wst.sse.core.participants;
-
-import java.util.Map;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.resources.IResourceDelta;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.wst.sse.core.builder.IBuilderModelProvider;
-import org.eclipse.wst.sse.core.builder.IBuilderParticipant;
-import org.eclipse.wst.sse.core.text.IStructuredDocument;
-import org.eclipse.wst.sse.core.text.IStructuredDocumentRegion;
-import org.eclipse.wst.sse.core.text.ITextRegion;
-import org.eclipse.wst.sse.core.text.ITextRegionList;
-
-
-/**
- * Publically usable implementor of IBuilderParticipant. Includes pre- and
- * post-build hooks and iteration through the Structured Document
- */
-
-public class AbstractBuilderParticipant implements IBuilderParticipant {
-
- private IFile fCurrentFile;
- private IBuilderModelProvider fModelProvider;
-
- public AbstractBuilderParticipant() {
- super();
- }
-
- protected boolean build(IFile file, IProject project, IBuilderModelProvider provider, IProgressMonitor monitor) {
- preBuild(file, provider, monitor);
- if (getCurrentFile().isAccessible() && !monitor.isCanceled()) {
- IStructuredDocument document = provider.getDocument(getCurrentFile());
- if (document != null) {
- IStructuredDocumentRegion region = document.getFirstStructuredDocumentRegion();
- while (region != null && !monitor.isCanceled()) {
- build(region);
- region = region.getNext();
- }
- }
- }
- postBuild(file, provider, monitor);
- return false;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.wst.sse.core.builder.IBuilderParticipant#build(org.eclipse.core.resources.IResource[],
- * org.eclipse.core.resources.IProject,
- * org.eclipse.wst.sse.core.builder.IBuilderModelProvider,
- * org.eclipse.core.runtime.IProgressMonitor)
- */
- public boolean build(IResource[] resources, IProject project, IBuilderModelProvider provider, IProgressMonitor monitor) {
- for (int i = 0; i < resources.length; i++) {
- if (!monitor.isCanceled()) {
- build((IFile) resources[i], project, provider, monitor);
- }
- }
- return false;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.wst.sse.core.builder.IBuilderParticipant#build(org.eclipse.core.resources.IResourceDelta,
- * org.eclipse.core.resources.IProject,
- * org.eclipse.wst.sse.core.builder.IBuilderModelProvider,
- * org.eclipse.core.runtime.IProgressMonitor)
- */
- public boolean build(IResourceDelta delta, IProject project, IBuilderModelProvider provider, IProgressMonitor monitor) {
- return build((IFile) delta.getResource(), project, provider, monitor);
- }
-
- protected void build(IStructuredDocumentRegion region) {
- doBuildFor(region);
- ITextRegionList list = region.getRegions();
- for (int i = 0; i < list.size(); i++) {
- doBuildFor(region, list.get(i));
- }
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.wst.sse.core.builder.IBuilderParticipant#cleanup(org.eclipse.core.resources.IResource[],
- * org.eclipse.core.resources.IProject,
- * org.eclipse.wst.sse.core.builder.IBuilderModelProvider,
- * org.eclipse.core.runtime.IProgressMonitor)
- */
- public boolean cleanup(IResource[] resources, IProject project, IBuilderModelProvider provider, IProgressMonitor monitor) {
- return false;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.wst.sse.core.builder.IBuilderParticipant#cleanup(org.eclipse.core.resources.IResourceDelta,
- * org.eclipse.core.resources.IProject,
- * org.eclipse.wst.sse.core.builder.IBuilderModelProvider,
- * org.eclipse.core.runtime.IProgressMonitor)
- */
- public boolean cleanup(IResourceDelta delta, IProject project, IBuilderModelProvider provider, IProgressMonitor monitor) {
- return false;
- }
-
- protected void doBuildFor(IStructuredDocumentRegion region) {
- }
-
- protected void doBuildFor(IStructuredDocumentRegion region, ITextRegion textRegion) {
- }
-
- /**
- * @return Returns the currentFile.
- */
- public IFile getCurrentFile() {
- return fCurrentFile;
- }
-
- /**
- * @return Returns the modelProvider.
- */
- public IBuilderModelProvider getModelProvider() {
- return fModelProvider;
- }
-
- protected void postBuild(IFile file, IBuilderModelProvider provider, IProgressMonitor monitor) {
- setCurrentFile(null);
- setModelProvider(null);
- }
-
- protected void preBuild(IFile file, IBuilderModelProvider provider, IProgressMonitor monitor) {
- setCurrentFile(file);
- setModelProvider(provider);
- }
-
- /**
- * @param currentFile
- * The currentFile to set.
- */
- protected void setCurrentFile(IFile currentFile) {
- fCurrentFile = currentFile;
- }
-
- /**
- * @param modelProvider
- * The modelProvider to set.
- */
- protected void setModelProvider(IBuilderModelProvider modelProvider) {
- fModelProvider = modelProvider;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.wst.sse.core.builder.IBuilderParticipant#shutdown(org.eclipse.core.resources.IProject)
- */
- public void shutdown(IProject project) {
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.wst.sse.core.builder.IBuilderParticipant#startup(org.eclipse.core.resources.IProject,
- * int, java.util.Map)
- */
- public void startup(IProject project, int kind, Map args) {
- }
-}
diff --git a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/participants/TaskTagSeeker.java b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/participants/TaskTagSeeker.java
deleted file mode 100644
index 2b2fe5de7e..0000000000
--- a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/participants/TaskTagSeeker.java
+++ /dev/null
@@ -1,468 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Jens Lukowski/Innoopract - initial renaming/restructuring
- *
- *******************************************************************************/
-package org.eclipse.wst.sse.core.participants;
-
-import java.io.BufferedReader;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.io.Reader;
-import java.nio.charset.CharacterCodingException;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.StringTokenizer;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IMarker;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.resources.IWorkspace;
-import org.eclipse.core.resources.IWorkspaceRunnable;
-import org.eclipse.core.resources.IncrementalProjectBuilder;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.core.runtime.QualifiedName;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.core.runtime.content.IContentDescription;
-import org.eclipse.jface.text.BadLocationException;
-import org.eclipse.jface.text.Document;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.IRegion;
-import org.eclipse.wst.sse.core.builder.IBuilderDelegate;
-import org.eclipse.wst.sse.core.document.DocumentReader;
-import org.eclipse.wst.sse.core.document.IEncodedDocument;
-import org.eclipse.wst.sse.core.internal.Logger;
-import org.eclipse.wst.sse.core.internal.SSECorePlugin;
-import org.eclipse.wst.sse.core.internal.modelhandler.ModelHandlerRegistry;
-import org.eclipse.wst.sse.core.modelhandler.IModelHandler;
-import org.eclipse.wst.sse.core.parser.RegionParser;
-import org.eclipse.wst.sse.core.parser.StructuredDocumentRegionHandler;
-import org.eclipse.wst.sse.core.parser.StructuredDocumentRegionParser;
-import org.eclipse.wst.sse.core.preferences.CommonModelPreferenceNames;
-import org.eclipse.wst.sse.core.text.IStructuredDocument;
-import org.eclipse.wst.sse.core.text.IStructuredDocumentRegion;
-import org.eclipse.wst.sse.core.text.ITextRegion;
-import org.eclipse.wst.sse.core.text.ITextRegionList;
-import org.eclipse.wst.sse.core.util.StringUtils;
-
-
-/**
- * A participant to create IMarker.TASKs for "todos" and similiar comments.
- * Clients should not subclass.
- */
-public abstract class TaskTagSeeker implements IBuilderDelegate {
-
- public static class TaskTag {
- public int priority;
- public String text;
-
- public TaskTag(String taskText, int taskPriority) {
- this.text = taskText;
- this.priority = taskPriority;
- }
- }
-
- private static final boolean _debug = "true".equalsIgnoreCase(Platform.getDebugOption("org.eclipse.wst.sse.core/builder/participant/tasktag")); //$NON-NLS-1$ //$NON-NLS-2$
- protected static final boolean _debugBuilderPerf = "true".equalsIgnoreCase(Platform.getDebugOption("org.eclipse.wst.sse.core/builder/time")); //$NON-NLS-1$ //$NON-NLS-2$
-
- public static String getTaskMarkerType() {
- return SSECorePlugin.ID + ".task"; //$NON-NLS-1$
- }
-
- // TODO: implement per-project enablement according to
- // http://dev.eclipse.org/viewcvs/index.cgi/%7Echeckout%7E/platform-core-home/documents/user_settings/faq.html
- boolean fEnabled = true;
-
- // the list of attributes for the new tasks for the current file
- protected List fNewMarkerAttributes = null;
-
- private TaskTag[] fTaskTags = null;
- List oldMarkers = null;
- private long time0;
-
- public TaskTagSeeker() {
- super();
- fNewMarkerAttributes = new ArrayList();
- if (_debug) {
- System.out.println(getClass().getName() + " instance created"); //$NON-NLS-1$
- }
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.wst.sse.core.builder.IBuilderDelegate#build(org.eclipse.core.resources.IFile,
- * int, java.util.Map, org.eclipse.core.runtime.IProgressMonitor)
- */
- public IStatus build(IFile file, int kind, Map args, IProgressMonitor monitor) {
- if (monitor.isCanceled() || !isShouldBuild(file)) {
- return Status.OK_STATUS;
- }
- if (_debugBuilderPerf) {
- time0 = System.currentTimeMillis();
- }
- if (fTaskTags.length > 0) {
- try {
- // Delete old Task markers
- file.deleteMarkers(getMarkerType(), true, IResource.DEPTH_ZERO);
- } catch (CoreException e) {
- Logger.logException("exception deleting old tasks", e); //$NON-NLS-1$
- }
- // on a clean build, don't add new Tasks
- if (kind != IncrementalProjectBuilder.CLEAN_BUILD && fEnabled) {
- findTasks(file, monitor);
- createNewMarkers(file, monitor);
- }
- }
- if (_debugBuilderPerf) {
- System.out.println("" + (System.currentTimeMillis() - time0) + "ms for " + file.getLocation()); //$NON-NLS-1$ //$NON-NLS-2$
- }
- return Status.OK_STATUS;
- }
-
- /**
- * Returns the attributes with which a newly created marker will be
- * initialized. Modified from the method in MarkerRulerAction
- *
- * @return the initial marker attributes
- */
- protected Map createInitialMarkerAttributes(String text, int documentLine, int startOffset, int length, int priority) {
- Map attributes = new HashMap(6);
- // marker line numbers are 1-based
- attributes.put(IMarker.LINE_NUMBER, new Integer(documentLine + 1));
- attributes.put(IMarker.CHAR_START, new Integer(startOffset));
- attributes.put(IMarker.CHAR_END, new Integer(startOffset + length));
- attributes.put(IMarker.MESSAGE, text);
- attributes.put(IMarker.USER_EDITABLE, Boolean.FALSE);
-
- switch (priority) {
- case IMarker.PRIORITY_HIGH : {
- attributes.put(IMarker.PRIORITY, new Integer(IMarker.PRIORITY_HIGH));
- }
- break;
- case IMarker.PRIORITY_LOW : {
- attributes.put(IMarker.PRIORITY, new Integer(IMarker.PRIORITY_LOW));
- }
- break;
- default : {
- attributes.put(IMarker.PRIORITY, new Integer(IMarker.PRIORITY_NORMAL));
- }
- }
-
- return attributes;
- }
-
- protected void createNewMarkers(IFile file, IProgressMonitor monitor) {
- final IFile finalFile = file;
- if (file.isAccessible() && fNewMarkerAttributes.size() > 0) {
- if (_debug) {
- System.out.println("" + fNewMarkerAttributes.size() + " tasks for " + file.getFullPath()); //$NON-NLS-1$ //$NON-NLS-2$
- }
- try {
- IWorkspaceRunnable r = new IWorkspaceRunnable() {
- public void run(IProgressMonitor progressMonitor) throws CoreException {
- for (int i = 0; i < fNewMarkerAttributes.size(); i++) {
- IMarker marker = finalFile.createMarker(getMarkerType());
- marker.setAttributes((Map) fNewMarkerAttributes.get(i));
- }
- }
- };
- finalFile.getWorkspace().run(r, null, IWorkspace.AVOID_UPDATE, monitor);
- fNewMarkerAttributes.clear();
- } catch (CoreException e1) {
- Logger.logException(e1);
- }
- }
- }
-
- private String detectCharset(IFile file) {
- if (file.getType() == IResource.FILE && file.isAccessible()) {
- IContentDescription d = null;
- try {
- // optimized description lookup, might not succeed
- d = file.getContentDescription();
- if (d != null)
- return d.getCharset();
- } catch (CoreException e) {
- // should not be possible given the accessible and file type
- // check above
- }
- InputStream contents = null;
- try {
- contents = file.getContents();
- IContentDescription description = Platform.getContentTypeManager().getDescriptionFor(contents, file.getName(), new QualifiedName[]{IContentDescription.CHARSET});
- if (description != null) {
- return description.getCharset();
- }
- } catch (IOException e) {
- // will try to cleanup in finally
- } catch (CoreException e) {
- Logger.logException(e);
- } finally {
- if (contents != null) {
- try {
- contents.close();
- } catch (Exception e) {
- // not sure how to recover at this point
- }
- }
- }
- }
- return ResourcesPlugin.getEncoding();
- }
-
- /**
- * @param document
- * @param documentRegion
- * @param comment
- */
- protected void findTasks(IDocument document, IStructuredDocumentRegion documentRegion, ITextRegion comment) {
- if (isCommentRegion(documentRegion, comment)) {
- int startOffset = documentRegion.getStartOffset(comment);
- int endOffset = documentRegion.getTextEndOffset(comment);
- try {
- int startLine = document.getLineOfOffset(startOffset);
- int endLine = document.getLineOfOffset(endOffset);
- for (int lineNumber = startLine; lineNumber <= endLine; lineNumber++) {
- IRegion line = document.getLineInformation(lineNumber);
- int begin = Math.max(startOffset, line.getOffset());
- int end = Math.min(endOffset, line.getOffset() + line.getLength());
- int length = end - begin;
-
- // TODO: improve our search algorithm; use search or
- // regionMatch?
-
- String commentedText = getCommentedText(document, begin, length);
-
- for (int i = 0; i < fTaskTags.length; i++) {
- int tagIndex = commentedText.indexOf(fTaskTags[i].text);
- if (tagIndex >= 0) {
- String markerDescription = commentedText.substring(tagIndex);
- int markerOffset = begin + tagIndex;
- int markerLength = end - markerOffset;
- fNewMarkerAttributes.add(createInitialMarkerAttributes(markerDescription, lineNumber, markerOffset, markerLength, fTaskTags[i].priority));
- break;
- }
- }
- }
- } catch (BadLocationException e) {
- Logger.logException(e);
- }
- }
- }
-
- private void findTasks(IFile file, IProgressMonitor monitor) {
- try {
- IModelHandler handler = ModelHandlerRegistry.getInstance().getHandlerFor(file);
-
- // records if the optimized streamish parse was possible
- boolean didStreamParse = false;
- final IProgressMonitor progressMonitor = monitor;
- final IEncodedDocument defaultDocument = handler.getDocumentLoader().createNewStructuredDocument();
- if (defaultDocument instanceof IStructuredDocument) {
- RegionParser parser = ((IStructuredDocument) defaultDocument).getParser();
- if (parser instanceof StructuredDocumentRegionParser) {
- didStreamParse = true;
- String charset = detectCharset(file);
- StructuredDocumentRegionParser documentParser = (StructuredDocumentRegionParser) parser;
- final IDocument textDocument = new Document();
- setDocumentContent(textDocument, file.getContents(true), charset);
- documentParser.reset(new DocumentReader(textDocument));
- documentParser.addStructuredDocumentRegionHandler(new StructuredDocumentRegionHandler() {
- /**
- * @see org.eclipse.wst.sse.core.parser.StructuredDocumentRegionHandler#nodeParsed(org.eclipse.wst.sse.core.text.IStructuredDocumentRegion)
- */
- public void nodeParsed(IStructuredDocumentRegion documentRegion) {
- ITextRegionList regions = documentRegion.getRegions();
- for (int j = 0; j < regions.size(); j++) {
- ITextRegion comment = regions.get(j);
- findTasks(textDocument, documentRegion, comment);
- }
- // disconnect the document regions
- if (documentRegion.getPrevious() != null) {
- documentRegion.getPrevious().setPrevious(null);
- documentRegion.getPrevious().setNext(null);
- }
- if (progressMonitor.isCanceled()) {
- textDocument.set(""); //$NON-NLS-1$
- }
- }
-
- /**
- * @see org.eclipse.wst.sse.core.parser.StructuredDocumentRegionHandler#resetNodes()
- */
- public void resetNodes() {
- }
- });
- documentParser.getDocumentRegions();
- }
- }
- if (!didStreamParse) {
- // Use a StructuredDocument
- IEncodedDocument document = handler.getDocumentLoader().createNewStructuredDocument(file);
- if (document instanceof IStructuredDocument) {
- IStructuredDocumentRegion documentRegion = ((IStructuredDocument) document).getFirstStructuredDocumentRegion();
- while (documentRegion != null) {
- ITextRegionList regions = documentRegion.getRegions();
- for (int j = 0; j < regions.size(); j++) {
- ITextRegion comment = regions.get(j);
- findTasks(document, documentRegion, comment);
- }
- documentRegion = documentRegion.getNext();
- }
- }
- }
- } catch (CoreException e) {
- Logger.logException("Exception with " + file.getFullPath().toString(), e);
- } catch (CharacterCodingException e) {
- Logger.log(Logger.INFO, "TaskTagSeeker encountered CharacterCodingException reading " + file.getFullPath().toOSString());
- } catch (IOException e) {
- Logger.logException(e);
- }
- }
-
-
- /**
- * @param document
- * @param begin
- * @param length
- * @return
- * @throws BadLocationException
- */
- protected String getCommentedText(IDocument document, int begin, int length) throws BadLocationException {
- return document.get(begin, length);
- }
-
- final protected String getMarkerType() {
- return SSECorePlugin.ID + ".task"; //$NON-NLS-1$
- }
-
- /**
- * @param region2
- * @return
- */
- protected abstract boolean isCommentRegion(IStructuredDocumentRegion region, ITextRegion textRegion);
-
- boolean isShouldBuild(IResource r) {
- // skip "dot" files
- String s = r.getName();
- return s.length() == 0 || s.charAt(0) != '.';
- }
-
- private void loadPreference() {
- if (_debug) {
- System.out.println(this + " loadPreference()"); //$NON-NLS-1$
- }
- fEnabled = SSECorePlugin.getDefault().getPluginPreferences().getBoolean(CommonModelPreferenceNames.TASK_TAG_ENABLE);
- String tagsString = SSECorePlugin.getDefault().getPluginPreferences().getString(CommonModelPreferenceNames.TASK_TAG_TAGS);
- String prioritiesString = SSECorePlugin.getDefault().getPluginPreferences().getString(CommonModelPreferenceNames.TASK_TAG_PRIORITIES);
-
- List list = new ArrayList();
- StringTokenizer toker = null;
- if (tagsString.length() > 0) {
- toker = new StringTokenizer(tagsString, ","); //$NON-NLS-1$
- while (toker.hasMoreTokens()) {
- // since we're separating the values with ',', escape ',' in
- // the
- // values
- list.add(StringUtils.replace(toker.nextToken(), "&comma;", ",").trim()); //$NON-NLS-1$ //$NON-NLS-2$
- }
- }
- String[] tags = (String[]) list.toArray(new String[0]);
- list.clear();
-
- if (prioritiesString.length() > 0) {
- toker = new StringTokenizer(prioritiesString, ","); //$NON-NLS-1$
- int i = 0;
- while (toker.hasMoreTokens() && i < tags.length) {
- Integer number = null;
- try {
- number = Integer.valueOf(toker.nextToken().trim());
- } catch (NumberFormatException e) {
- number = new Integer(IMarker.PRIORITY_NORMAL);
- }
- if (i < tags.length) {
- list.add(new TaskTag(tags[i++], number.intValue()));
- }
- }
- }
- fTaskTags = (TaskTag[]) list.toArray(new TaskTag[0]);
- }
-
- /**
- * Sets the document content from this stream, closing the stream when
- * done
- *
- * @param document
- * @param contentStream
- * @param charset
- */
- protected void setDocumentContent(IDocument document, InputStream contentStream, String charset) {
- Reader in = null;
- try {
- in = new BufferedReader(new InputStreamReader(contentStream, charset), 2048);
- StringBuffer buffer = new StringBuffer(2048);
- char[] readBuffer = new char[2048];
- int n = in.read(readBuffer);
- while (n > 0) {
- buffer.append(readBuffer, 0, n);
- n = in.read(readBuffer);
- }
- document.set(buffer.toString());
- } catch (IOException x) {
- } finally {
- if (in != null) {
- try {
- in.close();
- } catch (IOException x) {
- }
- }
- }
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.wst.sse.core.builder.IBuilderParticipant#shutdown(org.eclipse.core.resources.IProject)
- */
- public void shutdown(IProject project) {
- if (_debug) {
- System.out.println(this + " shutdown for " + project.getName()); //$NON-NLS-1$
- }
- fTaskTags = null;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.wst.sse.core.builder.IBuilderParticipant#startup(org.eclipse.core.resources.IProject,
- * int, java.util.Map)
- */
- public void startup(IProject project, int kind, Map args) {
- if (_debug) {
- System.out.println(this + " startup for " + project.getName()); //$NON-NLS-1$
- }
- if (_debugBuilderPerf) {
- time0 = System.currentTimeMillis();
- }
- loadPreference();
- if (_debugBuilderPerf) {
- System.out.println("" + (System.currentTimeMillis() - time0) + "ms loading prefs for " + project.getName()); //$NON-NLS-1$ //$NON-NLS-2$
- }
- }
-}
diff --git a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/preferences/CommonModelPreferenceNames.java b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/preferences/CommonModelPreferenceNames.java
deleted file mode 100644
index 13f15f34f5..0000000000
--- a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/preferences/CommonModelPreferenceNames.java
+++ /dev/null
@@ -1,161 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Jens Lukowski/Innoopract - initial renaming/restructuring
- *
- *******************************************************************************/
-package org.eclipse.wst.sse.core.preferences;
-
-import org.eclipse.wst.common.encoding.CommonEncodingPreferenceNames;
-
-/**
- * Here is a description of how each common model file preference is used.
- *
- * tabWidth The number of spaces representing a tab. This number is also used
- * as number of spaces to indent during formatting when indentUsingTabs is
- * false.
- *
- * splitLines Indicates if long lines should be splitted.
- *
- * splitLinesUsingEditorsWidth Indicates if long lines should be splitted
- * using the editor's current width. The editor's current width will be used
- * when splitting long lines if splitLinesUsingEditorWidth is true. lineWidth
- * will be used when splitting long lines if splitLinesUsingEditorWidth is
- * false.
- *
- * lineWidth The maximum width of a line before a line split is needed. This
- * number is only used when lineSplitting is true, otherwise it's ignored.
- *
- * splitMultiAttrs Indicates if tags with multiple attributes should be
- * formatted (splitting each attr on a new line).
- *
- * indentUsingTabs Indicates if tabs should be used for indentation during
- * formatting. The same number of spaces specified by tabWidth will be used
- * for indentation if indentUsingTabs is false.
- *
- * clearAllBlankLines Indicates if all blanks lines should be cleared during
- * formatting. Blanks lines will be kept when clearAllBlankLines is false.
- *
- * formattingSupported Indicates if the current content type supports
- * formatting. The splitLines, splitLinesUsingEditorsWidth, lineWidth,
- * splitMultiAttrs, and indentUsingTabs preferences will be meaningless if
- * formattingSupported is false.
- *
- * contentAssistSupported Indicates if the current content type supports
- * content assist. The autoPropose, and autoProposeCode preferences will be
- * meaningless if contentAssistSupported is false.
- *
- * preferredMarkupCaseSupported Indicates if the current content type supports
- * "preferred markup case for content assist, and code generation". The
- * tagNameCase, and attrNameCase preferences will be meaningless if
- * preferredMarkupCaseSupported is false.
- *
- */
-public interface CommonModelPreferenceNames {
- String TAB_WIDTH = "tabWidth";//$NON-NLS-1$
- String LINE_WIDTH = "lineWidth";//$NON-NLS-1$
- String SPLIT_MULTI_ATTRS = "splitMultiAttrs";//$NON-NLS-1$
- String INDENT_USING_TABS = "indentUsingTabs";//$NON-NLS-1$
- String CLEAR_ALL_BLANK_LINES = "clearAllBlankLines";//$NON-NLS-1$
-
- String TAG_NAME_CASE = "tagNameCase";//$NON-NLS-1$
- String ATTR_NAME_CASE = "attrNameCase";//$NON-NLS-1$
-
- String FORMATTING_SUPPORTED = "formattingSupported";//$NON-NLS-1$
-
- String PREFERRED_MARKUP_CASE_SUPPORTED = "preferredMarkupCaseSupported";//$NON-NLS-1$
-
- String TASK_TAG_TAGS = "task-tag-tags"; //$NON-NLS-1$
- String TASK_TAG_PRIORITIES = "task-tag-priorities"; //$NON-NLS-1$
- String TASK_TAG_ENABLE = "task-tags"; //$NON-NLS-1$
-
- /*
- * @deprecated - use from CommonEncodingPreferenceNames
- */
- String OUTPUT_CODESET = CommonEncodingPreferenceNames.OUTPUT_CODESET;
-
- /**
- * these are preferences that should be inherited from the "embedded
- * preference store" for example: if you ask for th OVERVIEW_RULER
- * preference for JSP, you will automatically get the preference from the
- * HTML preference store.
- */
- String EMBEDDED_CONTENT_TYPE_PREFERENCES[] = {TAB_WIDTH, LINE_WIDTH, SPLIT_MULTI_ATTRS, INDENT_USING_TABS, CLEAR_ALL_BLANK_LINES, TAG_NAME_CASE, ATTR_NAME_CASE,};
-
- String FORMATTING_PREFERENCES[] = {TAB_WIDTH, LINE_WIDTH, SPLIT_MULTI_ATTRS, INDENT_USING_TABS, CLEAR_ALL_BLANK_LINES,};
-
- String AUTO = "Auto";//$NON-NLS-1$
- String UTF_8 = "UTF-8";//$NON-NLS-1$
- String ISO_8859_1 = "ISO-8859-1";//$NON-NLS-1$
-
- int ASIS = 0;
- int LOWER = 1;
- int UPPER = 2;
-
- // cleanup preference names
- String CLEANUP_TAG_NAME_CASE = "cleanupTagNameCase";//$NON-NLS-1$
- String CLEANUP_ATTR_NAME_CASE = "cleanupAttrNameCase";//$NON-NLS-1$
- String COMPRESS_EMPTY_ELEMENT_TAGS = "compressEmptyElementTags";//$NON-NLS-1$
- String INSERT_REQUIRED_ATTRS = "insertRequiredAttrs";//$NON-NLS-1$
- String INSERT_MISSING_TAGS = "insertMissingTags";//$NON-NLS-1$
- String QUOTE_ATTR_VALUES = "quoteAttrValues";//$NON-NLS-1$
- String FORMAT_SOURCE = "formatSource";//$NON-NLS-1$
- String CONVERT_EOL_CODES = "convertEOLCodes";//$NON-NLS-1$
- String CLEANUP_EOL_CODE = "cleanupEOLCode";//$NON-NLS-1$
-
- String LAST_ACTIVE_PAGE = "lastActivePage";//$NON-NLS-1$
-
- // need to put default tab width preference here so it is accessible by
- // both model and editor
- // this way, editor does not need to query model's default tab width
- // preference
- int DEFAULT_TAB_WIDTH = 4;
- /**
- * @deprecated use CommonEncodingPreferenceNames.END_OF_LINE_CODE instead
- * TODO remove
- */
- String END_OF_LINE_CODE = CommonEncodingPreferenceNames.END_OF_LINE_CODE;
- /**
- * @deprecated use CommonEncodingPreferenceNames.NO_TRANSLATION instead
- * TODO remove
- */
- String NO_TRANSLATION = CommonEncodingPreferenceNames.NO_TRANSLATION;
- /**
- * @deprecated use CommonEncodingPreferenceNames.INPUT_CODESET instead
- * TODO remove
- */
- String INPUT_CODESET = CommonEncodingPreferenceNames.INPUT_CODESET;
- /**
- * @deprecated use CommonEncodingPreferenceNames.STRING_CRLF instead TODO
- * remove
- */
- String STRING_CRLF = CommonEncodingPreferenceNames.STRING_CRLF;
- /**
- * @deprecated use CommonEncodingPreferenceNames.STRING_CR instead TODO
- * remove
- */
- String STRING_CR = CommonEncodingPreferenceNames.STRING_CR;
- /**
- * @deprecated use CommonEncodingPreferenceNames.STRING_LF instead TODO
- * remove
- */
- String STRING_LF = CommonEncodingPreferenceNames.STRING_LF;
- /**
- * @deprecated use CommonEncodingPreferenceNames.CRLF instead TODO remove
- */
- String CRLF = CommonEncodingPreferenceNames.CRLF;
- /**
- * @deprecated use CommonEncodingPreferenceNames.LF instead TODO remove
- */
- String LF = CommonEncodingPreferenceNames.LF;
- /**
- * @deprecated use CommonEncodingPreferenceNames.CR instead TODO remove
- */
- String CR = CommonEncodingPreferenceNames.CR;
-}
diff --git a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/preferences/PreferenceChangeListener.java b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/preferences/PreferenceChangeListener.java
deleted file mode 100644
index e5711169cd..0000000000
--- a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/preferences/PreferenceChangeListener.java
+++ /dev/null
@@ -1,24 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Jens Lukowski/Innoopract - initial renaming/restructuring
- *
- *******************************************************************************/
-package org.eclipse.wst.sse.core.preferences;
-
-/**
- * @deprecated This used to be used by our own PreferenceManager but since
- * that class is no longer needed, this class should also no
- * longer be needed. Use the base's IPreferenceChangeListener or
- * IPropertyChangeListener instead.
- */
-public interface PreferenceChangeListener {
-
- void preferencesChanged();
-}
diff --git a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/text/DeleteEqualPositionUpdater.java b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/text/DeleteEqualPositionUpdater.java
deleted file mode 100644
index b5b9d72cc9..0000000000
--- a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/text/DeleteEqualPositionUpdater.java
+++ /dev/null
@@ -1,66 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Jens Lukowski/Innoopract - initial renaming/restructuring
- *
- *******************************************************************************/
-package org.eclipse.wst.sse.core.text;
-
-import org.eclipse.jface.text.BadPositionCategoryException;
-import org.eclipse.jface.text.DefaultPositionUpdater;
-
-/**
- * Follows the behavior of DefaultPositionUpdater except in addition to
- * deleting/overwriting text which completely contains the position deletes
- * the position, deleting text that equals the text in position also deletes
- * the position.
- *
- * @see org.eclipse.jface.text.DefaultPositionUpdater
- */
-public class DeleteEqualPositionUpdater extends DefaultPositionUpdater {
-
- /**
- * @param category
- */
- public DeleteEqualPositionUpdater(String category) {
- super(category);
- }
-
- /**
- * Determines whether the currently investigated position has been deleted
- * by the replace operation specified in the current event. If so, it
- * deletes the position and removes it from the document's position
- * category.
- *
- * NOTE: position is deleted if current event completely overwrites
- * position OR if current event deletes the area surrounding/including the
- * position
- *
- * @return <code>true</code> if position has been deleted
- */
- protected boolean notDeleted() {
- // position is deleted if current event completely overwrites position
- // OR if
- // current event deletes the area surrounding/including the position
- if ((fOffset < fPosition.offset && (fPosition.offset + fPosition.length < fOffset + fLength)) || (fOffset <= fPosition.offset && (fPosition.offset + fPosition.length <= fOffset + fLength) && fReplaceLength == 0)) {
-
- fPosition.delete();
-
- try {
- fDocument.removePosition(getCategory(), fPosition);
- } catch (BadPositionCategoryException x) {
- }
-
- return false;
- }
-
- return true;
- }
-
-}
diff --git a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/text/IStructuredDocument.java b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/text/IStructuredDocument.java
deleted file mode 100644
index 7e2cb01782..0000000000
--- a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/text/IStructuredDocument.java
+++ /dev/null
@@ -1,199 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Jens Lukowski/Innoopract - initial renaming/restructuring
- *
- *******************************************************************************/
-package org.eclipse.wst.sse.core.text;
-
-import org.eclipse.core.runtime.IAdaptable;
-import org.eclipse.jface.text.IDocumentExtension;
-import org.eclipse.wst.common.encoding.EncodingMemento;
-import org.eclipse.wst.sse.core.document.IEncodedDocument;
-import org.eclipse.wst.sse.core.events.IModelAboutToBeChangedListener;
-import org.eclipse.wst.sse.core.events.IStructuredDocumentListener;
-import org.eclipse.wst.sse.core.events.NewModelEvent;
-import org.eclipse.wst.sse.core.events.StructuredDocumentEvent;
-import org.eclipse.wst.sse.core.parser.RegionParser;
-import org.eclipse.wst.sse.core.undo.IStructuredTextUndoManager;
-
-
-/**
- * A IStructuredDocument is a collection of StructuredDocumentRegions. It's
- * often called "flat" because its contents by design do not contain much
- * structural information beyond containment. Clients should not implement.
- */
-public interface IStructuredDocument extends IEncodedDocument, IDocumentExtension, IAdaptable {
-
- String DEFAULT_STRUCTURED_PARTITIONING = "org.eclipse.wst.sse.core.default_structured_text_partitioning";
-
- void addDocumentAboutToChangeListener(IModelAboutToBeChangedListener listener);
-
- /**
- * The StructuredDocumentListeners and ModelChangedListeners are very
- * similar. They both receive identical events. The difference is the
- * timing. The "pure" StructuredDocumentListeners are notified after the
- * structuredDocument has been changed, but before other, related models
- * may have been changed such as the Structural Model. The Structural
- * model is in fact itself a "pure" StructuredDocumentListner. The
- * ModelChangedListeners can rest assured that all models and data have
- * been updated from the change by the tiem they are notified. This is
- * especially important for the text widget, for example, which may rely
- * on both structuredDocument and structural model information.
- */
- void addDocumentChangedListener(IStructuredDocumentListener listener);
-
- /**
- * The StructuredDocumentListeners and ModelChangedListeners are very
- * similar. They both receive identical events. The difference is the
- * timing. The "pure" StructuredDocumentListeners are notified after the
- * structuredDocument has been changed, but before other, related models
- * may have been changed such as the Structural Model. The Structural
- * model is in fact itself a "pure" StructuredDocumentListner. The
- * ModelChangedListeners can rest assured that all models and data have
- * been updated from the change by the tiem they are notified. This is
- * especially important for the text widget, for example, which may rely
- * on both structuredDocument and structural model information.
- */
- void addDocumentChangingListener(IStructuredDocumentListener listener);
-
- /**
- * this API ensures that any portion of the document within startOff to
- * length is not readonly (that is, that its editable). Note that if the
- * range overlaps with other readonly regions, those other readonly
- * regions will be adjusted.
- *
- * @param startOffset
- * @param length
- */
- void clearReadOnly(int startOffset, int length);
-
- /**
- * returns true if any portion of startOffset to length is readonly
- *
- * @param startOffset
- * @param length
- * @return
- */
- boolean containsReadOnly(int startOffset, int length);
-
- /**
- * This method is to remember info about the encoding When the resource
- * was last loaded or saved. Note: it is not kept "current", that is, can
- * not be depended on blindly to reflect what encoding to use. For that,
- * must go through the normal rules expressed in Loaders and Dumpers.
- */
-
- EncodingMemento getEncodingMemento();
-
- org.eclipse.wst.sse.core.text.IStructuredDocumentRegion getFirstStructuredDocumentRegion();
-
- org.eclipse.wst.sse.core.text.IStructuredDocumentRegion getLastStructuredDocumentRegion();
-
- /**
- * This can be considered the preferred delimiter.
- */
- public String getLineDelimiter();
-
- int getLineOfOffset(int offset); // throws SourceEditingException;
-
- /**
- * The parser is now required on constructor, so there are occasions it
- * needs to be retrieved, such as to be initialized by EmbeddedContentType
- */
- RegionParser getParser();
-
- IStructuredDocumentRegion getRegionAtCharacterOffset(int offset);
-
- IStructuredDocumentRegionList getRegionList();
-
-
- /**
- * Note: this method was made public, and part of the interface, for
- * easier testing. Clients normally never manipulate the reparser directly
- * (nor should they need to).
- */
- IStructuredTextReParser getReParser();
-
- String getText();
-
- IStructuredTextUndoManager getUndoManager();
-
- /**
- * causes that portion of the document from startOffset to length to be
- * marked as readonly. Note that if this range overlaps with some other
- * region with is readonly, the regions are effectivly combined.
- *
- * @param startOffset
- * @param length
- */
- void makeReadOnly(int startOffset, int length);
-
- /**
- * newInstance is similar to clone, except it contains no data. One
- * important thing to duplicate is the parser, with the parser correctly
- * "cloned", including its tokeninzer, block tags, etc.
- *
- * NOTE: even after obtaining a 'newInstance' the client may have to do
- * some initialization, for example, it may need to add its own model
- * listeners. Or, as another example, if the IStructuredDocument has a
- * parser of type StructuredDocumentRegionParser, then the client may need
- * to add its own StructuredDocumentRegionHandler to that parser, if it is
- * in fact needed.
- */
- IStructuredDocument newInstance();
-
- void removeDocumentAboutToChangeListener(IModelAboutToBeChangedListener listener);
-
- void removeDocumentChangedListener(IStructuredDocumentListener listener);
-
- void removeDocumentChangingListener(IStructuredDocumentListener listener);
-
- /**
- * One of the APIs to manipulate the IStructuredDocument.
- *
- * replaceText replaces the text from oldStart to oldEnd with the new text
- * found in the requestedChange string. If oldStart and oldEnd are equal,
- * it is an insertion request. If requestedChange is null (or empty) it is
- * a delete request. Otherwise it is a replace request.
- */
- StructuredDocumentEvent replaceText(Object source, int oldStart, int replacementLength, String requestedChange);
-
- /**
- * Note, same as replaceText API, but will allow readonly areas to be
- * replaced. This should seldom be called with a value of "true" for
- * ignoreReadOnlySetting. One case where its ok is with undo operations
- * (since, presumably, if user just did something that happended to
- * involve some inserting readonly text, they should normally be allowed
- * to still undo that operation. Otherwise, I can't think of a single
- * example, unless its to give the user a choice, e.g. "you are about to
- * overwrite read only portions, do you want to continue".
- */
- StructuredDocumentEvent replaceText(Object source, int oldStart, int replacementLength, String requestedChange, boolean ignoreReadOnlySetting);
-
- /**
- * This method is to remember info about the encoding When the resource
- * was last loaded or saved. Note: it is not kept "current", that is, can
- * not be depended on blindly to reflect what encoding to use. For that,
- * must go through the normal rules expressed in Loaders and Dumpers.
- */
- void setEncodingMemento(EncodingMemento encodingMemento);
-
- public void setLineDelimiter(String delimiter);
-
- /**
- * One of the APIs to manipulate the IStructuredDocument in terms of Text.
- *
- * The setText method replaces all text in the model.
- */
- NewModelEvent setText(Object requester, String allText);
-
- void setUndoManager(IStructuredTextUndoManager undoManager);
-
-}
diff --git a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/text/IStructuredDocumentRegion.java b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/text/IStructuredDocumentRegion.java
deleted file mode 100644
index 752f403255..0000000000
--- a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/text/IStructuredDocumentRegion.java
+++ /dev/null
@@ -1,96 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Jens Lukowski/Innoopract - initial renaming/restructuring
- *
- *******************************************************************************/
-package org.eclipse.wst.sse.core.text;
-
-import org.eclipse.wst.sse.core.events.StructuredDocumentEvent;
-
-
-
-/**
- * A ITextRegionCollection is a collection of ITextRegions. It is a structural
- * unit, but a minimal one. For example, in might consist of a "start tag" but
- * not a whole XML node.
- */
-public interface IStructuredDocumentRegion extends ITextRegionCollection {
-
- /**
- * For use by parsers and reparsers only.
- */
- void addRegion(ITextRegion aRegion);
-
- /**
- * For use by parsers and reparsers only.
- */
- void adjustLengthWith(int i);
-
- /**
- * For use by parsers and reparsers only.
- */
- void adjustStart(int i);
-
-
-
- IStructuredDocumentRegion getNext();
-
- IStructuredDocument getParentDocument();
-
- IStructuredDocumentRegion getPrevious();
-
- boolean isDeleted();
-
- boolean isEnded();
-
- boolean sameAs(IStructuredDocumentRegion region, int shift);
-
- boolean sameAs(ITextRegion oldRegion, IStructuredDocumentRegion documentRegion, ITextRegion newRegion, int shift);
-
- void setDeleted(boolean deleted);
-
- /**
- * For use by parsers and reparsers only.
- */
- void setEnded(boolean hasEnd);
-
- /**
- * For use by parsers and reparsers only.
- */
- void setLength(int newLength);
-
- /**
- * For use by parsers and reparsers only.
- */
- void setNext(IStructuredDocumentRegion newNext);
-
- /**
- * For use by parsers and reparsers only.
- */
- void setParentDocument(IStructuredDocument document);
-
- /**
- * For use by parsers and reparsers only.
- */
- void setPrevious(IStructuredDocumentRegion newPrevious);
-
- /**
- * For use by parsers and reparsers only.
- */
- void setStart(int newStart);
-
- /**
- * For use by parsers and reparsers only.
- */
- StructuredDocumentEvent updateModel(Object requester, IStructuredDocumentRegion flatnode, String changes, int start, int end);
-
-
-
-}
diff --git a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/text/IStructuredDocumentRegionList.java b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/text/IStructuredDocumentRegionList.java
deleted file mode 100644
index 6e906cd45d..0000000000
--- a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/text/IStructuredDocumentRegionList.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Jens Lukowski/Innoopract - initial renaming/restructuring
- *
- *******************************************************************************/
-package org.eclipse.wst.sse.core.text;
-
-
-
-import java.util.Enumeration;
-
-/**
- * This is a class used to provide a list of StructuredDocumentRegions, so the
- * implementation of how the list is formed can be hidden (encapsulated by
- * this class).
- */
-public interface IStructuredDocumentRegionList {
-
- Enumeration elements();
-
- int getLength();
-
- IStructuredDocumentRegion item(int i);
-}
diff --git a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/text/IStructuredTextPartitioner.java b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/text/IStructuredTextPartitioner.java
deleted file mode 100644
index 17a70a466c..0000000000
--- a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/text/IStructuredTextPartitioner.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Jens Lukowski/Innoopract - initial renaming/restructuring
- *
- *******************************************************************************/
-package org.eclipse.wst.sse.core.text;
-
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.IDocumentPartitioner;
-
-
-/**
- * A partitioner interface required by the StructuredTextPartitionerForJSP for
- * handling the embedded content type properly. This has not yet been
- * finalized.
- */
-
-public interface IStructuredTextPartitioner extends IDocumentPartitioner {
- void connect(IDocument document);
-
- /**
- * @deprecated - (dmw) not sure why we needed to make this part of
- * interface ... but probably shouldn't be.
- *
- * (nsd) Used by JSP partitioner to ensure that the partitioner of the
- * embedded content type gets to create the partition in case the specific
- * classes are important.
- */
- StructuredTypedRegion createPartition(int offset, int length, String type);
-
- void disconnect();
-
- String getDefault();
-
- String[] getLegalContentTypes();
-
- String getPartitionType(ITextRegion region, int offset);
-
- String getPartitionTypeBetween(IStructuredDocumentRegion previousNode, ITextRegion previousStartTagNameRegion, IStructuredDocumentRegion nextNode, ITextRegion nextEndTagNameRegion);
-}
diff --git a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/text/IStructuredTextReParser.java b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/text/IStructuredTextReParser.java
deleted file mode 100644
index acd0c113d6..0000000000
--- a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/text/IStructuredTextReParser.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Jens Lukowski/Innoopract - initial renaming/restructuring
- *
- *******************************************************************************/
-package org.eclipse.wst.sse.core.text;
-
-
-
-import org.eclipse.wst.sse.core.events.StructuredDocumentEvent;
-
-public interface IStructuredTextReParser {
-
- void initialize(Object requester, int start, int lengthToReplace, String changes);
-
- /**
- * This method is provided in anticipation of eventual multithreading.
- * This is needed since the intialize method sets state variables that
- * must be "in sync" with the structuredDocument.
- */
- public boolean isParsing();
-
- public IStructuredTextReParser newInstance();
-
- /**
- * An entry point for reparsing. It calculates the dirty start and dirty
- * end flatnodes based on the start point and length of the changes, which
- * are provided by the initialize method.
- *
- */
- public StructuredDocumentEvent reparse();
-
- public void setStructuredDocument(IStructuredDocument newStructuredDocument);
-}
diff --git a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/text/ITextRegion.java b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/text/ITextRegion.java
deleted file mode 100644
index 4a61fe9d04..0000000000
--- a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/text/ITextRegion.java
+++ /dev/null
@@ -1,82 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Jens Lukowski/Innoopract - initial renaming/restructuring
- *
- *******************************************************************************/
-package org.eclipse.wst.sse.core.text;
-
-import org.eclipse.wst.sse.core.events.StructuredDocumentEvent;
-
-
-
-/**
- * A simple description of a bit of text (technically, a bit of a text buffer)
- * than has a "type" associated with it. For example, for the XML text
- * "&LT;IMG&GT;", the ' <' might form a region of type "open bracket" where as
- * the text "IMG" might form a region of type "tag name".
- *
- * Note that there are three positions associated with a region, the start,
- * the end, and the end of the text. The end of the region should always be
- * greater than or equal to the end of the text, because the end of the text
- * simply includes any white space that might follow the non-whitespace
- * portion of the region. This whitespace is assumed to be ignorable except
- * for reasons of maintaining it in the original document for formatting,
- * appearance, etc.
- *
- */
-public interface ITextRegion {
-
- /**
- * For use by parsers and reparsers only.
- */
- void adjustLengthWith(int i);
-
- /**
- * For use by parsers and reparsers only.
- */
- void adjustStart(int i);
-
- /**
- *
- * For use by parsers and reparsers only.
- */
- void adjustTextLength(int i);
-
- void equatePositions(ITextRegion region);
-
- int getEnd();
-
- int getLength();
-
- int getStart();
-
- /**
- * In some implementations, the "end" of the region (accessible via
- * getEnd()) also contains any and all white space that may or may not be
- * present after the "token" (read: relevant) part of the region. This
- * method, getTextEnd(), is specific for the "token" part of the region,
- * without the whitespace.
- */
- int getTextEnd();
-
- /**
- * The text length is equal to length if there is no white space at the
- * end of a region. Otherwise it is smaller than length.
- */
- int getTextLength();
-
- String getType();
-
- /**
- * @deprecated - few implement this in a meaningful way.
- */
- StructuredDocumentEvent updateModel(Object requester, IStructuredDocumentRegion parent, String changes, int requestStart, int lengthToReplace);
-
-}
diff --git a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/text/ITextRegionCollection.java b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/text/ITextRegionCollection.java
deleted file mode 100644
index 5d933ae32b..0000000000
--- a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/text/ITextRegionCollection.java
+++ /dev/null
@@ -1,59 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Jens Lukowski/Innoopract - initial renaming/restructuring
- *
- *******************************************************************************/
-package org.eclipse.wst.sse.core.text;
-
-public interface ITextRegionCollection extends ITextRegion {
-
- boolean containsOffset(int i);
-
- boolean containsOffset(ITextRegion region, int i);
-
- void equatePositions(ITextRegion region);
-
- int getEndOffset();
-
- int getEndOffset(ITextRegion containedRegion);
-
- ITextRegion getFirstRegion();
-
- String getFullText();
-
- String getFullText(ITextRegion containedRegion);
-
- ITextRegion getLastRegion();
-
- int getLength();
-
- int getNumberOfRegions();
-
- ITextRegion getRegionAtCharacterOffset(int offset);
-
- ITextRegionList getRegions();
-
- int getStartOffset();
-
- int getStartOffset(ITextRegion containedRegion);
-
- String getText();
-
- String getText(ITextRegion containedRegion);
-
- int getTextEndOffset();
-
- int getTextEndOffset(ITextRegion containedRegion);
-
- /**
- * For use by parsers and reparsers only.
- */
- void setRegions(ITextRegionList embeddedRegions);
-}
diff --git a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/text/ITextRegionContainer.java b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/text/ITextRegionContainer.java
deleted file mode 100644
index f720a453b4..0000000000
--- a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/text/ITextRegionContainer.java
+++ /dev/null
@@ -1,27 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Jens Lukowski/Innoopract - initial renaming/restructuring
- *
- *******************************************************************************/
-package org.eclipse.wst.sse.core.text;
-
-/**
- *
- */
-public interface ITextRegionContainer extends ITextRegionCollection {
-
- ITextRegionCollection getParent();
-
- /**
- * For use by parsers and reparsers only.
- */
-
- void setParent(ITextRegionCollection parent);
-}
diff --git a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/text/ITextRegionList.java b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/text/ITextRegionList.java
deleted file mode 100644
index d38d3f2b6a..0000000000
--- a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/text/ITextRegionList.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Jens Lukowski/Innoopract - initial renaming/restructuring
- *
- *******************************************************************************/
-package org.eclipse.wst.sse.core.text;
-
-import java.util.Iterator;
-
-
-public interface ITextRegionList {
- public boolean add(ITextRegion region);
-
- public boolean addAll(int insertPos, ITextRegionList newRegions);
-
- public void clear();
-
- public ITextRegion get(int index);
-
- public int indexOf(ITextRegion region);
-
- public boolean isEmpty();
-
- public Iterator iterator();
-
- public ITextRegion remove(int index);
-
- public void remove(ITextRegion region);
-
- public void removeAll(ITextRegionList regionList);
-
- public int size();
-
- public ITextRegion[] toArray();
-
-}
diff --git a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/text/SimpleStructuredRegion.java b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/text/SimpleStructuredRegion.java
deleted file mode 100644
index 4ab5c4ab30..0000000000
--- a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/text/SimpleStructuredRegion.java
+++ /dev/null
@@ -1,91 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Jens Lukowski/Innoopract - initial renaming/restructuring
- *
- *******************************************************************************/
-package org.eclipse.wst.sse.core.text;
-
-import org.eclipse.jface.text.IRegion;
-
-
-
-/**
- * Similar to jface region except we wanted a setting on length
- */
-public class SimpleStructuredRegion implements StructuredRegion {
- /** The region length */
- private int fLength;
-
- /** The region offset */
- private int fOffset;
-
- /**
- * Create a new region.
- *
- * @param offset
- * the offset of the region
- * @param length
- * the length of the region
- */
- public SimpleStructuredRegion(int offset, int length) {
- fOffset = offset;
- fLength = length;
- }
-
- /**
- * Two regions are equal if they have the same offset and length.
- *
- * @see Object#equals
- */
- public boolean equals(Object o) {
- if (o instanceof IRegion) {
- IRegion r = (IRegion) o;
- return r.getOffset() == fOffset && r.getLength() == fLength;
- }
- return false;
- }
-
- /*
- * @see IRegion#getLength
- */
- public int getLength() {
- return fLength;
- }
-
- /*
- * @see IRegion#getOffset
- */
- public int getOffset() {
- return fOffset;
- }
-
- /**
- * @see Object#hashCode hascode is overridden since we provide our own
- * equals.
- */
- public int hashCode() {
- return (fOffset << 24) | (fLength << 16);
- }
-
- /**
- * Sets the length.
- *
- * @param length
- * The length to set
- */
- public void setLength(int length) {
- fLength = length;
- }
-
- public void setOffset(int offset) {
- fOffset = offset;
- }
-
-}
diff --git a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/text/SimpleStructuredTypedRegion.java b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/text/SimpleStructuredTypedRegion.java
deleted file mode 100644
index f4f1117b72..0000000000
--- a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/text/SimpleStructuredTypedRegion.java
+++ /dev/null
@@ -1,87 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Jens Lukowski/Innoopract - initial renaming/restructuring
- *
- *******************************************************************************/
-package org.eclipse.wst.sse.core.text;
-
-
-
-/**
- * Similar jace TypedRegion, but had to subclass our version which allowed
- * length to be set.
- */
-public class SimpleStructuredTypedRegion extends SimpleStructuredRegion implements StructuredTypedRegion {
-
- /** The region's type */
- private String fType;
-
- /**
- * Creates a typed region based on the given specification.
- *
- * @param offset
- * the region's offset
- * @param length
- * the region's length
- * @param type
- * the region's type
- */
- public SimpleStructuredTypedRegion(int offset, int length, String type) {
- super(offset, length);
- fType = type;
- }
-
- /**
- * Two typed positions are equal if they have the same offset, length, and
- * type.
- *
- * @see Object#equals
- */
- public boolean equals(Object o) {
- if (o instanceof SimpleStructuredTypedRegion) {
- SimpleStructuredTypedRegion r = (SimpleStructuredTypedRegion) o;
- return super.equals(r) && ((fType == null && r.getType() == null) || fType.equals(r.getType()));
- }
- return false;
- }
-
- /*
- * @see ITypedRegion#getType()
- */
- public String getType() {
- return fType;
- }
-
- /*
- * @see Object#hashCode
- */
- public int hashCode() {
- int type = fType == null ? 0 : fType.hashCode();
- return super.hashCode() | type;
- }
-
- public void setType(String type) {
- fType = type;
- }
-
- /**
- * @see java.lang.Object#toString()
- */
- public String toString() {
- StringBuffer s = new StringBuffer();
- s.append(getOffset());
- s.append(":"); //$NON-NLS-1$
- s.append(getLength());
- s.append(" - "); //$NON-NLS-1$
- s.append(getType());
- return s.toString();
- }
-
-}
diff --git a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/text/StructuredRegion.java b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/text/StructuredRegion.java
deleted file mode 100644
index b1face686e..0000000000
--- a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/text/StructuredRegion.java
+++ /dev/null
@@ -1,27 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Jens Lukowski/Innoopract - initial renaming/restructuring
- *
- *******************************************************************************/
-package org.eclipse.wst.sse.core.text;
-
-import org.eclipse.jface.text.IRegion;
-
-/**
- * Like super class except allows length and offset to be modified. This is
- * convenient for some algorithms, and allows region objects to be reused.
- * Note: There MIGHT be some code that assumes regions are immutable. This
- * class would not be appropriate for those uses.
- */
-public interface StructuredRegion extends IRegion {
- void setLength(int length);
-
- void setOffset(int offset);
-}
diff --git a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/text/StructuredTypedRegion.java b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/text/StructuredTypedRegion.java
deleted file mode 100644
index e4aee0036b..0000000000
--- a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/text/StructuredTypedRegion.java
+++ /dev/null
@@ -1,24 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Jens Lukowski/Innoopract - initial renaming/restructuring
- *
- *******************************************************************************/
-package org.eclipse.wst.sse.core.text;
-
-import org.eclipse.jface.text.ITypedRegion;
-
-/**
- * Similar to extended interface, except it allows the length, offset, and
- * type to be set. This is useful when iterating through a number of "small"
- * regions, that all map to the the same partion regions.
- */
-public interface StructuredTypedRegion extends StructuredRegion, ITypedRegion {
- void setType(String type);
-}
diff --git a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/text/rules/StructuredTextPartitioner.java b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/text/rules/StructuredTextPartitioner.java
deleted file mode 100644
index 9935668d09..0000000000
--- a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/text/rules/StructuredTextPartitioner.java
+++ /dev/null
@@ -1,609 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Jens Lukowski/Innoopract - initial renaming/restructuring
- *
- *******************************************************************************/
-package org.eclipse.wst.sse.core.text.rules;
-
-
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Locale;
-
-import org.eclipse.jface.text.DocumentEvent;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.IDocumentPartitioner;
-import org.eclipse.jface.text.ITypedRegion;
-import org.eclipse.wst.sse.core.events.StructuredDocumentRegionsReplacedEvent;
-import org.eclipse.wst.sse.core.internal.parser.ForeignRegion;
-import org.eclipse.wst.sse.core.parser.IBlockedStructuredDocumentRegion;
-import org.eclipse.wst.sse.core.text.IStructuredDocument;
-import org.eclipse.wst.sse.core.text.IStructuredDocumentRegion;
-import org.eclipse.wst.sse.core.text.ITextRegion;
-import org.eclipse.wst.sse.core.text.ITextRegionContainer;
-import org.eclipse.wst.sse.core.text.ITextRegionList;
-import org.eclipse.wst.sse.core.text.SimpleStructuredTypedRegion;
-import org.eclipse.wst.sse.core.text.StructuredRegion;
-import org.eclipse.wst.sse.core.text.StructuredTypedRegion;
-
-
-/**
- * Base Document partitioner for StructuredDocuments. BLOCK_TEXT ITextRegions
- * have a partition type of BLOCK or BLOCK:TAGNAME if a surrounding tagname
- * was recorded.
- */
-public class StructuredTextPartitioner implements IDocumentPartitioner {
-
- static class CachedComputedPartitions {
- int fLength;
- int fOffset;
- ITypedRegion[] fPartitions;
- boolean isInValid;
-
- CachedComputedPartitions(int offset, int length, ITypedRegion[] partitions) {
- fOffset = offset;
- fLength = length;
- fPartitions = partitions;
- isInValid = true;
- }
- }
-
- public final static String ST_DEFAULT_PARTITION = "org.eclipse.wst.sse.ST_DEFAULT"; //$NON-NLS-1$
- public final static String ST_UNKNOWN_PARTITION = "org.eclipse.wst.sse.UNKNOWN_PARTITION_TYPE"; //$NON-NLS-1$
- private CachedComputedPartitions cachedPartitions = new CachedComputedPartitions(-1, -1, null);
- protected String[] fSupportedTypes = null;
- protected StructuredTypedRegion internalReusedTempInstance = new SimpleStructuredTypedRegion(0, 0, ST_DEFAULT_PARTITION);
- protected IStructuredDocument structuredDocument;
-
- /**
- * StructuredTextPartitioner constructor comment.
- */
- public StructuredTextPartitioner() {
- super();
- }
-
- /**
- * Returns the partitioning of the given range of the connected document.
- * There must be a document connected to this partitioner.
- *
- * Note: this shouldn't be called dirctly by clients, unless they control
- * the threading that includes modifications to the document. Otherwise
- * the document could be modified while partitions are being computed. We
- * advise that clients use the computePartions API directly from the
- * document, so they won't have to worry about that.
- *
- * @param offset
- * the offset of the range of interest
- * @param length
- * the length of the range of interest
- * @return the partitioning of the range
- */
- public ITypedRegion[] computePartitioning(int offset, int length) {
- if (structuredDocument == null) {
- throw new IllegalStateException("document partitioner is not connected"); //$NON-NLS-1$
- }
- ITypedRegion[] results = null;
-
-
-
- if ((!cachedPartitions.isInValid) && (offset == cachedPartitions.fOffset) && (length == cachedPartitions.fLength)) {
- results = cachedPartitions.fPartitions;
- } else {
-
- if (length == 0) {
- results = new ITypedRegion[]{getPartition(offset)};
- } else {
- List list = new ArrayList();
- int endPos = offset + length;
- if (endPos > structuredDocument.getLength()) {
- // This can occur if the model instance is being
- // changed
- // and everyone's not yet up to date
- return new ITypedRegion[]{createPartition(offset, length, getUnknown())};
- }
- int currentPos = offset;
- StructuredTypedRegion previousPartition = null;
- while (currentPos < endPos) {
- internalGetPartition(currentPos, false);
- currentPos += internalReusedTempInstance.getLength();
- // check if this partition just continues last one
- // (type is the same),
- // if so, just extend length of last one, not need to
- // create new
- // instance.
- if (previousPartition != null && internalReusedTempInstance.getType().equals(previousPartition.getType())) {
- // same partition type
- previousPartition.setLength(previousPartition.getLength() + internalReusedTempInstance.getLength());
- } else {
- // not the same, so add to list
- StructuredTypedRegion partition = createNewPartitionInstance();
- list.add(partition);
- // and make current, previous
- previousPartition = partition;
- }
- }
- results = new ITypedRegion[list.size()];
- list.toArray(results);
- }
- if (results.length > 0) {
- // truncate returned results to requested range
- if (results[0].getOffset() < offset && results[0] instanceof StructuredRegion) {
- ((StructuredRegion) results[0]).setOffset(offset);
- }
- int lastEnd = results[results.length - 1].getOffset() + results[results.length - 1].getLength();
- if (lastEnd > offset + length && results[results.length - 1] instanceof StructuredRegion) {
- ((StructuredRegion) results[results.length - 1]).setLength(offset + length - results[results.length - 1].getOffset());
- }
- }
- cachedPartitions.fLength = length;
- cachedPartitions.fOffset = offset;
- cachedPartitions.fPartitions = results;
- cachedPartitions.isInValid = false;
- }
- return results;
- }
-
-
-
- /**
- * Connects the document to the partitioner, i.e. indicates the begin of
- * the usage of the receiver as partitioner of the given document.
- */
- public synchronized void connect(IDocument document) {
- if (document instanceof IStructuredDocument) {
- cachedPartitions.isInValid = true;
- this.structuredDocument = (IStructuredDocument) document;
- } else {
- throw new IllegalArgumentException("This class and API are for Structured Documents only"); //$NON-NLS-1$
- }
- }
-
- /**
- * Determines if the given ITextRegionContainer itself contains another
- * ITextRegionContainer
- *
- * @param ITextRegionContainer
- * @return boolean
- */
- protected boolean containsEmbeddedRegion(IStructuredDocumentRegion container) {
- boolean containsEmbeddedRegion = false;
-
- ITextRegionList regions = container.getRegions();
- for (int i = 0; i < regions.size(); i++) {
- ITextRegion region = regions.get(i);
- if (region instanceof ITextRegionContainer) {
- containsEmbeddedRegion = true;
- break;
- }
- }
- return containsEmbeddedRegion;
- }
-
- private StructuredTypedRegion createNewPartitionInstance() {
- return new SimpleStructuredTypedRegion(internalReusedTempInstance.getOffset(), internalReusedTempInstance.getLength(), internalReusedTempInstance.getType());
- }
-
- /**
- * Creates the concrete partition from the given values. Returns a new
- * instance for each call.
- *
- * Subclasses may override.
- *
- * @param offset
- * @param length
- * @param type
- * @return ITypedRegion
- *
- * TODO: should be protected
- */
- public StructuredTypedRegion createPartition(int offset, int length, String type) {
- return new SimpleStructuredTypedRegion(offset, length, type);
- }
-
- /**
- * Disconnects the document from the partitioner, i.e. indicates the end
- * of the usage of the receiver as partitioner of the given document.
- *
- * @see org.eclipse.jface.text.IDocumentPartitioner#disconnect()
- */
- public synchronized void disconnect() {
- cachedPartitions.isInValid = true;
- this.structuredDocument = null;
- }
-
- /**
- * Informs about a forthcoming document change.
- *
- * @see org.eclipse.jface.text.IDocumentPartitioner#documentAboutToBeChanged(DocumentEvent)
- */
- public void documentAboutToBeChanged(DocumentEvent event) {
- cachedPartitions.isInValid = true;
- }
-
- /**
- * The document has been changed. The partitioner updates the set of
- * regions and returns whether the structure of the document partitioning
- * has been changed, i.e. whether partitions have been added or removed.
- *
- * @see org.eclipse.jface.text.IDocumentPartitioner#documentChanged(DocumentEvent)
- */
- public boolean documentChanged(DocumentEvent event) {
- boolean result = false;
- if (event instanceof StructuredDocumentRegionsReplacedEvent) {
- // partitions don't always change while document regions do,
- // but that's the only "quick check" we have.
- // I'm not sure if something more sophisticated will be needed
- // in the future. (dmw, 02/18/04).
- result = true;
- }
- return result;
- }
-
- protected boolean doParserSpecificCheck(int offset, boolean partitionFound, IStructuredDocumentRegion sdRegion, IStructuredDocumentRegion previousStructuredDocumentRegion, ITextRegion next, ITextRegion previousStart) {
- // this (conceptually) abstract method is not concerned with
- // specific region types
- return false;
- }
-
- /**
- * Returns the content type of the partition containing the given
- * character position of the given document. The document has previously
- * been connected to the partitioner.
- *
- * @see org.eclipse.jface.text.IDocumentPartitioner#getContentType(int)
- */
- public String getContentType(int offset) {
- return getPartition(offset).getType();
- }
-
- /**
- * To be used by default!
- */
- public String getDefault() {
-
- return ST_DEFAULT_PARTITION;
- }
-
- /**
- * Returns the set of all possible content types the partitoner supports.
- * I.e. Any result delivered by this partitioner may not contain a content
- * type which would not be included in this method's result.
- *
- * @see org.eclipse.jface.text.IDocumentPartitioner#getLegalContentTypes()
- */
- public java.lang.String[] getLegalContentTypes() {
- if (fSupportedTypes == null) {
- initLegalContentTypes();
- }
- return fSupportedTypes;
- }
-
- /**
- * Returns the partition containing the given character position of the
- * given document. The document has previously been connected to the
- * partitioner.
- *
- * Note: this shouldn't be called dirctly by clients, unless they control
- * the threading that includes modifications to the document. Otherwise
- * the document could be modified while partitions are being computed. We
- * advise that clients use the getPartition API directly from the
- * document, so they won't have to worry about that.
- *
- *
- *
- * @see org.eclipse.jface.text.IDocumentPartitioner#getPartition(int)
- */
- public ITypedRegion getPartition(int offset) {
- internalGetPartition(offset, true);
- return createNewPartitionInstance();
- }
-
- protected String getPartitionFromBlockedText(ITextRegion region, int offset, String result) {
- // parser sensitive code was moved to subclass for quick transition
- // this (conceptually) abstract version isn't concerned with blocked
- // text
-
- return result;
- }
-
- protected String getPartitionType(ForeignRegion region, int offset) {
- String tagname = region.getSurroundingTag();
- String result = null;
- if (tagname != null) {
- result = "BLOCK:" + tagname.toUpperCase(Locale.ENGLISH); //$NON-NLS-1$
- } else {
- result = "BLOCK"; //$NON-NLS-1$
- }
- return result;
- }
-
- /**
- * @see com.ibm.sed.model.StructuredTextPartitioner#getPartitionType(com.ibm.sed.structuredDocument.ITextRegion)
- */
- protected String getPartitionType(IBlockedStructuredDocumentRegion blockedStructuredDocumentRegion, int offset) {
- String result = null;
- ITextRegionList regions = blockedStructuredDocumentRegion.getRegions();
-
- // regions should never be null, or hold zero regions, but just in
- // case...
- if (regions != null && regions.size() > 0) {
- if (regions.size() == 1) {
- // if only one, then its a "pure" blocked note.
- // if more than one, then must contain some embedded region
- // container
- ITextRegion blockedRegion = regions.get(0);
- // double check for code safefy, though should always be true
- if (blockedRegion instanceof ForeignRegion) {
- result = getPartitionType((ForeignRegion) blockedRegion, offset);
- }
- } else {
- // must have some embedded region container, so we'll make
- // sure we'll get the appropriate one
- result = getReleventRegionType(blockedStructuredDocumentRegion, offset);
- }
- }
- return result;
- }
-
- /**
- * Method getPartitionType.
- *
- * @param region
- * @return String
- */
- private String getPartitionType(ITextRegion region) {
- // if it get's to this "raw" level, then
- // must be default.
- return getDefault();
- }
-
- /**
- * Returns the partition based on region type. This basically maps from
- * one region-type space to another, higher level, region-type space.
- *
- * @param region
- * @param offset
- * @return String
- */
- protected String getPartitionType(ITextRegion region, int offset) {
- String result = getDefault();
- // if (region instanceof ContextRegionContainer) {
- // result = getPartitionType((ITextRegionContainer) region, offset);
- // } else {
- if (region instanceof ITextRegionContainer) {
- result = getPartitionType((ITextRegionContainer) region, offset);
- }
-
- result = getPartitionFromBlockedText(region, offset, result);
-
- return result;
-
- }
-
- /**
- * Similar to method with 'ITextRegion' as argument, except for
- * RegionContainers, if it has embedded regions, then we need to drill
- * down and return DocumentPartition based on "lowest level" region type.
- * For example, in <body id=" <%= object.getID() %>" > The text between
- * <%= and %> would be a "java region" not an "HTML region".
- */
- protected String getPartitionType(ITextRegionContainer region, int offset) {
- // TODO this method needs to be 'cleaned up' after refactoring
- // its instanceof logic seems messed up now.
- String result = null;
- if (region != null) {
- ITextRegion coreRegion = region;
- if (coreRegion instanceof ITextRegionContainer) {
- result = getPartitionType((ITextRegionContainer) coreRegion, ((ITextRegionContainer) coreRegion).getRegions(), offset);
- } else {
- result = getPartitionType(region);
- }
- } else {
- result = getPartitionType((ITextRegion) region, offset);
- }
-
- return result;
- }
-
- private String getPartitionType(ITextRegionContainer coreRegion, ITextRegionList regions, int offset) {
- String result = null;
- for (int i = 0; i < regions.size(); i++) {
- ITextRegion region = regions.get(i);
- if (coreRegion.containsOffset(region, offset)) {
- result = getPartitionType(region, offset);
- break;
- }
- }
- return result;
- }
-
- /**
- * Computes the partition type for the zero-length partition between a
- * start tag and end tag with the given name regions.
- *
- * @param previousStartTagNameRegion
- * @param nextEndTagNameRegion
- * @return String
- */
- protected String getPartitionTypeBetween(IStructuredDocumentRegion previousNode, ITextRegion previousStartTagNameRegion, IStructuredDocumentRegion nextNode, ITextRegion nextEndTagNameRegion) {
- return getDefault();
- }
-
- /**
- * Return the ITextRegion at the given offset. For most cases, this will
- * be the flatNode itself. Should it contain an embedded
- * ITextRegionContainer, will return the internal region at the offset
- *
- *
- * @param flatNode
- * @param offset
- * @return ITextRegion
- */
- private String getReleventRegionType(IStructuredDocumentRegion flatNode, int offset) {
- // * Note: the original form of this method -- which returned "deep"
- // region, isn't that
- // * useful, after doing parent elimination refactoring,
- // * since once the deep region is returned, its hard to get its text
- // or offset without
- // * proper parent.
- ITextRegion resultRegion = null;
- if (containsEmbeddedRegion(flatNode)) {
- resultRegion = flatNode.getRegionAtCharacterOffset(offset);
- if (resultRegion instanceof ITextRegionContainer) {
- resultRegion = flatNode.getRegionAtCharacterOffset(offset);
- ITextRegionList regions = ((ITextRegionContainer) resultRegion).getRegions();
- for (int i = 0; i < regions.size(); i++) {
- ITextRegion region = regions.get(i);
- if (flatNode.getStartOffset(region) <= offset && offset < flatNode.getEndOffset(region)) {
- resultRegion = region;
- break;
- }
- }
- }
- } else {
- resultRegion = flatNode;
- }
- return resultRegion.getType();
- }
-
- /**
- * To be used, instead of default, when there is some thing surprising
- * about are attempt to partition
- */
- protected String getUnknown() {
- return ST_UNKNOWN_PARTITION;
- }
-
- /**
- * to be abstract eventually
- */
- protected void initLegalContentTypes() {
- fSupportedTypes = new String[]{ST_DEFAULT_PARTITION, ST_UNKNOWN_PARTITION};
- }
-
- /**
- * Returns the partition containing the given character position of the
- * given document. The document has previously been connected to the
- * partitioner. If the checkBetween parameter is true, an offset between a
- * start and end tag will return a zero-length region.
- */
- private void internalGetPartition(int offset, boolean checkBetween) {
- if (structuredDocument == null) {
- throw new IllegalStateException("document partitioner is not connected"); //$NON-NLS-1$
- }
-
- boolean partitionFound = false;
- int docLength = structuredDocument.getLength();
- // get document region type and map to partition type :
- // Note: a partion can be smaller than a flatnode, if that flatnode
- // contains a region container.
- // That's why we need to get "relevent region".
- IStructuredDocumentRegion structuredDocumentRegion = structuredDocument.getRegionAtCharacterOffset(offset);
- // flatNode is null if empty document
- // this is king of a "normal case" for empty document
- if (structuredDocumentRegion == null && docLength == 0) {
- // In order to prevent infinite error loops, this partition must
- // never have a zero length
- // unless the document is also zero length
- setInternalPartition(offset, 0, getDefault());
- partitionFound = true;
- } else if (structuredDocumentRegion == null && docLength != 0) {
- // this case is "unusual". When would region be null, and document
- // longer
- // than 0. I think this means somethings "out of sync". And we may
- // want
- // to "flag" that fact and just return one big region of
- // 'unknown', instead
- // of one character at a time.
- setInternalPartition(offset, 1, getUnknown());
- partitionFound = true;
- } else if (checkBetween) {
- // dmw: minimizes out to the first if test above
- // if (structuredDocumentRegion == null && docLength == 0) {
- // // known special case for an empty document
- // setInternalPartition(offset, 0, getDefault());
- // partitionFound = true;
- // }
- // else
- if (structuredDocumentRegion.getStartOffset() == offset) {
- IStructuredDocumentRegion previousStructuredDocumentRegion = structuredDocumentRegion.getPrevious();
- if (previousStructuredDocumentRegion != null) {
- ITextRegion next = structuredDocumentRegion.getRegionAtCharacterOffset(offset);
- ITextRegion previousStart = previousStructuredDocumentRegion.getRegionAtCharacterOffset(previousStructuredDocumentRegion.getStartOffset());
- partitionFound = doParserSpecificCheck(offset, partitionFound, structuredDocumentRegion, previousStructuredDocumentRegion, next, previousStart);
- }
- }
- }
- // dmw: Given the first two tests above minimize to this, this block
- // can never run, right?
- // else if (structuredDocumentRegion == null) {
- // setInternalPartition(offset, 0, getDefault());
- // partitionFound = true;
- // }
-
- if (!partitionFound) {
- ITextRegion resultRegion = structuredDocumentRegion.getRegionAtCharacterOffset(offset);
- partitionFound = isDocumentRegionBasedPartition(structuredDocumentRegion, resultRegion, offset);
- if (!partitionFound) {
- // Note: this new logic doesn't handle container regions
- // inside of
- // container regions ... may need to make this first clause
- // a recursive method
- if (resultRegion != null && resultRegion instanceof ITextRegionContainer) {
- ITextRegionContainer containerRegion = (ITextRegionContainer) resultRegion;
- // then need to "drill down" for relevent region and
- // relevent offset
- ITextRegion deepRegion = containerRegion.getRegionAtCharacterOffset(offset);
- int endOffset = containerRegion.getEndOffset(deepRegion);
- String type = getPartitionType(deepRegion, endOffset);
- setInternalPartition(offset, endOffset - offset, type);
- } else {
- if (resultRegion != null) {
- String type = getPartitionType(resultRegion, offset);
- setInternalPartition(offset, structuredDocumentRegion.getEndOffset(resultRegion) - offset, type);
- } else {
- // can happen at EOF
- setInternalPartition(offset, 1, getUnknown());
- }
- }
- }
- }
- }
-
- /**
- * Provides for a per-StructuredDocumentRegion override selecting the
- * partition type using more than just a single ITextRegion.
- *
- * @param structuredDocumentRegion
- * the StructuredDocumentRegion
- * @param containedChildRegion
- * an ITextRegion within the given StructuredDocumentRegion
- * that would normally determine the partition type by itself
- * @param offset
- * the document offset
- * @return true if the partition type will be overridden, false to
- * continue normal processing
- */
- protected boolean isDocumentRegionBasedPartition(IStructuredDocumentRegion structuredDocumentRegion, ITextRegion containedChildRegion, int offset) {
- return false;
- }
-
- public IDocumentPartitioner newInstance() {
- return new StructuredTextPartitioner();
- }
-
- protected void setInternalPartition(int offset, int length, String type) {
- internalReusedTempInstance.setOffset(offset);
- internalReusedTempInstance.setLength(length);
- internalReusedTempInstance.setType(type);
- }
-
-}
diff --git a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/undo/CommandCursorPosition.java b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/undo/CommandCursorPosition.java
deleted file mode 100644
index 1591ae04fe..0000000000
--- a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/undo/CommandCursorPosition.java
+++ /dev/null
@@ -1,66 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Jens Lukowski/Innoopract - initial renaming/restructuring
- *
- *******************************************************************************/
-package org.eclipse.wst.sse.core.undo;
-
-
-
-public interface CommandCursorPosition {
-
- /**
- * Returns the cursor position to be set to after this command is redone.
- *
- * @return int
- */
- int getRedoCursorPosition();
-
- /**
- * Returns the length of text to be selected after this command is redone.
- *
- * @return int
- */
- int getRedoSelectionLength();
-
- /**
- * Returns the cursor position to be set to after this command is undone.
- *
- * @return int
- */
- int getUndoCursorPosition();
-
- /**
- * Returns the length of text to be selected after this command is undone.
- *
- * @return int
- */
- int getUndoSelectionLength();
-
- /**
- * Sets the cursor position to be used after this command is redone.
- */
- void setRedoCursorPosition(int cursorPosition);
-
- /**
- * Sets the length of text to be selected after this command is redone.
- */
- void setRedoSelectionLength(int selectionLength);
-
- /**
- * Sets the cursor position to be used after this command is undone.
- */
- void setUndoCursorPosition(int cursorPosition);
-
- /**
- * Sets the length of text to be selected after this command is undone.
- */
- void setUndoSelectionLength(int selectionLength);
-}
diff --git a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/undo/IDocumentSelectionMediator.java b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/undo/IDocumentSelectionMediator.java
deleted file mode 100644
index f321c38e1d..0000000000
--- a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/undo/IDocumentSelectionMediator.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Jens Lukowski/Innoopract - initial renaming/restructuring
- *
- *******************************************************************************/
-package org.eclipse.wst.sse.core.undo;
-
-import org.eclipse.jface.text.IDocument;
-
-
-public interface IDocumentSelectionMediator {
- /**
- * Returns the document selection mediator's input document.
- *
- * @return the document selection mediator's input document
- */
- IDocument getDocument();
-
- /**
- * Sets a new selection in the document as a result of an undo operation.
- *
- * UndoDocumentEvent contains the requester of the undo operation, and the
- * offset and length of the new selection. Implementation of
- * IDocumentSelectionMediator can check if it's the requester that caused
- * the new selection, and decide if the new selection should be applied.
- */
- void undoOperationSelectionChanged(UndoDocumentEvent event);
-}
diff --git a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/undo/IStructuredTextUndoManager.java b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/undo/IStructuredTextUndoManager.java
deleted file mode 100644
index 5f65824b6f..0000000000
--- a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/undo/IStructuredTextUndoManager.java
+++ /dev/null
@@ -1,155 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Jens Lukowski/Innoopract - initial renaming/restructuring
- *
- *******************************************************************************/
-package org.eclipse.wst.sse.core.undo;
-
-import org.eclipse.emf.common.command.Command;
-import org.eclipse.emf.common.command.CommandStack;
-
-public interface IStructuredTextUndoManager {
-
- /**
- * Begin recording undo transactions.
- */
- void beginRecording(Object requester);
-
- /**
- * Begin recording undo transactions.
- */
- void beginRecording(Object requester, int cursorPosition, int selectionLength);
-
- /**
- * Begin recording undo transactions.
- */
- void beginRecording(Object requester, String label);
-
- /**
- * Begin recording undo transactions.
- */
- void beginRecording(Object requester, String label, int cursorPosition, int selectionLength);
-
- /**
- * Begin recording undo transactions.
- */
- void beginRecording(Object requester, String label, String description);
-
- /**
- * Begin recording undo transactions.
- */
- void beginRecording(Object requester, String label, String description, int cursorPosition, int selectionLength);
-
- /**
- * Connect the mediator to the undo manager.
- */
- void connect(IDocumentSelectionMediator mediator);
-
- /**
- * Disable undo management.
- */
- void disableUndoManagement();
-
- /**
- * Disconnect the mediator from the undo manager.
- */
- void disconnect(IDocumentSelectionMediator mediator);
-
- /**
- * Enable undo management.
- */
- void enableUndoManagement();
-
- /**
- * End recording undo transactions.
- */
- void endRecording(Object requester);
-
- /**
- * End recording undo transactions.
- */
- void endRecording(Object requester, int cursorPosition, int selectionLength);
-
- /**
- * <p>
- * Normally, the undo manager can figure out the best times when to end a
- * pending command and begin a new one ... to the structure of a structued
- * document. There are times, however, when clients may wish to override
- * those algorithms and end one earlier than normal. The one known case is
- * for multipage editors. If a user is on one page, and type '123' as
- * attribute value, then click around to other parts of page, or different
- * pages, then return to '123|' and type 456, then "undo" they typically
- * expect the undo to just undo what they just typed, the 456, not the
- * whole attribute value.
- * <p>
- * If there is no pending command, the request is ignored.
- */
- public void forceEndOfPendingCommand(Object requester, int currentPosition, int length);
-
- /**
- * Some clients need to do complicated things with undo stack. Plus, in
- * some cases, if clients setCommandStack temporarily, they have
- * reponsibility to set back to original one when finished.
- */
- public CommandStack getCommandStack();
-
- /**
- * Get the redo command even if it's not committed yet.
- */
- Command getRedoCommand();
-
- /**
- * Get the undo command even if it's not committed yet.
- */
- Command getUndoCommand();
-
- /**
- * Redo the last command in the undo manager.
- */
- void redo();
-
- /**
- * Redo the last command in the undo manager and notify the requester
- * about the new selection.
- */
- void redo(IDocumentSelectionMediator requester);
-
- /**
- * Returns whether at least one text change can be repeated. A text change
- * can be repeated only if it was executed and rolled back.
- *
- * @return <code>true</code> if at least on text change can be repeated
- */
- boolean redoable();
-
- /**
- * Set the command stack.
- */
- void setCommandStack(CommandStack commandStack);
-
- /**
- * Undo the last command in the undo manager.
- */
- void undo();
-
- /**
- * Undo the last command in the undo manager and notify the requester
- * about the new selection.
- */
- void undo(IDocumentSelectionMediator requester);
-
- /**
- * Returns whether at least one text change can be rolled back.
- *
- * @return <code>true</code> if at least one text change can be rolled
- * back
- */
- boolean undoable();
-}
diff --git a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/undo/StructuredTextCommand.java b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/undo/StructuredTextCommand.java
deleted file mode 100644
index cb0e44b0be..0000000000
--- a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/undo/StructuredTextCommand.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Jens Lukowski/Innoopract - initial renaming/restructuring
- *
- *******************************************************************************/
-package org.eclipse.wst.sse.core.undo;
-
-
-
-public interface StructuredTextCommand {
-
- String getTextDeleted();
-
- int getTextEnd();
-
- String getTextInserted();
-
- int getTextStart();
-
- void setTextDeleted(String textDeleted);
-
- void setTextEnd(int textEnd);
-
- void setTextInserted(String textInserted);
-
- void setTextStart(int textStart);
-}
diff --git a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/undo/UndoDocumentEvent.java b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/undo/UndoDocumentEvent.java
deleted file mode 100644
index f608829df7..0000000000
--- a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/undo/UndoDocumentEvent.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Jens Lukowski/Innoopract - initial renaming/restructuring
- *
- *******************************************************************************/
-package org.eclipse.wst.sse.core.undo;
-
-import org.eclipse.jface.text.IDocument;
-
-public class UndoDocumentEvent {
- private IDocument fDocument;
- private int fLength;
- private int fOffset;
- private IDocumentSelectionMediator fRequester;
-
- public UndoDocumentEvent(IDocumentSelectionMediator requester, IDocument document, int offset, int length) {
- fRequester = requester;
- fDocument = document;
- fOffset = offset;
- fLength = length;
- }
-
- public IDocument getDocument() {
- return fDocument;
- }
-
- public int getLength() {
- return fLength;
- }
-
- public int getOffset() {
- return fOffset;
- }
-
- public IDocumentSelectionMediator getRequester() {
- return fRequester;
- }
-}
diff --git a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/util/Assert.java b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/util/Assert.java
deleted file mode 100644
index 5fb1d0de65..0000000000
--- a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/util/Assert.java
+++ /dev/null
@@ -1,166 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Jens Lukowski/Innoopract - initial renaming/restructuring
- *
- *******************************************************************************/
-package org.eclipse.wst.sse.core.util;
-
-import org.eclipse.wst.sse.core.internal.Logger;
-
-/**
- * <code>Assert</code> is useful for for embedding runtime sanity checks in
- * code. The predicate methods all test a condition and throw some type of
- * unchecked exception if the condition does not hold.
- * <p>
- * Assertion failure exceptions, like most runtime exceptions, are thrown when
- * something is misbehaving. Assertion failures are invariably unspecified
- * behavior; consequently, clients should never rely on these being thrown
- * (and certainly should not being catching them specifically).
- * </p>
- */
-public final class Assert {
-
- /**
- * <code>AssertionFailedException</code> is a runtime exception thrown
- * by some of the methods in <code>Assert</code>.
- * <p>
- * This class is not declared public to prevent some misuses; programs
- * that catch or otherwise depend on assertion failures are susceptible to
- * unexpected breakage when assertions in the code are added or removed.
- * </p>
- */
- class AssertionFailedException extends RuntimeException {
- /**
- * Comment for <code>serialVersionUID</code>
- */
- private static final long serialVersionUID = 1L;
-
- /**
- * Constructs a new exception.
- */
- public AssertionFailedException() {
- super();
- }
-
- /**
- * Constructs a new exception with the given message.
- */
- public AssertionFailedException(String detail) {
- super(detail);
- }
- }
-
- /**
- * Asserts that an argument is legal. If the given boolean is not
- * <code>true</code>, an <code>IllegalArgumentException</code> is
- * thrown.
- *
- * @param expression
- * the outcode of the check
- * @return <code>true</code> if the check passes (does not return if the
- * check fails)
- * @exception IllegalArgumentException
- * if the legality test failed
- */
- public static boolean isLegal(boolean expression) {
- return isLegal(expression, ""); //$NON-NLS-1$
- }
-
- /**
- * Asserts that an argument is legal. If the given boolean is not
- * <code>true</code>, an <code>IllegalArgumentException</code> is
- * thrown. The given message is included in that exception, to aid
- * debugging.
- *
- * @param expression
- * the outcode of the check
- * @param message
- * the message to include in the exception
- * @return <code>true</code> if the check passes (does not return if the
- * check fails)
- * @exception IllegalArgumentException
- * if the legality test failed
- */
- public static boolean isLegal(boolean expression, String message) {
- if (!expression)
- throw new IllegalArgumentException();
- return expression;
- }
-
- /**
- * Asserts that the given object is not <code>null</code>. If this is
- * not the case, some kind of unchecked exception is thrown.
- *
- * @param object
- * the value to test
- * @exception IllegalArgumentException
- * if the object is <code>null</code>
- */
- public static void isNotNull(Object object) {
- isNotNull(object, ""); //$NON-NLS-1$
- }
-
- /**
- * Asserts that the given object is not <code>null</code>. If this is
- * not the case, some kind of unchecked exception is thrown. The given
- * message is included in that exception, to aid debugging.
- *
- * @param object
- * the value to test
- * @param message
- * the message to include in the exception
- * @exception IllegalArgumentException
- * if the object is <code>null</code>
- */
- public static void isNotNull(Object object, String message) {
- if (object == null) {
- Logger.log(Logger.ERROR, "null_argument: " + message); //$NON-NLS-1$
- throw new Assert().new AssertionFailedException();
- }
- }
-
- /**
- * Asserts that the given boolean is <code>true</code>. If this is not
- * the case, some kind of unchecked exception is thrown.
- *
- * @param expression
- * the outcode of the check
- * @return <code>true</code> if the check passes (does not return if the
- * check fails)
- */
- public static boolean isTrue(boolean expression) {
- return isTrue(expression, ""); //$NON-NLS-1$
- }
-
- /**
- * Asserts that the given boolean is <code>true</code>. If this is not
- * the case, some kind of unchecked exception is thrown. The given message
- * is included in that exception, to aid debugging.
- *
- * @param expression
- * the outcode of the check
- * @param message
- * the message to include in the exception
- * @return <code>true</code> if the check passes (does not return if the
- * check fails)
- */
- public static boolean isTrue(boolean expression, String message) {
- if (!expression) {
- Logger.log(Logger.ERROR, "assertion failed: " + message); //$NON-NLS-1$
- throw new Assert().new AssertionFailedException();
- }
- return expression;
- }
-
- /* This class is not intended to be instantiated. */
- private Assert() {
- super();
- }
-}
diff --git a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/util/Debug.java b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/util/Debug.java
deleted file mode 100644
index 56f40af3a1..0000000000
--- a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/util/Debug.java
+++ /dev/null
@@ -1,221 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Jens Lukowski/Innoopract - initial renaming/restructuring
- *
- *******************************************************************************/
-package org.eclipse.wst.sse.core.util;
-
-
-
-import java.util.Enumeration;
-
-import org.eclipse.wst.sse.core.text.IStructuredDocument;
-import org.eclipse.wst.sse.core.text.IStructuredDocumentRegion;
-import org.eclipse.wst.sse.core.text.IStructuredDocumentRegionList;
-import org.eclipse.wst.sse.core.text.ITextRegion;
-import org.eclipse.wst.sse.core.text.ITextRegionCollection;
-import org.eclipse.wst.sse.core.text.ITextRegionContainer;
-import org.eclipse.wst.sse.core.text.ITextRegionList;
-
-
-public final class Debug {
- public static final boolean checkForMemoryLeaks = false;
-
- public static final boolean collectStats = false;
-
- public static final int DEBUG = 0;
-
- public static final boolean DEBUG_THREADLOCAL = false;
-
- public static final boolean debugBreakpoints = false;
- public static final boolean debugCaretMediator = false;
- public static final boolean debugDisplayTreePositions = false;
- //
- public static final boolean debugMediator = false;
- //
- public static final boolean debugNotification = false;
- public static final boolean debugNotificationAndEvents = false;
-
- public static final boolean debugNotifyDeferred = false;
- public static final boolean debugReconciling = false;
- //
- public static final boolean debugRtfFormatProvider = false;
- //
- public static final boolean debugStructuredDocument = false;
- public static final boolean debugTaglibs = false;
- //
- public static final boolean debugTokenizer = false;
- //
- public static final boolean debugTreeModel = false;
- public static final boolean debugUpdateTreePositions = false;
- public static final boolean displayInfo = false;
-
- /** effects output of Logger */
- public static final boolean displayToConsole = true;
- public static final boolean displayWarnings = false;
- //
- public static final boolean failedTests = false;
- public static final boolean headParsing = false;
- public static final boolean jsDebugContextAssist = false;
- //
- public static final boolean jsDebugSyntaxColoring = false;
-
- public static final boolean LOCKS = false;
- //
- public static final boolean perfTest = false;
- public static final boolean perfTestAdapterClassLoading = false;
- public static final boolean perfTestFormat = false;
- public static final boolean perfTestRawStructuredDocumentOnly = false;
- public static final boolean perfTestStructuredDocumentEventOnly = false;
- public static final boolean perfTestStructuredDocumentOnly = false;
-
- //
- public static final boolean syntaxHighlighting = false;
- //
- public static final boolean useStandardEolInWidget = false;
-
- /**
- * For tests and debug only
- */
-
- public static final void dump(IStructuredDocument structuredDocument) {
- dump(structuredDocument, false);
- }
-
- public static final void dump(IStructuredDocument structuredDocument, boolean verbose) {
- ITextRegionCollection flatNode = null;
- System.out.println("Dump of structuredDocument:"); //$NON-NLS-1$
- IStructuredDocumentRegionList flatNodes = structuredDocument.getRegionList();
- Enumeration structuredDocumentRegions = flatNodes.elements();
- while (structuredDocumentRegions.hasMoreElements()) {
- flatNode = (ITextRegionCollection) structuredDocumentRegions.nextElement();
- if (!verbose) {
- String outString = flatNode.toString();
- outString = org.eclipse.wst.sse.core.util.StringUtils.escape(outString);
- System.out.println(outString);
- } else {
- dump(flatNode, verbose);
- }
- }
- System.out.println();
- System.out.println("= = = = = ="); //$NON-NLS-1$
- System.out.println();
- }
-
- /**
- * @param flatNode
- * @param verbose
- */
- public static final void dump(ITextRegionCollection region, boolean verbose) {
- if (region == null)
- return;
- if (verbose) {
- printParent(region);
- }
- printChildRegions(region, 0);
- }
-
- private static void printChildRegions(ITextRegionCollection region, int depth) {
- if (region != null) {
- // ==> // ITextRegionCollection regionCollection = region;
- System.out.println(region);
- ITextRegionList regionList = region.getRegions();
- for (int i = 0; i < regionList.size(); i++) {
- ITextRegion r = regionList.get(i);
- if (r instanceof ITextRegionCollection) {
- ITextRegionCollection rc = (ITextRegionCollection) r;
- printChildRegions(rc, depth++);
- } else {
- System.out.println(space(depth) + r);
- depth--;
- }
- }
- }
- }
-
- /**
- * Simple utility to make sure println's are some what in order
- */
- public static final synchronized void println(String msg) {
- System.out.println(System.currentTimeMillis() + "\t" + msg); //$NON-NLS-1$
- }
-
- private static void printParent(IStructuredDocumentRegion region) {
- System.out.println(" [parent document: " + toStringUtil(region.getParentDocument()) + "]"); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- private static void printParent(ITextRegionCollection region) {
- if (region instanceof IStructuredDocumentRegion) {
- printParent((IStructuredDocumentRegion) region);
- } else if (region instanceof ITextRegionContainer) {
- printParent((ITextRegionContainer) region);
- } else
- System.out.println(" [parent document: " + "(na)" + "]"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- }
-
- private static void printParent(ITextRegionContainer region) {
- System.out.println(" [parent document: " + toStringUtil(region.getParent()) + "]"); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- /**
- * @param depth
- * @return
- */
- private static String space(int depth) {
- String result = " "; //$NON-NLS-1$
- for (int i = 0; i < depth; i++) {
- result += " "; //$NON-NLS-1$
- }
- return result;
- }
-
- public static final String toStringUtil(IStructuredDocument object) {
- String className = object.getClass().getName();
- String shortClassName = className.substring(className.lastIndexOf(".") + 1); //$NON-NLS-1$
- // ==> // String resultText = null;
- String result = shortClassName;
- // NOTE: if the document held by any region has been updated and the
- // region offsets have not
- // yet been updated, the output from this method invalid.
- //return com.ibm.sed.util.StringUtils.escape("('"+(getFirstRegion()
- // == null || document == null? "" :
- // getText(getFirstRegion()))+"'"+getStart()+" -
- // "+getEnd()+"'"+(getClose() == null || document == null ||
- // getRegions().size()<2 ? "" : getText(getClose()))+"')
- // "+getRegions());
- return result;
-
- }
-
- public static final String toStringUtil(ITextRegionCollection object) {
- String className = object.getClass().getName();
- String shortClassName = className.substring(className.lastIndexOf(".") + 1); //$NON-NLS-1$
- // ==> // String resultText = null;
- String result = shortClassName;
- // NOTE: if the document held by any region has been updated and the
- // region offsets have not
- // yet been updated, the output from this method invalid.
- //return com.ibm.sed.util.StringUtils.escape("('"+(getFirstRegion()
- // == null || document == null? "" :
- // getText(getFirstRegion()))+"'"+getStart()+" -
- // "+getEnd()+"'"+(getClose() == null || document == null ||
- // getRegions().size()<2 ? "" : getText(getClose()))+"')
- // "+getRegions());
- return result;
-
- }
-
- /**
- * Debug constructor comment.
- */
- public Debug() {
- super();
- }
-}
diff --git a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/util/DocumentInputStream.java b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/util/DocumentInputStream.java
deleted file mode 100644
index e36b217fc2..0000000000
--- a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/util/DocumentInputStream.java
+++ /dev/null
@@ -1,108 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Jens Lukowski/Innoopract - initial renaming/restructuring
- *
- *******************************************************************************/
-package org.eclipse.wst.sse.core.util;
-
-import java.io.IOException;
-import java.io.InputStream;
-
-import org.eclipse.jface.text.BadLocationException;
-import org.eclipse.jface.text.IDocument;
-
-public class DocumentInputStream extends InputStream {
- private IDocument fDocument;
- private int fMark = -1;
- private int fPosition = 0;
-
- public DocumentInputStream(IDocument source) {
- super();
- fDocument = source;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.io.InputStream#available()
- */
- public int available() throws IOException {
- return fDocument.getLength() - fPosition;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.io.InputStream#close()
- */
- public void close() throws IOException {
- this.fDocument = null;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.io.InputStream#mark(int)
- */
- public synchronized void mark(int readlimit) {
- fMark = fPosition;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.io.InputStream#markSupported()
- */
- public boolean markSupported() {
- return true;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.io.InputStream#read()
- */
- public int read() throws IOException {
- try {
- if (fPosition < fDocument.getLength())
- return fDocument.getChar(fPosition++);
- else
- return -1;
- } catch (BadLocationException e) {
- throw new IOException(e.getMessage());
- }
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.io.InputStream#reset()
- */
- public synchronized void reset() throws IOException {
- fPosition = fMark;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.io.InputStream#skip(long)
- */
- public long skip(long n) throws IOException {
- long skipped = n;
- if (n < fDocument.getLength() - fPosition) {
- skipped = n;
- fPosition += skipped;
- } else {
- skipped = fDocument.getLength() - fPosition;
- fPosition = fDocument.getLength();
- }
- return skipped;
- }
-}
diff --git a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/util/JarUtilities.java b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/util/JarUtilities.java
deleted file mode 100644
index 997b66c01f..0000000000
--- a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/util/JarUtilities.java
+++ /dev/null
@@ -1,210 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Jens Lukowski/Innoopract - initial renaming/restructuring
- *
- *******************************************************************************/
-package org.eclipse.wst.sse.core.util;
-
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.File;
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.ArrayList;
-import java.util.Enumeration;
-import java.util.List;
-import java.util.zip.ZipEntry;
-import java.util.zip.ZipFile;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.core.runtime.jobs.ISchedulingRule;
-import org.eclipse.core.runtime.jobs.MultiRule;
-import org.eclipse.wst.sse.core.internal.Logger;
-
-
-public class JarUtilities {
-
- /**
- * @see http://java.sun.com/products/jsp/errata_1_1_a_042800.html, Issues
- * 8 & 9
- *
- * "There are two cases. In both cases the TLD_URI is to be interpreted
- * relative to the root of the Web Application. In the first case the
- * TLD_URI refers to a TLD file directly. In the second case, the TLD_URI
- * refers to a JAR file. If so, that JAR file should have a TLD at
- * location META-INF/taglib.tld."
- */
- public static final String JSP11_TAGLIB = "META-INF/taglib.tld"; //$NON-NLS-1$
-
- public static void closeJarFile(ZipFile file) {
- if (file == null)
- return;
- try {
- file.close();
- }
- catch (IOException ioe) {
- // no cleanup can be done
- Logger.log(Logger.ERROR, "Could not close file " + file.getName()); //$NON-NLS-1$
- }
- }
-
- /**
- * Provides a stream to a local copy of the input or null if not possible
- */
- protected static InputStream getCachedInputStream(String jarFilename, String entryName) {
- File testFile = new File(jarFilename);
- if (!testFile.exists())
- return null;
-
- ISchedulingRule rule = null;
- IFile[] jarIFiles = ResourcesPlugin.getWorkspace().getRoot().findFilesForLocation(new Path(jarFilename));
- ISchedulingRule[] rules = new ISchedulingRule[jarIFiles.length];
- for (int i = 0; i < jarIFiles.length; i++) {
- rules[i] = ResourcesPlugin.getWorkspace().getRuleFactory().deleteRule(jarIFiles[i]);
- }
- if (jarIFiles.length > 0) {
- rule = new MultiRule(rules);
- Platform.getJobManager().beginRule(rule, null);
- }
- ZipFile jarfile = null;
- try {
- jarfile = new ZipFile(jarFilename);
- }
- catch (IOException ioExc) {
- Logger.logException(ioExc);
- closeJarFile(jarfile);
- }
-
- InputStream cache = null;
-
- if (jarfile != null) {
- try {
- ZipEntry zentry = jarfile.getEntry(entryName);
- if (zentry != null) {
- InputStream entryInputStream = null;
- try {
- entryInputStream = jarfile.getInputStream(zentry);
- }
- catch (IOException ioExc) {
- Logger.logException(ioExc);
- }
-
- if (entryInputStream != null) {
- int c;
- ByteArrayOutputStream buffer = null;
- if (zentry.getSize() > 0) {
- buffer = new ByteArrayOutputStream((int) zentry.getSize());
- }
- else {
- buffer = new ByteArrayOutputStream();
- }
- // array dim restriction?
- byte bytes[] = new byte[2048];
- try {
- while ((c = entryInputStream.read(bytes)) >= 0) {
- buffer.write(bytes, 0, c);
- }
- cache = new ByteArrayInputStream(buffer.toByteArray());
- closeJarFile(jarfile);
- }
- catch (IOException ioe) {
- // no cleanup can be done
- }
- finally {
- try {
- entryInputStream.close();
- }
- catch (IOException e) {
- }
- }
- }
- }
- }
- finally {
- closeJarFile(jarfile);
- }
- }
- if (rule != null) {
- Platform.getJobManager().endRule(rule);
- }
- return cache;
- }
-
- public static String[] getEntryNames(IResource jarResource) {
- if (jarResource == null || jarResource.getLocation() == null)
- return new String[0];
- return getEntryNames(jarResource.getLocation().toString());
- }
-
- public static String[] getEntryNames(String jarFilename) {
- return getEntryNames(jarFilename, true);
- }
-
- public static String[] getEntryNames(String jarFilename, boolean excludeDirectories) {
- ISchedulingRule rule = null;
- IFile[] jarIFiles = ResourcesPlugin.getWorkspace().getRoot().findFilesForLocation(new Path(jarFilename));
- ISchedulingRule[] rules = new ISchedulingRule[jarIFiles.length];
- for (int i = 0; i < jarIFiles.length; i++) {
- rules[i] = ResourcesPlugin.getWorkspace().getRuleFactory().deleteRule(jarIFiles[i]);
- }
- if (jarIFiles.length > 0) {
- rule = new MultiRule(rules);
- Platform.getJobManager().beginRule(rule, null);
- }
-
- ZipFile jarfile = null;
- List entryNames = new ArrayList();
- try {
- jarfile = new ZipFile(jarFilename);
- Enumeration entries = jarfile.entries();
- while (entries.hasMoreElements()) {
- ZipEntry z = (ZipEntry) entries.nextElement();
- if (!(z.isDirectory() && excludeDirectories))
- entryNames.add(z.getName());
- }
- }
- catch (IOException ioExc) {
- Logger.log(Logger.WARNING, "JarUtilities: " + ioExc.getMessage());
- }
- finally {
- closeJarFile(jarfile);
- if (rule != null) {
- Platform.getJobManager().endRule(rule);
- }
- }
- String[] names = (String[]) entryNames.toArray(new String[0]);
- return names;
- }
-
- public static InputStream getInputStream(IResource jarResource, String entryName) {
- if (jarResource == null)
- return null;
- return getInputStream(jarResource.getLocation().toString(), entryName);
- }
-
- public static InputStream getInputStream(String jarFilename, String entryName) {
- // check sanity
- if (jarFilename == null || jarFilename.length() < 1 || entryName == null || entryName.length() < 1)
- return null;
-
- // JAR files are not allowed to have leading '/' in member names
- String internalName = null;
- if (entryName.startsWith("/")) //$NON-NLS-1$
- internalName = entryName.substring(1);
- else
- internalName = entryName;
-
- return getCachedInputStream(jarFilename, internalName);
- }
-}
diff --git a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/util/PathHelper.java b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/util/PathHelper.java
deleted file mode 100644
index 94a66bebf9..0000000000
--- a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/util/PathHelper.java
+++ /dev/null
@@ -1,148 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Jens Lukowski/Innoopract - initial renaming/restructuring
- *
- *******************************************************************************/
-package org.eclipse.wst.sse.core.util;
-
-
-
-import java.io.File;
-import java.util.StringTokenizer;
-
-/**
- * Collection of helper methods to manage and convert links Originally part of
- * the LinksManager (com.ibm.iwt.parser.util)
- */
-public class PathHelper {
- public static final String BACKWARD_SLASH = "\\";//$NON-NLS-1$
-
- public static final String FORWARD_SLASH = "/";//$NON-NLS-1$
- public static final String RELATIVE_PATH_SIG = "../";//$NON-NLS-1$
-
- /**
- * adjust relative path isside the absolute path
- */
- public static String adjustPath(String path) {
- int i = 0;
- while ((i = path.indexOf(RELATIVE_PATH_SIG)) > 0) {
- // split the string into two
- String part1 = path.substring(0, i - 1);
- String part2 = path.substring(i + RELATIVE_PATH_SIG.length() - 1);
- // strip one path seg from part1
- int j = part1.lastIndexOf(FORWARD_SLASH);
- if (j == -1) {
- // can't resolve. passed path is like
- // E:/eclipseproject/../../sample.css.
- return "";//$NON-NLS-1$
- }
- part1 = part1.substring(0, j);
- path = part1 + part2;
- }
- return path;
- }
-
- /**
- * Append trailing url slash if needed
- */
- public static String appendTrailingURLSlash(String input) {
- // check to see already a slash
- if (!input.endsWith(FORWARD_SLASH)) {
- input += FORWARD_SLASH;
- }
- return input;
- }
-
- /**
- * Convert to relative url based on base
- */
- public static String convertToRelative(String input, String base) {
- // tokenize the strings
- StringTokenizer inputTokenizer = new StringTokenizer(input, FORWARD_SLASH);
- StringTokenizer baseTokenizer = new StringTokenizer(base, FORWARD_SLASH);
- String token1 = "", token2 = "";//$NON-NLS-2$//$NON-NLS-1$
- //
- // Go through until equls
- while (true) {
- if (!inputTokenizer.hasMoreTokens() || !baseTokenizer.hasMoreTokens())
- break;
- token1 = baseTokenizer.nextToken();
- token2 = inputTokenizer.nextToken();
- if (!token1.equals(token2))
- break;
- }
- // now generate the backs
- String output = "";//$NON-NLS-1$
- while (baseTokenizer.hasMoreTokens()) {
- baseTokenizer.nextToken();
- output += "../"; //$NON-NLS-1$
- }
- output += token2;
- // generate the rest
- while (inputTokenizer.hasMoreTokens()) {
- output = output + FORWARD_SLASH + inputTokenizer.nextToken();
- }
- return output;
- }
-
- /**
- * Return the containing folder path. Will handle both url and file path
- */
- public static String getContainingFolderPath(String path) {
- String retValue = path;
-
- int urlSlashIndex = path.lastIndexOf(FORWARD_SLASH);
- int filePathSlashIndex = path.lastIndexOf(File.separator);
- int index = filePathSlashIndex;
- if (urlSlashIndex > filePathSlashIndex)
- index = urlSlashIndex;
- if (index >= 0)
- retValue = path.substring(0, index);
- return retValue;
- }
-
- /**
- * Remove leading path separator
- */
- public static String removeLeadingPathSeparator(String path) {
- if (path.startsWith(File.separator))
- path = path.substring(File.separator.length());
- return path;
- }
-
- /**
- * Remove leading path separator
- */
- public static String removeLeadingSeparator(String path) {
- if (path.startsWith(File.separator))
- path = path.substring(File.separator.length());
- else if (path.startsWith(FORWARD_SLASH) || path.startsWith(BACKWARD_SLASH))
- path = path.substring(FORWARD_SLASH.length());
- return path;
- }
-
- /**
- * Switch to file path slashes
- */
- public static String switchToFilePathSlashes(String path) {
- path = path.replace(FORWARD_SLASH.charAt(0), File.separatorChar);
- path = path.replace(BACKWARD_SLASH.charAt(0), File.separatorChar);
- return path;
- }
-
- /**
- * Switch to file path slashes
- */
- public static String switchToForwardSlashes(String path) {
- path = path.replace(File.separatorChar, FORWARD_SLASH.charAt(0));
- path = path.replace(BACKWARD_SLASH.charAt(0), FORWARD_SLASH.charAt(0));
- return path;
- }
-}
diff --git a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/util/ProjectResolver.java b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/util/ProjectResolver.java
deleted file mode 100644
index f73f86a935..0000000000
--- a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/util/ProjectResolver.java
+++ /dev/null
@@ -1,228 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Jens Lukowski/Innoopract - initial renaming/restructuring
- *
- *******************************************************************************/
-package org.eclipse.wst.sse.core.util;
-
-import java.io.InputStream;
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.util.StringTokenizer;
-
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.wst.xml.uriresolver.util.URIHelper;
-
-public class ProjectResolver implements URIResolver {
- private String fFileBaseLocation = null;
- private IProject fProject = null;
-
- /**
- * It is strongly recommended that clients use
- * project.getAdapter(URIResolver.class) to obtain a URIResolver aware of
- * the Project's special requirements. Note that a URIResolver may not be
- * returned at all so manually creating this object may still be required.
- */
- public ProjectResolver(IProject project) {
- super();
- fProject = project;
- }
-
- public String getFileBaseLocation() {
- return fFileBaseLocation;
- }
-
- public String getLocationByURI(String uri) {
- return getLocationByURI(uri, getFileBaseLocation());
- }
-
- // defect 244817 end
- /**
- * Resolve the (possibly relative) URI acording to RFC1808 using the
- * default file base location. Resolves resource references into absolute
- * resource locations without ensuring that the resource actually exists.
- *
- * Note: currently resolveCrossProjectLinks is ignored in this
- * implementation.
- */
- public String getLocationByURI(String uri, boolean resolveCrossProjectLinks) {
- return getLocationByURI(uri, getFileBaseLocation(), resolveCrossProjectLinks);
- }
-
- public String getLocationByURI(String uri, String baseReference) {
- if (uri == null)
- return null;
- /*
- * defect 244817 try { URL aURL = new URL(uri);
- */
- /**
- * An actual URL was given, but only the "file:///" protocol is
- * supported. Resolve the URI by finding the file to which it points.
- */
- /*
- * defect 244817 if (!aURL.getProtocol().equals("platform")) {
- * //$NON-NLS-1$ if (aURL.getProtocol().equals("file") &&
- * (aURL.getHost().equals("localhost") || aURL.getHost().length() ==
- * 0)) { //$NON-NLS-2$//$NON-NLS-1$ return aURL.getFile(); } return
- * uri; } } catch (MalformedURLException mfuExc) { }
- */
- // defect 244817 start
- if (isFileURL(uri)) {
- try {
- URL url = new URL(uri);
- return getPath(url);
- } catch (MalformedURLException e) {
- }
- }
- // defect 244817 end
-
- // which of the serveral are we suppose to use here?
- //
-
- // https://bugs.eclipse.org/bugs/show_bug.cgi?id=71223
- // Workaround for problem in URIHelper; uris starting with '/' are
- // returned as-is.
- String location = uri;
- if (uri.startsWith("/")) {
- IProject p = getProject();
- if(p != null && p.exists())
- location = p.getLocation().toString() + uri;
- }
- else {
- location = URIHelper.normalize(uri, baseReference, getRootLocationString());
- }
- return location;
- }
-
- /**
- * Perform the getLocationByURI action using the baseReference as the
- * point of reference instead of the default for this resolver
- *
- * Note: currently resolveCrossProjectLinks is ignored in this
- * implementation.
- */
- public String getLocationByURI(String uri, String baseReference, boolean resolveCrossProjectLinks) {
- return getLocationByURI(uri, baseReference);
- }
-
- /**
- *
- * @param path
- * @param host
- * @return String
- */
- private String getPath(IPath path, String host) {
- IPath newPath = path;
- // They are potentially for only Windows operating system.
- // a.) if path has a device, and if it begins with IPath.SEPARATOR,
- // remove it
- final String device = path.getDevice();
- if ((device != null) && (device.length() > 0)) {
- if (device.charAt(0) == IPath.SEPARATOR) {
- final String newDevice = device.substring(1);
- newPath = path.setDevice(newDevice);
- }
- }
- // b.) if it has a hostname, it is UNC name... Any java or eclipse api
- // helps it ??
- if (path != null && host != null && host.length() != 0) {
- IPath uncPath = new Path(host);
- uncPath = uncPath.append(path);
- newPath = uncPath.makeUNC(true);
- }
- return newPath.toString();
- }
-
- /**
- *
- * @param url
- * @return String
- */
- private String getPath(URL url) {
- String ref = url.getRef() == null ? "" : "#" + url.getRef(); //$NON-NLS-1$ //$NON-NLS-2$
- String strPath = url.getFile() + ref;
- IPath path;
- if (strPath.length() == 0) {
- path = Path.ROOT;
- } else {
- path = new Path(strPath);
- String query = null;
- StringTokenizer parser = new StringTokenizer(strPath, "?"); //$NON-NLS-1$
- int tokenCount = parser.countTokens();
- if (tokenCount == 2) {
- path = new Path((String) parser.nextElement());
- query = (String) parser.nextElement();
- }
- if (query == null) {
- parser = new StringTokenizer(path.toString(), "#"); //$NON-NLS-1$
- tokenCount = parser.countTokens();
- if (tokenCount == 2) {
- path = new Path((String) parser.nextElement());
- }
- }
- }
- return getPath(path, url.getHost());
- }
-
- public org.eclipse.core.resources.IProject getProject() {
- return fProject;
- }
-
- public org.eclipse.core.resources.IContainer getRootLocation() {
- return fProject;
- }
-
- protected String getRootLocationString() {
- return fProject.getLocation().toString();
- }
-
- public InputStream getURIStream(String uri) {
- return null;
- }
-
- // defect 244817 start
- /**
- *
- * @param passedSpec
- * @return boolean
- */
- private boolean isFileURL(String passedSpec) {
- if (passedSpec == null) {
- return false;
- }
- final String spec = passedSpec.trim();
- if (spec.length() == 0) {
- return false;
- }
- final int limit = spec.length();
- String newProtocol = null;
- for (int index = 0; index < limit; index++) {
- final char p = spec.charAt(index);
- if (p == '/') { //$NON-NLS-1$
- break;
- }
- if (p == ':') { //$NON-NLS-1$
- newProtocol = spec.substring(0, index);
- break;
- }
- }
- return (newProtocol != null && newProtocol.compareToIgnoreCase("file") == 0); //$NON-NLS-1$
- }
-
- public void setFileBaseLocation(String newFileBaseLocation) {
- fFileBaseLocation = newFileBaseLocation;
- }
-
- public void setProject(IProject newProject) {
- fProject = newProject;
- }
-}
diff --git a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/util/ResourceUtil.java b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/util/ResourceUtil.java
deleted file mode 100644
index b507cf7617..0000000000
--- a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/util/ResourceUtil.java
+++ /dev/null
@@ -1,69 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Jens Lukowski/Innoopract - initial renaming/restructuring
- *
- *******************************************************************************/
-package org.eclipse.wst.sse.core.util;
-
-
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IWorkspaceRoot;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.wst.sse.core.IStructuredModel;
-
-
-/**
- * @deprecated - incorrect and not updated for M3 changes
- */
-public class ResourceUtil {
-
- /**
- * Obtain IFile from IStructuredModel
- */
- public static IFile getFileFor(IStructuredModel model) {
- if (model == null)
- return null;
- String path = model.getBaseLocation();
- if (path == null || path.length() == 0) {
- Object id = model.getId();
- if (id == null)
- return null;
- path = id.toString();
- }
- IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
- IFile file = root.getFileForLocation(new Path(path));
- return file;
- }
-
- /**
- * Obtain IFiles from IStructuredModel (includes linkedResources)
- *
- * @return the corresponding files in the workspace, or an empty array if
- * none
- */
- public static IFile[] getFilesFor(IStructuredModel model) {
- IFile[] files = new IFile[0];
-
- if (model != null) {
- String path = model.getBaseLocation();
- if (path == null || path.length() == 0) {
- Object id = model.getId();
- if (id == null)
- return files;
- path = id.toString();
- }
- IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
- files = root.findFilesForLocation(new Path(path));
- }
- return files;
- }
-}
diff --git a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/util/ScriptLanguageKeys.java b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/util/ScriptLanguageKeys.java
deleted file mode 100644
index b8ee24fda6..0000000000
--- a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/util/ScriptLanguageKeys.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Jens Lukowski/Innoopract - initial renaming/restructuring
- *
- *******************************************************************************/
-package org.eclipse.wst.sse.core.util;
-
-/**
- * Contains list of script languages and mime types
- */
-public interface ScriptLanguageKeys {
-
- public static final String JAVA = "java"; //$NON-NLS-1$
-
- public static final String[] JAVA_LANGUAGE_KEYS = new String[]{"java"}; //$NON-NLS-1$
-
- public static final String JAVASCRIPT = "javascript"; //$NON-NLS-1$
- public static final String[] JAVASCRIPT_LANGUAGE_KEYS = {"javascript", //$NON-NLS-1$
- "javascript1.0", //$NON-NLS-1$
- "javascript1.1", //$NON-NLS-1$
- "javascript1.2", //$NON-NLS-1$
- "javascript1.3", //$NON-NLS-1$
- "javascript1.4", //$NON-NLS-1$
- "javascript1.5", //$NON-NLS-1$
- "javascript1.6", //$NON-NLS-1$
- "jscript", //$NON-NLS-1$
- "sashscript"}; //$NON-NLS-1$
-
- public static final String[] JAVASCRIPT_MIME_TYPE_KEYS = {"text/javascript", //$NON-NLS-1$
- "text/jscript", //$NON-NLS-1$
- "text/sashscript"}; //$NON-NLS-1$
-}
diff --git a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/util/StringUtils.java b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/util/StringUtils.java
deleted file mode 100644
index f80097e0ac..0000000000
--- a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/util/StringUtils.java
+++ /dev/null
@@ -1,742 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Jens Lukowski/Innoopract - initial renaming/restructuring
- *
- *******************************************************************************/
-package org.eclipse.wst.sse.core.util;
-
-
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.StringTokenizer;
-
-import org.eclipse.jface.text.BadLocationException;
-import org.eclipse.jface.text.Document;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.IRegion;
-import org.eclipse.wst.sse.core.exceptions.SourceEditingRuntimeException;
-
-
-public class StringUtils {
- protected static final String AMPERSTAND = "&"; //$NON-NLS-1$
- protected static final String AMPERSTAND_ENTITY = "&&;"; //$NON-NLS-1$
- protected static final String CARRIAGE_RETURN = "\r"; //$NON-NLS-1$
- protected static final String CARRIAGE_RETURN_ENTITY = "\\r"; //$NON-NLS-1$
- protected static final String CR = "\r"; //$NON-NLS-1$
- protected static final String CRLF = "\r\n"; //$NON-NLS-1$
- protected static final String DELIMITERS = " \t\n\r\f"; //$NON-NLS-1$
- protected static final String DOUBLE_QUOTE = "\""; //$NON-NLS-1$
- protected static final char DOUBLE_QUOTE_CHAR = '\"'; //$NON-NLS-1$
- protected static final String DOUBLE_QUOTE_ENTITY = "&quot;"; //$NON-NLS-1$
-
- protected static final String EQUAL_SIGN = "="; //$NON-NLS-1$
- protected static final String EQUAL_SIGN_ENTITY = "&#61;"; //$NON-NLS-1$
- private static final String FALSE = "false"; //$NON-NLS-1$
- protected static final String GREATER_THAN = ">"; //$NON-NLS-1$
- protected static final String GREATER_THAN_ENTITY = "&gt;"; //$NON-NLS-1$
- protected static final String LESS_THAN = "<"; //$NON-NLS-1$
- protected static final String LESS_THAN_ENTITY = "&lt;"; //$NON-NLS-1$
- protected static final String LF = "\n"; //$NON-NLS-1$
- protected static final String LINE_FEED = "\n"; //$NON-NLS-1$
- protected static final String LINE_FEED_ENTITY = "\\n"; //$NON-NLS-1$
- protected static final String LINE_FEED_TAG = "<dl>"; //$NON-NLS-1$
- protected static final String LINE_TAB = "\t"; //$NON-NLS-1$
- protected static final String LINE_TAB_ENTITY = "\\t"; //$NON-NLS-1$
- protected static final String LINE_TAB_TAG = "<dd>"; //$NON-NLS-1$
- protected static final String SINGLE_QUOTE = "'"; //$NON-NLS-1$
- protected static final char SINGLE_QUOTE_CHAR = '\''; //$NON-NLS-1$
- protected static final String SINGLE_QUOTE_ENTITY = "&#039;"; //$NON-NLS-1$
- protected static final String SPACE = " "; //$NON-NLS-1$
- protected static final String SPACE_ENTITY = "&nbsp;"; //$NON-NLS-1$
- private static final String TRUE = "true"; //$NON-NLS-1$
-
- /**
- * Append appendString to the end of aString only if aString does not end
- * with the insertString.
- */
- public static String appendIfNotEndWith(String aString, String appendString) {
- if ((aString != null) && (appendString != null))
- if (aString.endsWith(appendString))
- return aString;
- else
- return aString + appendString;
- else
- return aString;
- }
-
- /**
- * Breaks out space-separated words into an array of words. For example:
- * <code>"no comment"</code> into an array <code>a[0]="no"</code> and
- * <code>a[1]= "comment"</code>.
- *
- * @param value
- * the string to be converted
- * @return the list of words
- */
- public static String[] asArray(String value) {
- ArrayList list = new ArrayList();
- StringTokenizer stok = new StringTokenizer(value);
- while (stok.hasMoreTokens()) {
- list.add(stok.nextToken());
- }
- String result[] = new String[list.size()];
- list.toArray(result);
- return result;
- }
-
- /**
- * Breaks out delim-separated words into an array of words. For example:
- * <code>"no comment"</code> into an array <code>a[0]="no"</code> and
- * <code>a[1]= "comment"</code>.
- *
- * @param value
- * the string to be converted
- * @return the list of words
- */
- public static String[] asArray(String value, String delim) {
- return asArray(value, delim, false);
- }
-
- /**
- * Breaks out delim-separated words into an array of words. For example:
- * <code>"no comment"</code> into an array <code>a[0]="no"</code> and
- * <code>a[1]= "comment"</code>.
- *
- * @param value
- * the string to be converted
- * @return the list of words
- */
- public static String[] asArray(String value, String delim, boolean returnTokens) {
- ArrayList list = new ArrayList();
- StringTokenizer stok = new StringTokenizer(value, delim, returnTokens);
- while (stok.hasMoreTokens()) {
- list.add(stok.nextToken());
- }
- String result[] = new String[list.size()];
- list.toArray(result);
- return result;
- }
-
- /**
- * Breaks out delim-separated words into an array of words. For example:
- * <code>"abc,,def"</code> into an array <code>a[0]="abc"</code>,
- * <code>a[1]=null</code>, and <code>a[2]= "def"</code> where "," is
- * the delim.
- *
- * @param value
- * the string to be converted
- * @return the list of words
- */
- public static String[] asFixedArray(String value, String delim) {
- String array[] = asArray(value, delim, true);
- int arrayLength = array.length;
- boolean stringFound = false;
- ArrayList list = new ArrayList();
-
- for (int i = 0; i < arrayLength; i++) {
- String token = array[i];
- if (token.compareTo(delim) == 0) {
- if (!stringFound)
- list.add(null);
- stringFound = false;
- }
- else {
- list.add(token);
- stringFound = true;
- }
- }
- // add one more null if last token is the delim
- if (!stringFound)
- list.add(null);
-
- String result[] = new String[list.size()];
- list.toArray(result);
- return result;
- }
-
- public static String chop(String source) {
- return chop(source, "/"); //$NON-NLS-1$
- }
-
- public static String chop(String source, String delimiter) {
- return source.substring(0, source.lastIndexOf(delimiter));
- }
-
- public static boolean contains(String[] arrayOfStrings, String needle, boolean caseSensitive) {
- boolean result = false;
- if (needle == null)
- return false;
- if (arrayOfStrings == null)
- return false;
-
- if (caseSensitive) {
- for (int i = 0; i < arrayOfStrings.length; i++) {
- if (needle.equals(arrayOfStrings[i])) {
- result = true;
- break;
- }
- }
- }
- else {
- for (int i = 0; i < arrayOfStrings.length; i++) {
- if (needle.equalsIgnoreCase(arrayOfStrings[i])) {
- result = true;
- break;
- }
- }
- }
- return result;
- }
-
- public static boolean containsLetters(String fullValue) {
-
- if (fullValue == null || fullValue.length() == 0)
- return false;
-
- char[] chars = fullValue.toCharArray();
- for (int i = 0; i < fullValue.length(); i++)
- if (Character.isLetter(chars[i]))
- return true;
-
- return false;
- }
-
- public static boolean containsLineDelimiter(String aString) {
- return indexOfLineDelimiter(aString) != -1;
- }
-
- public static String convertLineDelimiters(String allText, String lineDelimiterToUse) {
- IDocument tempDoc = new Document(allText);
-
- if (lineDelimiterToUse == null)
- lineDelimiterToUse = System.getProperty("line.separator"); //$NON-NLS-1$
-
- String newText = ""; //$NON-NLS-1$
- int lineCount = tempDoc.getNumberOfLines();
- for (int i = 0; i < lineCount; i++) {
- try {
- org.eclipse.jface.text.IRegion lineInfo = tempDoc.getLineInformation(i);
- int lineStartOffset = lineInfo.getOffset();
- int lineLength = lineInfo.getLength();
- int lineEndOffset = lineStartOffset + lineLength;
- newText += allText.substring(lineStartOffset, lineEndOffset);
-
- if ((i < lineCount - 1) && (tempDoc.getLineDelimiter(i) != null))
- newText += lineDelimiterToUse;
- }
- catch (BadLocationException exception) {
- throw new SourceEditingRuntimeException(exception);
- }
- }
-
- return newText;
- }
-
- /**
- * Replaces all instances of special HTML characters with the appropriate
- * HTML entity equivalent. WARNING only use this method for strings that
- * dont already have HTML-specific items such as tags and entities.
- *
- * @param String
- * content String to convert
- *
- * @return String the converted string
- * @see HTMLPrinter#convertToHTMLContent(String content)
- */
- public static String convertToHTMLContent(String content) {
- content = replace(content, AMPERSTAND, AMPERSTAND_ENTITY);
- content = replace(content, LESS_THAN, LESS_THAN_ENTITY);
- content = replace(content, GREATER_THAN, GREATER_THAN_ENTITY);
- content = replace(content, LINE_FEED, LINE_FEED_TAG);
- content = replace(content, LINE_TAB, LINE_TAB_TAG);
- content = replace(content, SINGLE_QUOTE, SINGLE_QUOTE_ENTITY);
- content = replace(content, DOUBLE_QUOTE, DOUBLE_QUOTE_ENTITY);
- content = replace(content, SPACE + SPACE, SPACE_ENTITY + SPACE_ENTITY); // replacing
- // every
- // space
- // would
- // be
- // too
- // much
- return content;
- }
-
- /**
- * Converts a string into a form that will not conflict with saving it
- * into an INI file
- */
- public static String escape(String normalString) {
- if (normalString == null)
- return null;
- StringBuffer escapedBuffer = new StringBuffer();
- StringTokenizer toker = new StringTokenizer(normalString, EQUAL_SIGN + LINE_FEED + CARRIAGE_RETURN + LINE_TAB, true);
- String chunk = null;
- while (toker.hasMoreTokens()) {
- chunk = toker.nextToken();
- if (chunk.equals(EQUAL_SIGN)) {
- escapedBuffer.append(EQUAL_SIGN_ENTITY);
- }
- else if (chunk.equals(LINE_FEED)) {
- escapedBuffer.append(LINE_FEED_ENTITY);
- }
- else if (chunk.equals(CARRIAGE_RETURN)) {
- escapedBuffer.append(CARRIAGE_RETURN_ENTITY);
- }
- else if (chunk.equals(LINE_TAB)) {
- escapedBuffer.append(LINE_TAB_ENTITY);
- }
- else {
- escapedBuffer.append(chunk);
- }
- }
- return escapedBuffer.toString();
- }
-
- /**
- * Returns the first line of the given text without a trailing delimiter
- *
- * @param text
- * @return
- */
- public static String firstLineOf(String text) {
- if (text == null || text.length() < 1) {
- return text;
- }
- IDocument doc = new Document(text);
- try {
- int lineNumber = doc.getLineOfOffset(0);
- IRegion line = doc.getLineInformation(lineNumber);
- return doc.get(line.getOffset(), line.getLength());
- }
- catch (BadLocationException e) {
- // do nothing
- }
- return text;
- }
-
- public static int indexOfLastLineDelimiter(String aString) {
- return indexOfLastLineDelimiter(aString, aString.length());
- }
-
- public static int indexOfLastLineDelimiter(String aString, int offset) {
- int index = -1;
-
- if (aString != null && aString.length() > 0) {
- index = aString.lastIndexOf(CRLF, offset);
- if (index == -1) {
- index = aString.lastIndexOf(CR, offset);
- if (index == -1)
- index = aString.lastIndexOf(LF, offset);
- }
- }
-
- return index;
- }
-
- public static int indexOfLineDelimiter(String aString) {
- return indexOfLineDelimiter(aString, 0);
- }
-
- public static int indexOfLineDelimiter(String aString, int offset) {
- int index = -1;
-
- if (aString != null && aString.length() > 0) {
- index = aString.indexOf(CRLF, offset);
- if (index == -1) {
- index = aString.indexOf(CR, offset);
- if (index == -1)
- index = aString.indexOf(LF, offset);
- }
- }
-
- return index;
- }
-
- public static int indexOfNonblank(String aString) {
- return indexOfNonblank(aString, 0);
- }
-
- public static int indexOfNonblank(String aString, int offset) {
- int index = -1;
-
- if (aString != null && aString.length() > 0) {
- for (int i = offset; i < aString.length(); i++) {
- if (DELIMITERS.indexOf(aString.substring(i, i + 1)) == -1) {
- index = i;
- break;
- }
- }
- }
-
- return index;
- }
-
- /**
- * Insert insertString to the beginning of aString only if aString does
- * not start with the insertString.
- */
- public static String insertIfNotStartWith(String aString, String insertString) {
- if ((aString != null) && (insertString != null))
- if (aString.startsWith(insertString))
- return aString;
- else
- return insertString + aString;
- else
- return aString;
- }
-
- public static boolean isQuoted(String string) {
- if ((string == null) || (string.length() < 2))
- return false;
-
- int lastIndex = string.length() - 1;
- char firstChar = string.charAt(0);
- char lastChar = string.charAt(lastIndex);
-
- return (((firstChar == SINGLE_QUOTE_CHAR) && (lastChar == SINGLE_QUOTE_CHAR)) || ((firstChar == DOUBLE_QUOTE_CHAR) && (lastChar == DOUBLE_QUOTE_CHAR)));
- }
-
- /**
- * Unit tests.
- *
- * @param args
- * java.lang.String[]
- */
- public static void main(String[] args) {
- // testPaste();
- testStripNonLetterDigits();
- }
-
- /*
- * Returns the merged form of both strings
- */
- public static String merge(String newStart, String newEnd) {
- String[] regions = overlapRegions(newStart, newEnd);
- return regions[0] + regions[1] + regions[2];
- }
-
- public static int occurrencesOf(String searchString, char targetChar) {
- int result = 0;
- int len = searchString.length();
- for (int i = 0; i < len; i++) {
- if (targetChar == searchString.charAt(i))
- result++;
- }
- return result;
- }
-
- /**
- *
- * @return java.lang.String[]
- * @param start
- * java.lang.String
- * @param end
- * java.lang.String
- *
- * Returns a 3 String array containing unique text from the start,
- * duplicated text that overlaps the start and end, and the unique text
- * from the end.
- */
- private static String[] overlapRegions(String start, String end) {
- String[] results = null;
- if (start != null && end == null) {
- results = new String[]{start, "", ""}; //$NON-NLS-2$//$NON-NLS-1$
- }
- else if (start == null && end != null) {
- results = new String[]{"", "", end}; //$NON-NLS-2$//$NON-NLS-1$
- }
- else if (start == null && end == null) {
- results = new String[]{"", "", ""}; //$NON-NLS-3$//$NON-NLS-2$//$NON-NLS-1$
- }
- else if (start != null && end != null) {
-
- int startLength = start.length();
- int endLength = end.length();
-
- if (startLength == 0 || endLength == 0) {
- results = new String[]{"", "", ""}; //$NON-NLS-3$//$NON-NLS-2$//$NON-NLS-1$
- }
- else {
- results = new String[3];
- String testStart = ""; //$NON-NLS-1$
- String testEnd = ""; //$NON-NLS-1$
- int mergeLength = Math.min(startLength, endLength);
- boolean finished = false;
- while (mergeLength > 0 && !finished) {
- testStart = start.substring(startLength - mergeLength);
- testEnd = end.substring(0, mergeLength);
- // case sensitive
- if (testStart.equals(testEnd)) {
- finished = true;
- results[0] = start.substring(0, startLength - mergeLength);
- results[1] = start.substring(startLength - mergeLength);
- results[2] = end.substring(mergeLength);
- }
- mergeLength--;
- }
- if (!finished) {
- results[0] = start;
- results[1] = ""; //$NON-NLS-1$
- results[2] = end;
- }
- }
- }
- return results;
- }
-
- /**
- * Packs an array of Strings into a single comma delimited String.
- *
- * @param strings
- * @return
- * @todo Generated comment
- */
- public static String pack(String[] strings) {
- StringBuffer buf = new StringBuffer();
- for (int i = 0; i < strings.length; i++) {
- buf.append(StringUtils.replace(strings[i], ",", "&comma;")); //$NON-NLS-1$ //$NON-NLS-2$
- if (i < strings.length - 1)
- buf.append(","); //$NON-NLS-1$
- }
- return buf.toString();
- }
-
- /*
- * Pastes the new text into the old at the start position, replacing text
- * implied by length.
- */
- public static String paste(String oldText, String newText, int start, int length) {
- String result = null;
- StringBuffer sb = new StringBuffer();
- int startIndex = start;
- int endIndex = start + length;
- if (startIndex > oldText.length()) {
- startIndex = oldText.length();
- }
- sb.append(oldText.substring(0, startIndex));
- // null or empty new text accompliches a delete
- if (newText != null) {
- sb.append(newText);
- }
- if (endIndex < oldText.length()) {
-
- sb.append(oldText.substring(endIndex));
- }
- result = sb.toString();
- return result;
- }
-
- /**
- * Replace matching literal portions of a string with another string
- */
- public static String replace(String aString, String source, String target) {
- if (aString == null)
- return null;
- String normalString = ""; //$NON-NLS-1$
- int length = aString.length();
- int position = 0;
- int previous = 0;
- int spacer = source.length();
- while (position + spacer - 1 < length && aString.indexOf(source, position) > -1) {
- position = aString.indexOf(source, previous);
- normalString = normalString + aString.substring(previous, position) + target;
- position += spacer;
- previous = position;
- }
- normalString = normalString + aString.substring(position, aString.length());
-
- return normalString;
- }
-
- /**
- * Restore the entity references for markup delimiters in text where they
- * have been replaced by the proper Unicode values through a DOM text
- * parser.
- */
- public static String restoreMarkers(String text) {
- String content = text;
- content = replace(content, AMPERSTAND, AMPERSTAND_ENTITY);
- content = replace(content, LESS_THAN, LESS_THAN_ENTITY);
- content = replace(content, GREATER_THAN, GREATER_THAN_ENTITY);
- return content;
- }
-
- /**
- * Removes extra whitespace characters and quotes
- */
- public static String strip(String quotedString) {
- if (quotedString == null || quotedString.length() == 0)
- return quotedString;
- String trimmed = quotedString.trim();
- if (trimmed.length() < 2)
- return quotedString;
-
- char first = trimmed.charAt(0);
- char nextToLast = trimmed.charAt(trimmed.length() - 2);
- char last = trimmed.charAt(trimmed.length() - 1);
-
- if ((first == '\"' && last == '\"' && nextToLast != '\\') || (first == '\'' && last == '\'' && nextToLast != '\\')) {
- return trimmed.substring(1, trimmed.length() - 1);
- }
- return trimmed;
- }
-
- /**
- * This method strips anything from the beginning and end of a string that
- * is not a letter or digit. It is used by some encoding detectors to come
- * up with the encoding name from illformed input (e.g in <?xml
- * encoding="abc?> -- where final quote is left off, the '>' is returned
- * with the rest of the attribute value 'abc').
- */
- public static String stripNonLetterDigits(String fullValue) {
- if (fullValue == null || fullValue.length() == 0)
- return fullValue;
- int fullValueLength = fullValue.length();
- int firstPos = 0;
- while (firstPos < fullValueLength && !Character.isLetterOrDigit(fullValue.charAt(firstPos))) {
- firstPos++;
- }
- int lastPos = fullValueLength - 1;
- while (lastPos > firstPos && !Character.isLetterOrDigit(fullValue.charAt(lastPos))) {
- lastPos--;
- }
- String result = fullValue;
- if (firstPos != 0 || lastPos != fullValueLength) {
- result = fullValue.substring(firstPos, lastPos + 1);
- }
- return result;
- }
-
- /**
- * Similar to strip, except quotes don't need to match such as "UTF' is
- * still stripped of both quotes. (Plus, this one does not detect escaped
- * quotes)
- */
- public static String stripQuotes(String quotedValue) {
- if (quotedValue == null)
- return null;
- // normally will never have leading or trailing blanks,
- // but if it does, we'll do lenient interpretation
- return stripQuotesLeaveInsideSpace(quotedValue).trim();
- }
-
- /**
- * Like strip quotes, except leaves the start and end space inside the
- * quotes
- *
- * @param quotedValue
- * @return
- */
- public static String stripQuotesLeaveInsideSpace(String quotedValue) {
- if (quotedValue == null)
- return null;
- // nomally will never have leading or trailing blanks ... but just in
- // case.
- String result = quotedValue.trim();
- int len = result.length();
- if (len > 0) {
- char firstChar = result.charAt(0);
- if ((firstChar == SINGLE_QUOTE_CHAR) || (firstChar == DOUBLE_QUOTE_CHAR)) {
- result = result.substring(1, len);
- }
- len = result.length();
- if (len > 0) {
- char lastChar = result.charAt(len - 1);
- if ((lastChar == SINGLE_QUOTE_CHAR) || (lastChar == DOUBLE_QUOTE_CHAR)) {
- result = result.substring(0, len - 1);
- }
- }
- }
- return result;
- }
-
- public static void testPaste() {
- String testString = "The quick brown fox ..."; //$NON-NLS-1$
- System.out.println(paste(testString, null, 4, 5));
- System.out.println(paste(testString, null, 4, 6));
- System.out.println(paste(testString, "", 4, 6)); //$NON-NLS-1$
- System.out.println(paste(testString, "fast", 4, 6)); //$NON-NLS-1$
- System.out.println(paste(testString, "fast ", 4, 6)); //$NON-NLS-1$
- System.out.println(paste(testString, "But ", 0, 0)); //$NON-NLS-1$
- System.out.println(paste("", "burp", 4, 6)); //$NON-NLS-2$//$NON-NLS-1$
- }
-
- public static void testStripNonLetterDigits() {
- String testString = "abc"; //$NON-NLS-1$
- System.out.println(testString + " -->" + stripNonLetterDigits(testString) + "<--"); //$NON-NLS-1$ //$NON-NLS-2$
- testString = ""; //$NON-NLS-1$
- System.out.println(testString + " -->" + stripNonLetterDigits(testString) + "<--"); //$NON-NLS-1$ //$NON-NLS-2$
- testString = "\"abc\""; //$NON-NLS-1$
- System.out.println(testString + " -->" + stripNonLetterDigits(testString) + "<--"); //$NON-NLS-1$ //$NON-NLS-2$
- testString = "\"ab-c1?"; //$NON-NLS-1$
- System.out.println(testString + " -->" + stripNonLetterDigits(testString) + "<--"); //$NON-NLS-1$ //$NON-NLS-2$
- testString = "+++"; //$NON-NLS-1$
- System.out.println(testString + " -->" + stripNonLetterDigits(testString) + "<--"); //$NON-NLS-1$ //$NON-NLS-2$
- testString = "abc="; //$NON-NLS-1$
- System.out.println(testString + " -->" + stripNonLetterDigits(testString) + "<--"); //$NON-NLS-1$ //$NON-NLS-2$
- testString = "abc "; //$NON-NLS-1$
- System.out.println(testString + " -->" + stripNonLetterDigits(testString) + "<--"); //$NON-NLS-1$ //$NON-NLS-2$
-
- }
-
- public static String toString(boolean booleanValue) {
- if (booleanValue)
- return TRUE;
- else
- return FALSE;
- }
-
- /**
- * Remove "escaped" chars from a string.
- */
- public static String unescape(String aString) {
- if (aString == null)
- return null;
- String normalString = replace(aString, EQUAL_SIGN_ENTITY, EQUAL_SIGN);
- normalString = replace(normalString, LINE_FEED_ENTITY, LINE_FEED);
- normalString = replace(normalString, CARRIAGE_RETURN_ENTITY, CARRIAGE_RETURN);
- normalString = replace(normalString, LINE_TAB_ENTITY, LINE_TAB);
- return normalString;
- }
-
- public static String uniqueEndOf(String newStart, String newEnd) {
- String[] regions = overlapRegions(newStart, newEnd);
- return regions[2];
- }
-
- /**
- * Unpacks a comma delimited String into an array of Strings
- *
- * @param s
- * @return
- * @todo Generated comment
- */
- public static String[] unpack(String s) {
- if (s == null)
- return new String[0];
- StringTokenizer toker = new StringTokenizer(s, ","); //$NON-NLS-1$
- List list = new ArrayList();
- while (toker.hasMoreTokens()) {
- // since we're separating the values with ',', escape ',' in the
- // values
- list.add(StringUtils.replace(toker.nextToken(), "&comma;", ",").trim()); //$NON-NLS-1$ //$NON-NLS-2$
- }
- return (String[]) list.toArray(new String[0]);
- }
-
- /**
- * StringUtils constructor comment.
- */
- private StringUtils() {
- super();
- }
-
-}
diff --git a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/util/TextUtilities.java b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/util/TextUtilities.java
deleted file mode 100644
index 544d2c7764..0000000000
--- a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/util/TextUtilities.java
+++ /dev/null
@@ -1,63 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Jens Lukowski/Innoopract - initial renaming/restructuring
- *
- *******************************************************************************/
-package org.eclipse.wst.sse.core.util;
-
-
-
-/**
- * Collection of text functions.
- * @deprecated - the JFace class is public in 3.1
- */
-// This class was originally copied from org.eclipse.jface.text, and made
-// public
-public class TextUtilities {
- /**
- * Returns whether the text ends with one of the given search strings.
- */
- public static boolean endsWith(String[] searchStrings, String text) {
- for (int i = 0; i < searchStrings.length; i++) {
- if (text.endsWith(searchStrings[i]))
- return true;
- }
- return false;
- }
-
- /**
- * Returns the position in the string greater than offset of the longest
- * matching search string.
- */
- public static int[] indexOf(String[] searchStrings, String text, int offset) {
-
- int[] result = {-1, -1};
-
- for (int i = 0; i < searchStrings.length; i++) {
- int index = text.indexOf(searchStrings[i], offset);
- if (index >= 0) {
-
- if (result[0] == -1) {
- result[0] = index;
- result[1] = i;
- } else if (index < result[0]) {
- result[0] = index;
- result[1] = i;
- } else if (index == result[0] && searchStrings[i].length() > searchStrings[result[1]].length()) {
- result[0] = index;
- result[1] = i;
- }
- }
- }
-
- return result;
-
- }
-}
diff --git a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/util/URIResolver.java b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/util/URIResolver.java
deleted file mode 100644
index d2e28d0b9a..0000000000
--- a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/util/URIResolver.java
+++ /dev/null
@@ -1,82 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Jens Lukowski/Innoopract - initial renaming/restructuring
- *
- *******************************************************************************/
-package org.eclipse.wst.sse.core.util;
-
-import java.io.InputStream;
-
-import org.eclipse.core.resources.IContainer;
-import org.eclipse.core.resources.IProject;
-
-
-/**
- * @deprecated
- *
- * @author nsd
- *
- * Will be removed in M4 and replaced with Flexible Project support
- */
-
-public interface URIResolver {
-
- String getFileBaseLocation();
-
- /**
- * Resolve the (possibly relative) URI acording to RFC1808 using the
- * default file base location. Resolves resource references into absolute
- * resource locations without ensuring that the resource actually exists.
- */
- String getLocationByURI(String uri);
-
- /**
- * Resolve the (possibly relative) URI acording to RFC1808 using the
- * default file base location. Resolves resource references into absolute
- * resource locations without ensuring that the resource actually exists.
- *
- * If resolveCrossProjectLinks is set to true, then this method will
- * properly resolve the URI if it is a valid URI to another (appropriate)
- * project.
- */
- String getLocationByURI(String uri, boolean resolveCrossProjectLinks);
-
- /**
- * Perform the getLocationByURI action using the baseReference as the
- * point of reference instead of the default for this resolver
- */
- String getLocationByURI(String uri, String baseReference);
-
- /**
- * Perform the getLocationByURI action using the baseReference as the
- * point of reference instead of the default for this resolver
- *
- * If resolveCrossProjectLinks is set to true, then this method will
- * properly resolve the URI if it is a valid URI to another (appropriate)
- * project.
- */
- String getLocationByURI(String uri, String baseReference, boolean resolveCrossProjectLinks);
-
- IProject getProject();
-
- IContainer getRootLocation();
-
- /**
- * Attempts to return a direct inputstream to the given URI which must be
- * relative to the default point of reference.
- * @deprecated
- */
- InputStream getURIStream(String uri);
-
- void setFileBaseLocation(String newLocation);
-
- void setProject(IProject newProject);
-
-}
diff --git a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/util/Utilities.java b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/util/Utilities.java
deleted file mode 100644
index c3c6a3d2aa..0000000000
--- a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/util/Utilities.java
+++ /dev/null
@@ -1,130 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Jens Lukowski/Innoopract - initial renaming/restructuring
- *
- *******************************************************************************/
-package org.eclipse.wst.sse.core.util;
-
-
-
-import java.io.BufferedInputStream;
-import java.io.InputStream;
-
-import org.eclipse.wst.common.encoding.CodedIO;
-import org.eclipse.wst.common.encoding.internal.BufferedLimitedStream;
-
-
-
-public class Utilities {
-
- /**
- * a common calculation in some of the parsing methods (e.g. in
- * ContextRegion and IStructuredDocumentRegion)
- */
- public static int calculateLengthDifference(String changes, int lengthToReplace) {
- // determine the length by the text itself, or, if there is no text to
- // insert (i.e. we are doing a delete) then calculate the length as
- // a negative number to denote the amount to delete.
- // For a straight insert, the selection Length will be zero.
- int lengthDifference = 0;
- if (changes == null) {
- // the delete case
- lengthDifference = 0 - lengthToReplace;
- } else {
- lengthDifference = changes.length() - lengthToReplace;
- }
- if (Debug.debugStructuredDocument) {
- System.out.println("lengthDifference: " + lengthDifference);//$NON-NLS-1$
- }
- return lengthDifference;
- }
-
- /**
- * Returns true iff both parameters are not null and the object is within
- * the array. Careful, this uses identity. Not good for basic strings.
- */
- public static boolean contains(Object[] objectArray, Object object) {
- boolean result = false;
- // if object or objectArray is null, return false
- if ((objectArray != null) && (object != null)) {
- for (int i = 0; i < objectArray.length; i++) {
- if (objectArray[i] == object) {
- result = true;
- break;
- }
- }
- }
- return result;
- }
-
- public static boolean containsString(String[] objectArray, String object) {
- boolean result = false;
- // if object or objectArray is null, return false
- if ((objectArray != null) && (object != null)) {
- for (int i = 0; i < objectArray.length; i++) {
- if (objectArray[i].equals(object)) {
- result = true;
- break;
- }
- }
- }
- return result;
- }
-
- /**
- * Ensures that an InputStream has mark/reset support, is readlimit is
- * set, and that the stream is "limitable" (that is, reports "end of
- * input" rather than allow going past mark). This is very specialized
- * stream introduced to overcome
- * https://bugs.eclipse.org/bugs/show_bug.cgi?id=67211. See also
- * https://bugs.eclipse.org/bugs/show_bug.cgi?id=68565
- */
- public static InputStream getLimitedStream(InputStream original) {
- if (original == null)
- return null;
- if (original instanceof BufferedLimitedStream)
- return original;
- return new BufferedLimitedStream(original, CodedIO.MAX_BUF_SIZE);
- }
-
- /**
- * Ensures that an InputStream has mark/reset support.
- */
- public static InputStream getMarkSupportedStream(InputStream original) {
- if (original == null)
- return null;
- if (original.markSupported())
- return original;
- InputStream buffered = new BufferedInputStream(original, CodedIO.MAX_BUF_SIZE);
- buffered.mark(CodedIO.MAX_MARK_SIZE);
- return buffered;
- }
-
- /**
- * Used for log/trace messages. Id is assumed to be some form of a
- * filename. See IModelManager.
- */
- public static String makeShortId(Object id) {
- if (id == null)
- id = "NOID"; //com.ibm.sed.util.Assert.isNotNull(id);
- // //$NON-NLS-1$
- String whole = id.toString();
- String part = whole.substring(whole.lastIndexOf("/") + 1); //$NON-NLS-1$
- return "..." + part; //$NON-NLS-1$
- }
-
-
- /**
- * Utilities constructor comment.
- */
- public Utilities() {
- super();
- }
-}
diff --git a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/validate/ValidationAdapter.java b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/validate/ValidationAdapter.java
deleted file mode 100644
index 29316d1ba7..0000000000
--- a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/validate/ValidationAdapter.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Jens Lukowski/Innoopract - initial renaming/restructuring
- *
- *******************************************************************************/
-package org.eclipse.wst.sse.core.validate;
-
-
-
-import org.eclipse.wst.sse.core.INodeAdapter;
-import org.eclipse.wst.sse.core.IndexedRegion;
-
-/**
- */
-public interface ValidationAdapter extends INodeAdapter {
-
- /**
- */
- void setReporter(ValidationReporter reporter);
-
- /**
- */
- void validate(IndexedRegion node);
-}
diff --git a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/validate/ValidationMessage.java b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/validate/ValidationMessage.java
deleted file mode 100644
index 46c38b6228..0000000000
--- a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/validate/ValidationMessage.java
+++ /dev/null
@@ -1,69 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Jens Lukowski/Innoopract - initial renaming/restructuring
- *
- *******************************************************************************/
-package org.eclipse.wst.sse.core.validate;
-
-
-
-/**
- */
-public class ValidationMessage {
- public static final int ERROR = 1;
- public static final int INFORMATION = 3;
- public static final int WARNING = 2;
- private int length;
-
- private String message;
- private int offset;
- private int severity;
-
- /**
- */
- public ValidationMessage(String message, int offset, int severity) {
- this(message, offset, 0, severity);
- }
-
- /**
- */
- public ValidationMessage(String message, int offset, int length, int severity) {
- super();
-
- this.message = message;
- this.offset = offset;
- this.length = length;
- this.severity = severity;
- }
-
- /**
- */
- public int getLength() {
- return this.length;
- }
-
- /**
- */
- public String getMessage() {
- return this.message;
- }
-
- /**
- */
- public int getOffset() {
- return this.offset;
- }
-
- /**
- */
- public int getSeverity() {
- return this.severity;
- }
-}
diff --git a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/validate/ValidationReporter.java b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/validate/ValidationReporter.java
deleted file mode 100644
index 67ed09ca98..0000000000
--- a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/validate/ValidationReporter.java
+++ /dev/null
@@ -1,24 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Jens Lukowski/Innoopract - initial renaming/restructuring
- *
- *******************************************************************************/
-package org.eclipse.wst.sse.core.validate;
-
-
-
-/**
- */
-public interface ValidationReporter {
-
- /**
- */
- void report(ValidationMessage message);
-}

Back to the top