diff options
Diffstat (limited to 'bundles/org.eclipse.wst.jsdt.web.core')
49 files changed, 0 insertions, 5840 deletions
diff --git a/bundles/org.eclipse.wst.jsdt.web.core/.classpath b/bundles/org.eclipse.wst.jsdt.web.core/.classpath deleted file mode 100644 index cb0105380b..0000000000 --- a/bundles/org.eclipse.wst.jsdt.web.core/.classpath +++ /dev/null @@ -1,7 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<classpath> - <classpathentry kind="src" path="src/"/> - <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/> - <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/> - <classpathentry kind="output" path="bin"/> -</classpath> diff --git a/bundles/org.eclipse.wst.jsdt.web.core/.options b/bundles/org.eclipse.wst.jsdt.web.core/.options deleted file mode 100644 index 89a2c969e5..0000000000 --- a/bundles/org.eclipse.wst.jsdt.web.core/.options +++ /dev/null @@ -1,35 +0,0 @@ -org.eclipse.jst.jsp.core/debug=true -org.eclipse.jst.jsp.core/debug/tracefilter= -org.eclipse.jst.jsp.core/debug/jspindexmanager=false -org.eclipse.jst.jsp.core/debug/jsptranslation=false -org.eclipse.jst.jsp.core/debug/jsptranslationstodisk=false -org.eclipse.jst.jsp.core/debug/jspsearch=false - -org.eclipse.jst.jsp.core/taglib/resolve=false - - -# org.eclipse.jst.jsp.core.contentmodel.tld.TLDCMDocumentManager._debug -org.eclipse.jst.jsp.core/debug/tldcmdocument/manager=false -org.eclipse.jst.jsp.core/debug/tldcmdocument/cache=false - -# org.eclipse.jst.jsp.core.contentmodel.tld.CMDocumentFactoryTLD._debug -org.eclipse.jst.jsp.core/debug/tldcmdocument/factory=false - -#org.eclipse.jst.jsp.core.internal.contentmodel.ProjectDescription._debugIndexCreation -org.eclipse.jst.jsp.core/taglib/indexcreation=false -#org.eclipse.jst.jsp.core.internal.contentmodel.ProjectDescription._debugIndexTime -org.eclipse.jst.jsp.core/taglib/indextime=false - -#org.eclipse.jst.jsp.core.internal.contentmodel.TaglibIndex._debugEvents -org.eclipse.jst.jsp.core/taglib/events=false -#org.eclipse.jst.jsp.core.internal.contentmodel.TaglibIndex._debugIndexCreation -org.eclipse.jst.jsp.core/taglib/indexcreation=false -#org.eclipse.jst.jsp.core.internal.contentmodel.TaglibIndex._debugResolution -org.eclipse.jst.jsp.core/taglib/resolve=false - -org.eclipse.jst.jsp.core/debug/jspjavamapping=false - -org.eclipse.jst.jsp.core/debug/jspvalidator=false -org.eclipse.jst.jsp.core/debug/taglibvars=false - -org.eclipse.jst.jsp.core/debug/taglibclassloader
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.jsdt.web.core/.project b/bundles/org.eclipse.wst.jsdt.web.core/.project deleted file mode 100644 index 22cb875e7e..0000000000 --- a/bundles/org.eclipse.wst.jsdt.web.core/.project +++ /dev/null @@ -1,28 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<projectDescription> - <name>org.eclipse.wst.jsdt.web.core</name> - <comment></comment> - <projects> - </projects> - <buildSpec> - <buildCommand> - <name>org.eclipse.jdt.core.javabuilder</name> - <arguments> - </arguments> - </buildCommand> - <buildCommand> - <name>org.eclipse.pde.ManifestBuilder</name> - <arguments> - </arguments> - </buildCommand> - <buildCommand> - <name>org.eclipse.pde.SchemaBuilder</name> - <arguments> - </arguments> - </buildCommand> - </buildSpec> - <natures> - <nature>org.eclipse.jdt.core.javanature</nature> - <nature>org.eclipse.pde.PluginNature</nature> - </natures> -</projectDescription> diff --git a/bundles/org.eclipse.wst.jsdt.web.core/.settings/org.eclipse.jdt.ui.prefs b/bundles/org.eclipse.wst.jsdt.web.core/.settings/org.eclipse.jdt.ui.prefs deleted file mode 100644 index a5be61a3f5..0000000000 --- a/bundles/org.eclipse.wst.jsdt.web.core/.settings/org.eclipse.jdt.ui.prefs +++ /dev/null @@ -1,49 +0,0 @@ -#Tue Mar 27 10:40:34 CDT 2007 -cleanup.add_default_serial_version_id=true -cleanup.add_generated_serial_version_id=false -cleanup.add_missing_annotations=true -cleanup.add_missing_deprecated_annotations=true -cleanup.add_missing_nls_tags=false -cleanup.add_missing_override_annotations=true -cleanup.add_serial_version_id=false -cleanup.always_use_blocks=true -cleanup.always_use_parentheses_in_expressions=false -cleanup.always_use_this_for_non_static_field_access=false -cleanup.always_use_this_for_non_static_method_access=false -cleanup.convert_to_enhanced_for_loop=false -cleanup.format_source_code=true -cleanup.make_local_variable_final=true -cleanup.make_parameters_final=false -cleanup.make_private_fields_final=true -cleanup.make_variable_declarations_final=false -cleanup.never_use_blocks=false -cleanup.never_use_parentheses_in_expressions=true -cleanup.organize_imports=true -cleanup.qualify_static_field_accesses_with_declaring_class=true -cleanup.qualify_static_member_accesses_through_instances_with_declaring_class=true -cleanup.qualify_static_member_accesses_through_subtypes_with_declaring_class=true -cleanup.qualify_static_member_accesses_with_declaring_class=true -cleanup.qualify_static_method_accesses_with_declaring_class=true -cleanup.remove_private_constructors=true -cleanup.remove_trailing_whitespaces=true -cleanup.remove_trailing_whitespaces_all=true -cleanup.remove_unnecessary_casts=true -cleanup.remove_unnecessary_nls_tags=true -cleanup.remove_unused_imports=true -cleanup.remove_unused_local_variables=true -cleanup.remove_unused_private_fields=true -cleanup.remove_unused_private_members=true -cleanup.remove_unused_private_methods=true -cleanup.remove_unused_private_types=true -cleanup.sort_members=true -cleanup.sort_members_all=true -cleanup.use_blocks=true -cleanup.use_blocks_only_for_return_and_throw=false -cleanup.use_parentheses_in_expressions=false -cleanup.use_this_for_non_static_field_access=false -cleanup.use_this_for_non_static_field_access_only_if_necessary=true -cleanup.use_this_for_non_static_method_access=false -cleanup.use_this_for_non_static_method_access_only_if_necessary=true -cleanup_profile=_Eclipse [built-in] + Brad Tweaks -cleanup_settings_version=2 -eclipse.preferences.version=1 diff --git a/bundles/org.eclipse.wst.jsdt.web.core/META-INF/MANIFEST.MF b/bundles/org.eclipse.wst.jsdt.web.core/META-INF/MANIFEST.MF deleted file mode 100644 index 76954a2671..0000000000 --- a/bundles/org.eclipse.wst.jsdt.web.core/META-INF/MANIFEST.MF +++ /dev/null @@ -1,35 +0,0 @@ -Manifest-Version: 1.0 -Bundle-ManifestVersion: 2 -Bundle-Name: JSDT Web Support Core (Incubation) -Bundle-SymbolicName: org.eclipse.wst.jsdt.web.core; singleton:=true -Bundle-Version: 0.0.1.qualifier -Bundle-Activator: org.eclipse.wst.jsdt.web.core.internal.JsCorePlugin -Bundle-Vendor: Eclipse.org -Bundle-Localization: plugin -Export-Package: org.eclipse.wst.jsdt.web.core.internal;x-friends:="org.eclipse.wst.jsdt.web.ui", - org.eclipse.wst.jsdt.web.core.internal.java;x-friends:="org.eclipse.wst.jsdt.web.ui", - org.eclipse.wst.jsdt.web.core.internal.java.search;x-friends:="org.eclipse.wst.jsdt.web.ui", - org.eclipse.wst.jsdt.web.core.internal.modelhandler;x-friends:="org.eclipse.wst.jsdt.web.ui", - org.eclipse.wst.jsdt.web.core.internal.project, - org.eclipse.wst.jsdt.web.core.internal.provisional.contenttype;x-friends:="org.eclipse.wst.jsdt.web.ui", - org.eclipse.wst.jsdt.web.core.internal.provisional.text;x-friends:="org.eclipse.wst.jsdt.web.ui", - org.eclipse.wst.jsdt.web.core.internal.tasks;x-friends:="org.eclipse.wst.jsdt.web.ui", - org.eclipse.wst.jsdt.web.core.internal.validation;x-friends:="org.eclipse.wst.jsdt.web.ui", - org.eclipse.wst.jsdt.web.core.text -Require-Bundle: com.ibm.icu;bundle-version="[3.4.4,4.0.0)", - org.eclipse.core.runtime;bundle-version="[3.2.0,4.0.0)", - org.eclipse.core.resources;bundle-version="[3.2.0,4.0.0)", - org.eclipse.core.filebuffers;bundle-version="[3.2.0,4.0.0)", - org.eclipse.wst.sse.core;bundle-version="[1.1.0,1.2.0)", - org.eclipse.wst.xml.core;bundle-version="[1.1.0,1.2.0)", - org.eclipse.wst.html.core;bundle-version="[1.1.0,1.2.0)", - org.eclipse.wst.validation;bundle-version="[1.1.0,1.2.0)", - org.eclipse.jface.text, - org.eclipse.wst.jsdt.core, - org.eclipse.wst.common.project.facet.core, - org.eclipse.wst.jsdt.ui -Eclipse-LazyStart: true -Import-Package: org.eclipse.swt.widgets, - org.eclipse.wst.common.componentcore, - org.eclipse.wst.common.componentcore.internal.util, - org.eclipse.wst.common.componentcore.resources diff --git a/bundles/org.eclipse.wst.jsdt.web.core/META-INF/eclipse.inf b/bundles/org.eclipse.wst.jsdt.web.core/META-INF/eclipse.inf deleted file mode 100644 index 92ffed2421..0000000000 --- a/bundles/org.eclipse.wst.jsdt.web.core/META-INF/eclipse.inf +++ /dev/null @@ -1,2 +0,0 @@ -#Processed using Jarprocessor -pack200.conditioned = true diff --git a/bundles/org.eclipse.wst.jsdt.web.core/build.properties b/bundles/org.eclipse.wst.jsdt.web.core/build.properties deleted file mode 100644 index 8491309914..0000000000 --- a/bundles/org.eclipse.wst.jsdt.web.core/build.properties +++ /dev/null @@ -1,9 +0,0 @@ -source.. = src/ -bin.includes = .options,\ - META-INF/,\ - .,\ - plugin.properties,\ - plugin.xml,\ - component.xml -src.includes = component.xml -
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.jsdt.web.core/component.xml b/bundles/org.eclipse.wst.jsdt.web.core/component.xml deleted file mode 100644 index 0d66ac286d..0000000000 --- a/bundles/org.eclipse.wst.jsdt.web.core/component.xml +++ /dev/null @@ -1,25 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<component xmlns="http://eclipse.org/wtp/releng/tools/component-model" name="org.eclipse.wst.jsdt.web"> - <component-depends unrestricted="true" /> - <plugin id="org.eclipse.wst.jsdt.web.core" fragment="false" /> - <package name="org.eclipse.wst.jsdt.web.core.taglib" api="false"> - <type name="IJarRecord" implement="false" /> - <!-- <type name="ITagDirRecord" implement="false" /> --> - <!-- <type name="ITaglibIndexListener" implement="true" /> --> - <type name="ITaglibDescriptor" implement="false" /> - <type name="ITaglibRecord" implement="false" /> - <!-- <type name="ITaglibRecordEvent" implement="false" /> --> - <type name="ITLDRecord" implement="false" /> - <type name="IURLRecord" implement="false" /> - <type name="TaglibIndex" subclass="false" instantiate="false" /> - </package> - <plugin id="org.eclipse.wst.jsdt.web.ui" fragment="false" /> - <package name="org.eclipse.wst.jsdt.web.ui" api="false"> - <type name="StructuredTextViewerConfigurationJSP" subclass="true" instantiate="true" /> - </package> - <package name="org.eclipse.wst.jsdt.web.ui.views.contentoutline" api="false"> - <type name="JSPContentOutlineConfiguration" subclass="true" instantiate="true" /> - </package> - <plugin id="org.eclipse.wst.jsdt.web.ui.infopop" fragment="false" /> - <description url="http://eclipse.org/webtools/jst/components/jsp/overview.html" /> -</component>
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.jsdt.web.core/plugin.xml b/bundles/org.eclipse.wst.jsdt.web.core/plugin.xml deleted file mode 100644 index 2222c04817..0000000000 --- a/bundles/org.eclipse.wst.jsdt.web.core/plugin.xml +++ /dev/null @@ -1,103 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<?eclipse version="3.0"?> -<plugin> - <!-- Install Handler for web JSDT.. Pigybacks on wst.web facet--> - <extension point="org.eclipse.wst.common.project.facet.core.facets"> - - <event-handler facet="wst.web" type="POST_INSTALL" version="[1.0"> - <delegate class="org.eclipse.wst.jsdt.web.core.internal.project.JsNatureInstaller"/> - </event-handler> - - <event-handler facet="wst.web" type="POST_UNINSTALL" version="[1.0"> - <delegate class="org.eclipse.wst.jsdt.web.core.internal.project.JsNatureUninstaller"/> - </event-handler> - - <event-handler facet="jst.web" type="POST_INSTALL" version="[2.4"> - <delegate class="org.eclipse.wst.jsdt.web.core.internal.project.JsNatureInstaller"/> - </event-handler> - - <event-handler facet="jst.web" type="POST_UNINSTALL" version="[2.4"> - <delegate class="org.eclipse.wst.jsdt.web.core.internal.project.JsNatureUninstaller"/> - </event-handler> - - - </extension> - - <extension id="embeded.jsNature" name="JavaScript Embeded" point="org.eclipse.core.resources.natures"> - <runtime> - <run class="org.eclipse.wst.jsdt.web.core.internal.project.JsWebNature"/> - </runtime> - <builder id="org.eclipse.wst.jsdt.web.core.embeded.javascript"/> - </extension> - - - <!-- - Not using this at the moment, but everythings in place if we need in the future. - --> - - <extension id="embeded.javascript" name="Embeded JavaScript Builder" point="org.eclipse.core.resources.builders"> - <builder hasNature="true" callOnEmptyDelta="true"> - - <run class="org.eclipse.wst.jsdt.web.core.internal.IncrementalBuilder"/> - </builder> - </extension> - - - - - - <extension point="org.eclipse.wst.sse.core.taskscanner"> - <scanner - id="org.eclipse.wst.jsdt.web.core.internal.tasks.JsFileTaskScanner" - class="org.eclipse.wst.jsdt.web.core.internal.tasks.JsFileTaskScanner" - contentTypeIds="org.eclipse.wst.html.core.htmlsource" /> - </extension> - - - <extension point="org.eclipse.wst.sse.core.formatProcessors"> - <processor - class="org.eclipse.wst.html.core.internal.format.HTMLFormatProcessorImpl" - contentTypeId="org.eclipse.wst.html.core.htmlsource"> - </processor> - </extension> - - - <!--======================================================================================--> - <!-- JSP batch validation --> - <!--======================================================================================--> - <extension - id="JsBatchValidator" - name="JavaScript Syntax Validation" - point="org.eclipse.wst.validation.validator"> - <validator> - <projectNature id="org.eclipse.wst.jsdt.core.jsNature" /> - - <filter - objectClass="org.eclipse.core.resources.IFile" - nameFilter="*.html"> - </filter> - <filter - objectClass="org.eclipse.core.resources.IFile" - nameFilter="*.htm"> - </filter> - - <filter - objectClass="org.eclipse.core.resources.IFile" - nameFilter="*.jsp"> - </filter> - - - <enablement/> - - <helper - class="org.eclipse.wst.validation.internal.operations.WorkbenchContext"> - </helper> - - <run - enabled="true" - class="org.eclipse.wst.jsdt.web.core.internal.validation.JsBatchValidator"> - </run> - </validator> - </extension> - -</plugin> diff --git a/bundles/org.eclipse.wst.jsdt.web.core/src/org/eclipse/wst/jsdt/web/core/internal/IncrementalBuilder.java b/bundles/org.eclipse.wst.jsdt.web.core/src/org/eclipse/wst/jsdt/web/core/internal/IncrementalBuilder.java deleted file mode 100644 index f8e930e214..0000000000 --- a/bundles/org.eclipse.wst.jsdt.web.core/src/org/eclipse/wst/jsdt/web/core/internal/IncrementalBuilder.java +++ /dev/null @@ -1,39 +0,0 @@ -/** - * - */ -package org.eclipse.wst.jsdt.web.core.internal; - -import java.util.Map; - -import org.eclipse.core.resources.IProject; -import org.eclipse.core.resources.IncrementalProjectBuilder; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IProgressMonitor; - -/** - * @author childsb - * - * Project builder-- I thought having a builder would activate the plugin, but - * it doesn't. - * - * I'm leaving it here incase we need it later. - * - */ -public class IncrementalBuilder extends IncrementalProjectBuilder { - public IncrementalBuilder() { - System.out.println("Unimplemented method:IncrementalProjectBuilder()"); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.core.resources.IncrementalProjectBuilder#build(int, - * java.util.Map, org.eclipse.core.runtime.IProgressMonitor) - */ - - protected IProject[] build(int kind, Map args, IProgressMonitor monitor) throws CoreException { - // TODO Auto-generated method stub - System.out.println("Unimplemented method:IncrementalBuilder.build"); - return null; - } -} diff --git a/bundles/org.eclipse.wst.jsdt.web.core/src/org/eclipse/wst/jsdt/web/core/internal/JSPCorePluginResources.properties b/bundles/org.eclipse.wst.jsdt.web.core/src/org/eclipse/wst/jsdt/web/core/internal/JSPCorePluginResources.properties deleted file mode 100644 index 9b58c0a836..0000000000 --- a/bundles/org.eclipse.wst.jsdt.web.core/src/org/eclipse/wst/jsdt/web/core/internal/JSPCorePluginResources.properties +++ /dev/null @@ -1,24 +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 -############################################################################### -JSPIndexManager_0=Updating JSP Index -JSPIndexManager_2=JSP Indexer indexing {0} files -JSP_Search=JSP Search - -JSPDocumentLoader_1=Program Error: structured model had no structuredDocument -JSPEL_Syntax=EL Syntax Error -JSPEL_Token=Unable to analyse EL expression due to lexical analysis error -MESSAGE_JSP_VALIDATING_MESSAGE_UI_=JSP Validator validating {0} -JSPFContentPropertiesManager_Updating=Updating JSP Fragment Content Settings -JSPFContentPropertiesManager_Problems_Updating=Problem saving JSP Fragment Content Settings for {0} -JSPDirectiveValidator_0={0} is a reserved prefix. Try another -JSPDirectiveValidator_1=Cannot find the tag library descriptor for {0} -JSPDirectiveValidator_2=The prefix {0} is used more than once -JSPDirectiveValidator_3=A {0} value is required in this directive -JSPBatchValidator_0=Gathering files in {0} diff --git a/bundles/org.eclipse.wst.jsdt.web.core/src/org/eclipse/wst/jsdt/web/core/internal/JsCoreMessages.java b/bundles/org.eclipse.wst.jsdt.web.core/src/org/eclipse/wst/jsdt/web/core/internal/JsCoreMessages.java deleted file mode 100644 index b3f05e686b..0000000000 --- a/bundles/org.eclipse.wst.jsdt.web.core/src/org/eclipse/wst/jsdt/web/core/internal/JsCoreMessages.java +++ /dev/null @@ -1,46 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2005 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.jsdt.web.core.internal; - -import org.eclipse.osgi.util.NLS; - -/** - * Strings used by JSP Core - * - * @plannedfor 1.0 - */ -public class JsCoreMessages extends NLS { - private static final String BUNDLE_NAME = "org.eclipse.wst.jsdt.web.core.internal.JSPCorePluginResources"; //$NON-NLS-1$ - public static String JSP_Search; - public static String JSPBatchValidator_0; - public static String JSPDirectiveValidator_0; - public static String JSPDirectiveValidator_1; - public static String JSPDirectiveValidator_2; - public static String JSPDirectiveValidator_3; - public static String JSPDocumentLoader_1; - public static String JSPEL_Syntax; - public static String JSPEL_Token; - public static String JSPFContentPropertiesManager_Problems_Updating; - public static String JSPFContentPropertiesManager_Updating; - public static String JSPIndexManager_0; - public static String JSPIndexManager_2; - /** - * @deprecated - */ - - public static String MESSAGE_JSP_VALIDATING_MESSAGE_UI_; - static { - // initialize resource bundle - NLS.initializeMessages(JsCoreMessages.BUNDLE_NAME, JsCoreMessages.class); - } - - private JsCoreMessages() {} -} diff --git a/bundles/org.eclipse.wst.jsdt.web.core/src/org/eclipse/wst/jsdt/web/core/internal/JsCorePlugin.java b/bundles/org.eclipse.wst.jsdt.web.core/src/org/eclipse/wst/jsdt/web/core/internal/JsCorePlugin.java deleted file mode 100644 index f3be6c6344..0000000000 --- a/bundles/org.eclipse.wst.jsdt.web.core/src/org/eclipse/wst/jsdt/web/core/internal/JsCorePlugin.java +++ /dev/null @@ -1,72 +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.jsdt.web.core.internal; - -import org.eclipse.core.runtime.Plugin; -import org.eclipse.wst.jsdt.web.core.internal.java.search.JsIndexManager; -import org.osgi.framework.BundleContext; - -/** - * The main plugin class to be used in the desktop. - */ -public class JsCorePlugin extends Plugin { - // The shared instance. - private static JsCorePlugin plugin; - public static final String PLUGIN_ID = "org.eclipse.wst.jsdt.web.core"; - - /** - * Returns the shared instance. - * - * @deprecated - will be removed. Currently used to get "model preferences", - * but there are other, better ways. - */ - - public static JsCorePlugin getDefault() { - return JsCorePlugin.plugin; - } - - /** - * The constructor. - */ - public JsCorePlugin() { - super(); - JsCorePlugin.plugin = this; - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.core.runtime.Plugin#start(org.osgi.framework.BundleContext) - */ - - public void start(BundleContext context) throws Exception { - super.start(context); - // JSPIndexManager depends on TaglibController, so TaglibController - // should be started first - // listen for classpath changes - JsIndexManager.getInstance().initialize(); - // listen for resource changes to update content properties keys - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.core.runtime.Plugin#stop(org.osgi.framework.BundleContext) - */ - - public void stop(BundleContext context) throws Exception { - // stop listenning for resource changes to update content properties - // keys - // stop any indexing - JsIndexManager.getInstance().shutdown(); - super.stop(context); - } -} diff --git a/bundles/org.eclipse.wst.jsdt.web.core/src/org/eclipse/wst/jsdt/web/core/internal/Logger.java b/bundles/org.eclipse.wst.jsdt.web.core/src/org/eclipse/wst/jsdt/web/core/internal/Logger.java deleted file mode 100644 index bb730e339b..0000000000 --- a/bundles/org.eclipse.wst.jsdt.web.core/src/org/eclipse/wst/jsdt/web/core/internal/Logger.java +++ /dev/null @@ -1,153 +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.jsdt.web.core.internal; - -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Platform; -import org.eclipse.core.runtime.Status; -import org.osgi.framework.Bundle; - -import com.ibm.icu.util.StringTokenizer; - -/** - * 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 { - public static final int ERROR = IStatus.ERROR; // 4 - public static final int ERROR_DEBUG = 200 + Logger.ERROR; - public static final int INFO = IStatus.INFO; // 1 - public static final int INFO_DEBUG = 200 + Logger.INFO; - public static final int OK = IStatus.OK; // 0 - public static final int OK_DEBUG = 200 + Logger.OK; - private static final String PLUGIN_ID = "org.eclipse.wst.jsdt.web.core"; //$NON-NLS-1$ - 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 + Logger.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 == Logger.OK_DEBUG || level == Logger.INFO_DEBUG || level == Logger.WARNING_DEBUG || level == Logger.ERROR_DEBUG) { - if (!Logger.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, Logger.PLUGIN_ID, severity, message, exception); - Bundle bundle = Platform.getBundle(Logger.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 (Logger.isTracing(category)) { - message = (message != null) ? message : "null"; //$NON-NLS-1$ - Status statusObj = new Status(IStatus.OK, Logger.PLUGIN_ID, IStatus.OK, message, exception); - Bundle bundle = Platform.getBundle(Logger.PLUGIN_ID); - if (bundle != null) { - Platform.getLog(bundle).log(statusObj); - } - } - } - - /** - * @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 (!Logger.isDebugging()) { - return false; - } - String traceFilter = Platform.getDebugOption(Logger.PLUGIN_ID + Logger.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) { - Logger._log(level, message, null); - } - - public static void log(int level, String message, Throwable exception) { - Logger._log(level, message, exception); - } - - public static void logException(String message, Throwable exception) { - Logger._log(Logger.ERROR, message, exception); - } - - public static void logException(Throwable exception) { - Logger._log(Logger.ERROR, exception.getMessage(), exception); - } - - public static void trace(String category, String message) { - Logger._trace(category, message, null); - } - - public static void traceException(String category, String message, Throwable exception) { - Logger._trace(category, message, exception); - } - - public static void traceException(String category, Throwable exception) { - Logger._trace(category, exception.getMessage(), exception); - } -} diff --git a/bundles/org.eclipse.wst.jsdt.web.core/src/org/eclipse/wst/jsdt/web/core/internal/java/CompilationUnitHelper.java b/bundles/org.eclipse.wst.jsdt.web.core/src/org/eclipse/wst/jsdt/web/core/internal/java/CompilationUnitHelper.java deleted file mode 100644 index 21d996448d..0000000000 --- a/bundles/org.eclipse.wst.jsdt.web.core/src/org/eclipse/wst/jsdt/web/core/internal/java/CompilationUnitHelper.java +++ /dev/null @@ -1,47 +0,0 @@ -package org.eclipse.wst.jsdt.web.core.internal.java; - -import org.eclipse.wst.jsdt.core.WorkingCopyOwner; - -/** - * To ensure there is only one instance of ProblemRequestor and WorkingCopyOwner - * for JSP plugins. These were removed from JSPTranslation to ensure that the - * JSPTranslation was not held in memory by any type of JDT lists (caching - * search results, etc...) - * - * @author pavery - */ -public class CompilationUnitHelper { - private static CompilationUnitHelper instance; - - public synchronized static final CompilationUnitHelper getInstance() { - if (CompilationUnitHelper.instance == null) { - CompilationUnitHelper.instance = new CompilationUnitHelper(); - } - return CompilationUnitHelper.instance; - } - private JsProblemRequestor fProblemRequestor = null; - private WorkingCopyOwner fWorkingCopyOwner = null; - - private CompilationUnitHelper() { - // force use of instance - } - - public JsProblemRequestor getProblemRequestor() { - if (fProblemRequestor == null) { - fProblemRequestor = new JsProblemRequestor(); - } - return fProblemRequestor; - } - - public WorkingCopyOwner getWorkingCopyOwner() { - if (fWorkingCopyOwner == null) { - fWorkingCopyOwner = new WorkingCopyOwner() { - - public String toString() { - return "JSP Working copy owner"; //$NON-NLS-1$ - } - }; - } - return fWorkingCopyOwner; - } -} diff --git a/bundles/org.eclipse.wst.jsdt.web.core/src/org/eclipse/wst/jsdt/web/core/internal/java/DocumentChangeListenerToTextEdit.java b/bundles/org.eclipse.wst.jsdt.web.core/src/org/eclipse/wst/jsdt/web/core/internal/java/DocumentChangeListenerToTextEdit.java deleted file mode 100644 index 5deade547d..0000000000 --- a/bundles/org.eclipse.wst.jsdt.web.core/src/org/eclipse/wst/jsdt/web/core/internal/java/DocumentChangeListenerToTextEdit.java +++ /dev/null @@ -1,57 +0,0 @@ -/** - * - */ -package org.eclipse.wst.jsdt.web.core.internal.java; - -import org.eclipse.jface.text.DocumentEvent; -import org.eclipse.jface.text.IDocumentListener; -import org.eclipse.text.edits.DeleteEdit; -import org.eclipse.text.edits.InsertEdit; -import org.eclipse.text.edits.MultiTextEdit; -import org.eclipse.text.edits.ReplaceEdit; - -/** - * @author childsb - * - */ -public class DocumentChangeListenerToTextEdit implements IDocumentListener { - private MultiTextEdit textEdit; - - public DocumentChangeListenerToTextEdit() { - textEdit = new MultiTextEdit(); - } - - public void documentAboutToBeChanged(DocumentEvent event) { - // System.out.println("Unimplemented - // method:DocumentChangeListenerToTextEdit.documentAboutToBeChanged"); - } - - public void documentChanged(DocumentEvent event) { - int length = event.getLength(); - int offset = event.getOffset(); - String text = event.getText(); - if (length < 0) { - return; - } - if (length == 0) { - /* inserting text operation */ - InsertEdit edit = new InsertEdit(offset, text); - textEdit.addChild(edit); - System.out.println("-------------Insert Text Edit"); - } else if (text == null || text.equals("")) { - /* delete operation */ - DeleteEdit edit = new DeleteEdit(offset, length); - textEdit.addChild(edit); - System.out.println("-------------Delete Text Edit"); - } else if (length > 0) { - /* replace text operation */ - ReplaceEdit edit = new ReplaceEdit(offset, length, text); - textEdit.addChild(edit); - System.out.println("-------------Replace Text Edit"); - } - } - - public MultiTextEdit getTextEdits() { - return textEdit; - } -} diff --git a/bundles/org.eclipse.wst.jsdt.web.core/src/org/eclipse/wst/jsdt/web/core/internal/java/IJsTranslation.java b/bundles/org.eclipse.wst.jsdt.web.core/src/org/eclipse/wst/jsdt/web/core/internal/java/IJsTranslation.java deleted file mode 100644 index 2e7b2153c7..0000000000 --- a/bundles/org.eclipse.wst.jsdt.web.core/src/org/eclipse/wst/jsdt/web/core/internal/java/IJsTranslation.java +++ /dev/null @@ -1,111 +0,0 @@ -/** - * - */ -package org.eclipse.wst.jsdt.web.core.internal.java; - -import java.util.List; - -import org.eclipse.wst.jsdt.core.ICompilationUnit; -import org.eclipse.wst.jsdt.core.IJavaElement; -import org.eclipse.wst.jsdt.core.WorkingCopyOwner; - -/** - * @author childsb - * - */ -public interface IJsTranslation { - /* - * (non-Javadoc) - * - * @see org.eclipse.wst.jsdt.web.core.internal.java.JSPTranslation_Interface#fixupMangledName(java.lang.String) - */ - public abstract String fixupMangledName(String displayString); - - public abstract IJavaElement[] getAllElementsInJsRange(int jspStart, int jspEnd); - - /* - * (non-Javadoc) - * - * @see org.eclipse.wst.jsdt.web.core.internal.java.JSPTranslation_Interface#getCompilationUnit() - */ - public abstract ICompilationUnit getCompilationUnit(); - - /* - * (non-Javadoc) - * - * @see org.eclipse.wst.jsdt.web.core.internal.java.JSPTranslation_Interface#getElementsFromJspRange(int, - * int) - */ - public abstract IJavaElement[] getElementsFromJsRange(int jspStart, int jspEnd); - - /* - * (non-Javadoc) - * - * @see org.eclipse.wst.jsdt.web.core.internal.java.JSPTranslation_Interface#getJspText() - */ - public abstract String getHtmlText(); - - /* - * (non-Javadoc) - * - * @see org.eclipse.wst.jsdt.web.core.internal.java.JSPTranslation_Interface#isUseBean(int) - */ - // public boolean isUseBean(int javaOffset) { - // System.out.println("REMOVE JSPTranslation.isUseBean(int javaOffset)"); - // return false; - // } - /* - * (non-Javadoc) - * - * @see org.eclipse.wst.jsdt.web.core.internal.java.JSPTranslation_Interface#getJavaPath() - */ - public abstract String getJavaPath(); - - public abstract IJavaElement getJsElementAtOffset(int htmlstart); - - /* - * (non-Javadoc) - * - * @see org.eclipse.wst.jsdt.web.core.internal.java.IJSPTranslation#getJavaText() - */ - /* - * (non-Javadoc) - * - * @see org.eclipse.wst.jsdt.web.core.internal.java.JSPTranslation_Interface#getJavaText() - */ - public abstract String getJsText(); - - /* - * (non-Javadoc) - * - * @see org.eclipse.wst.jsdt.web.core.internal.java.JSPTranslation_Interface#getProblems() - */ - public abstract List getProblems(); - - /* - * (non-Javadoc) - * - * @see org.eclipse.wst.jsdt.web.core.internal.java.JSPTranslation_Interface#getWorkingCopyOwner() - */ - public abstract WorkingCopyOwner getWorkingCopyOwner(); - - public abstract boolean ifOffsetInImportNode(int offset); - - //public abstract boolean isOffsetInScriptNode(int offset); - - public abstract void reconcileCompilationUnit(); - - /* - * (non-Javadoc) - * - * @see org.eclipse.wst.jsdt.web.core.internal.java.JSPTranslation_Interface#release() - */ - public abstract void release(); - - /* - * (non-Javadoc) - * - * @see org.eclipse.wst.jsdt.web.core.internal.java.JSPTranslation_Interface#setProblemCollectingActive(boolean) - */ - public abstract void setProblemCollectingActive(boolean collect); -}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.jsdt.web.core/src/org/eclipse/wst/jsdt/web/core/internal/java/JsDataTypes.java b/bundles/org.eclipse.wst.jsdt.web.core/src/org/eclipse/wst/jsdt/web/core/internal/java/JsDataTypes.java deleted file mode 100644 index 7ab0b5d4f1..0000000000 --- a/bundles/org.eclipse.wst.jsdt.web.core/src/org/eclipse/wst/jsdt/web/core/internal/java/JsDataTypes.java +++ /dev/null @@ -1,30 +0,0 @@ -package org.eclipse.wst.jsdt.web.core.internal.java; - -import org.eclipse.wst.html.core.internal.provisional.HTML40Namespace; -import org.eclipse.wst.html.core.text.IHTMLPartitions; - -public interface JsDataTypes extends HTML40Namespace { - /* - * remove when when we refactor (need to add this content type to many - * project types in wst) - */ - public static final String BASE_FILE_EXTENSION = ".js"; - public static String[] CONSTANTS = { "false", "null", "true" }; //$NON-NLS-3$//$NON-NLS-2$//$NON-NLS-1$ - public static final String[] EVENTS = { HTML40Namespace.ATTR_NAME_ONCLICK, HTML40Namespace.ATTR_NAME_ONDBLCLICK, HTML40Namespace.ATTR_NAME_ONMOUSEDOWN, - HTML40Namespace.ATTR_NAME_ONMOUSEUP, HTML40Namespace.ATTR_NAME_ONMOUSEOVER, HTML40Namespace.ATTR_NAME_ONMOUSEMOVE, - HTML40Namespace.ATTR_NAME_ONMOUSEOUT, HTML40Namespace.ATTR_NAME_ONKEYPRESS, HTML40Namespace.ATTR_NAME_ONKEYDOWN, HTML40Namespace.ATTR_NAME_ONKEYUP, - HTML40Namespace.ATTR_NAME_ONHELP }; - public static final String[] HTMLATREVENTS = { "onload ", "onunload", "onclick", "onmousedown", "onmouseup", "onmouseover", "onmousemove", "onmouseout", - "onfocus", "onblur", "onkeypress", "onkeydown", "onkeyup", "onsubmit", "onreset", "onselect", "onchange", }; - public static final String[] JSVALIDDATATYPES = { "JAVASCRIPT", "TEXT/JAVASCRIPT" }; //$NON-NLS-1$ - public static String[] KEYWORDS = { "abstract", "break", "case", "catch", "class", "const", "continue", "debugger", "default", "delete", "do", "else", - "enum", "export", "extends", "final", "finally", "for", "function", "goto", "if", "implements", "import", "in", "instanceof", "interface", - "native", "new", "package", "private", "protected", "public", "return", - "static", "super", "switch", "synchronized", "this", "throw", "throws", "transient", "try", "typeof", "volatile", "while", "with" }; //$NON-NLS-1$ - // public static final String - // NEW_PARTITION_TYPE="org.eclipse.wst.jsdt.StructuredJs"; - // public static final String NEW_PARTITION_TYPE=IHTMLPartitions.SCRIPT; - public static final String NEW_PARTITION_TYPE = IHTMLPartitions.SCRIPT; - public static final String[] TAKEOVER_PARTITION_TYPES = { "none" }; - public static String[] TYPES = { "boolean", "byte", "char", "double", "int", "long", "short", "float", "var", "void" }; //$NON-NLS-1$ -} diff --git a/bundles/org.eclipse.wst.jsdt.web.core/src/org/eclipse/wst/jsdt/web/core/internal/java/JsNameManglerUtil.java b/bundles/org.eclipse.wst.jsdt.web.core/src/org/eclipse/wst/jsdt/web/core/internal/java/JsNameManglerUtil.java deleted file mode 100644 index d953f82ac5..0000000000 --- a/bundles/org.eclipse.wst.jsdt.web.core/src/org/eclipse/wst/jsdt/web/core/internal/java/JsNameManglerUtil.java +++ /dev/null @@ -1,130 +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.jsdt.web.core.internal.java; - -import java.io.File; - -/** - * @author pavery - */ -public class JsNameManglerUtil { - /** - * Determine if given string is a valid Hex representation of an ASCII - * character (eg. 2F -> /) - * - * @param possible - * @return - */ - private static boolean isValid(String possible) { - boolean result = false; - if (possible.length() == 2) { - char c1 = possible.charAt(0); - char c2 = possible.charAt(1); - // 1st character must be a digit - if (Character.isDigit(c1)) { - // 2nd character must be digit or upper case letter A-F - if (Character.isDigit(c2)) { - result = true; - } else if (Character.isUpperCase(c2) && (c2 == 'A' || c2 == 'B' || c2 == 'C' || c2 == 'D' || c2 == 'E' || c2 == 'F')) { - result = true; - } - } - } - return result; - } - - /** - * Mangle string to WAS-like specifications - * - */ - public final static String mangle(String name) { - StringBuffer modifiedName = new StringBuffer(); - // extension (.jsp, .jspf, .jspx, etc...) should already be encoded in - // name - int length = name.length(); - // in case name is forbidden (a number, class, for, etc...) - modifiedName.append('_'); - // ensure rest of characters are valid - for (int i = 0; i < length; i++) { - char currentChar = name.charAt(i); - if (Character.isJavaIdentifierPart(currentChar) == true) { - modifiedName.append(currentChar); - } else { - modifiedName.append(JsNameManglerUtil.mangleChar(currentChar)); - } - } - return modifiedName.toString(); - } - - /** - * take a character and return its hex equivalent - */ - private final static String mangleChar(char ch) { - if (ch == File.separatorChar) { - ch = '/'; - } - if (Character.isLetterOrDigit(ch) == true) { - return "" + ch; //$NON-NLS-1$ - } - return "_" + Integer.toHexString(ch).toUpperCase() + "_"; //$NON-NLS-1$ //$NON-NLS-2$ - } - - /** - * WAS mangles Tom&Jerry as: _Tom_26_Jerry; this takes in the mangled name - * and returns the original name. - * - * Unmangles the qualified type name. If an underscore is found it is - * assumed to be a mangled representation of a non-alpha, non-digit - * character of the form _NN_, where NN are hex digits representing the - * encoded character. This routine converts it back to the original - * character. - */ - public final static String unmangle(String qualifiedTypeName) { - if (qualifiedTypeName.charAt(0) != '_') { - return qualifiedTypeName; - } - StringBuffer buf = new StringBuffer(); - String possible = ""; //$NON-NLS-1$ - // remove the .java extension if there is one - if (qualifiedTypeName.endsWith(".js")) { - qualifiedTypeName = qualifiedTypeName.substring(0, qualifiedTypeName.length() - 3); - } - for (int i = 1; i < qualifiedTypeName.length(); i++) { // start at - // index 1 b/c - // 1st char is - // always '_' - char c = qualifiedTypeName.charAt(i); - if (c == '_') { - int endIndex = qualifiedTypeName.indexOf('_', i + 1); - if (endIndex == -1) { - buf.append(c); - } else { - char unmangled; - try { - possible = qualifiedTypeName.substring(i + 1, endIndex); - if (JsNameManglerUtil.isValid(possible)) { - unmangled = (char) Integer.decode("0x" + possible).intValue();//$NON-NLS-1$ - i = endIndex; - } else { - unmangled = c; - } - } catch (NumberFormatException e) { - unmangled = c; - } - buf.append(unmangled); - } - } else { - buf.append(c); - } - } - return buf.toString(); - } -} diff --git a/bundles/org.eclipse.wst.jsdt.web.core/src/org/eclipse/wst/jsdt/web/core/internal/java/JsProblemRequestor.java b/bundles/org.eclipse.wst.jsdt.web.core/src/org/eclipse/wst/jsdt/web/core/internal/java/JsProblemRequestor.java deleted file mode 100644 index 6bb98b04fc..0000000000 --- a/bundles/org.eclipse.wst.jsdt.web.core/src/org/eclipse/wst/jsdt/web/core/internal/java/JsProblemRequestor.java +++ /dev/null @@ -1,77 +0,0 @@ -package org.eclipse.wst.jsdt.web.core.internal.java; - -/** - * @author pavery - */ -import java.util.ArrayList; -import java.util.List; - -import org.eclipse.wst.jsdt.core.IProblemRequestor; -import org.eclipse.wst.jsdt.core.compiler.IProblem; - -class JsProblemRequestor implements IProblemRequestor { - private List fCollectedProblems; - private boolean fIsActive = false; - private boolean fIsRunning = false; - - public void acceptProblem(IProblem problem) { - if (isActive()) { - fCollectedProblems.add(problem); - } - } - - public void beginReporting() { - fIsRunning = true; - fCollectedProblems = new ArrayList(); - } - - public void endReporting() { - fIsRunning = false; - } - - /** - * @return the list of collected problems - */ - public List getCollectedProblems() { - return fCollectedProblems; - } - - public boolean isActive() { - return fIsActive && fCollectedProblems != null; - } - - public boolean isRunning() { - return fIsRunning; - } - - /** - * Sets the active state of this problem requestor. - * - * @param isActive - * the state of this problem requestor - */ - public void setIsActive(boolean isActive) { - if (fIsActive != isActive) { - fIsActive = isActive; - if (fIsActive) { - startCollectingProblems(); - } else { - stopCollectingProblems(); - } - } - } - - /** - * Tells this annotation model to collect temporary problems from now on. - */ - private void startCollectingProblems() { - fCollectedProblems = new ArrayList(); - } - - /** - * Tells this annotation model to no longer collect temporary problems. - */ - private void stopCollectingProblems() { - // do nothing - } -} diff --git a/bundles/org.eclipse.wst.jsdt.web.core/src/org/eclipse/wst/jsdt/web/core/internal/java/JsTranslation.java b/bundles/org.eclipse.wst.jsdt.web.core/src/org/eclipse/wst/jsdt/web/core/internal/java/JsTranslation.java deleted file mode 100644 index 82926a17f9..0000000000 --- a/bundles/org.eclipse.wst.jsdt.web.core/src/org/eclipse/wst/jsdt/web/core/internal/java/JsTranslation.java +++ /dev/null @@ -1,415 +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.jsdt.web.core.internal.java; - -import java.util.ArrayList; -import java.util.List; -import java.util.Vector; - -import org.eclipse.core.filebuffers.FileBuffers; -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.IResourceChangeEvent; -import org.eclipse.core.resources.IResourceChangeListener; -import org.eclipse.core.resources.ResourcesPlugin; -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.jobs.Job; -import org.eclipse.jface.text.IDocument; -import org.eclipse.jface.text.Position; -import org.eclipse.wst.jsdt.core.IBuffer; -import org.eclipse.wst.jsdt.core.ICompilationUnit; -import org.eclipse.wst.jsdt.core.IJavaElement; -import org.eclipse.wst.jsdt.core.IJavaProject; -import org.eclipse.wst.jsdt.core.IPackageDeclaration; -import org.eclipse.wst.jsdt.core.IPackageFragmentRoot; -import org.eclipse.wst.jsdt.core.ISourceRange; -import org.eclipse.wst.jsdt.core.JavaModelException; -import org.eclipse.wst.jsdt.core.LibrarySuperType; -import org.eclipse.wst.jsdt.core.WorkingCopyOwner; -import org.eclipse.wst.jsdt.internal.core.DocumentContextFragmentRoot; -import org.eclipse.wst.jsdt.internal.core.SourceRefElement; -import org.eclipse.wst.jsdt.web.core.internal.Logger; -import org.eclipse.wst.jsdt.web.core.internal.project.JsWebNature; -import org.eclipse.wst.sse.core.StructuredModelManager; -import org.eclipse.wst.sse.core.internal.provisional.IStructuredModel; -import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocument; -import org.eclipse.wst.xml.core.internal.provisional.document.IDOMModel; -import org.eclipse.wst.xml.core.internal.provisional.document.IDOMNode; - -/** - * @author brad childs - */ -public class JsTranslation implements IJsTranslation { - - private static final boolean DEBUG; - static { - String value = Platform.getDebugOption("org.eclipse.wst.jsdt.web.core/debug/jsptranslation"); //$NON-NLS-1$ - DEBUG = value != null && value.equalsIgnoreCase("true"); //$NON-NLS-1$ - } - - private ICompilationUnit fCompilationUnit = null; - private DocumentContextFragmentRoot fDocumentScope; - private IJavaProject fJavaProject = null; - private byte[] fLock = null; - private IProgressMonitor fProgressMonitor = null; - private IStructuredDocument fHtmlDocument; - private String fModelBaseLocation; - - - private static final String SUPER_TYPE_NAME = "Window"; - private static final String SUPER_TYPE_LIBRARY = "org.eclipse.wst.jsdt.launching.baseBrowserLibrary"; - - private JsTranslator translator; - - private String mangledName; - private boolean listenForChanges; - -// public JsTranslation(IStructuredDocument htmlDocument, IJavaProject javaProj) { -// fLock = new byte[0]; -// fJavaProject = javaProj; -// fHtmlDocument = htmlDocument; -// setBaseLocation(); -// translator = new JsTranslator(htmlDocument, fModelBaseLocation); -// mangledName = createMangledName(); -// listenForChanges = true; -// } - - public JsTranslation(IStructuredDocument htmlDocument, IJavaProject javaProj, boolean listenForChanges) { - fLock = new byte[0]; - fJavaProject = javaProj; - fHtmlDocument = htmlDocument; - setBaseLocation(); - translator = new JsTranslator(htmlDocument, fModelBaseLocation,listenForChanges); - mangledName = createMangledName(); - this.listenForChanges=listenForChanges; - } - - public IJavaProject getJavaProject() { - return fJavaProject; - } - - private IPackageFragmentRoot getDocScope(boolean reset) { - if(fDocumentScope==null) { - IProject project = getJavaProject().getProject(); - IResource absoluteRoot = ((IContainer)getJavaProject().getResource()).findMember( WebRootFinder.getWebContentFolder(fJavaProject.getProject())); - fDocumentScope = new DocumentContextFragmentRoot(fJavaProject, getFile(), WebRootFinder.getWebContentFolder(fJavaProject.getProject()), WebRootFinder.getServerContextRoot(fJavaProject.getProject()), JsWebNature.VIRTUAL_SCOPE_ENTRY); fDocumentScope.setIncludedFiles(translator.getRawImports()); - return fDocumentScope; - } - - if(reset) fDocumentScope.setIncludedFiles(translator.getRawImports()); - return fDocumentScope; - } - - private void setBaseLocation() { - IDOMModel xmlModel=null; - try { - xmlModel = (IDOMModel) StructuredModelManager.getModelManager().getExistingModelForRead(fHtmlDocument); - if(xmlModel==null) { - xmlModel = (IDOMModel) StructuredModelManager.getModelManager().getModelForRead(fHtmlDocument); - } - fModelBaseLocation = xmlModel.getBaseLocation(); - }finally { - if(xmlModel!=null) xmlModel.releaseFromRead(); - } - // return xmlModel; - } - - public IFile getFile() { - return FileBuffers.getWorkspaceFileAtLocation(new Path(fModelBaseLocation)); - } - - - public IDocument getHtmlDocument() { - return fHtmlDocument; - } - - public int getMissingTagStart() { - return translator.getMissingEndTagRegionStart(); - } - - private String getWebRoot() { - return WebRootFinder.getWebContentFolder(fJavaProject.getProject()).toString(); - } - - public String getDirectoryUnderRoot() { - String webRoot = getWebRoot() ; - IPath projectWebRootPath = getJavaProject().getPath().append(webRoot); - IPath filePath = new Path(fModelBaseLocation).removeLastSegments(1); - return filePath.removeFirstSegments(projectWebRootPath.matchingFirstSegments(filePath)).toString(); - } - - /** - * Originally from ReconcileStepForJava. Creates an ICompilationUnit from - * the contents of the JSP document. - * - * @return an ICompilationUnit from the contents of the JSP document - */ - private ICompilationUnit createCompilationUnit() throws JavaModelException { - //System.out.println("------------------------- CREATING CU ----------------------------"); - LibrarySuperType superType = new LibrarySuperType(SUPER_TYPE_LIBRARY, fJavaProject, SUPER_TYPE_NAME); - - IPackageFragmentRoot root = getDocScope(true); - //String directoryUnderWebroot = getDirectoryUnderRoot(); - ICompilationUnit cu = root.getPackageFragment("").getCompilationUnit(getMangledName() + JsDataTypes.BASE_FILE_EXTENSION).getWorkingCopy(getWorkingCopyOwner(), getProblemRequestor(), getProgressMonitor()); - //ICompilationUnit cu = fDocumentScope.getDefaultPackageFragment().getCompilationUnit(getMangledName() + JsDataTypes.BASE_FILE_EXTENSION,SUPER_TYPE_NAME).getWorkingCopy(getWorkingCopyOwner(), getProblemRequestor(), getProgressMonitor()); - - IBuffer buffer; - try { - buffer = cu.getBuffer(); - } catch (JavaModelException e) { - e.printStackTrace(); - buffer = null; - } - if (buffer != null) { - translator.setBuffer(buffer); - } - return cu; - } - - public String fixupMangledName(String displayString) { - if (displayString == null) { - return null; - } - return displayString.replaceAll(getMangledName() + ".js", getHtmlPageName()); - } - - public IJavaElement[] getAllElementsInJsRange(int javaPositionStart, int javaPositionEnd) { - IJavaElement[] EMTPY_RESULT_SET = new IJavaElement[0]; - IJavaElement[] result = EMTPY_RESULT_SET; - IJavaElement[] allChildren = null; - try { - allChildren = getCompilationUnit().getChildren(); - } catch (JavaModelException e) { - } - Vector validChildren = new Vector(); - for (int i = 0; i < allChildren.length; i++) { - if (allChildren[i] instanceof IJavaElement && allChildren[i].getElementType() != IJavaElement.PACKAGE_DECLARATION) { - ISourceRange range = getJSSourceRangeOf(allChildren[i]); - if (javaPositionStart <= range.getOffset() && range.getLength() + range.getOffset() <= (javaPositionEnd)) { - validChildren.add(allChildren[i]); - } else if (allChildren[i].getElementType() == IJavaElement.TYPE) { - validChildren.add(allChildren[i]); - } - } - } - if (validChildren.size() > 0) { - result = (IJavaElement[]) validChildren.toArray(new IJavaElement[] {}); - } - if (result == null || result.length == 0) { - return EMTPY_RESULT_SET; - } - return result; - } - - public ICompilationUnit getCompilationUnit() { - synchronized (fLock) { - try { - if (fCompilationUnit == null) { - fCompilationUnit = createCompilationUnit(); - return fCompilationUnit; - } - - } catch (JavaModelException jme) { - if (JsTranslation.DEBUG) { - Logger.logException("error creating JSP working copy... ", jme); //$NON-NLS-1$ - } - } - - } - getDocScope(true); - try { - fCompilationUnit = fCompilationUnit.getWorkingCopy(getWorkingCopyOwner(), getProblemRequestor(), getProgressMonitor()); - //fCompilationUnit.makeConsistent(getProgressMonitor()); - } catch (JavaModelException ex) { - // TODO Auto-generated catch block - ex.printStackTrace(); - } - return fCompilationUnit; - } - - public IJavaElement[] getElementsFromJsRange(int javaPositionStart, int javaPositionEnd) { - IJavaElement[] EMTPY_RESULT_SET = new IJavaElement[0]; - IJavaElement[] result = EMTPY_RESULT_SET; - try { - ICompilationUnit cu = getCompilationUnit(); - if (cu != null) { - synchronized (fLock) { - int cuDocLength = cu.getBuffer().getLength(); - int javaLength = javaPositionEnd - javaPositionStart; - if (cuDocLength > 0 && javaPositionStart >= 0 && javaLength >= 0 && javaPositionEnd <= cuDocLength) { - result = cu.codeSelect(javaPositionStart, javaLength, getWorkingCopyOwner()); - } - } - } - if (result == null || result.length == 0) { - return EMTPY_RESULT_SET; - } - } catch (JavaModelException x) { - Logger.logException(x); - } - return result; - } - - private String getHtmlPageName() { - IPath path = new Path(fModelBaseLocation); - return path.lastSegment(); - - } - - public String getHtmlText() { - return fHtmlDocument.get(); - } - - public String getJavaPath() { - //String webRoot = getWebRoot() ; - //IPackageFragmentRoot root = getDocScope(false); - //String cuPath = root.getPath().append("/" + getMangledName() + JsDataTypes.BASE_FILE_EXTENSION ).toString(); - //ICompilationUnit cu = getCompilationUnit(); - //IPath realCuPath = cu.getPath(); - IPath rootPath = new Path(fModelBaseLocation).removeLastSegments(1); - String cuPath = rootPath.append("/" + getMangledName() + JsDataTypes.BASE_FILE_EXTENSION ).toString(); - return cuPath; - } - - public IJavaElement getJsElementAtOffset(int jsOffset) { - IJavaElement elements = null; - try { - elements = getCompilationUnit().getElementAt(jsOffset); - } catch (JavaModelException e) { - // TODO Auto-generated catch block - if (JsTranslation.DEBUG) { - Logger.logException("error retrieving java elemtnt from compilation unit... ", e); //$NON-NLS-1$ - } - // } - } - return elements; - } - - private ISourceRange getJSSourceRangeOf(IJavaElement element) { - // returns the offset in html of given element - ISourceRange range = null; - if (element instanceof SourceRefElement) { - try { - range = ((SourceRefElement) element).getSourceRange(); - } catch (JavaModelException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - } - return range; - } - - public String getJsText() { - return translator.getJsText(); - } - - public String getMangledName() { - return this.mangledName; - } - - private String createMangledName() { - return JsNameManglerUtil.mangle(fModelBaseLocation); - } - - /** - * - * @return the problem requestor for the CompilationUnit in this - * JSPTranslation - */ - private JsProblemRequestor getProblemRequestor() { - return CompilationUnitHelper.getInstance().getProblemRequestor(); - } - - public List getProblems() { - List problems = getProblemRequestor().getCollectedProblems(); - getProblemRequestor().endReporting(); - return problems != null ? problems : new ArrayList(); - } - - private IProgressMonitor getProgressMonitor() { - if (fProgressMonitor == null) { - fProgressMonitor = new NullProgressMonitor(); - } - return fProgressMonitor; - } - - public WorkingCopyOwner getWorkingCopyOwner() { - return CompilationUnitHelper.getInstance().getWorkingCopyOwner(); - } - - public boolean ifOffsetInImportNode(int offset) { - Position[] importRanges = translator.getImportHtmlRanges(); - for (int i = 0; i < importRanges.length; i++) { - if (importRanges[i].includes(offset)) { - return true; - } - } - return false; - } - - public void reconcileCompilationUnit() { - // if(true) return; - ICompilationUnit cu = getCompilationUnit(); - if (fCompilationUnit == null) { - return; - } - if (cu != null) { - try { - synchronized (fLock) { - // if(false) - //cu.makeConsistent(getProgressMonitor()); - cu.reconcile(ICompilationUnit.NO_AST, true, getWorkingCopyOwner(), getProgressMonitor()); - } - } catch (JavaModelException e) { - Logger.logException(e); - } - } - } - - - public void release() { - if(translator!=null) translator.release(); - synchronized (fLock) { - if (fCompilationUnit != null) { - try { - if (JsTranslation.DEBUG) { - System.out.println("------------------------------------------------------------------"); //$NON-NLS-1$ - System.out.println("(-) JSPTranslation [" + this + "] discarding CompilationUnit: " + fCompilationUnit); //$NON-NLS-1$ //$NON-NLS-2$ - System.out.println("------------------------------------------------------------------"); //$NON-NLS-1$ - } - fCompilationUnit.discardWorkingCopy(); - } catch (JavaModelException e) { - // we're done w/ it anyway - } - } - } - } - - public void setProblemCollectingActive(boolean collect) { - ICompilationUnit cu = getCompilationUnit(); - if (cu != null) { - getProblemRequestor().setIsActive(collect); - } - } - - public void classpathChange() { - - if(fDocumentScope!=null){ - fDocumentScope.classpathChange(); - } - } -}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.jsdt.web.core/src/org/eclipse/wst/jsdt/web/core/internal/java/JsTranslationAdapter.java b/bundles/org.eclipse.wst.jsdt.web.core/src/org/eclipse/wst/jsdt/web/core/internal/java/JsTranslationAdapter.java deleted file mode 100644 index fe1f57b722..0000000000 --- a/bundles/org.eclipse.wst.jsdt.web.core/src/org/eclipse/wst/jsdt/web/core/internal/java/JsTranslationAdapter.java +++ /dev/null @@ -1,123 +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.jsdt.web.core.internal.java; - -import org.eclipse.core.resources.IProject; -import org.eclipse.core.resources.IResourceChangeEvent; -import org.eclipse.core.resources.IResourceChangeListener; -import org.eclipse.core.resources.IWorkspaceRoot; -import org.eclipse.core.resources.ResourcesPlugin; -import org.eclipse.core.runtime.IPath; -import org.eclipse.core.runtime.NullProgressMonitor; -import org.eclipse.core.runtime.Path; -import org.eclipse.core.runtime.Platform; -import org.eclipse.jface.text.IDocument; -import org.eclipse.wst.jsdt.core.IJavaProject; -import org.eclipse.wst.jsdt.core.JavaCore; -import org.eclipse.wst.jsdt.web.core.internal.Logger; -import org.eclipse.wst.sse.core.internal.provisional.INodeAdapter; -import org.eclipse.wst.sse.core.internal.provisional.INodeNotifier; -import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocument; -import org.eclipse.wst.xml.core.internal.provisional.document.IDOMModel; - -/** - * An adapter for getting a JSPTranslation of the document. - * - * @author pavery - */ -public class JsTranslationAdapter implements INodeAdapter, IResourceChangeListener { - - private static final boolean DEBUG = "true".equalsIgnoreCase(Platform.getDebugOption("org.eclipse.wst.jsdt.web.core/debug/jsptranslation")); //$NON-NLS-1$ //$NON-NLS-2$ - private IStructuredDocument fHtmlDocument = null; - private JsTranslation fJSPTranslation = null; - private NullProgressMonitor fTranslationMonitor = null; - private String baseLocation; - private boolean listenForChanges=false; - - public JsTranslationAdapter(IDOMModel xmlModel) { - fHtmlDocument = xmlModel.getStructuredDocument(); - baseLocation = xmlModel.getBaseLocation(); - initializeJavaPlugins(); - - - } - public void shouldListenForChanges(boolean listenForProjectChanges) { - if(listenForProjectChanges) { - ResourcesPlugin.getWorkspace().addResourceChangeListener(this, IResourceChangeEvent.POST_CHANGE); - } - } - - public IJavaProject getJavaProject() { - IJavaProject javaProject = null; - IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot(); - IPath filePath = new Path(baseLocation); - IProject project = null; - if (filePath.segmentCount() > 0) { - project = root.getProject(filePath.segment(0)); - } - if (project != null) { - javaProject = JavaCore.create(project); - } - - return javaProject; - } - - /** - * Returns the JSPTranslation for this adapter. - * - * @return a JSPTranslationExtension - */ - public JsTranslation getJSPTranslation(boolean listenForChanges) { - if (fJSPTranslation == null || (!this.listenForChanges && listenForChanges)) { - - if(fJSPTranslation!=null) fJSPTranslation.release(); - - fJSPTranslation = new JsTranslation(fHtmlDocument, getJavaProject(),listenForChanges); - this.listenForChanges=listenForChanges; - } - shouldListenForChanges(listenForChanges); - return fJSPTranslation; - } - - - private void initializeJavaPlugins() { - JavaCore.getPlugin(); - } - - public boolean isAdapterForType(Object type) { - return type.equals(IJsTranslation.class); - } - - public void notifyChanged(INodeNotifier notifier, int eventType, Object changedFeature, Object oldValue, Object newValue, int pos) {} - - public void release() { - if (fTranslationMonitor != null) { - fTranslationMonitor.setCanceled(true); - } - ResourcesPlugin.getWorkspace().removeResourceChangeListener(this); - if (fJSPTranslation != null) { - if (JsTranslationAdapter.DEBUG) { - System.out.println("JSPTranslationAdapter releasing:" + fJSPTranslation); //$NON-NLS-1$ - } - fJSPTranslation.release(); - } - } - - /* (non-Javadoc) - * @see org.eclipse.core.resources.IResourceChangeListener#resourceChanged(org.eclipse.core.resources.IResourceChangeEvent) - */ - public void resourceChanged(IResourceChangeEvent event) { - IProject changedProject = (event==null || event.getResource()==null)?null:event.getResource().getProject(); - if(changedProject!=null && getJavaProject().getProject().equals(changedProject) && fJSPTranslation!=null){ - fJSPTranslation.classpathChange(); - } - } -}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.jsdt.web.core/src/org/eclipse/wst/jsdt/web/core/internal/java/JsTranslationAdapterFactory.java b/bundles/org.eclipse.wst.jsdt.web.core/src/org/eclipse/wst/jsdt/web/core/internal/java/JsTranslationAdapterFactory.java deleted file mode 100644 index fa1efb3b4a..0000000000 --- a/bundles/org.eclipse.wst.jsdt.web.core/src/org/eclipse/wst/jsdt/web/core/internal/java/JsTranslationAdapterFactory.java +++ /dev/null @@ -1,68 +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.jsdt.web.core.internal.java; - -import org.eclipse.core.runtime.Platform; -import org.eclipse.wst.sse.core.internal.provisional.AbstractAdapterFactory; -import org.eclipse.wst.sse.core.internal.provisional.INodeAdapter; -import org.eclipse.wst.sse.core.internal.provisional.INodeAdapterFactory; -import org.eclipse.wst.sse.core.internal.provisional.INodeNotifier; -import org.eclipse.wst.xml.core.internal.provisional.document.IDOMNode; - -/** - * Factory for JSPTranslationAdapters. - * - * @author pavery - * - */ -public class JsTranslationAdapterFactory extends AbstractAdapterFactory { - // for debugging - private static final boolean DEBUG; - private boolean listenForProjectChanges; - - static { - String value = Platform.getDebugOption("org.eclipse.wst.jsdt.web.core/debug/jsptranslation"); //$NON-NLS-1$ - DEBUG = value != null && value.equalsIgnoreCase("true"); //$NON-NLS-1$ - } - private JsTranslationAdapter fAdapter = null; - - public JsTranslationAdapterFactory() { - super(IJsTranslation.class, true); - listenForProjectChanges = true; - } - - - public INodeAdapterFactory copy() { - return new JsTranslationAdapterFactory(); - } - - - protected INodeAdapter createAdapter(INodeNotifier target) { - if (target instanceof IDOMNode && fAdapter == null) { - fAdapter = new JsTranslationAdapter(((IDOMNode) target).getModel()); - if (JsTranslationAdapterFactory.DEBUG) { - System.out.println("(+) JSPTranslationAdapterFactory [" + this + "] created adapter: " + fAdapter); //$NON-NLS-1$ //$NON-NLS-2$ - } - } - return fAdapter; - } - - - public void release() { - if (fAdapter != null) { - if (JsTranslationAdapterFactory.DEBUG) { - System.out.println("(-) JSPTranslationAdapterFactory [" + this + "] releasing adapter: " + fAdapter); //$NON-NLS-1$ //$NON-NLS-2$ - } - fAdapter.release(); - } - super.release(); - } -}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.jsdt.web.core/src/org/eclipse/wst/jsdt/web/core/internal/java/JsTranslator.java b/bundles/org.eclipse.wst.jsdt.web.core/src/org/eclipse/wst/jsdt/web/core/internal/java/JsTranslator.java deleted file mode 100644 index c6faff3c4a..0000000000 --- a/bundles/org.eclipse.wst.jsdt.web.core/src/org/eclipse/wst/jsdt/web/core/internal/java/JsTranslator.java +++ /dev/null @@ -1,390 +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.jsdt.web.core.internal.java; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Iterator; - -import org.eclipse.core.filebuffers.FileBuffers; -import org.eclipse.core.resources.IFile; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Path; -import org.eclipse.core.runtime.Platform; -import org.eclipse.core.runtime.Status; -import org.eclipse.core.runtime.jobs.IJobChangeListener; -import org.eclipse.core.runtime.jobs.Job; -import org.eclipse.jface.text.DocumentEvent; -import org.eclipse.jface.text.IDocumentListener; -import org.eclipse.jface.text.Position; -import org.eclipse.wst.jsdt.core.IBuffer; -import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocument; -import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegion; -import org.eclipse.wst.sse.core.internal.provisional.text.ITextRegion; -import org.eclipse.wst.sse.core.internal.provisional.text.ITextRegionCollection; -import org.eclipse.wst.sse.core.internal.provisional.text.ITextRegionList; -import org.eclipse.wst.xml.core.internal.provisional.document.IDOMModel; -import org.eclipse.wst.xml.core.internal.provisional.document.IDOMNode; -import org.eclipse.wst.xml.core.internal.regions.DOMRegionContext; - -/** - * Translates a JSP document into a HttpServlet. Keeps two way mapping from java - * translation to the original JSP source, which can be obtained through - * getJava2JspRanges() and getJsp2JavaRanges(). - * - * @author pavery - */ -public class JsTranslator extends Job implements IDocumentListener{ - - private static final boolean DEBUG; - private static final boolean DEBUG_SAVE_OUTPUT = "true".equalsIgnoreCase(Platform.getDebugOption("org.eclipse.wst.jsdt.web.core/debug/jsptranslationstodisk")); //$NON-NLS-1$ //$NON-NLS-2$ - public static final String ENDL = "\n"; //$NON-NLS-1$ - static { - String value = Platform.getDebugOption("org.eclipse.wst.jsdt.web.core/debug/jspjavamapping"); //$NON-NLS-1$ - DEBUG = value != null && value.equalsIgnoreCase("true"); //$NON-NLS-1$ - } - - private IStructuredDocumentRegion fCurrentNode; - private StringBuffer fScriptText = new StringBuffer(); - private IStructuredDocument fStructuredDocument = null; - private ArrayList importLocationsInHtml = new ArrayList(); - /* use java script by default */ - private boolean isGlobalJs = true; - private ArrayList rawImports = new ArrayList(); // traslated - private ArrayList scriptLocationInHtml = new ArrayList(); - private int scriptOffset = 0; - private byte[] fLock = new byte[0]; - private byte[] finished = new byte[0]; - private IBuffer compUnitBuff; - private boolean cancelParse = false; - private int missingEndTagRegionStart = -1; - private static final boolean ADD_SEMICOLON_AT_INLINE=true; - - - - private void advanceNextNode() { - setCurrentNode(getCurrentNode().getNext()); - } - - public JsTranslator(IStructuredDocument document, String fileName) { - super("JavaScript translation for : " + fileName); - fStructuredDocument = document; - - fStructuredDocument.addDocumentListener(this); - setPriority(Job.LONG); - setSystem(true); - schedule(); - reset(); - } - - public JsTranslator(IStructuredDocument document, String fileName, boolean listenForChanges) { - super("JavaScript translation for : " + fileName); - fStructuredDocument = document; - if(listenForChanges) { - fStructuredDocument.addDocumentListener(this); - setPriority(Job.LONG); - setSystem(true); - schedule(); - } - reset(); - } - - public String getJsText() { - synchronized(finished) { - return fScriptText.toString(); - } - } - - final public IStructuredDocumentRegion getCurrentNode() { - return fCurrentNode; - } - - public void setBuffer(IBuffer buffer) { - compUnitBuff = buffer; - synchronized(finished) { - compUnitBuff.setContents(fScriptText.toString()); - } - } - - public Position[] getHtmlLocations() { - synchronized(finished) { - return (Position[]) scriptLocationInHtml.toArray(new Position[scriptLocationInHtml.size()]); - } - } - - public int getMissingEndTagRegionStart() { - return missingEndTagRegionStart; - } - - public Position[] getImportHtmlRanges() { - synchronized(finished) { - return (Position[]) importLocationsInHtml.toArray(new Position[importLocationsInHtml.size()]); - } - } - - private char[] getPad(int numberOfChars) { - final char[] spaceArray = new char[numberOfChars]; - Arrays.fill(spaceArray, ' '); - return spaceArray; - } - - public String[] getRawImports() { - synchronized(finished) { - return (String[]) this.rawImports.toArray(new String[rawImports.size()]); - } - } - - - - /** - * - * @return the status of the translator's progrss monitor, false if the - * monitor is null - */ - private boolean isCanceled() { - return cancelParse; - } - - /** - * Reinitialize some fields - */ - private void reset() { - synchronized(fLock) { - scriptOffset = 0; - // reset progress monitor - cancelParse = false; - fScriptText = new StringBuffer(); - fCurrentNode = fStructuredDocument.getFirstStructuredDocumentRegion(); - rawImports.clear(); - importLocationsInHtml.clear(); - scriptLocationInHtml.clear(); - missingEndTagRegionStart = -1; - } - translate(); - } - - - - private IStructuredDocumentRegion setCurrentNode(IStructuredDocumentRegion currentNode) { - synchronized(fLock) { - return this.fCurrentNode = currentNode; - } - } - - public void translate() { - //setCurrentNode(fStructuredDocument.getFirstStructuredDocumentRegion()); - synchronized(finished) { - while (getCurrentNode() != null && !isCanceled()) { - // System.out.println("Translator Looking at Node - // type:"+getCurrentNode().getType()+"---------------------------------:"); - // System.out.println(new NodeHelper(getCurrentNode())); - // i.println("/---------------------------------------------------"); - if (getCurrentNode().getType() == DOMRegionContext.XML_TAG_NAME) { - NodeHelper nh = new NodeHelper(getCurrentNode()); - if ((!nh.isEndTag() || nh.isSelfClosingTag()) && nh.nameEquals("script")) { - /* - * Handles the following cases: <script - * type="javascriptype"> <script language="javascriptype> - * <script src='' type=javascriptype> <script src='' - * language=javascripttype <script src=''> global js type. - * <script> (global js type) - */ - if (NodeHelper.isInArray(JsDataTypes.JSVALIDDATATYPES, nh.getAttributeValue("type")) || NodeHelper.isInArray(JsDataTypes.JSVALIDDATATYPES, nh.getAttributeValue("language")) || isGlobalJs) { - if (nh.containsAttribute(new String[] { "src" })) { - // Handle import - translateScriptImportNode(getCurrentNode()); - } - // } else { - // handle script section - - if (getCurrentNode().getNext() != null /*&& getCurrentNode().getNext().getType() == DOMRegionContext.BLOCK_TEXT*/) { - translateJSNode(getCurrentNode().getNext()); - } - } // End search for <script> sections - } else if (nh.containsAttribute(JsDataTypes.HTMLATREVENTS)) { - /* Check for embeded JS events in any tags */ - translateInlineJSNode(getCurrentNode()); - } else if (nh.nameEquals("META") && nh.attrEquals("http-equiv", "Content-Script-Type") && nh.containsAttribute(new String[] { "content" })) { - // <META http-equiv="Content-Script-Type" content="type"> - isGlobalJs = NodeHelper.isInArray(JsDataTypes.JSVALIDDATATYPES, nh.getAttributeValue("content")); - } // End big if of JS types - } - if (getCurrentNode() != null) { - advanceNextNode(); - } - } // end while loop - } - finishedTranslation(); - } - - private void finishedTranslation() { - if(compUnitBuff!=null) compUnitBuff.setContents(fScriptText.toString()); - } - - public void translateInlineJSNode(IStructuredDocumentRegion container) { - // System.out - // .println("JSPTranslator.translateInlineJSNode Entered - // w/ScriptOffset:" - // + scriptOffset); - - NodeHelper nh = new NodeHelper(container); - // System.out.println("inline js node looking at:\n" + nh); - /* start a function header.. will amend later */ - ITextRegionList t = container.getRegions(); - ITextRegion r; - Iterator regionIterator = t.iterator(); - while (regionIterator.hasNext() && !isCanceled() ) { - r = (ITextRegion) regionIterator.next(); - if (r.getType() == DOMRegionContext.XML_TAG_ATTRIBUTE_NAME) { - int start = r.getStart(); - int offset = r.getTextEnd(); - String tagAttrname = container.getText().substring(start, offset).trim(); - /* - * Attribute values aren't case sensative, also make sure next - * region is attrib value - */ - if (NodeHelper.isInArray(JsDataTypes.HTMLATREVENTS, tagAttrname)) { - if (regionIterator.hasNext()) { - regionIterator.next(); - } - if (regionIterator.hasNext()) { - r = ((ITextRegion) regionIterator.next()); - } - if (r.getType() == DOMRegionContext.XML_TAG_ATTRIBUTE_VALUE) { - int valStartOffset = container.getStartOffset(r); - // int valEndOffset = r.getTextEnd(); - String rawText = container.getText().substring(r.getStart(), r.getTextEnd()); - if (rawText == null || rawText.length() == 0) { - return; - } - /* Strip quotes */ - switch (rawText.charAt(0)) { - case '\'': - case '"': - rawText = rawText.substring(1); - valStartOffset++; - } - switch (rawText.charAt(rawText.length() - 1)) { - case '\'': - case '"': - rawText = rawText.substring(0, rawText.length() - 1); - } - // Position inScript = new Position(scriptOffset, - // rawText.length()); - /* Quoted text starts +1 and ends -1 char */ - if(ADD_SEMICOLON_AT_INLINE) rawText = rawText + ";"; - Position inHtml = new Position(valStartOffset, rawText.length()); - scriptLocationInHtml.add(inHtml); - /* need to pad the script text with spaces */ - char[] spaces = getPad(valStartOffset - scriptOffset); - fScriptText.append(spaces); - fScriptText.append(rawText); - scriptOffset = fScriptText.length(); - } - } - } - } - } - - - public void translateJSNode(IStructuredDocumentRegion container) { - ITextRegionCollection containerRegion = container; - Iterator regions = containerRegion.getRegions().iterator(); - ITextRegion region = null; - - if(container==null) return; - - char[] spaces = getPad(container.getStartOffset() - scriptOffset); - fScriptText.append(spaces); - scriptOffset = container.getStartOffset(); - - if(container.getType()!=DOMRegionContext.BLOCK_TEXT && container.getType()!= DOMRegionContext.XML_CDATA_TEXT) { - return; - } - - while (regions.hasNext() && !isCanceled()) { - region = (ITextRegion) regions.next(); - String type = region.getType(); - // content assist was not showing up in JSP inside a javascript - // region - if (type == DOMRegionContext.BLOCK_TEXT) { - int scriptStart = container.getStartOffset(); - int scriptTextEnd = container.getEndOffset() - container.getStartOffset(); - String regionText = container.getText().substring(region.getStart(), region.getEnd()); - int regionLength = regionText.length(); - // /Position inScript = new Position(scriptOffset, - // regionLength); - Position inHtml = new Position(scriptStart, scriptTextEnd); - scriptLocationInHtml.add(inHtml); - spaces = getPad(scriptStart - scriptOffset); - fScriptText.append(spaces); - // fJsToHTMLRanges.put(inScript, inHtml); - fScriptText.append(regionText); - scriptOffset = fScriptText.length(); - } - } - - IStructuredDocumentRegion endTag = container.getNext(); - - if(endTag==null) { - missingEndTagRegionStart = container.getStartOffset(); - }else if(endTag!=null) { - NodeHelper nh = new NodeHelper(endTag); - String name = nh.getTagName(); - - if(name==null || !name.trim().equalsIgnoreCase("script") || !nh.isEndTag()) { - missingEndTagRegionStart = container.getStartOffset(); - } - } - } - - public void translateScriptImportNode(IStructuredDocumentRegion region) { - NodeHelper nh = new NodeHelper(region); - String importName = nh.getAttributeValue("src"); - if (importName != null && !importName.equals("")) { - rawImports.add(importName); - Position inHtml = new Position(region.getStartOffset(), region.getEndOffset()); - importLocationsInHtml.add(inHtml); - } - } - - - - /* (non-Javadoc) - * @see org.eclipse.jface.text.IDocumentListener#documentAboutToBeChanged(org.eclipse.jface.text.DocumentEvent) - */ - public void documentAboutToBeChanged(DocumentEvent event) { - cancelParse = true; - - } - - /* (non-Javadoc) - * @see org.eclipse.jface.text.IDocumentListener#documentChanged(org.eclipse.jface.text.DocumentEvent) - */ - public void documentChanged(DocumentEvent event) { - reset(); - - } - - /* (non-Javadoc) - * @see org.eclipse.core.runtime.jobs.Job#run(org.eclipse.core.runtime.IProgressMonitor) - */ - protected IStatus run(IProgressMonitor monitor) { - - return Status.OK_STATUS; - } - - public void release() { - fStructuredDocument.removeDocumentListener(this); - } - -}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.jsdt.web.core/src/org/eclipse/wst/jsdt/web/core/internal/java/NodeHelper.java b/bundles/org.eclipse.wst.jsdt.web.core/src/org/eclipse/wst/jsdt/web/core/internal/java/NodeHelper.java deleted file mode 100644 index 4046b22509..0000000000 --- a/bundles/org.eclipse.wst.jsdt.web.core/src/org/eclipse/wst/jsdt/web/core/internal/java/NodeHelper.java +++ /dev/null @@ -1,239 +0,0 @@ -package org.eclipse.wst.jsdt.web.core.internal.java; - -import java.util.Iterator; - -import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegion; -import org.eclipse.wst.sse.core.internal.provisional.text.ITextRegion; -import org.eclipse.wst.sse.core.internal.provisional.text.ITextRegionList; -import org.eclipse.wst.xml.core.internal.regions.DOMRegionContext; - -public class NodeHelper { - protected static final char DOUBLE_QUOTE_CHAR = '\"'; - protected static final String DOUBLE_QUOTE_ENTITY = """; //$NON-NLS-1$ - protected static final char SINGLE_QUOTE_CHAR = '\''; - protected static final String SINGLE_QUOTE_ENTITY = "'"; //$NON-NLS-1$ - - public static boolean isInArray(String StringArray[], String text) { - if (StringArray == null || text == null) { - return false; - } - for (int i = 0; i < StringArray.length; i++) { - if (StringArray[i].equalsIgnoreCase(text.trim())) { - return true; - } - } - return false; - } - - 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 == NodeHelper.SINGLE_QUOTE_CHAR) && (lastChar == NodeHelper.SINGLE_QUOTE_CHAR)) || ((firstChar == NodeHelper.DOUBLE_QUOTE_CHAR) && (lastChar == NodeHelper.DOUBLE_QUOTE_CHAR))); - } - protected final IStructuredDocumentRegion region; - - public NodeHelper(IStructuredDocumentRegion region) { - this.region = region; - } - - public boolean attrEquals(String attribute, String value) { - String attValue = getAttributeValue(attribute); - if(attValue==null) return false; - return attValue.equalsIgnoreCase(value); - } - - public String AttrToString() { - if (region == null) { - return null; - } - // For debuging - ITextRegionList t = region.getRegions(); - ITextRegion r; - Iterator regionIterator = t.iterator(); - String StructuredValue = "Tag name:" + getTagName() + "\tAttribute\tValue\n"; - while (regionIterator.hasNext()) { - r = (ITextRegion) regionIterator.next(); - if (r.getType() == DOMRegionContext.XML_TAG_ATTRIBUTE_NAME) { - int start = r.getStart(); - int offset = r.getTextEnd(); - StructuredValue += "\t\t" + region.getText().substring(start, offset); - /* - * Theres a XML_TAG_ATTRIBUTE_EQUALS after the - * XML_TAG_ATTRIBUTE_NAME we have to get rid of - */ - if (regionIterator.hasNext()) { - regionIterator.next(); - } - if (regionIterator.hasNext()) { - r = ((ITextRegion) regionIterator.next()); - } - System.out.println("attrib type"); - if (r.getType() == DOMRegionContext.XML_TAG_ATTRIBUTE_VALUE) { - int valStart = r.getStart(); - int valOffset = r.getTextEnd(); - StructuredValue += "\t\t" + stripEndQuotes(region.getText().substring(valStart, valOffset)) + "\n"; - } - } - } - return StructuredValue; - } - - public boolean containsAttribute(String name[]) { - if (name == null) { - return false; - } - if (region == null) { - return false; - } - ITextRegionList t = region.getRegions(); - ITextRegion r; - Iterator regionIterator = t.iterator(); - while (regionIterator.hasNext()) { - r = (ITextRegion) regionIterator.next(); - if (r.getType() == DOMRegionContext.XML_TAG_ATTRIBUTE_NAME) { - int start = r.getStart(); - int offset = r.getTextEnd(); - String tagname = region.getText().substring(start, offset).trim(); - /* Attribute values aren't case sensative */ - if (NodeHelper.isInArray(name, tagname)) { - return true; - } - } - } - return false; - } - - public String getAttributeValue(String name) { - if (region == null) { - return null; - } - if (name == null) { - return null; - } - ITextRegionList t = region.getRegions(); - ITextRegion r; - Iterator regionIterator = t.iterator(); - while (regionIterator.hasNext()) { - r = (ITextRegion) regionIterator.next(); - if (r.getType() == DOMRegionContext.XML_TAG_ATTRIBUTE_NAME) { - int start = r.getStart(); - int offset = r.getTextEnd(); - String tagname = region.getText().substring(start, offset).trim(); - /* - * Attribute values aren't case sensative, also make sure next - * region is attrib value - */ - if (tagname.equalsIgnoreCase(name)) { - if (regionIterator.hasNext()) { - regionIterator.next(); - } - if (regionIterator.hasNext()) { - r = ((ITextRegion) regionIterator.next()); - } - if (r.getType() == DOMRegionContext.XML_TAG_ATTRIBUTE_VALUE) { - int valStart = r.getStart(); - int valOffset = r.getTextEnd(); - return stripEndQuotes(region.getText().substring(valStart, valOffset)); - } - } - } - } - return null; - } - - public String getElementAsFlatString() { - /* - * Returns a full string of this element minus and 'illegal' characters - * (usefull for identifying the HTML element in a generic JS function) - */ - if (region == null) { - return null; - } - String fullRegionText = region.getFullText(); - if (fullRegionText == null) { - return null; - } - return fullRegionText.replaceAll("[^a-zA-Z0-9]", ""); - } - - public String getTagName() { - if (region == null) { - return null; - } - ITextRegionList t = region.getRegions(); - ITextRegion r; - Iterator regionIterator = t.iterator(); - while (regionIterator.hasNext()) { - r = (ITextRegion) regionIterator.next(); - if (r.getType() == DOMRegionContext.XML_TAG_NAME) { - int start = r.getStart(); - int offset = r.getTextEnd(); - return region.getText().substring(start, offset); - } - } - return null; - } - - public boolean isEndTag() { - if (region == null) { - return false; - } - ITextRegionList t = region.getRegions(); - ITextRegion r; - Iterator regionIterator = t.iterator(); - while (regionIterator.hasNext()) { - r = (ITextRegion) regionIterator.next(); - if (r.getType() == DOMRegionContext.XML_END_TAG_OPEN) { - return true; - } - } - return false; - } - - public boolean isSelfClosingTag() { - if (region == null) { - return false; - } - if (region == null) { - return false; - } - ITextRegionList regions = region.getRegions(); - ITextRegion r = regions.get(regions.size() - 1); - return r.getType() == DOMRegionContext.XML_EMPTY_TAG_CLOSE; - } - - public boolean nameEquals(String name) { - if (region == null) { - return false; - } - String tagName; - return ((tagName = getTagName()) != null && tagName.equalsIgnoreCase(name)); - } - - public String stripEndQuotes(String text) { - if (text == null) { - return null; - } - if (NodeHelper.isQuoted(text)) { - return text.substring(1, text.length() - 1); - } - return text; - } - - - public String toString() { - ITextRegionList t = region.getRegions(); - Iterator regionIterator = t.iterator(); - String nodeText = new String(); - while (regionIterator.hasNext()) { - ITextRegion r = (ITextRegion) regionIterator.next(); - String nodeType = r.getType(); - nodeText += ("\tNode Type:" + nodeType + " \t\tValue:" + region.getText().substring(r.getStart(), r.getTextEnd()) + "\n"); - } - return nodeText; - } -}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.jsdt.web.core/src/org/eclipse/wst/jsdt/web/core/internal/java/WebRootFinder.java b/bundles/org.eclipse.wst.jsdt.web.core/src/org/eclipse/wst/jsdt/web/core/internal/java/WebRootFinder.java deleted file mode 100644 index cc28352938..0000000000 --- a/bundles/org.eclipse.wst.jsdt.web.core/src/org/eclipse/wst/jsdt/web/core/internal/java/WebRootFinder.java +++ /dev/null @@ -1,36 +0,0 @@ -package org.eclipse.wst.jsdt.web.core.internal.java; - -import org.eclipse.core.resources.IProject; -import org.eclipse.core.runtime.IPath; -import org.eclipse.core.runtime.Path; -import org.eclipse.wst.common.componentcore.ComponentCore; -import org.eclipse.wst.common.componentcore.internal.util.ComponentUtilities; -import org.eclipse.wst.common.componentcore.resources.IVirtualComponent; -import org.eclipse.wst.common.componentcore.resources.IVirtualFolder; - -public class WebRootFinder { - public static IPath getServerContextRoot(IProject project) { - String contextRoot = ComponentUtilities.getServerContextRoot(project); - if(contextRoot==null) { - contextRoot = project.getName(); - } - return new Path(contextRoot); - } - - private static String getProjectRoot(IProject project) { - return project.getLocation().toString(); - } - - public static IPath getWebContentFolder(IProject project) { - IVirtualComponent comp = ComponentCore.createComponent(project); - if (comp != null) { - IVirtualFolder rootFolder = comp.getRootFolder(); - return rootFolder.getUnderlyingFolder().getProjectRelativePath(); - } - return new Path(""); - } - - public static String getWebContext(IProject project) { - return null; - } -} diff --git a/bundles/org.eclipse.wst.jsdt.web.core/src/org/eclipse/wst/jsdt/web/core/internal/java/search/IndexWorkspaceJob.java b/bundles/org.eclipse.wst.jsdt.web.core/src/org/eclipse/wst/jsdt/web/core/internal/java/search/IndexWorkspaceJob.java deleted file mode 100644 index 90dbf67b8a..0000000000 --- a/bundles/org.eclipse.wst.jsdt.web.core/src/org/eclipse/wst/jsdt/web/core/internal/java/search/IndexWorkspaceJob.java +++ /dev/null @@ -1,148 +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.jsdt.web.core.internal.java.search; - -import org.eclipse.wst.jsdt.web.core.internal.validation.Util; -import java.util.ArrayList; -import java.util.List; - -import org.eclipse.core.resources.IFile; -import org.eclipse.core.resources.IResource; -import org.eclipse.core.resources.IResourceProxy; -import org.eclipse.core.resources.IResourceProxyVisitor; -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.Status; -import org.eclipse.core.runtime.content.IContentType; -import org.eclipse.core.runtime.jobs.Job; -import org.eclipse.wst.jsdt.web.core.internal.JsCoreMessages; -import org.eclipse.wst.jsdt.web.core.internal.provisional.contenttype.ContentTypeIdForEmbededJs; - -/** - * Re-indexes the entire workspace. Ensures the JSP Index is in a stable state - * before performing a search. (like after a crash or if previous indexing was - * canceled) - * - * @author pavery - */ -public class IndexWorkspaceJob extends Job { - // for debugging - static final boolean DEBUG; - static { - String value = Platform.getDebugOption("org.eclipse.wst.jsdt.web.core/debug/jspindexmanager"); //$NON-NLS-1$ - DEBUG = value != null && value.equalsIgnoreCase("true"); //$NON-NLS-1$ - } - /** - * Visitor that retrieves jsp project paths for all jsp files in the - * workspace, and adds the files to be indexed as they are encountered - */ - private class JSPFileVisitor implements IResourceProxyVisitor { - private List files = new ArrayList(); - // monitor from the Job - IProgressMonitor fInnerMonitor = null; - - public JSPFileVisitor(IProgressMonitor monitor) { - this.fInnerMonitor = monitor; - } - - public final IFile[] getFiles() { - return (IFile[]) this.files.toArray(new IFile[this.files.size()]); - } - - public boolean visit(IResourceProxy proxy) throws CoreException { - // check job canceled - if (this.fInnerMonitor != null && this.fInnerMonitor.isCanceled()) { - setCanceledState(); - return false; - } - // check search support canceled - if (JsSearchSupport.getInstance().isCanceled()) { - setCanceledState(); - return false; - } - if (proxy.getType() == IResource.FILE) { - // https://w3.opensource.ibm.com/bugzilla/show_bug.cgi?id=3553 - // check this before description - // check name before actually getting the file (less work) - if (Util.isJsType(proxy.getName())) { - IFile file = (IFile) proxy.requestResource(); - if (file.exists()) { - if (IndexWorkspaceJob.DEBUG) { - System.out.println("(+) IndexWorkspaceJob adding file: " + file.getName()); //$NON-NLS-1$ - } - // this call will check the ContentTypeDescription, so - // don't need to do it here. - // JSPSearchSupport.getInstance().addJspFile(file); - this.files.add(file); - this.fInnerMonitor.subTask(proxy.getName()); - // don't search deeper for files - return false; - } - } - } - return true; - } - } - private IContentType fContentTypeJSP = null; - - public IndexWorkspaceJob() { - // pa_TODO may want to say something like "Rebuilding JSP Index" to be - // more - // descriptive instead of "Updating JSP Index" since they are 2 - // different things - super(JsCoreMessages.JSPIndexManager_0); - setPriority(Job.LONG); - setSystem(true); - } - - - - protected IStatus run(IProgressMonitor monitor) { - IStatus status = Status.OK_STATUS; - if (monitor.isCanceled()) { - setCanceledState(); - return Status.CANCEL_STATUS; - } - if (IndexWorkspaceJob.DEBUG) { - System.out.println(" ^ IndexWorkspaceJob started: "); //$NON-NLS-1$ - } - long start = System.currentTimeMillis(); - try { - JSPFileVisitor visitor = new JSPFileVisitor(monitor); - // collect all jsp files - ResourcesPlugin.getWorkspace().getRoot().accept(visitor, IResource.DEPTH_INFINITE); - // request indexing - // this is pretty much like faking an entire workspace resource - // delta - JsIndexManager.getInstance().indexFiles(visitor.getFiles()); - } catch (CoreException e) { - if (IndexWorkspaceJob.DEBUG) { - e.printStackTrace(); - } - } finally { - if (monitor != null) { - monitor.done(); - } - } - long finish = System.currentTimeMillis(); - if (IndexWorkspaceJob.DEBUG) { - System.out.println(" ^ IndexWorkspaceJob finished\n total time running: " + (finish - start)); //$NON-NLS-1$ - } - return status; - } - - void setCanceledState() { - JsIndexManager.getInstance().setIndexState(JsIndexManager.S_CANCELED); - } -} diff --git a/bundles/org.eclipse.wst.jsdt.web.core/src/org/eclipse/wst/jsdt/web/core/internal/java/search/JSDTSearchDocumentDelegate.java b/bundles/org.eclipse.wst.jsdt.web.core/src/org/eclipse/wst/jsdt/web/core/internal/java/search/JSDTSearchDocumentDelegate.java deleted file mode 100644 index 569bbaca6a..0000000000 --- a/bundles/org.eclipse.wst.jsdt.web.core/src/org/eclipse/wst/jsdt/web/core/internal/java/search/JSDTSearchDocumentDelegate.java +++ /dev/null @@ -1,79 +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.jsdt.web.core.internal.java.search; - -import org.eclipse.core.resources.IFile; -import org.eclipse.wst.jsdt.core.IJavaElement; -import org.eclipse.wst.jsdt.internal.core.search.JavaSearchDocument; -import org.eclipse.wst.jsdt.web.core.internal.java.JsTranslation; - -/** - * Wrapper method to set getPath() path to be the path of the compilation unit - * for the jsp file. (since it's a final method, it needs to be set via - * constructor) - * - * @author pavery - */ -/* Used to extend SearchDocument */ -public class JSDTSearchDocumentDelegate extends JavaSearchDocument { - private JsSearchDocument fJSPSearchDoc = null; - - public JSDTSearchDocumentDelegate(JsSearchDocument jspSearchDoc) { - super(jspSearchDoc.getPath(), jspSearchDoc.getParticipant()); - this.fJSPSearchDoc = jspSearchDoc; - } - - - public byte[] getByteContents() { - return this.fJSPSearchDoc.getByteContents(); - } - - - public char[] getCharContents() { - return this.fJSPSearchDoc.getCharContents(); - } - - - public String getEncoding() { - return this.fJSPSearchDoc.getEncoding(); - } - - public IFile getFile() { - return this.fJSPSearchDoc.getFile(); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.wst.jsdt.core.search.SearchDocument#getJavaElement() - */ - - public IJavaElement getJavaElement() { - return getJspTranslation().getCompilationUnit(); - } - - public String getJavaText() { - return this.fJSPSearchDoc.getJavaText(); - } - - public JsTranslation getJspTranslation() { - return this.fJSPSearchDoc.getJSPTranslation(); - } - - - public boolean isVirtual() { - return true; - } - - public void release() { - this.fJSPSearchDoc.release(); - } -} diff --git a/bundles/org.eclipse.wst.jsdt.web.core/src/org/eclipse/wst/jsdt/web/core/internal/java/search/JsIndexManager.java b/bundles/org.eclipse.wst.jsdt.web.core/src/org/eclipse/wst/jsdt/web/core/internal/java/search/JsIndexManager.java deleted file mode 100644 index 162bb2ca8f..0000000000 --- a/bundles/org.eclipse.wst.jsdt.web.core/src/org/eclipse/wst/jsdt/web/core/internal/java/search/JsIndexManager.java +++ /dev/null @@ -1,665 +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.jsdt.web.core.internal.java.search; - -import org.eclipse.wst.jsdt.web.core.internal.validation.Util; -import java.io.File; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; - -import org.eclipse.core.resources.IFile; -import org.eclipse.core.resources.IProject; -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.ResourcesPlugin; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IPath; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Path; -import org.eclipse.core.runtime.Platform; -import org.eclipse.core.runtime.Plugin; -import org.eclipse.core.runtime.Status; -import org.eclipse.core.runtime.content.IContentType; -import org.eclipse.core.runtime.jobs.IJobChangeEvent; -import org.eclipse.core.runtime.jobs.Job; -import org.eclipse.core.runtime.jobs.JobChangeAdapter; -import org.eclipse.osgi.util.NLS; -import org.eclipse.wst.jsdt.internal.core.JavaModelManager; -import org.eclipse.wst.jsdt.internal.core.search.indexing.IndexManager; -import org.eclipse.wst.jsdt.web.core.internal.JsCoreMessages; -import org.eclipse.wst.jsdt.web.core.internal.JsCorePlugin; -import org.eclipse.wst.jsdt.web.core.internal.Logger; -import org.eclipse.wst.jsdt.web.core.internal.project.JsWebNature; -import org.eclipse.wst.jsdt.web.core.internal.provisional.contenttype.ContentTypeIdForEmbededJs; -import org.osgi.framework.Bundle; - -/** - * Responsible for keeping the JSP index up to date. - * - * @author pavery - */ -public class JsIndexManager { - // for debugging - // TODO move this to Logger, as we have in SSE - static final boolean DEBUG; - private static JsIndexManager fSingleton = null; - static long fTotalTime = 0; - private static final String PKEY_INDEX_STATE = "jspIndexState"; //$NON-NLS-1$ - // TODO: consider enumeration for these int constants - // set to S_UPDATING once a resource change comes in - // set to S_STABLE if: - // - we know we aren't interested in the resource change - // - or the ProcessFilesJob completes - // set to S_CANCELED if an indexing job is canceled - // set to S_REBUILDING if re-indexing the entire workspace - /** - * indexing job was canceled in the middle of it, index needs to be rebuilt - */ - public static final int S_CANCELED = 4; - /** entire index is being rebuilt */ - public static final int S_REBUILDING = 3; - // the int '0' is reserved for the default value if a preference is not - // there - /** index is reliable to use */ - public static final int S_STABLE = 1; - /** index is being updated (from a resource delta) */ - public static final int S_UPDATING = 2; - static { - String value = Platform.getDebugOption("org.eclipse.wst.jsdt.web.core/debug/jspindexmanager"); //$NON-NLS-1$ - DEBUG = value != null && value.equalsIgnoreCase("true"); //$NON-NLS-1$ - } - - public synchronized static JsIndexManager getInstance() { - if (JsIndexManager.fSingleton == null) { - JsIndexManager.fSingleton = new JsIndexManager(); - } - return JsIndexManager.fSingleton; - } - // end class JSPResourceVisitor - private class IndexJobCoordinator extends JobChangeAdapter { - - public void aboutToRun(IJobChangeEvent event) { - Job jobToCoordinate = event.getJob(); - if (isJobToAvoid(jobToCoordinate)) { - // job will be rescheduled when the job we - // are avoiding (eg. build) is done - getProcessFilesJob().cancel(); - // System.out.println("cancel:" + jobToCoordinate.getName()); - } - } - - - public void done(IJobChangeEvent event) { - Job jobToCoordinate = event.getJob(); - if (isJobToAvoid(jobToCoordinate)) { - if (getProcessFilesJob().getFiles().length > 0) { - getProcessFilesJob().schedule(500); - // System.out.println("schedule:" + - // jobToCoordinate.getName()); - } - } - } - - private boolean isJobToAvoid(Job jobToCoordinate) { - boolean result = false; - if (jobToCoordinate.belongsTo(ResourcesPlugin.FAMILY_AUTO_BUILD) || jobToCoordinate.belongsTo(ResourcesPlugin.FAMILY_MANUAL_BUILD) || jobToCoordinate.belongsTo(ResourcesPlugin.FAMILY_AUTO_REFRESH)) { - result = true; - } - return result; - } - } - // end class ProcessFilesJob - private class JSPResourceChangeListener implements IResourceChangeListener { - /** - * @see org.eclipse.core.resources.IResourceChangeListener#resourceChanged(org.eclipse.core.resources.IResourceChangeEvent) - */ - public void resourceChanged(IResourceChangeEvent event) { - if (isInitializing()) { - return; - } - // ignore resource changes if already rebuilding - if (getIndexState() == JsIndexManager.S_REBUILDING) { - return; - } - // previously canceled, needs entire index rebuild - if (getIndexState() == JsIndexManager.S_CANCELED) { - // rebuildIndex(); - // just resume indexing - getProcessFilesJob().schedule(500); - // System.out.println("schedule: resource changed, previously - // canceled"); - return; - } - IResourceDelta delta = event.getDelta(); - if (delta != null) { - // only care about adds or changes right now... - int kind = delta.getKind(); - boolean added = (kind & IResourceDelta.ADDED) == IResourceDelta.ADDED; - boolean changed = (kind & IResourceDelta.CHANGED) == IResourceDelta.CHANGED; - if (added || changed) { - // only analyze the full (starting at root) delta - // hierarchy - if (delta.getFullPath().toString().equals("/")) { //$NON-NLS-1$ - try { - JSPResourceVisitor v = getVisitor(); - // clear from last run - v.reset(); - // count files, possibly do this in a job too... - // don't include PHANTOM resources - delta.accept(v, false); - // process files from this delta - IFile[] files = v.getFiles(); - if (files.length > 0) { - /* - * Job change listener should set back to stable - * when finished - */ - setUpdatingState(); - // processFiles(files); - indexFiles(files); - } - } catch (CoreException e) { - // need to set state here somehow, and reindex - // otherwise index will be unreliable - if (JsIndexManager.DEBUG) { - Logger.logException(e); - } - } catch (Exception e) { - // need to set state here somehow, and reindex - // otherwise index will be unreliable - if (JsIndexManager.DEBUG) { - Logger.logException(e); - } - } - } - } - } - } - } - /** - * Collects JSP files from a resource delta. - */ - private class JSPResourceVisitor implements IResourceDeltaVisitor { - // using hash map ensures only one of each file - // must be reset before every use - private HashMap jspFiles = null; - - public JSPResourceVisitor() { - this.jspFiles = new HashMap(); - } - - private void deleteIndex(IFile folder) { - // cleanup index - IndexManager im = JavaModelManager.getJavaModelManager().getIndexManager(); - IPath folderPath = folder.getFullPath(); - IPath indexLocation = JsSearchSupport.getInstance().computeIndexLocation(folderPath); - im.removeIndex(indexLocation); - // im.indexLocations.removeKey(folderPath); - // im.indexLocations.removeValue(indexLocation); - File f = indexLocation.toFile(); - f.delete(); - } - - public IFile[] getFiles() { - return (IFile[]) this.jspFiles.values().toArray(new IFile[this.jspFiles.size()]); - } - - // https://bugs.eclipse.org/bugs/show_bug.cgi?id=93463 - private boolean isHiddenResource(IPath p) { - String[] segments = p.segments(); - for (int i = 0; i < segments.length; i++) { - if (segments[i].startsWith(".")) { - return true; - } - } - return false; - } - - public void reset() { - this.jspFiles.clear(); - } - - public boolean visit(IResourceDelta delta) throws CoreException { - // in case JSP search was canceled (eg. when closing the editor) - if (JsSearchSupport.getInstance().isCanceled() || frameworkIsShuttingDown()) { - setCanceledState(); - return false; - } - try { - if (!isHiddenResource(delta.getFullPath())) { - int kind = delta.getKind(); - boolean added = (kind & IResourceDelta.ADDED) == IResourceDelta.ADDED; - boolean isInterestingChange = false; - if ((kind & IResourceDelta.CHANGED) == IResourceDelta.CHANGED) { - int flags = delta.getFlags(); - // ignore things like marker changes - isInterestingChange = (flags & IResourceDelta.CONTENT) == IResourceDelta.CONTENT || (flags & IResourceDelta.REPLACED) == IResourceDelta.REPLACED; - } - boolean removed = (kind & IResourceDelta.REMOVED) == IResourceDelta.REMOVED; - if (added || isInterestingChange) { - visitAdded(delta); - } else if (removed) { - visitRemoved(delta); - } - } - } catch (Exception e) { - // need to set state here somehow, and reindex - // otherwise index will be unreliable - if (JsIndexManager.DEBUG) { - Logger.logException("Delta analysis may not be complete", e); //$NON-NLS-1$ - } - } - // if the delta has children, continue to add/remove files - return true; - } - - private void visitAdded(IResourceDelta delta) { - // https://w3.opensource.ibm.com/bugzilla/show_bug.cgi?id=3553 - // quick check if it's even JSP related to improve - // performance - // checking name from the delta before getting - // resource because it's lighter - int numSegments = delta.getFullPath().segmentCount(); - String filename = delta.getFullPath().segment(numSegments - 1); - if (Util.isJsType(filename)) { - IResource r = delta.getResource(); - if (r != null && r.exists() && r.getType() == IResource.FILE) { - this.jspFiles.put(r.getFullPath(), r); - } - } - } - - private void visitRemoved(IResourceDelta delta) { - // handle cleanup - if (delta.getResource() != null) { - IResource r = delta.getResource(); - if (r.getType() == IResource.FOLDER && r.exists()) { - deleteIndex((IFile) r); - } - } - } - } - /** - * schedules JSP files for indexing by Java core - */ - private class ProcessFilesJob extends Job { - List fileList = null; - // keep track of how many files we've indexed - int lastFileCursor = 0; - - ProcessFilesJob(String taskName) { - super(taskName); - fileList = new ArrayList(); - } - - synchronized void clearFiles() { - fileList.clear(); - lastFileCursor = 0; - // System.out.println("cleared files"); - } - - synchronized IFile[] getFiles() { - return (IFile[]) fileList.toArray(new IFile[fileList.size()]); - } - - private boolean isCanceled(IProgressMonitor runMonitor) { - boolean canceled = false; - // check specific monitor passed into run method (the progress - // group in this case) - // check main search support canceled - if (runMonitor != null && runMonitor.isCanceled()) { - canceled = true; - } else if (JsSearchSupport.getInstance().isCanceled()) { - canceled = true; - if (runMonitor != null) { - runMonitor.setCanceled(true); - } - } - return canceled; - } - - synchronized void process(IFile[] files) { - for (int i = 0; i < files.length; i++) { - fileList.add(files[i]); - } - if (JsIndexManager.DEBUG) { - System.out.println("JSPIndexManager queuing " + files.length + " files"); //$NON-NLS-2$ //$NON-NLS-1$ - } - } - - - protected IStatus run(IProgressMonitor monitor) { - // System.out.println("indexer monitor" + monitor); - if (isCanceled(monitor) || frameworkIsShuttingDown()) { - setCanceledState(); - return Status.CANCEL_STATUS; - } - long start = System.currentTimeMillis(); - try { - IFile[] filesToBeProcessed = getFiles(); - if (JsIndexManager.DEBUG) { - System.out.println("JSPIndexManager indexing " + filesToBeProcessed.length + " files"); //$NON-NLS-2$ //$NON-NLS-1$ - } - // API indicates that monitor is never null - monitor.beginTask("", filesToBeProcessed.length); //$NON-NLS-1$ - JsSearchSupport ss = JsSearchSupport.getInstance(); - String processingNFiles = ""; //$NON-NLS-1$ - for (; lastFileCursor < filesToBeProcessed.length; lastFileCursor++) { - if (isCanceled(monitor) || frameworkIsShuttingDown()) { - setCanceledState(); - return Status.CANCEL_STATUS; - } - try { - ss.addJspFile(filesToBeProcessed[lastFileCursor]); - // JSP Indexer processing n files - processingNFiles = NLS.bind(JsCoreMessages.JSPIndexManager_2, new String[] { Integer.toString((filesToBeProcessed.length - lastFileCursor)) }); - monitor.subTask(processingNFiles + " - " + filesToBeProcessed[lastFileCursor].getName()); //$NON-NLS-1$ - monitor.worked(1); - if (JsIndexManager.DEBUG) { - System.out.println("JSPIndexManager Job added file: " + filesToBeProcessed[lastFileCursor].getName()); //$NON-NLS-1$ - } - } catch (Exception e) { - // RATLC00284776 - // ISSUE: we probably shouldn't be catching EVERY - // exception, but - // the framework only allows to return IStatus in - // order to communicate - // that something went wrong, which means the loop - // won't complete, and we would hit the same problem - // the next time. - // - // a possible solution is to keep track of the - // exceptions logged - // and only log a certain amt of the same one, - // otherwise skip it. - if (!frameworkIsShuttingDown()) { - String filename = filesToBeProcessed[lastFileCursor] != null ? filesToBeProcessed[lastFileCursor].getFullPath().toString() : ""; //$NON-NLS-1$ - Logger.logException("JSPIndexer problem indexing:" + filename, e); //$NON-NLS-1$ - } - } - } // end for - } finally { - // just in case something didn't follow API (monitor is null) - if (monitor != null) { - monitor.done(); - } - } - // successfully finished, clear files list - clearFiles(); - long finish = System.currentTimeMillis(); - long diff = finish - start; - if (JsIndexManager.DEBUG) { - JsIndexManager.fTotalTime += diff; - System.out.println("============================================================================"); //$NON-NLS-1$ - System.out.println("this time: " + diff + " cumulative time for resource changed: " + JsIndexManager.fTotalTime); //$NON-NLS-1$ //$NON-NLS-2$ - System.out.println("============================================================================"); //$NON-NLS-1$ - } - return Status.OK_STATUS; - } - } - private IContentType fContentTypeJSP = null; - private JSPResourceVisitor fVisitor = null; - private IndexWorkspaceJob indexingJob = new IndexWorkspaceJob(); - private IndexJobCoordinator indexJobCoordinator; - private boolean initialized; - private boolean initializing = true; - private IResourceChangeListener jspResourceChangeListener; - /** symbolic name for OSGI framework */ - private final String OSGI_FRAMEWORK_ID = "org.eclipse.osgi"; //$NON-NLS-1$ - // Job for processing resource delta - private ProcessFilesJob processFilesJob = null; - - private JsIndexManager() { - processFilesJob = new ProcessFilesJob(JsCoreMessages.JSPIndexManager_0); - // only show in verbose mode - processFilesJob.setSystem(true); - processFilesJob.setPriority(Job.LONG); - processFilesJob.addJobChangeListener(new JobChangeAdapter() { - - public void done(IJobChangeEvent event) { - super.done(event); - setStableState(); - } - }); - } - - /** - * A check to see if the OSGI framework is shutting down. - * - * @return true if the System Bundle is stopped (ie. the framework is - * shutting down) - */ - boolean frameworkIsShuttingDown() { - // in the Framework class there's a note: - // set the state of the System Bundle to STOPPING. - // this must be done first according to section 4.19.2 from the OSGi - // R3 spec. - boolean shuttingDown = Platform.getBundle(OSGI_FRAMEWORK_ID).getState() == Bundle.STOPPING; - if (JsIndexManager.DEBUG && shuttingDown) { - System.out.println("JSPIndexManager: system is shutting down!"); //$NON-NLS-1$ - } - return shuttingDown; - } - - IndexWorkspaceJob getIndexingJob() { - return indexingJob; - } - - int getIndexState() { - return JsCorePlugin.getDefault().getPluginPreferences().getInt(JsIndexManager.PKEY_INDEX_STATE); - } - - - - ProcessFilesJob getProcessFilesJob() { - return processFilesJob; - } - - /** - * Package protected for access by inner Job class in resourceChanged(...) - * - * @return - */ - JSPResourceVisitor getVisitor() { - if (this.fVisitor == null) { - this.fVisitor = new JSPResourceVisitor(); - } - return this.fVisitor; - } - - /** - * Creates and schedules a Job to process collected files. All JSP indexing - * should be done through this method or processFiles(IFile file) - * - * @param files - */ - final void indexFiles(IFile[] files) { - // don't use this rule - // https://w3.opensource.ibm.com/bugzilla/show_bug.cgi?id=4931 - // processFiles.setRule(new IndexFileRule()); - processFilesJob.process(files); - } - - public void initialize() { - JsIndexManager singleInstance = JsIndexManager.getInstance(); - if (!singleInstance.initialized) { - singleInstance.initialized = true; - singleInstance.indexJobCoordinator = new IndexJobCoordinator(); - singleInstance.jspResourceChangeListener = new JSPResourceChangeListener(); - // added as JobChange listener so JSPIndexManager can be smarter - // about when it runs - Platform.getJobManager().addJobChangeListener(singleInstance.indexJobCoordinator); - // add JSPIndexManager to keep JSP Index up to date - // listening for IResourceChangeEvent.PRE_DELETE and - // IResourceChangeEvent.POST_CHANGE - ResourcesPlugin.getWorkspace().addResourceChangeListener(jspResourceChangeListener, IResourceChangeEvent.POST_CHANGE); - // https://w3.opensource.ibm.com/bugzilla/show_bug.cgi?id=5091 - // makes sure IndexManager is aware of our indexes - saveIndexes(); - rebuildIndexIfNeeded(); - singleInstance.initializing = false; - } - } - - boolean isInitializing() { - return initializing; - } - - void rebuildIndex() { - if (JsIndexManager.DEBUG) { - System.out.println("*** JSP Index unstable, requesting re-indexing"); //$NON-NLS-1$ - } - getIndexingJob().addJobChangeListener(new JobChangeAdapter() { - - public void aboutToRun(IJobChangeEvent event) { - super.aboutToRun(event); - setRebuildingState(); - } - - - public void done(IJobChangeEvent event) { - super.done(event); - setStableState(); - getIndexingJob().removeJobChangeListener(this); - } - }); - // we're about to reindex everything anyway - getProcessFilesJob().clearFiles(); - getIndexingJob().schedule(); - } - - synchronized void rebuildIndexIfNeeded() { - if (getIndexState() != JsIndexManager.S_STABLE) { - rebuildIndex(); - } - } - - // https://w3.opensource.ibm.com/bugzilla/show_bug.cgi?id=5091 - // makes sure IndexManager is aware of our indexes - void saveIndexes() { - IndexManager indexManager = JavaModelManager.getJavaModelManager().getIndexManager(); - IProject[] allProjects = ResourcesPlugin.getWorkspace().getRoot().getProjects(); - for (int j = 0; j < allProjects.length; j++) { - if (!JsWebNature.hasNature(allProjects[j]) || !allProjects[j].isOpen()) { - continue; - } - IPath jspModelWorkingLocation = JsSearchSupport.getInstance().getModelJspPluginWorkingLocation(allProjects[j]); - File folder = new File(jspModelWorkingLocation.toOSString()); - String[] files = folder.list(); - String locay = ""; //$NON-NLS-1$ - try { - for (int i = 0; i < files.length; i++) { - if (files[i].toLowerCase().endsWith(".index")) { //$NON-NLS-1$ - locay = jspModelWorkingLocation.toString() + "/" + files[i]; //$NON-NLS-1$ - // reuse index file -// index = new Index(locay, allProjects[j].getFullPath().toOSString(), true); -// //$NON-NLS-1$ -// index.save(); - indexManager.getIndex(allProjects[j].getFullPath(), new Path(locay), true, false); - // indexManager.saveIndex(index); - } - } - } catch (Exception e) { - // we should be shutting down, want to shut down quietly - if (JsIndexManager.DEBUG) { - e.printStackTrace(); - } - } - } - } - - void setCanceledState() { - setIndexState(JsIndexManager.S_CANCELED); - } - - synchronized void setIndexState(int state) { - if (JsIndexManager.DEBUG) { - System.out.println("JSPIndexManager setting index state to: " + state2String(state)); //$NON-NLS-1$ - } - Plugin jspModelPlugin = JsCorePlugin.getDefault(); - jspModelPlugin.getPluginPreferences().setValue(JsIndexManager.PKEY_INDEX_STATE, state); - jspModelPlugin.savePluginPreferences(); - } - - void setRebuildingState() { - setIndexState(JsIndexManager.S_REBUILDING); - } - - void setStableState() { - // if (getIndexState() != S_CANCELED) - setIndexState(JsIndexManager.S_STABLE); - } - - void setUpdatingState() { - // if (getIndexState() != S_CANCELED) - setIndexState(JsIndexManager.S_UPDATING); - } - - public void shutdown() { - // stop listening - ResourcesPlugin.getWorkspace().removeResourceChangeListener(jspResourceChangeListener); - // saveIndexes(); - // stop any searching - JsSearchSupport.getInstance().setCanceled(true); - // stop listening to jobs - Platform.getJobManager().removeJobChangeListener(indexJobCoordinator); - int maxwait = 5000; - if (processFilesJob != null) { - processFilesJob.cancel(); - } - // attempt to make sure this indexing job is litterally - // done before continuing, since we are shutting down - waitTillNotRunning(maxwait, processFilesJob); - if (indexingJob != null) { - indexingJob.cancel(); - } - waitTillNotRunning(maxwait, processFilesJob); - } - - private String state2String(int state) { - String s = "UNKNOWN"; //$NON-NLS-1$ - switch (state) { - case (JsIndexManager.S_STABLE): - s = "S_STABLE"; //$NON-NLS-1$ - break; - case (JsIndexManager.S_UPDATING): - s = "S_UPDATING"; //$NON-NLS-1$ - break; - case (JsIndexManager.S_CANCELED): - s = "S_CANCELED"; //$NON-NLS-1$ - break; - case (JsIndexManager.S_REBUILDING): - s = "S_REBUILDING"; //$NON-NLS-1$ - break; - } - return s; - } - - private void waitTillNotRunning(int maxSeconds, Job job) { - int pauseTime = 10; - int maxtries = maxSeconds / pauseTime; - int count = 0; - while (count++ < maxtries && job.getState() == Job.RUNNING) { - try { - Thread.sleep(pauseTime); - // System.out.println("count: " + count + " max: " + - // maxtries); - } catch (InterruptedException e) { - Logger.logException(e); - } - } - } -}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.jsdt.web.core/src/org/eclipse/wst/jsdt/web/core/internal/java/search/JsPathIndexer.java b/bundles/org.eclipse.wst.jsdt.web.core/src/org/eclipse/wst/jsdt/web/core/internal/java/search/JsPathIndexer.java deleted file mode 100644 index 3f451a6e9d..0000000000 --- a/bundles/org.eclipse.wst.jsdt.web.core/src/org/eclipse/wst/jsdt/web/core/internal/java/search/JsPathIndexer.java +++ /dev/null @@ -1,100 +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.jsdt.web.core.internal.java.search; -import org.eclipse.wst.jsdt.web.core.internal.validation.Util; -import java.util.HashMap; - -import org.eclipse.core.resources.IFile; -import org.eclipse.core.resources.IResource; -import org.eclipse.core.resources.IResourceProxy; -import org.eclipse.core.resources.IResourceProxyVisitor; -import org.eclipse.core.resources.ResourcesPlugin; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IPath; -import org.eclipse.core.runtime.Platform; -import org.eclipse.core.runtime.content.IContentDescription; -import org.eclipse.core.runtime.content.IContentType; -import org.eclipse.wst.jsdt.core.search.IJavaSearchScope; -import org.eclipse.wst.jsdt.core.search.SearchPattern; -import org.eclipse.wst.jsdt.web.core.internal.provisional.contenttype.ContentTypeIdForEmbededJs; - -/** - * pa_TODO Still need to take into consideration: - focus in workspace - search - * pattern - * - * @author pavery - */ -public class JsPathIndexer { - // for debugging - static final boolean DEBUG; - static { - String value = Platform.getDebugOption("org.eclipse.wst.jsdt.web.core/debug/jspsearch"); //$NON-NLS-1$ - DEBUG = value != null && value.equalsIgnoreCase("true"); //$NON-NLS-1$ - } - // visitor that retrieves jsp project paths for all jsp files in the - // workspace - class JSPFileVisitor implements IResourceProxyVisitor { - // hash map forces only one of each file - private HashMap fPaths = new HashMap(); - SearchPattern fPattern = null; - IJavaSearchScope fScope = null; - - public JSPFileVisitor(SearchPattern pattern, IJavaSearchScope scope) { - this.fPattern = pattern; - this.fScope = scope; - } - - public IPath[] getPaths() { - return (IPath[]) fPaths.values().toArray(new IPath[fPaths.size()]); - } - - public boolean visit(IResourceProxy proxy) throws CoreException { - if (JsSearchSupport.getInstance().isCanceled()) { - return false; - } - if (proxy.getType() == IResource.FILE) { - //IContentType contentTypeJSP = Platform.getContentTypeManager().getContentType(ContentTypeIdForJSP.ContentTypeIdHtml); - // https://w3.opensource.ibm.com/bugzilla/show_bug.cgi?id=3553 - // check this before description - // check name before actually getting the file (less work) - if (Util.isJsType(proxy.getName())) { - IFile file = (IFile) proxy.requestResource(); - IContentDescription contentDescription = file.getContentDescription(); - String ctId = null; - if (contentDescription != null) { - ctId = contentDescription.getContentType().getId(); - } - //if (ContentTypeIdForJSP.ContentTypeIdHtml.equals(ctId)) { - if (this.fScope.encloses(proxy.requestFullPath().toString())) { - if (JsPathIndexer.DEBUG) { - System.out.println("adding selected index path:" + file.getParent().getFullPath()); //$NON-NLS-1$ - } - fPaths.put(file.getParent().getFullPath(), JsSearchSupport.getInstance().computeIndexLocation(file.getParent().getFullPath())); - } - //} - } - // don't search deeper for files - return false; - } - return true; - } - } - - public IPath[] getVisibleJspPaths(SearchPattern pattern, IJavaSearchScope scope) { - JSPFileVisitor jspFileVisitor = new JSPFileVisitor(pattern, scope); - try { - ResourcesPlugin.getWorkspace().getRoot().accept(jspFileVisitor, 0); - } catch (CoreException e) { - e.printStackTrace(); - } - return jspFileVisitor.getPaths(); - } -} diff --git a/bundles/org.eclipse.wst.jsdt.web.core/src/org/eclipse/wst/jsdt/web/core/internal/java/search/JsSearchDocument.java b/bundles/org.eclipse.wst.jsdt.web.core/src/org/eclipse/wst/jsdt/web/core/internal/java/search/JsSearchDocument.java deleted file mode 100644 index 3ffdd78eb8..0000000000 --- a/bundles/org.eclipse.wst.jsdt.web.core/src/org/eclipse/wst/jsdt/web/core/internal/java/search/JsSearchDocument.java +++ /dev/null @@ -1,209 +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.jsdt.web.core.internal.java.search; - -import java.io.IOException; - -import org.eclipse.core.resources.IFile; -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.Path; -import org.eclipse.wst.jsdt.core.search.SearchParticipant; -import org.eclipse.wst.jsdt.web.core.internal.Logger; -import org.eclipse.wst.jsdt.web.core.internal.java.IJsTranslation; -import org.eclipse.wst.jsdt.web.core.internal.java.JsTranslation; -import org.eclipse.wst.jsdt.web.core.internal.java.JsTranslationAdapter; -import org.eclipse.wst.jsdt.web.core.internal.java.JsTranslationAdapterFactory; -import org.eclipse.wst.sse.core.StructuredModelManager; -import org.eclipse.wst.sse.core.internal.exceptions.UnsupportedCharsetExceptionWithDetail; -import org.eclipse.wst.sse.core.internal.provisional.IModelManager; -import org.eclipse.wst.sse.core.internal.provisional.IStructuredModel; -import org.eclipse.wst.xml.core.internal.provisional.document.IDOMDocument; -import org.eclipse.wst.xml.core.internal.provisional.document.IDOMModel; - -/** - * Created with a .jsp file, but should appear to be a .java file for indexing - * and searching purposes. There are purposely few fields in this class, and - * those fields are lightweight since it's possible for many JSP search - * documents to exist in memory at one time (eg. after importing a project with - * a large number of JSP files) - * - * @author pavery - */ -public class JsSearchDocument { - private String UNKNOWN_PATH = "**path unknown**"; //$NON-NLS-1$ - private char[] fCachedCharContents; - private String fCUPath = UNKNOWN_PATH; - private String fJSPPathString = UNKNOWN_PATH; - private long fLastModifiedStamp; - private SearchParticipant fParticipant = null; - - - /** - * @param file - * @param participant - * @throws CoreException - */ - public JsSearchDocument(String filePath, SearchParticipant participant) { - this.fJSPPathString = filePath; - this.fParticipant = participant; - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.wst.jsdt.core.search.SearchDocument#getByteContents() - */ - public byte[] getByteContents() { - // TODO Auto-generated method stub - return null; - } - - /** - * @see org.eclipse.wst.jsdt.core.search.SearchDocument#getCharContents() - */ - public char[] getCharContents() { - if (fCachedCharContents == null || isDirty()) { - JsTranslation trans = getJSPTranslation(); - fCachedCharContents = trans != null ? trans.getJsText().toCharArray() : new char[0]; - fCUPath = trans.getJavaPath(); - } - return fCachedCharContents; - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.wst.jsdt.core.search.SearchDocument#getEncoding() - */ - public String getEncoding() { - // TODO Auto-generated method stub - return null; - } - - public IFile getFile() { - IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot(); - IPath jspPath = new Path(this.fJSPPathString); - IFile jspFile = root.getFile(jspPath); - if (!jspFile.exists()) { - // possibly outside workspace - jspFile = root.getFileForLocation(jspPath); - } - return jspFile; - } - - public String getJavaText() { - return new String(getCharContents()); - } - - /** - * It's not recommended for clients to hold on to this JSPTranslation since - * it's kind of large. If possible, hold on to the JSPSearchDocument, which - * is more of a lightweight proxy. - * - * @return the JSPTranslation for the jsp file, or null if it's an - * unsupported file. - */ - public final JsTranslation getJSPTranslation() { - JsTranslation translation = null; - IFile jspFile = getFile(); - if (!JsSearchSupport.isJsp(jspFile)) { - return translation; - } - IStructuredModel model = null; - try { - // get existing model for read, then get document from it - IModelManager modelManager = StructuredModelManager.getModelManager(); - if (modelManager != null) { - model = modelManager.getExistingModelForRead(jspFile); - if(model==null) - model = modelManager.getModelForRead(jspFile); - } - // handle unsupported - if (model instanceof IDOMModel) { - IDOMModel xmlModel = (IDOMModel) model; - JsTranslationAdapterFactory factory = new JsTranslationAdapterFactory(); - xmlModel.getFactoryRegistry().addFactory(factory); - IDOMDocument doc = xmlModel.getDocument(); - JsTranslationAdapter adapter = (JsTranslationAdapter) doc.getAdapterFor(IJsTranslation.class); - translation = adapter.getJSPTranslation(false); - } - } catch (IOException e) { - Logger.logException(e); - } catch (CoreException e) { - Logger.logException(e); - } catch (UnsupportedCharsetExceptionWithDetail e) { - // no need to log this. Just consider it an invalid file for our - // purposes. - // Logger.logException(e); - } finally { - if (model != null) { - model.releaseFromRead(); - } - } - return translation; - } - - public SearchParticipant getParticipant() { - return this.fParticipant; - } - - /** - * the path to the Java compilation unit - * - * @see org.eclipse.wst.jsdt.core.search.SearchDocument#getPath() - */ - public String getPath() { - // caching the path since it's expensive to get translation - // important that isDirty() check is second to cache modification stamp - if (this.fCUPath == null || isDirty() || this.fCUPath == UNKNOWN_PATH) { - JsTranslation trans = getJSPTranslation(); - if (trans != null) { - try { - this.fCUPath = trans.getJavaPath(); - } catch (RuntimeException ex) { - // TODO Auto-generated catch block - ex.printStackTrace(); - } - // save since it's expensive to calculate again later - fCachedCharContents = trans.getJsText().toCharArray(); - } - } - return fCUPath != null ? fCUPath : UNKNOWN_PATH; - } - - private boolean isDirty() { - boolean modified = false; - IFile f = getFile(); - if (f != null) { - long currentStamp = f.getModificationStamp(); - if (currentStamp != fLastModifiedStamp) { - modified = true; - } - fLastModifiedStamp = currentStamp; - } - return modified; - } - - public void release() { - // nothing to do now since JSPTranslation is created on the fly - } - - /** - * for debugging - */ - - public String toString() { - return "[JSPSearchDocument:" + this.fJSPPathString + "]"; //$NON-NLS-1$ //$NON-NLS-2$ - } -}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.jsdt.web.core/src/org/eclipse/wst/jsdt/web/core/internal/java/search/JsSearchParticipant.java b/bundles/org.eclipse.wst.jsdt.web.core/src/org/eclipse/wst/jsdt/web/core/internal/java/search/JsSearchParticipant.java deleted file mode 100644 index a120dbb004..0000000000 --- a/bundles/org.eclipse.wst.jsdt.web.core/src/org/eclipse/wst/jsdt/web/core/internal/java/search/JsSearchParticipant.java +++ /dev/null @@ -1,110 +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.jsdt.web.core.internal.java.search; - -import java.util.ArrayList; -import java.util.List; - -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.wst.jsdt.core.search.IJavaSearchScope; -import org.eclipse.wst.jsdt.core.search.SearchDocument; -import org.eclipse.wst.jsdt.core.search.SearchEngine; -import org.eclipse.wst.jsdt.core.search.SearchParticipant; -import org.eclipse.wst.jsdt.core.search.SearchPattern; -import org.eclipse.wst.jsdt.core.search.SearchRequestor; - -/** - * Integration of JSP w/ java search. - * - * @author pavery - */ -public class JsSearchParticipant extends SearchParticipant { - // for debugging - private static final boolean DEBUG = JsSearchParticipant.calculateValue(); - - private static boolean calculateValue() { - String value = Platform.getDebugOption("org.eclipse.jstd.jsp.core/debug/jspsearch"); //$NON-NLS-1$ - boolean debug = value != null && value.equalsIgnoreCase("true"); //$NON-NLS-1$ - return debug; - } - - - public String getDescription() { - return "Embeded JavaScript"; //$NON-NLS-1$ - } - - /** - * @see org.eclipse.wst.jsdt.core.search.SearchParticipant#getDocument(org.eclipse.core.resources.IFile) - */ - public SearchDocument getDocument(IFile file) { - // never gets called? - return null; - } - - /** - * Important to never return null here or else Java search participation - * will break. - */ - - public SearchDocument getDocument(String documentPath) { - SearchDocument sDoc = JsSearchSupport.getInstance().getSearchDocument(documentPath); - if (sDoc == null) { - // return a dummy doc here so search participation doesn't break - return new NullSearchDocument(documentPath); - } - return sDoc; - } - - - public void indexDocument(SearchDocument document, IPath indexPath) { - if (!(document instanceof JSDTSearchDocumentDelegate)) { - return; - } - // use Java search indexing - SearchEngine.getDefaultSearchParticipant().indexDocument(document, indexPath); - } - - - public void locateMatches(SearchDocument[] indexMatches, SearchPattern pattern, IJavaSearchScope scope, SearchRequestor requestor, IProgressMonitor monitor) - throws CoreException { - if (monitor != null && monitor.isCanceled()) { - return; - } - // filter out null matches - List filtered = new ArrayList(); - SearchDocument match = null; - for (int i = 0; i < indexMatches.length; i++) { - if (JsSearchParticipant.DEBUG) { - System.out.println("found possible matching JavaSearchDocumentDelegate: " + indexMatches[i]); //$NON-NLS-1$ - } - match = indexMatches[i]; - if (match != null) { - // some matches may be null, or if the index is out of date, - // the file may not even exist - if (match instanceof JSDTSearchDocumentDelegate && ((JSDTSearchDocumentDelegate) match).getFile().exists()) { - filtered.add(match); - } - } - } - indexMatches = (SearchDocument[]) filtered.toArray(new SearchDocument[filtered.size()]); - SearchEngine.getDefaultSearchParticipant().locateMatches(indexMatches, pattern, scope, requestor, monitor); - } - - - public IPath[] selectIndexes(SearchPattern pattern, IJavaSearchScope scope) { - JsPathIndexer indexer = new JsPathIndexer(); - return indexer.getVisibleJspPaths(pattern, scope); - } -}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.jsdt.web.core/src/org/eclipse/wst/jsdt/web/core/internal/java/search/JsSearchScope.java b/bundles/org.eclipse.wst.jsdt.web.core/src/org/eclipse/wst/jsdt/web/core/internal/java/search/JsSearchScope.java deleted file mode 100644 index f96077ba63..0000000000 --- a/bundles/org.eclipse.wst.jsdt.web.core/src/org/eclipse/wst/jsdt/web/core/internal/java/search/JsSearchScope.java +++ /dev/null @@ -1,134 +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.jsdt.web.core.internal.java.search; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; - -import org.eclipse.core.resources.IResourceProxy; -import org.eclipse.core.runtime.IPath; -import org.eclipse.wst.jsdt.core.IJavaElement; -import org.eclipse.wst.jsdt.core.search.IJavaSearchScope; - -/** - * Used to constrain JSP/java search to certain paths and elements. - * - * @author pavery - */ -public class JsSearchScope implements IJavaSearchScope { - private boolean fEnclosesAll = false; - private List fJavaElements = null; - private List fResourcePaths = null; - - public JsSearchScope() { - // empty constructor just returns true for everything - // everything is in scope - this.fEnclosesAll = true; - init(); - } - - public JsSearchScope(IJavaElement[] javaElement) { - init(); - fJavaElements.addAll(Arrays.asList(javaElement)); - } - - public JsSearchScope(String[] resourceStringPath) { - init(); - fResourcePaths.addAll(Arrays.asList(resourceStringPath)); - } - - public void addElement(IJavaElement element) { - this.fJavaElements.add(element); - } - - public void addPath(String path) { - this.fResourcePaths.add(path); - } - - public boolean encloses(IJavaElement element) { - // pa_TOD implement - if (this.fEnclosesAll) { - return true; - } - return true; - } - - public boolean encloses(IResourceProxy element) { - if (this.fEnclosesAll) { - return true; - } else if (enclosesPath(element.requestFullPath().toOSString())) { - return true; - } - return true; - } - - public boolean encloses(String resourcePathString) { - if (this.fEnclosesAll) { - return true; - } else if (enclosesPath(resourcePathString)) { - return true; - } - return false; - } - - private boolean enclosesPath(String possible) { - String[] paths = (String[]) fResourcePaths.toArray(new String[fResourcePaths.size()]); - for (int i = 0; i < paths.length; i++) { - if (possible.equals(paths[i])) { - return true; - } - } - return false; - } - - public IPath[] enclosingProjectsAndJars() { - // pa_TODO - return null; - } - - public String getDescription() { - return "JSPSearchScope"; //$NON-NLS-1$ - } - - public boolean includesBinaries() { - /* TEMP CHANGE BC may 30 */ - return false; - } - - public boolean includesClasspaths() { - /* TEMP CHANGE BC may 30 */ - return false; - } - - private void init() { - this.fResourcePaths = new ArrayList(); - this.fJavaElements = new ArrayList(); - } - - public void setIncludesBinaries(boolean includesBinaries) { - // do nothing - } - - public void setIncludesClasspaths(boolean includesClasspaths) { - // do nothing - } - - /* (non-Javadoc) - * @see org.eclipse.wst.jsdt.core.search.IJavaSearchScope#shouldExclude(java.lang.String, java.lang.String) - */ - public boolean shouldExclude(String container, String resourceName) { - // TODO Auto-generated method stub - System.out.println("Unimplemented method:JsSearchScope.shouldExclude"); - return false; - } - -}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.jsdt.web.core/src/org/eclipse/wst/jsdt/web/core/internal/java/search/JsSearchSupport.java b/bundles/org.eclipse.wst.jsdt.web.core/src/org/eclipse/wst/jsdt/web/core/internal/java/search/JsSearchSupport.java deleted file mode 100644 index 568ead189c..0000000000 --- a/bundles/org.eclipse.wst.jsdt.web.core/src/org/eclipse/wst/jsdt/web/core/internal/java/search/JsSearchSupport.java +++ /dev/null @@ -1,512 +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.jsdt.web.core.internal.java.search; - -import org.eclipse.wst.jsdt.web.core.internal.validation.Util; -import java.io.File; -import java.util.zip.CRC32; - -import org.eclipse.core.resources.IFile; -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.ResourcesPlugin; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IPath; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.NullProgressMonitor; -import org.eclipse.core.runtime.Path; -import org.eclipse.core.runtime.Platform; -import org.eclipse.core.runtime.Status; -import org.eclipse.core.runtime.content.IContentType; -import org.eclipse.core.runtime.jobs.Job; -import org.eclipse.wst.jsdt.core.IJavaElement; -import org.eclipse.wst.jsdt.core.search.IJavaSearchConstants; -import org.eclipse.wst.jsdt.core.search.IJavaSearchScope; -import org.eclipse.wst.jsdt.core.search.SearchDocument; -import org.eclipse.wst.jsdt.core.search.SearchEngine; -import org.eclipse.wst.jsdt.core.search.SearchPattern; -import org.eclipse.wst.jsdt.core.search.SearchRequestor; -import org.eclipse.wst.jsdt.internal.core.JavaModelManager; -import org.eclipse.wst.jsdt.web.core.internal.JsCoreMessages; -import org.eclipse.wst.jsdt.web.core.internal.JsCorePlugin; -import org.eclipse.wst.jsdt.web.core.internal.Logger; -import org.eclipse.wst.jsdt.web.core.internal.java.JsNameManglerUtil; -import org.eclipse.wst.jsdt.web.core.internal.provisional.contenttype.ContentTypeIdForEmbededJs; - -/** - * Central access to java indexing and search. All contact between JDT indexing - * and Searching should be done through here. - * - * Clients should access the methods of this class via the single instance via - * <code>getInstance()</code>. - * - * @author pavery - */ -public class JsSearchSupport { - // for debugging - static final boolean DEBUG; - private static JsSearchSupport singleton = null; - static { - String value = Platform.getDebugOption("org.eclipse.wst.jsdt.web.core/debug/jspsearch"); //$NON-NLS-1$ - DEBUG = value != null && value.equalsIgnoreCase("true"); //$NON-NLS-1$ - } - - /** - * Clients should access the methods of this class via the single instance - * via getInstance() - * - * @return - */ - public synchronized static JsSearchSupport getInstance() { - if (JsSearchSupport.singleton == null) { - JsSearchSupport.singleton = new JsSearchSupport(); - } - return JsSearchSupport.singleton; - } - - // private IPath fJspPluginLocation = null; - /** - * Utility method to check if a file is a jsp file (since this is done - * frequently) - */ - public static boolean isJsp(IFile file) { - - if (file != null && file.exists()) { - return Util.isJsType(file.getName()); - } - return false; - } - /** - * This operation ensures that the live resource's search markers show up in - * the open editor. It also allows the ability to pass in a ProgressMonitor - */ - private class SearchJob extends Job implements IJavaSearchConstants { - IJavaElement fElement = null; - boolean fIsCaseSensitive = false; - int fLimitTo = IJavaSearchConstants.ALL_OCCURRENCES; - int fMatchMode = SearchPattern.R_PATTERN_MATCH; - SearchRequestor fRequestor = null; - IJavaSearchScope fScope = null; - int fSearchFor = IJavaSearchConstants.FIELD; - String fSearchText = ""; //$NON-NLS-1$ - - // constructor w/ java element - public SearchJob(IJavaElement element, IJavaSearchScope scope, SearchRequestor requestor) { - super(JsCoreMessages.JSP_Search + element.getElementName()); - this.fElement = element; - this.fScope = scope; - this.fRequestor = requestor; - } - - // constructor w/ search text - public SearchJob(String searchText, IJavaSearchScope scope, int searchFor, int limitTo, int matchMode, boolean isCaseSensitive, - SearchRequestor requestor) { - super(JsCoreMessages.JSP_Search + searchText); - this.fSearchText = searchText; - this.fScope = scope; - this.fSearchFor = searchFor; - this.fLimitTo = limitTo; - this.fMatchMode = matchMode; - this.fIsCaseSensitive = isCaseSensitive; - this.fRequestor = requestor; - } - - - public IStatus run(IProgressMonitor jobMonitor) { - if (jobMonitor != null && jobMonitor.isCanceled()) { - return Status.CANCEL_STATUS; - } - if (JsSearchSupport.getInstance().isCanceled()) { - return Status.CANCEL_STATUS; - } - SearchPattern javaSearchPattern = null; - // if an element is available, use that to create search pattern - // (eg. LocalVariable) - // otherwise use the text and other paramters - if (this.fElement != null) { - javaSearchPattern = SearchPattern.createPattern(this.fElement, this.fLimitTo); - } else { - javaSearchPattern = SearchPattern.createPattern(this.fSearchText, this.fSearchFor, this.fLimitTo, this.fMatchMode); - } - if (javaSearchPattern != null) { - JsSearchParticipant[] participants = { getSearchParticipant() }; - SearchEngine engine = new SearchEngine(); - try { - if (jobMonitor != null) { - jobMonitor.beginTask("", IProgressMonitor.UNKNOWN); //$NON-NLS-1$ - } - engine.search(javaSearchPattern, participants, this.fScope, this.fRequestor, jobMonitor); - } catch (CoreException e) { - if (JsSearchSupport.DEBUG) { - Logger.logException(e); - } - } - // non-CoreExceptions will permanently stall the Worker thread - catch (Exception e) { - if (JsSearchSupport.DEBUG) { - Logger.logException(e); - } - } finally { - if (jobMonitor != null) { - jobMonitor.done(); - } - } - } - return Status.OK_STATUS; - } - } - // end SearchJob - /** - * Runnable forces caller to wait until finished (as opposed to using a Job) - */ - private class SearchRunnable implements IWorkspaceRunnable, IJavaSearchConstants { - IJavaElement fElement = null; - boolean fIsCaseSensitive = false; - int fLimitTo = IJavaSearchConstants.ALL_OCCURRENCES; - int fMatchMode = SearchPattern.R_PATTERN_MATCH; - SearchRequestor fRequestor = null; - IJavaSearchScope fScope = null; - int fSearchFor = IJavaSearchConstants.FIELD; - String fSearchText = ""; //$NON-NLS-1$ - - // constructor w/ java element - public SearchRunnable(IJavaElement element, IJavaSearchScope scope, SearchRequestor requestor) { - this.fElement = element; - this.fScope = scope; - this.fRequestor = requestor; - } - - // constructor w/ search text - public SearchRunnable(String searchText, IJavaSearchScope scope, int searchFor, int limitTo, int matchMode, boolean isCaseSensitive, - SearchRequestor requestor) { - this.fSearchText = searchText; - this.fScope = scope; - this.fSearchFor = searchFor; - this.fLimitTo = limitTo; - this.fMatchMode = matchMode; - this.fIsCaseSensitive = isCaseSensitive; - this.fRequestor = requestor; - } - - public void run(IProgressMonitor monitor) throws CoreException { - if (monitor != null && monitor.isCanceled()) { - return; - } - if (JsSearchSupport.getInstance().isCanceled()) { - return; - } - SearchPattern javaSearchPattern = null; - // if an element is available, use that to create search pattern - // (eg. LocalVariable) - // otherwise use the text and other paramters - if (this.fElement != null) { - javaSearchPattern = SearchPattern.createPattern(this.fElement, fLimitTo); - } else { - javaSearchPattern = SearchPattern.createPattern(fSearchText, fSearchFor, fLimitTo, fMatchMode); - } - if (javaSearchPattern != null) { - JsSearchParticipant[] participants = { getSearchParticipant() }; - SearchEngine engine = new SearchEngine(); - try { - if (monitor != null) { - monitor.beginTask("", 0); //$NON-NLS-1$ - } - engine.search(javaSearchPattern, participants, fScope, fRequestor, monitor); - } catch (CoreException e) { - Logger.logException(e); - // throw e; - } - // non-CoreExceptions will permanently stall the Worker thread - catch (Exception e) { - Logger.logException(e); - } finally { - if (monitor != null) { - monitor.done(); - } - } - } - } - } - // pa_TODO may be slow (esp for indexing entire workspace) - private final CRC32 fChecksumCalculator = new CRC32(); - /** main cancel montior for all search support */ - private final IProgressMonitor fMonitor = new NullProgressMonitor(); - // end SearchRunnable - private JsSearchParticipant fParticipant = null; - - private JsSearchSupport() { - // force use of single instance - } - - /** - * schedules a search document representing this JSP file for indexing (by - * the java indexer) - * - * @param file - * the JSP file - * @return true if indexing was successful, false otherwise - * @throws CoreException - */ - public SearchDocument addJspFile(IFile file) { - if (JsSearchSupport.getInstance().isCanceled() || !file.isAccessible()) { - return null; - } - if (JsSearchSupport.DEBUG) { - System.out.println("adding JSP file:" + file.getFullPath()); //$NON-NLS-1$ - } - // create - SearchDocument delegate = createSearchDocument(file); - // null if not a jsp file - if (delegate != null) { - try { - getSearchParticipant().scheduleDocumentIndexing(delegate, computeIndexLocation(file.getParent().getFullPath())); - } catch (Exception e) { - // ensure that failure here doesn't keep other documents from - // being indexed - // if peformed in a batch call (like JSPIndexManager) - if (JsSearchSupport.DEBUG) { - e.printStackTrace(); - } - } - } - if (JsSearchSupport.DEBUG) { - System.out.println("scheduled" + delegate + "for indexing"); //$NON-NLS-1$ //$NON-NLS-2$ - } - return delegate; - } - - public final IPath computeContainerLocation(IPath indexLocation) { - return null; - } - - // This is called from JSPPathIndexer - // pa_TODO - // how can we make sure participant indexLocations are updated at startup? - public final IPath computeIndexLocation(IPath containerPath) { - String indexLocation = null; - // we don't want to inadvertently use a JDT Index - // we want to be sure to use the Index from the JSP location - // Object obj = indexLocations.get(containerPath); - // if (obj != null) { - // indexLocation = (String) obj; - // } else { - // create index entry - String pathString = containerPath.toOSString(); - this.fChecksumCalculator.reset(); - this.fChecksumCalculator.update(pathString.getBytes()); - String fileName = Long.toString(this.fChecksumCalculator.getValue()) + ".index"; //$NON-NLS-1$ - // this is the only difference from - // IndexManager#computeIndexLocation(...) - indexLocation = getModelJspPluginWorkingLocation(getProject(containerPath)).append(fileName).toOSString(); - // pa_TODO need to add to java path too, so JDT search support knows - // there should be a non internal way to do this. - // https://bugs.eclipse.org/bugs/show_bug.cgi?id=77564 - JavaModelManager.getJavaModelManager().getIndexManager().indexLocations.put(containerPath, new Path(indexLocation)); - // } - return new Path(indexLocation); - } - - /** - * @param jspFile - * @return SearchDocument if the file is not null, exists, and is a JSP - * file, otherwise null. - */ - private SearchDocument createSearchDocument(IFile jspFile) { - JSDTSearchDocumentDelegate delegate = null; - if (jspFile != null && jspFile.exists() && JsSearchSupport.isJsp(jspFile)) { - delegate = new JSDTSearchDocumentDelegate(new JsSearchDocument(jspFile.getFullPath().toString(), getSearchParticipant())); - } - return delegate; - } - - /** - * Unmangles the searchDocPath and returns the corresponding JSP file. - * - * @param searchDocPath - */ - private IFile fileForCUPath(String searchDocPath) { - String[] split = searchDocPath.split("/"); //$NON-NLS-1$ - String classname = split[split.length - 1]; - // ignore anything but .java matches (like .class binary matches) - if (!searchDocPath.endsWith(".js")) { //$NON-NLS-1$ - return null; - } - String filePath = JsNameManglerUtil.unmangle(classname); - // try absolute path - IFile f = ResourcesPlugin.getWorkspace().getRoot().getFileForLocation(new Path(filePath)); - // workspace relative then - if (f == null) { - // https://bugs.eclipse.org/bugs/show_bug.cgi?id=86009 - // must have a project name as well - // which would mean >= 2 path segments - IPath path = new Path(filePath); - if (path.segmentCount() >= 2) { - f = ResourcesPlugin.getWorkspace().getRoot().getFile(path); - } - } - return f; - } - - // copied from JDT IndexManager - public IPath getModelJspPluginWorkingLocation(IProject project) { - if (project == null) { - System.out.println("Null project"); - } - IPath workingLocationFile = project.getWorkingLocation(JsCorePlugin.PLUGIN_ID).append("jspsearch"); - // ensure that it exists on disk - File folder = new File(workingLocationFile.toOSString()); - if (!folder.isDirectory()) { - try { - folder.mkdir(); - } catch (SecurityException e) { - } - } - return workingLocationFile; - } - - /** - * JSP Indexing and Search jobs check this - * - * @return - */ - public final IProgressMonitor getProgressMonitor() { - return this.fMonitor; - } - - private IProject getProject(IPath path) { - // Return the project containing the given path - IWorkspace workspace = ResourcesPlugin.getWorkspace(); - IResource resource = workspace.getRoot().findMember(path.toString()); - if (resource == null) { - return null; - } - IProject project = resource.getProject(); - return project; - } - - /** - * Centralized place to access JSPSearchDocuments (used by - * JSPSearchParticipant and JSPSearchRequestor) - * - * @param searchDocPath - * @param doc - * @return the JSPSearchDocument or null if one is not found - */ - public SearchDocument getSearchDocument(String searchDocPath) { - SearchDocument delegate = null; - IFile f = fileForCUPath(searchDocPath); - if (f != null) { - delegate = createSearchDocument(f); - } else { - // handle failure case... (file deleted maybe?) - } - return delegate; - } - - JsSearchParticipant getSearchParticipant() { - if (this.fParticipant == null) { - this.fParticipant = new JsSearchParticipant(); - } - return this.fParticipant; - } - - /** - * JSP Indexing and Search jobs check this - * - * @return - */ - public synchronized final boolean isCanceled() { - return fMonitor.isCanceled(); - } - - /** - * Search for an IJavaElement, constrained by the given parameters. Runs in - * a background Job (results may still come in after this method call) - * - * @param element - * @param scope - * @param requestor - */ - public void search(IJavaElement element, IJavaSearchScope scope, SearchRequestor requestor) { - JsIndexManager.getInstance().rebuildIndexIfNeeded(); - SearchJob job = new SearchJob(element, scope, requestor); - setCanceled(false); - job.setUser(true); - // https://w3.opensource.ibm.com/bugzilla/show_bug.cgi?id=5032 - // job.setRule(ResourcesPlugin.getWorkspace().getRoot()); - job.schedule(); - } - - /** - * Perform a java search w/ the given parameters. Runs in a background Job - * (results may still come in after this method call) - * - * @param searchText - * the string of text to search on - * @param searchFor - * IJavaSearchConstants.TYPE, METHOD, FIELD, PACKAGE, etc... - * @param limitTo - * IJavaSearchConstants.DECLARATIONS, - * IJavaSearchConstants.REFERENCES, - * IJavaSearchConstants.IMPLEMENTORS, or - * IJavaSearchConstants.ALL_OCCURRENCES - * @param matchMode - * allow * wildcards or not - * @param isCaseSensitive - * @param requestor - * passed in to accept search matches (and do "something" with - * them) - */ - public void search(String searchText, IJavaSearchScope scope, int searchFor, int limitTo, int matchMode, boolean isCaseSensitive, SearchRequestor requestor) { - JsIndexManager.getInstance().rebuildIndexIfNeeded(); - SearchJob job = new SearchJob(searchText, scope, searchFor, limitTo, matchMode, isCaseSensitive, requestor); - setCanceled(false); - job.setUser(true); - // https://w3.opensource.ibm.com/bugzilla/show_bug.cgi?id=5032 - // pops up user operation blocked dialog if you perform a long search, - // then open a file because it locks the workspace - // job.setRule(ResourcesPlugin.getWorkspace().getRoot()); - job.schedule(); - } - - /** - * Search for an IJavaElement, constrained by the given parameters. Runs in - * an IWorkspace runnable (results will be reported by the end of this - * method) - * - * @param element - * @param scope - * @param requestor - */ - public void searchRunnable(IJavaElement element, IJavaSearchScope scope, SearchRequestor requestor) { - JsIndexManager.getInstance().rebuildIndexIfNeeded(); - SearchRunnable searchRunnable = new SearchRunnable(element, scope, requestor); - try { - setCanceled(false); - ResourcesPlugin.getWorkspace().run(searchRunnable, JsSearchSupport.getInstance().getProgressMonitor()); - } catch (CoreException e) { - e.printStackTrace(); - } - } - - /** - * JSP Indexing and Search jobs check this - * - * @return - */ - public synchronized final void setCanceled(boolean cancel) { - // System.out.println("search support monitor" + fMonitor); - fMonitor.setCanceled(cancel); - } -}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.jsdt.web.core/src/org/eclipse/wst/jsdt/web/core/internal/java/search/NullSearchDocument.java b/bundles/org.eclipse.wst.jsdt.web.core/src/org/eclipse/wst/jsdt/web/core/internal/java/search/NullSearchDocument.java deleted file mode 100644 index 04c4cec042..0000000000 --- a/bundles/org.eclipse.wst.jsdt.web.core/src/org/eclipse/wst/jsdt/web/core/internal/java/search/NullSearchDocument.java +++ /dev/null @@ -1,43 +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.jsdt.web.core.internal.java.search; - -import org.eclipse.wst.jsdt.core.search.SearchDocument; -import org.eclipse.wst.jsdt.web.core.internal.java.JsTranslator; - -/** - * An empty servlet, safe for Java search participation - * - * @author pavery - */ -public class NullSearchDocument extends SearchDocument { - StringBuffer fEmptyServletBuffer = null; - - public NullSearchDocument(String documentPath) { - super(documentPath, new JsSearchParticipant()); - this.fEmptyServletBuffer = new StringBuffer(); - } - - - public byte[] getByteContents() { - return this.fEmptyServletBuffer.toString().getBytes(); - } - - - public char[] getCharContents() { - return this.fEmptyServletBuffer.toString().toCharArray(); - } - - - public String getEncoding() { - return null; - } -} diff --git a/bundles/org.eclipse.wst.jsdt.web.core/src/org/eclipse/wst/jsdt/web/core/internal/modelhandler/IWebDocumentChangeListener.java b/bundles/org.eclipse.wst.jsdt.web.core/src/org/eclipse/wst/jsdt/web/core/internal/modelhandler/IWebDocumentChangeListener.java deleted file mode 100644 index 3a6625024f..0000000000 --- a/bundles/org.eclipse.wst.jsdt.web.core/src/org/eclipse/wst/jsdt/web/core/internal/modelhandler/IWebDocumentChangeListener.java +++ /dev/null @@ -1,16 +0,0 @@ -/** - * - */ -package org.eclipse.wst.jsdt.web.core.internal.modelhandler; - -/** - * @author childsb - * - */ -public interface IWebDocumentChangeListener extends IWebResourceChangedListener { - public static final int BORING = 0; - public static final int DIRTY_DOC = 1; - public static final int DIRTY_MODEL = 2; - - public int getIntrestLevelAtOffset(int documentOffset); -} diff --git a/bundles/org.eclipse.wst.jsdt.web.core/src/org/eclipse/wst/jsdt/web/core/internal/modelhandler/IWebResourceChangedListener.java b/bundles/org.eclipse.wst.jsdt.web.core/src/org/eclipse/wst/jsdt/web/core/internal/modelhandler/IWebResourceChangedListener.java deleted file mode 100644 index 1fbbfa9a68..0000000000 --- a/bundles/org.eclipse.wst.jsdt.web.core/src/org/eclipse/wst/jsdt/web/core/internal/modelhandler/IWebResourceChangedListener.java +++ /dev/null @@ -1,12 +0,0 @@ -/** - * - */ -package org.eclipse.wst.jsdt.web.core.internal.modelhandler; - -/** - * @author childsb - * - */ -public interface IWebResourceChangedListener { - public void resourceChanged(); -} diff --git a/bundles/org.eclipse.wst.jsdt.web.core/src/org/eclipse/wst/jsdt/web/core/internal/modelhandler/WebResourceChangeHandler.java b/bundles/org.eclipse.wst.jsdt.web.core/src/org/eclipse/wst/jsdt/web/core/internal/modelhandler/WebResourceChangeHandler.java deleted file mode 100644 index add1f69d44..0000000000 --- a/bundles/org.eclipse.wst.jsdt.web.core/src/org/eclipse/wst/jsdt/web/core/internal/modelhandler/WebResourceChangeHandler.java +++ /dev/null @@ -1,208 +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.jsdt.web.core.internal.modelhandler; - -import java.util.ArrayList; -import java.util.Enumeration; - -import org.eclipse.core.resources.IResourceChangeEvent; -import org.eclipse.core.resources.IResourceChangeListener; -import org.eclipse.core.resources.ResourcesPlugin; -import org.eclipse.jface.text.DocumentEvent; -import org.eclipse.jface.text.IDocumentListener; -import org.eclipse.swt.widgets.Display; -import org.eclipse.wst.sse.core.StructuredModelManager; -import org.eclipse.wst.sse.core.internal.model.ModelLifecycleEvent; -import org.eclipse.wst.sse.core.internal.provisional.IModelLifecycleListener; -import org.eclipse.wst.sse.core.internal.provisional.IStructuredModel; -import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocument; -import org.eclipse.wst.xml.core.internal.provisional.document.IDOMModel; - -import java.util.Hashtable; - -/** - * Copyright IBM 2007. All rights reserved. This class maintains resource change - * events for web document moedels. Author Bradley Childs. (childsb@us.ibm.com) - */ -public class WebResourceChangeHandler implements IResourceChangeListener, IDocumentListener, IModelLifecycleListener { - /* - * Check the level of dirty regions when signaling for document events. - * - * sometimes the SSE editor doesn't re-validate regions when text is - * inserted, so setting this to false causes every document change event to - * trigger a revalidation. - * - * setting to true may speed things up. - * - */ - private static final boolean CHECK_INTREST_LEVEL = false; - private static Hashtable instances = new Hashtable(); - private static final boolean SIGNAL_MODEL = false; - - public static WebResourceChangeHandler getInstance(IStructuredModel xmlModel, IWebResourceChangedListener changeListener) { - WebResourceChangeHandler handler = null; - synchronized (WebResourceChangeHandler.instances) { - Enumeration values = WebResourceChangeHandler.instances.elements(); - while (values.hasMoreElements()) { - Object model = values.nextElement(); - if (model == xmlModel) { - handler = (WebResourceChangeHandler) WebResourceChangeHandler.instances.get(model); - } - } - if (handler == null) { - handler = new WebResourceChangeHandler(); - WebResourceChangeHandler.instances.put(handler, xmlModel); - } - } - handler.initialize(); - handler.fchangeListener.add(changeListener); - return handler; - } - private class ModelIrritantThread implements Runnable { - public void run() { - signalAllDirtyModel(); - } - - public void signalAllDirtyModel() { - for (int i = 0; i < fchangeListener.size(); i++) { - ((IWebResourceChangedListener) fchangeListener.get(i)).resourceChanged(); - } - if (!WebResourceChangeHandler.SIGNAL_MODEL) { - return; - } - IDOMModel xmlModel = null; - Object modelRef = getModel(); - if (modelRef == null) { - return; - } - try { -// for(int i =0;i<fchangeListener.size();i++) { -// ((IWebResourceChangedListener)fchangeListener.get(i)).resourceChanged(); -// } - xmlModel = (IDOMModel) StructuredModelManager.getModelManager().getExistingModelForEdit(((IStructuredModel) modelRef).getBaseLocation()); - if (xmlModel != null) { - IStructuredDocument doc = xmlModel.getStructuredDocument(); - xmlModel.aboutToChangeModel(); - // xmlModel.setReinitializeNeeded(true); - // (doc).replace(0, doc.getLength(),doc.get()); - xmlModel.changedModel(); - } - } catch (Exception e) { - System.out.println("Error when trying to agitate the model.."); - } finally { - if (xmlModel != null) { - xmlModel.releaseFromEdit(); - } - } - } - } - private ArrayList fchangeListener = new ArrayList(); - private ModelIrritantThread irritator; - - private WebResourceChangeHandler() {} - - /* - * (non-Javadoc) - * - * @see org.eclipse.jface.text.IDocumentListener#documentAboutToBeChanged(org.eclipse.jface.text.DocumentEvent) - */ - public void documentAboutToBeChanged(DocumentEvent event) {} - - /* - * (non-Javadoc) - * - * @see org.eclipse.jface.text.IDocumentListener#documentChanged(org.eclipse.jface.text.DocumentEvent) - */ - public void documentChanged(DocumentEvent event) { -// if (WebResourceChangeHandler.CHECK_INTREST_LEVEL) { -// for (int i = 0; i < fchangeListener.size(); i++) { -// Object o = fchangeListener.get(i); -// if (o instanceof IWebDocumentChangeListener) { -// int intrest = ((IWebDocumentChangeListener) o).getIntrestLevelAtOffset(event.fOffset); -// switch (intrest) { -// case IWebDocumentChangeListener.DIRTY_MODEL: -// irritator.signalAllDirtyModel(); -// return; -// case IWebDocumentChangeListener.DIRTY_DOC: -// ((IWebDocumentChangeListener) o).resourceChanged(); -// break; -// } -// return; -// } -// } -// } else { - irritator.signalAllDirtyModel(); - //} - } - - - public boolean equals(Object o) { - return (o instanceof WebResourceChangeHandler && ((WebResourceChangeHandler) o).fchangeListener == this.fchangeListener); - } - - - public void finalize() { - ResourcesPlugin.getWorkspace().removeResourceChangeListener(this); - if (WebResourceChangeHandler.instances == null) { - return; - } - Object o = null; - synchronized (WebResourceChangeHandler.instances) { - o = WebResourceChangeHandler.instances.get(this); - WebResourceChangeHandler.instances.remove(this); - } - if (o != null) { - IStructuredModel fXMLModel = (IStructuredModel) o; - IStructuredDocument fJspDocument = fXMLModel.getStructuredDocument(); - if (fJspDocument != null) { - fJspDocument.removeDocumentListener(this); - } - } - } - - private IStructuredModel getModel() { - if (WebResourceChangeHandler.instances == null) { - return null; - } - return (IStructuredModel) WebResourceChangeHandler.instances.get(this); - } - - private void initialize() { - IStructuredModel xmlModel = getModel(); - ResourcesPlugin.getWorkspace().addResourceChangeListener(this, IResourceChangeEvent.POST_CHANGE); - xmlModel.addModelLifecycleListener(this); - IStructuredDocument fJspDocument = xmlModel.getStructuredDocument(); - if (fJspDocument != null) { - fJspDocument.addDocumentListener(this); - } - irritator = new ModelIrritantThread(); - } - - public void processPostModelEvent(ModelLifecycleEvent event) { - if (irritator != null) { - irritator.signalAllDirtyModel(); - } - if (WebResourceChangeHandler.instances == null) { - return; - } - if (event.getType() == ModelLifecycleEvent.MODEL_RELEASED) { - synchronized (WebResourceChangeHandler.instances) { - WebResourceChangeHandler.instances.remove(this); - } - } - } - - public void processPreModelEvent(ModelLifecycleEvent event) {} - - public void resourceChanged(IResourceChangeEvent event) { - Display.getDefault().asyncExec(irritator); - } -} diff --git a/bundles/org.eclipse.wst.jsdt.web.core/src/org/eclipse/wst/jsdt/web/core/internal/project/JsNatureInstaller.java b/bundles/org.eclipse.wst.jsdt.web.core/src/org/eclipse/wst/jsdt/web/core/internal/project/JsNatureInstaller.java deleted file mode 100644 index f6b5984f11..0000000000 --- a/bundles/org.eclipse.wst.jsdt.web.core/src/org/eclipse/wst/jsdt/web/core/internal/project/JsNatureInstaller.java +++ /dev/null @@ -1,41 +0,0 @@ -package org.eclipse.wst.jsdt.web.core.internal.project; - -import org.eclipse.core.resources.IProject; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.NullProgressMonitor; -import org.eclipse.core.runtime.Status; -import org.eclipse.core.runtime.SubProgressMonitor; -import org.eclipse.wst.common.project.facet.core.IDelegate; -import org.eclipse.wst.common.project.facet.core.IProjectFacetVersion; -import org.eclipse.wst.jsdt.web.core.internal.JsCorePlugin; - -public class JsNatureInstaller implements IDelegate { - public void execute(IProject project, IProjectFacetVersion fv, Object config, IProgressMonitor monitor) throws CoreException { - if (monitor == null) { - monitor = new NullProgressMonitor(); - } - monitor.beginTask("Installing Facet for JavaScript Development Tools" + ".", 100); //$NON-NLS-1$ - try { - installNature(project, monitor); - } finally { - monitor.done(); - } - } - - public void installNature(IProject project, IProgressMonitor monitor) throws CoreException { - monitor.beginTask("Installing JavaScript Development Tools...", 100); - monitor.subTask("Adding JavaScript Development Toolkit Nature..."); - SubProgressMonitor sub = new SubProgressMonitor(monitor, 25); - try { - monitor.worked(20); - JsWebNature jsNature = new JsWebNature(project, monitor); - monitor.worked(20); - jsNature.configure(); - monitor.worked(40); - } catch (Exception e) { - throw new CoreException(new Status(IStatus.ERROR, JsCorePlugin.PLUGIN_ID, IStatus.OK, "Error installing runtime! JavaScript Development Tools could not be added..", e)); - } - } -} diff --git a/bundles/org.eclipse.wst.jsdt.web.core/src/org/eclipse/wst/jsdt/web/core/internal/project/JsNatureUninstaller.java b/bundles/org.eclipse.wst.jsdt.web.core/src/org/eclipse/wst/jsdt/web/core/internal/project/JsNatureUninstaller.java deleted file mode 100644 index e8e2c44eab..0000000000 --- a/bundles/org.eclipse.wst.jsdt.web.core/src/org/eclipse/wst/jsdt/web/core/internal/project/JsNatureUninstaller.java +++ /dev/null @@ -1,46 +0,0 @@ -package org.eclipse.wst.jsdt.web.core.internal.project; - -import org.eclipse.core.resources.IProject; -import org.eclipse.core.resources.IProjectNature; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.NullProgressMonitor; -import org.eclipse.core.runtime.Status; -import org.eclipse.core.runtime.SubProgressMonitor; -import org.eclipse.wst.common.project.facet.core.IDelegate; -import org.eclipse.wst.common.project.facet.core.IProjectFacetVersion; -import org.eclipse.wst.jsdt.web.core.internal.JsCorePlugin; - -public class JsNatureUninstaller implements IDelegate { - public void execute(IProject project, IProjectFacetVersion fv, Object config, IProgressMonitor monitor) throws CoreException { - if (monitor == null) { - monitor = new NullProgressMonitor(); - } - monitor.beginTask("Uninstalling Facet for JavaScript Development Tools" + ".", 100); //$NON-NLS-1$ - try { - uninstallNature(project, monitor); - } finally { - monitor.done(); - } - } - - public void uninstallNature(IProject project, IProgressMonitor monitor) throws CoreException { - monitor.beginTask("Uninstalling JavaScript Development Tools...", 100); - // by using natures we can leverage the precondition support - monitor.subTask("Removing JavaScript Development Toolking Nature..."); - SubProgressMonitor sub = new SubProgressMonitor(monitor, 25); - if (!JsWebNature.hasNature(project)) { - return; - } - try { - IProjectNature jsNature = new JsWebNature(project, monitor); - monitor.worked(20); - monitor.worked(50); - jsNature.deconfigure(); - monitor.worked(20); - } catch (CoreException e) { - throw new CoreException(new Status(IStatus.ERROR, JsCorePlugin.PLUGIN_ID, IStatus.OK, "Error installing runtime! JavaScript Development Tools could not be removed, or is not present in target project..", e)); - } - } -} diff --git a/bundles/org.eclipse.wst.jsdt.web.core/src/org/eclipse/wst/jsdt/web/core/internal/project/JsWebNature.java b/bundles/org.eclipse.wst.jsdt.web.core/src/org/eclipse/wst/jsdt/web/core/internal/project/JsWebNature.java deleted file mode 100644 index 6b7c8bf3d3..0000000000 --- a/bundles/org.eclipse.wst.jsdt.web.core/src/org/eclipse/wst/jsdt/web/core/internal/project/JsWebNature.java +++ /dev/null @@ -1,259 +0,0 @@ -package org.eclipse.wst.jsdt.web.core.internal.project; - -import java.util.Arrays; -import java.util.Vector; - -import org.eclipse.core.resources.IProject; -import org.eclipse.core.resources.IProjectDescription; -import org.eclipse.core.resources.IProjectNature; -import org.eclipse.core.resources.IResource; -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.OperationCanceledException; -import org.eclipse.core.runtime.Path; -import org.eclipse.wst.jsdt.core.IClasspathEntry; -import org.eclipse.wst.jsdt.core.JavaCore; -import org.eclipse.wst.jsdt.core.LibrarySuperType; -import org.eclipse.wst.jsdt.internal.core.JavaProject; -import org.eclipse.wst.jsdt.ui.PreferenceConstants; -import org.eclipse.wst.jsdt.web.core.internal.java.WebRootFinder; - -public class JsWebNature implements IProjectNature { - //private static final String FILENAME_CLASSPATH = ".classpath"; //$NON-NLS-1$ - // private static final String NATURE_IDS[] = - // {"org.eclipse.wst.jsdt.web.core.embeded.jsNature",JavaCore.NATURE_ID}; - // //$NON-NLS-1$ - private static final String NATURE_IDS[] = { JavaCore.NATURE_ID }; - - public static final IPath VIRTUAL_BROWSER_CLASSPATH = new Path("org.eclipse.wst.jsdt.launching.baseBrowserLibrary"); - public static final String VIRTUAL_CONTAINER = "org.eclipse.wst.jsdt.launching.WebProject"; - public static final IClasspathEntry VIRTUAL_SCOPE_ENTRY = JavaCore.newContainerEntry(new Path(VIRTUAL_CONTAINER)); - private static final String SUPER_TYPE_NAME = "Window"; - private static final String SUPER_TYPE_LIBRARY = "org.eclipse.wst.jsdt.launching.baseBrowserLibrary"; - - public static void addJsNature(IProject project, IProgressMonitor monitor) throws CoreException { - if (monitor != null && monitor.isCanceled()) { - throw new OperationCanceledException(); - } - if (!JsWebNature.hasNature(project)) { - IProjectDescription description = project.getDescription(); - String[] prevNatures = description.getNatureIds(); - String[] newNatures = new String[prevNatures.length + JsWebNature.NATURE_IDS.length]; - System.arraycopy(prevNatures, 0, newNatures, 0, prevNatures.length); - // newNatures[prevNatures.length] = JavaCore.NATURE_ID; - for (int i = 0; i < JsWebNature.NATURE_IDS.length; i++) { - newNatures[prevNatures.length + i] = JsWebNature.NATURE_IDS[i]; - } - description.setNatureIds(newNatures); - project.setDescription(description, monitor); - } else { - if (monitor != null) { - monitor.worked(1); - } - } - } - - public static boolean hasNature(IProject project) { - try { - for (int i = 0; i < JsWebNature.NATURE_IDS.length; i++) { - if (!project.hasNature(JsWebNature.NATURE_IDS[i])) { - return false; - } - } - } catch (CoreException ex) { - return false; - } - return true; - } - - public static void removeJsNature(IProject project, IProgressMonitor monitor) throws CoreException { - if (monitor != null && monitor.isCanceled()) { - throw new OperationCanceledException(); - } - if (JsWebNature.hasNature(project)) { - IProjectDescription description = project.getDescription(); - String[] prevNatures = description.getNatureIds(); - String[] newNatures = new String[prevNatures.length - JsWebNature.NATURE_IDS.length]; - int k = 0; - head: for (int i = 0; i < prevNatures.length; i++) { - for (int j = 0; j < JsWebNature.NATURE_IDS.length; j++) { - if (prevNatures[i] == JsWebNature.NATURE_IDS[j]) { - continue head; - } - } - newNatures[k++] = prevNatures[i]; - } - description.setNatureIds(newNatures); - project.setDescription(description, monitor); - } else { - if (monitor != null) { - monitor.worked(1); - } - } - } - private Vector classPathEntries = new Vector(); - private boolean DEBUG = false; - private IProject fCurrProject; - private JavaProject fJavaProject; - private IPath fOutputLocation; - private IProgressMonitor monitor; - - public JsWebNature() { - monitor = new NullProgressMonitor(); - } - - public JsWebNature(IProject project, IProgressMonitor monitor) { - fCurrProject = project; - if (monitor != null) { - this.monitor = monitor; - } else { - monitor = new NullProgressMonitor(); - } - } - - public void configure() throws CoreException { - - initOutputPath(); - createSourceClassPath(); - initJREEntry(); - initLocalClassPath(); - - if (hasProjectClassPathFile()) { - IClasspathEntry[] entries = getRawClassPath(); - if (entries != null && entries.length > 0) { - classPathEntries.removeAll(Arrays.asList(entries)); - classPathEntries.addAll(Arrays.asList(entries)); - } - } - - JsWebNature.addJsNature(fCurrProject, monitor); - fJavaProject = (JavaProject) JavaCore.create(fCurrProject); - fJavaProject.setProject(fCurrProject); - try { - // , fOutputLocation - if (!hasProjectClassPathFile()) { - fJavaProject.setRawClasspath((IClasspathEntry[]) classPathEntries.toArray(new IClasspathEntry[] {}), fOutputLocation, monitor); - }else{ - fJavaProject.setRawClasspath((IClasspathEntry[]) classPathEntries.toArray(new IClasspathEntry[] {}), monitor); - } - } catch (Exception e) { - System.out.println(e); - } - LibrarySuperType superType = new LibrarySuperType(new Path( SUPER_TYPE_LIBRARY), getJavaProject(), SUPER_TYPE_NAME); - getJavaProject().setCommonSuperType(superType); - // getJavaProject().addToBuildSpec(BUILDER_ID); - fCurrProject.refreshLocal(IResource.DEPTH_INFINITE, monitor); - } - - private void createSourceClassPath() { - if (hasAValidSourcePath()) { - return; - } - // IPath projectPath = fCurrProject.getFullPath(); - // classPathEntries.add(JavaCore.newSourceEntry(projectPath)); - } - - public void deconfigure() throws CoreException { - Vector badEntries = new Vector(); - IClasspathEntry[] defaultJRELibrary = PreferenceConstants.getDefaultJRELibrary(); - IClasspathEntry[] localEntries = initLocalClassPath(); - badEntries.addAll(Arrays.asList(defaultJRELibrary)); - badEntries.addAll(Arrays.asList(localEntries)); - IClasspathEntry[] entries = getRawClassPath(); - Vector goodEntries = new Vector(); - for (int i = 0; i < entries.length; i++) { - if (!badEntries.contains(entries[i])) { - goodEntries.add(entries[i]); - } - } - // getJavaProject().removeFromBuildSpec(BUILDER_ID); - IPath outputLocation = getJavaProject().getOutputLocation(); - getJavaProject().setRawClasspath((IClasspathEntry[]) goodEntries.toArray(new IClasspathEntry[] {}), outputLocation, monitor); - getJavaProject().deconfigure(); - JsWebNature.removeJsNature(fCurrProject, monitor); - fCurrProject.refreshLocal(IResource.DEPTH_INFINITE, monitor); - } - - public JavaProject getJavaProject() { - if (fJavaProject == null) { - fJavaProject = (JavaProject) JavaCore.create(fCurrProject); - fJavaProject.setProject(fCurrProject); - } - return fJavaProject; - } - - public IProject getProject() { - return this.fCurrProject; - } - - private IClasspathEntry[] getRawClassPath() { - JavaProject proj = new JavaProject(); - proj.setProject(fCurrProject); - return proj.readRawClasspath(); - } - - private boolean hasAValidSourcePath() { - if (hasProjectClassPathFile()) { - try { - IClasspathEntry[] entries = getRawClassPath(); - for (int i = 0; i < entries.length; i++) { - if (entries[i].getEntryKind() == IClasspathEntry.CPE_SOURCE) { - return true; - } - } - } catch (Exception e) { - if (DEBUG) { - System.out.println("Error checking sourcepath:" + e); - } - } - } - return false; - } - - private boolean hasProjectClassPathFile() { - if (fCurrProject == null) { - return false; - } - return fCurrProject.getFile(JavaProject.CLASSPATH_FILENAME).exists(); - } - - private void initJREEntry() { - IClasspathEntry[] defaultJRELibrary = PreferenceConstants.getDefaultJRELibrary(); - try { - IClasspathEntry[] entries = getRawClassPath(); - for (int i = 0; i < entries.length; i++) { - if (entries[i] == defaultJRELibrary[0]) { - return; - } - } - classPathEntries.add(defaultJRELibrary[0]); - } catch (Exception e) { - if (DEBUG) { - System.out.println("Error checking sourcepath:" + e); - } - } - } - - private IClasspathEntry[] initLocalClassPath() { - - classPathEntries.add(JsWebNature.VIRTUAL_SCOPE_ENTRY); - IClasspathEntry browserLibrary = JavaCore.newContainerEntry( VIRTUAL_BROWSER_CLASSPATH); - classPathEntries.add(browserLibrary); - //IPath webRoot = WebRootFinder.getWebContentFolder(fCurrProject); - // IClasspathEntry source = JavaCore.newSourceEntry(fCurrProject.getFullPath().append(webRoot).append("/")); - // classPathEntries.add(source); - return new IClasspathEntry[] { JsWebNature.VIRTUAL_SCOPE_ENTRY , browserLibrary/*,source*/}; - } - - private void initOutputPath() { - if (fOutputLocation == null) { - fOutputLocation = fCurrProject.getFullPath(); - } - } - - public void setProject(IProject project) { - this.fCurrProject = project; - } -} diff --git a/bundles/org.eclipse.wst.jsdt.web.core/src/org/eclipse/wst/jsdt/web/core/internal/provisional/contenttype/ContentTypeIdForEmbededJs.java b/bundles/org.eclipse.wst.jsdt.web.core/src/org/eclipse/wst/jsdt/web/core/internal/provisional/contenttype/ContentTypeIdForEmbededJs.java deleted file mode 100644 index febd65744f..0000000000 --- a/bundles/org.eclipse.wst.jsdt.web.core/src/org/eclipse/wst/jsdt/web/core/internal/provisional/contenttype/ContentTypeIdForEmbededJs.java +++ /dev/null @@ -1,34 +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.jsdt.web.core.internal.provisional.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 ContentTypeIdForEmbededJs { - /** - * The value of the contenttype id field must match what is specified in - * plugin.xml file. Note: this value is intentially set with default - * protected method so it will not be inlined. - */ - public final static String[] ContentTypeIds = ContentTypeIdForEmbededJs. getJsConstantString(); - - static String[] getJsConstantString() { - return new String[] {"org.eclipse.wst.html.core.htmlsource","org.eclipse.jst.jsp.core.jspsource"}; //$NON-NLS-1$ - } - - private ContentTypeIdForEmbededJs() { - super(); - } -} diff --git a/bundles/org.eclipse.wst.jsdt.web.core/src/org/eclipse/wst/jsdt/web/core/internal/provisional/contenttype/IContentDescriptionForJSP.java b/bundles/org.eclipse.wst.jsdt.web.core/src/org/eclipse/wst/jsdt/web/core/internal/provisional/contenttype/IContentDescriptionForJSP.java deleted file mode 100644 index 85bc972080..0000000000 --- a/bundles/org.eclipse.wst.jsdt.web.core/src/org/eclipse/wst/jsdt/web/core/internal/provisional/contenttype/IContentDescriptionForJSP.java +++ /dev/null @@ -1,23 +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.jsdt.web.core.internal.provisional.contenttype; - -import org.eclipse.core.runtime.QualifiedName; -import org.eclipse.wst.sse.core.internal.encoding.ICodedResourcePlugin; - -public interface IContentDescriptionForJSP { - public final static QualifiedName CONTENT_FAMILY_ATTRIBUTE = new QualifiedName(ICodedResourcePlugin.ID, "contentFamilyAttribute"); //$NON-NLS-1$; - /** - * Extra properties as part of ContentDescription, if the content is JSP. - */ - public final static QualifiedName CONTENT_TYPE_ATTRIBUTE = new QualifiedName(ICodedResourcePlugin.ID, "contentTypeAttribute"); //$NON-NLS-1$ - public final static QualifiedName LANGUAGE_ATTRIBUTE = new QualifiedName(ICodedResourcePlugin.ID, "languageAttribute"); //$NON-NLS-1$ -}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.jsdt.web.core/src/org/eclipse/wst/jsdt/web/core/internal/provisional/text/IJSPPartitionTypes.java b/bundles/org.eclipse.wst.jsdt.web.core/src/org/eclipse/wst/jsdt/web/core/internal/provisional/text/IJSPPartitionTypes.java deleted file mode 100644 index 9ced77a1a2..0000000000 --- a/bundles/org.eclipse.wst.jsdt.web.core/src/org/eclipse/wst/jsdt/web/core/internal/provisional/text/IJSPPartitionTypes.java +++ /dev/null @@ -1,22 +0,0 @@ -package org.eclipse.wst.jsdt.web.core.internal.provisional.text; - -/** - * This interface is not intended to be implemented. It defines the partition - * types for JSP. Clients should reference the partition type Strings defined - * here directly. - * - * @deprecated use - * org.eclipse.wst.jsdt.web.core.internal.provisional.text.IJSPPartitions - */ - -public interface IJSPPartitionTypes { - String JSP_COMMENT = "org.eclipse.wst.jsdt.web.JSP_COMMENT"; //$NON-NLS-1$ - String JSP_CONTENT_DELIMITER = IJSPPartitionTypes.JSP_SCRIPT_PREFIX + "DELIMITER"; //$NON-NLS-1$ - String JSP_CONTENT_JAVA = IJSPPartitionTypes.JSP_SCRIPT_PREFIX + "JAVA"; //$NON-NLS-1$ - String JSP_CONTENT_JAVASCRIPT = IJSPPartitionTypes.JSP_SCRIPT_PREFIX + "JAVASCRIPT"; //$NON-NLS-1$ - String JSP_DEFAULT = "org.eclipse.wst.jsdt.web.DEFAULT_JSP"; //$NON-NLS-1$ - String JSP_DEFAULT_EL = IJSPPartitionTypes.JSP_SCRIPT_PREFIX + "JSP_EL"; //$NON-NLS-1$ - String JSP_DEFAULT_EL2 = IJSPPartitionTypes.JSP_SCRIPT_PREFIX + "JSP_EL2"; //$NON-NLS-1$ - String JSP_DIRECTIVE = "org.eclipse.wst.jsdt.web.JSP_DIRECTIVE"; //$NON-NLS-1$ - String JSP_SCRIPT_PREFIX = "org.eclipse.wst.jsdt.web.SCRIPT."; //$NON-NLS-1$ -} diff --git a/bundles/org.eclipse.wst.jsdt.web.core/src/org/eclipse/wst/jsdt/web/core/internal/tasks/JsFileTaskScanner.java b/bundles/org.eclipse.wst.jsdt.web.core/src/org/eclipse/wst/jsdt/web/core/internal/tasks/JsFileTaskScanner.java deleted file mode 100644 index f42afa61d3..0000000000 --- a/bundles/org.eclipse.wst.jsdt.web.core/src/org/eclipse/wst/jsdt/web/core/internal/tasks/JsFileTaskScanner.java +++ /dev/null @@ -1,22 +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.jsdt.web.core.internal.tasks; - -import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegion; -import org.eclipse.wst.sse.core.internal.provisional.text.ITextRegion; -import org.eclipse.wst.xml.core.internal.tasks.XMLFileTaskScanner; - -public class JsFileTaskScanner extends XMLFileTaskScanner { - - protected boolean isCommentRegion(IStructuredDocumentRegion region, ITextRegion textRegion) { - return super.isCommentRegion(region, textRegion); - } -} diff --git a/bundles/org.eclipse.wst.jsdt.web.core/src/org/eclipse/wst/jsdt/web/core/internal/validation/JsBatchValidator.java b/bundles/org.eclipse.wst.jsdt.web.core/src/org/eclipse/wst/jsdt/web/core/internal/validation/JsBatchValidator.java deleted file mode 100644 index c1ade19837..0000000000 --- a/bundles/org.eclipse.wst.jsdt.web.core/src/org/eclipse/wst/jsdt/web/core/internal/validation/JsBatchValidator.java +++ /dev/null @@ -1,437 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006 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.jsdt.web.core.internal.validation; - -import java.io.IOException; -import java.io.InputStream; -import java.lang.reflect.InvocationTargetException; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; -import java.util.Locale; - -import org.eclipse.core.resources.IFile; -import org.eclipse.core.resources.IProject; -import org.eclipse.core.resources.IResource; -import org.eclipse.core.resources.IResourceProxy; -import org.eclipse.core.resources.IResourceProxyVisitor; -import org.eclipse.core.resources.IWorkspace; -import org.eclipse.core.resources.IWorkspaceRoot; -import org.eclipse.core.resources.IWorkspaceRunnable; -import org.eclipse.core.resources.ResourcesPlugin; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IConfigurationElement; -import org.eclipse.core.runtime.IExecutableExtension; -import org.eclipse.core.runtime.IPath; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.NullProgressMonitor; -import org.eclipse.core.runtime.Path; -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.core.runtime.content.IContentType; -import org.eclipse.core.runtime.jobs.ISchedulingRule; -import org.eclipse.core.runtime.jobs.Job; -import org.eclipse.osgi.util.NLS; -import org.eclipse.wst.jsdt.core.IClasspathAttribute; -import org.eclipse.wst.jsdt.core.IClasspathEntry; -import org.eclipse.wst.jsdt.core.IJavaProject; -import org.eclipse.wst.jsdt.core.IPackageFragmentRoot; -import org.eclipse.wst.jsdt.core.JavaCore; -import org.eclipse.wst.jsdt.core.JavaModelException; -import org.eclipse.wst.jsdt.web.core.internal.JsCoreMessages; -import org.eclipse.wst.jsdt.web.core.internal.Logger; -import org.eclipse.wst.jsdt.web.core.internal.provisional.contenttype.ContentTypeIdForEmbededJs; -import org.eclipse.wst.sse.core.StructuredModelManager; -import org.eclipse.wst.sse.core.internal.provisional.IStructuredModel; -import org.eclipse.wst.sse.core.utils.StringUtils; -import org.eclipse.wst.validation.internal.ConfigurationManager; -import org.eclipse.wst.validation.internal.ProjectConfiguration; -import org.eclipse.wst.validation.internal.ValidationRegistryReader; -import org.eclipse.wst.validation.internal.core.Message; -import org.eclipse.wst.validation.internal.core.ValidationException; -import org.eclipse.wst.validation.internal.operations.IWorkbenchContext; -import org.eclipse.wst.validation.internal.operations.WorkbenchReporter; -import org.eclipse.wst.validation.internal.provisional.core.IMessage; -import org.eclipse.wst.validation.internal.provisional.core.IReporter; -import org.eclipse.wst.validation.internal.provisional.core.IValidationContext; -import org.eclipse.wst.validation.internal.provisional.core.IValidatorJob; - -/** - * Performs JSP validation tasks for batch validation. The individual validator - * classes will still be used for source validation. - */ -public final class JsBatchValidator implements IValidatorJob, IExecutableExtension { - // for debugging - static final boolean DEBUG = Boolean.valueOf(Platform.getDebugOption("org.eclipse.wst.jsdt.web.core/debug/jspvalidator")).booleanValue(); //$NON-NLS-1$ - private static final String PLUGIN_ID_JSP_CORE = "org.eclipse.wst.jsdt.web.core"; //$NON-NLS-1$ - private IPath[] excludeLibPaths; - - private final static String [] rhinoValidator = {"org.eclipse.atf.javascript.internal.validation.JSSyntaxValidator"}; - static { - // Temp code to clear Rhino Syntax validation markers. - IWorkspace workspace = ResourcesPlugin.getWorkspace(); - IProject[] projects = workspace.getRoot().getProjects(); - for (int j = 0; j < projects.length; j++) { - IProject project = projects[j]; - //try { - if (project.isOpen()) { - try { - if (project.hasNature(JavaCore.NATURE_ID)) { - WorkbenchReporter.removeAllMessages(project, rhinoValidator, null); - } - } catch (CoreException e) { - // Do nothing - } - } - } - - } - - /** - * Gets current validation project configuration based on current project - * (which is based on current document) - * - * @return ProjectConfiguration - */ - static private ProjectConfiguration getProjectConfiguration(IFile file) { - ProjectConfiguration projectConfiguration = null; - if (file != null) { - IProject project = file.getProject(); - if (project != null) { - try { - projectConfiguration = ConfigurationManager.getManager().getProjectConfiguration(project); - } catch (InvocationTargetException e) { - Logger.log(Logger.WARNING_DEBUG, e.getMessage(), e); - } - } - } - return projectConfiguration; - } - - /** - * Checks if validator is enabled according in Validation preferences - * - * @param vmd - * @return - */ - static boolean isBatchValidatorPreferenceEnabled(IFile file) { - if (file == null) { - return true; - } - boolean enabled = true; - ProjectConfiguration configuration = JsBatchValidator.getProjectConfiguration(file); - if (configuration != null) { - org.eclipse.wst.validation.internal.ValidatorMetaData metadata = ValidationRegistryReader.getReader().getValidatorMetaData(JsBatchValidator.class.getName()); - if (configuration != null && metadata != null) { - if (!configuration.isBuildEnabled(metadata) && !configuration.isManualEnabled(metadata)) { - enabled = false; - } - } - } - return enabled; - } - class JSPFileVisitor implements IResourceProxyVisitor { - private List fFiles = new ArrayList(); - private IReporter fReporter = null; - - public JSPFileVisitor(IReporter reporter) { - fReporter = reporter; - } - - final IFile[] getFiles() { - return (IFile[]) fFiles.toArray(new IFile[fFiles.size()]); - } - - public boolean visit(IResourceProxy proxy) throws CoreException { - // check validation - if (fReporter.isCancelled()) { - return false; - } - if (proxy.getType() == IResource.FILE) { - if (Util.isJsType(proxy.getName()) && proxy.isAccessible()) { - IFile file = (IFile) proxy.requestResource(); - if (JsBatchValidator.DEBUG) { - System.out.println("(+) JSPValidator adding file: " + file.getName()); //$NON-NLS-1$ - } - fFiles.add(file); - // don't search deeper for files - return false; - } - } - return true; - } - } - class LocalizedMessage extends Message { - private String _message = null; - - public LocalizedMessage(int severity, String messageText) { - this(severity, messageText, null); - } - - public LocalizedMessage(int severity, String messageText, IResource targetObject) { - this(severity, messageText, (Object) targetObject); - } - - public LocalizedMessage(int severity, String messageText, Object targetObject) { - super(null, severity, null); - setLocalizedMessage(messageText); - setTargetObject(targetObject); - } - - private String getLocalizedText() { - return _message; - } - - - public String getText() { - return getLocalizedText(); - } - - - public String getText(ClassLoader cl) { - return getLocalizedText(); - } - - - public String getText(Locale l) { - return getLocalizedText(); - } - - - public String getText(Locale l, ClassLoader cl) { - return getLocalizedText(); - } - - public void setLocalizedMessage(String message) { - _message = message; - } - } - //String fAdditionalContentTypesIDs[] = null; - private IContentType[] fContentTypes = null; - private IContentType fJSPFContentType = null; - private JsValidator fJSPJavaValidator = new JsValidator(this); - - public void cleanup(IReporter reporter) { - fJSPJavaValidator.cleanup(reporter); - } - private IPath[] getLibraryPaths(IFile file) { - - if(excludeLibPaths!=null) return excludeLibPaths; - - IProject project = file.getProject(); - IJavaProject javaProject= JavaCore.create(project); - - if(javaProject==null) return new IPath[0]; - - IClasspathEntry[] entries = new IClasspathEntry[0]; - try { - entries = javaProject.getResolvedClasspath(true); - } catch (JavaModelException ex) { - // TODO Auto-generated catch block - ex.printStackTrace(); - } - ArrayList ignorePaths = new ArrayList(); - nextEntry: for(int i = 0;i<entries.length;i++) { - if(entries[i].getEntryKind() == IClasspathEntry.CPE_LIBRARY) { - IClasspathAttribute[] attribs = entries[i].getExtraAttributes(); - for(int k=0; attribs!=null && k<attribs.length;k++) { - if(attribs[k].getName().equalsIgnoreCase("validate") && attribs[k].getValue().equalsIgnoreCase("false")) { - ignorePaths.add(entries[i].getPath()); - continue nextEntry; - } - } - } - } - - excludeLibPaths = (Path[])ignorePaths.toArray(new Path[ignorePaths.size()]); - return excludeLibPaths; - } - - - void doValidate(IValidationContext helper, IReporter reporter) throws ValidationException { - - String[] uris = helper.getURIs(); - if (uris.length > 0) { - IWorkspaceRoot wsRoot = ResourcesPlugin.getWorkspace().getRoot(); - IFile currentFile = null; - - for (int i = 0; i < uris.length && !reporter.isCancelled(); i++) { - currentFile = wsRoot.getFile(new Path(uris[i])); - if (currentFile != null && currentFile.exists()) { - if (shouldValidate(currentFile) ) { - Message message = new LocalizedMessage(IMessage.LOW_SEVERITY, "" + (i + 1) + "/" + uris.length + " - " + currentFile.getFullPath().toString().substring(1)); - reporter.displaySubtask(this, message); - reporter.removeAllMessages(this, currentFile); - validateFile(currentFile, reporter); - } - if (JsBatchValidator.DEBUG) { - System.out.println("validating: [" + uris[i] + "]"); //$NON-NLS-1$ //$NON-NLS-2$ - } - } - } - } else { - // if uris[] length 0 -> validate() gets called for each project - if (helper instanceof IWorkbenchContext) { - IProject project = ((IWorkbenchContext) helper).getProject(); - Message message = new LocalizedMessage(IMessage.LOW_SEVERITY, NLS.bind(JsCoreMessages.JSPBatchValidator_0, project.getFullPath())); - reporter.displaySubtask(this, message); - JSPFileVisitor visitor = new JSPFileVisitor(reporter); - try { - // collect all jsp files for the project - project.accept(visitor, IResource.DEPTH_INFINITE); - } catch (CoreException e) { - if (JsBatchValidator.DEBUG) { - e.printStackTrace(); - } - } - IFile[] files = visitor.getFiles(); - for (int i = 0; i < files.length && !reporter.isCancelled(); i++) { - if (shouldValidate(files[i]) ) { - message = new LocalizedMessage(IMessage.LOW_SEVERITY, "" + (i + 1) + "/" + files.length + " - " + files[i].getFullPath().toString().substring(1)); - reporter.displaySubtask(this, message); - validateFile(files[i], reporter); - } - if (JsBatchValidator.DEBUG) { - System.out.println("validating: [" + files[i] + "]"); //$NON-NLS-1$ //$NON-NLS-2$ - } - } - } - } - } - -// /** -// * Checks if file is a jsp fragment or not. If so, check if the fragment -// * should be validated or not. -// * -// * @param file -// * Assumes shouldValidate was already called on file so it should -// * not be null and does exist -// * @return false if file is a fragment and it should not be validated, true -// * otherwise -// */ -// private boolean fragmentCheck(IFile file) { -// return isFragment(file); -// } - - public ISchedulingRule getSchedulingRule(IValidationContext helper) { - if (helper instanceof IWorkbenchContext) { - /* - * Use a single build rule when running batch validation. - */ - return ResourcesPlugin.getWorkspace().getRuleFactory().buildRule(); - } - /* - * For other kinds of validation, use no specific rule - */ - return null; - } - - - - - - private void performValidation(IFile f, IReporter reporter, IStructuredModel model) { - if (!reporter.isCancelled()) { - fJSPJavaValidator.performValidation(f, reporter, model,true); - } - } - - /** - * @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 { - - } - - private boolean shouldValidate(IFile file) { - //if(true) return true; - IResource resource = file; - IPath[] libPaths = getLibraryPaths(file); - IPath filePath = file.getFullPath().removeLastSegments(1); - for(int i = 0;i<libPaths.length;i++) { - if(libPaths[i].isPrefixOf(filePath)){ - return false; - } - } - - do { - if (resource.isDerived() || resource.isTeamPrivateMember() || !resource.isAccessible() || resource.getName().charAt(0) == '.') { - return false; - } - resource = resource.getParent(); - } while ((resource.getType() & IResource.PROJECT) == 0); - return true; - } - - public void validate(IValidationContext helper, IReporter reporter) throws ValidationException { - doValidate(helper, reporter); - } - - /** - * Validate one file. It's assumed that the file has JSP content type. - * - * @param f - * @param reporter - */ - void validateFile(IFile f, IReporter reporter) { - IStructuredModel model = null; - try { - // get JSP model on behalf of all JSP validators - model = StructuredModelManager.getModelManager().getExistingModelForRead(f); - if(model==null) { - model = model = StructuredModelManager.getModelManager().getModelForRead(f); - } - if (!reporter.isCancelled() && model != null) { - reporter.removeAllMessages(this, f); - performValidation(f, reporter, model); - } - } catch (IOException e) { - Logger.logException(e); - } catch (CoreException e) { - Logger.logException(e); - } finally { - if (model != null) { - model.releaseFromRead(); - } - } - } - - public IStatus validateInJob(final IValidationContext helper, final IReporter reporter) throws ValidationException { - Job currentJob = Platform.getJobManager().currentJob(); - ISchedulingRule rule = null; - if (currentJob != null) { - rule = currentJob.getRule(); - } - IWorkspaceRunnable validationRunnable = new IWorkspaceRunnable() { - public void run(IProgressMonitor monitor) throws CoreException { - try { - doValidate(helper, reporter); - } catch (ValidationException e) { - throw new CoreException(new Status(IStatus.ERROR, JsBatchValidator.PLUGIN_ID_JSP_CORE, 0, JsBatchValidator.PLUGIN_ID_JSP_CORE, e)); - } - } - }; - try { - JavaCore.run(validationRunnable, rule, new NullProgressMonitor()); - } catch (CoreException e) { - if (e.getCause() instanceof ValidationException) { - throw (ValidationException) e.getCause(); - } - throw new ValidationException(new LocalizedMessage(IMessage.ERROR_AND_WARNING, e.getMessage()), e); - } - return Status.OK_STATUS; - } -} diff --git a/bundles/org.eclipse.wst.jsdt.web.core/src/org/eclipse/wst/jsdt/web/core/internal/validation/JsValidator.java b/bundles/org.eclipse.wst.jsdt.web.core/src/org/eclipse/wst/jsdt/web/core/internal/validation/JsValidator.java deleted file mode 100644 index d0ae9e582f..0000000000 --- a/bundles/org.eclipse.wst.jsdt.web.core/src/org/eclipse/wst/jsdt/web/core/internal/validation/JsValidator.java +++ /dev/null @@ -1,310 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006, 2006 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.jsdt.web.core.internal.validation; - -import java.io.IOException; -import java.util.ArrayList; -import java.util.List; -import java.util.Locale; - -import org.eclipse.core.resources.IFile; -import org.eclipse.core.resources.IProject; -import org.eclipse.core.resources.IResource; -import org.eclipse.core.resources.IResourceProxy; -import org.eclipse.core.resources.IResourceProxyVisitor; -import org.eclipse.core.resources.IWorkspaceRoot; -import org.eclipse.core.resources.ResourcesPlugin; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.Path; -import org.eclipse.core.runtime.Platform; -import org.eclipse.core.runtime.content.IContentType; -import org.eclipse.wst.jsdt.core.compiler.IProblem; -import org.eclipse.wst.jsdt.web.core.internal.Logger; -import org.eclipse.wst.jsdt.web.core.internal.java.IJsTranslation; -import org.eclipse.wst.jsdt.web.core.internal.java.JsTranslation; -import org.eclipse.wst.jsdt.web.core.internal.java.JsTranslationAdapter; -import org.eclipse.wst.jsdt.web.core.internal.java.JsTranslationAdapterFactory; -import org.eclipse.wst.sse.core.StructuredModelManager; -import org.eclipse.wst.sse.core.internal.provisional.IStructuredModel; -import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocument; -import org.eclipse.wst.validation.internal.core.Message; -import org.eclipse.wst.validation.internal.core.ValidationException; -import org.eclipse.wst.validation.internal.operations.IWorkbenchContext; -import org.eclipse.wst.validation.internal.operations.WorkbenchReporter; -import org.eclipse.wst.validation.internal.provisional.core.IMessage; -import org.eclipse.wst.validation.internal.provisional.core.IReporter; -import org.eclipse.wst.validation.internal.provisional.core.IValidationContext; -import org.eclipse.wst.validation.internal.provisional.core.IValidator; -import org.eclipse.wst.xml.core.internal.provisional.document.IDOMDocument; -import org.eclipse.wst.xml.core.internal.provisional.document.IDOMModel; - -public class JsValidator implements IValidator{ - private static final boolean DEBUG = Boolean.valueOf(Platform.getDebugOption("org.eclipse.wst.jsdt.web.core/debug/jspvalidator")).booleanValue(); //$NON-NLS-1$ - private IValidator fMessageOriginator; - - private static String [] jsdtValidator = {"org.eclipse.wst.jsdt.web.core.internal.validation.JsBatchValidator"}; - - - protected class LocalizedMessage extends Message { - private String _message = null; - - public LocalizedMessage(int severity, String messageText) { - this(severity, messageText, null); - } - - public LocalizedMessage(int severity, String messageText, IResource targetObject) { - this(severity, messageText, (Object) targetObject); - } - - public LocalizedMessage(int severity, String messageText, Object targetObject) { - super(null, severity, null); - setLocalizedMessage(messageText); - setTargetObject(targetObject); - } - - public String getLocalizedMessage() { - return _message; - } - - - public String getText() { - return getLocalizedMessage(); - } - - - public String getText(ClassLoader cl) { - return getLocalizedMessage(); - } - - - public String getText(Locale l) { - return getLocalizedMessage(); - } - - - public String getText(Locale l, ClassLoader cl) { - return getLocalizedMessage(); - } - - public void setLocalizedMessage(String message) { - _message = message; - } - } - public JsValidator() { - this.fMessageOriginator = this; - } - - public JsValidator(IValidator validator) { - this.fMessageOriginator = validator; - } - - /** - * Creates an IMessage from an IProblem - * - * @param problem - * @param f - * @param translation - * @param structuredDoc - * @return message representation of the problem, or null if it could not - * create one - */ - private IMessage createMessageFromProblem(IProblem problem, IFile f, JsTranslation translation, IStructuredDocument structuredDoc) { - int sourceStart = problem.getSourceStart(); - int sourceEnd = problem.getSourceEnd(); - if (sourceStart == -1) { - return null; - } - // line number for marker starts @ 1 - // line number from document starts @ 0 - int lineNo = structuredDoc.getLineOfOffset(sourceStart) + 1; - int sev = problem.isError() ? IMessage.HIGH_SEVERITY : IMessage.NORMAL_SEVERITY; - IMessage m = new LocalizedMessage(sev, problem.getMessage(), f); - m.setLineNo(lineNo); - m.setOffset(sourceStart); - m.setLength(sourceEnd - sourceStart + 1); - return m; - } - - void performValidation(IFile f, IReporter reporter, IStructuredModel model, boolean inBatch) { - if (model instanceof IDOMModel) { - IDOMModel domModel = (IDOMModel) model; - setupAdapterFactory(domModel); - IDOMDocument xmlDoc = domModel.getDocument(); - JsTranslationAdapter translationAdapter = (JsTranslationAdapter) xmlDoc.getAdapterFor(IJsTranslation.class); - //translationAdapter.resourceChanged(); - JsTranslation translation = translationAdapter.getJSPTranslation(false); - if (!reporter.isCancelled()) { - translation.setProblemCollectingActive(true); - translation.reconcileCompilationUnit(); - List problems = translation.getProblems(); - // add new messages - if(!inBatch) reporter.removeAllMessages(this, f); - for (int i = 0; i < problems.size() && !reporter.isCancelled(); i++) { - IMessage m = createMessageFromProblem((IProblem) problems.get(i), f, translation, domModel.getStructuredDocument()); - if (m != null) { - reporter.addMessage(fMessageOriginator, m); - } - } - } - } - } - - /** - * When loading model from a file, you need to explicitly add adapter - * factory. - * - * @param sm - */ - private void setupAdapterFactory(IStructuredModel sm) { - if (sm.getFactoryRegistry().getFactoryFor(IJsTranslation.class) == null) { - JsTranslationAdapterFactory factory = new JsTranslationAdapterFactory(); - sm.getFactoryRegistry().addFactory(factory); - } - } - private boolean shouldValidate(IFile file) { - IResource resource = file; - do { - if (resource.isDerived() || resource.isTeamPrivateMember() || !resource.isAccessible() || resource.getName().charAt(0) == '.') { - return false; - } - resource = resource.getParent(); - } while ((resource.getType() & IResource.PROJECT) == 0); - return true; - } - public void validate(IValidationContext helper, IReporter reporter) throws ValidationException { - /* Added by BC ---- */ - // if(true) return; - /* end Added by BC ---- */ - - String[] uris = helper.getURIs(); - IWorkspaceRoot wsRoot = ResourcesPlugin.getWorkspace().getRoot(); - if (uris.length > 0) { - IFile currentFile = null; - for (int i = 0; i < uris.length && !reporter.isCancelled(); i++) { - currentFile = wsRoot.getFile(new Path(uris[i])); - reporter.removeAllMessages(this, currentFile); - if (currentFile != null && currentFile.exists()) { - if (shouldValidate(currentFile) ){ //&& fragmentCheck(currentFile)) { - int percent = (i * 100) / uris.length + 1; - Message message = new LocalizedMessage(IMessage.LOW_SEVERITY, percent + "% " + uris[i]); - reporter.displaySubtask(this, message); - validateFile(currentFile, reporter); - } - if (DEBUG) { - System.out.println("validating: [" + uris[i] + "]"); //$NON-NLS-1$ //$NON-NLS-2$ - } - } - } - } else { - // if uris[] length 0 -> validate() gets called for each project - if (helper instanceof IWorkbenchContext) { - IProject project = ((IWorkbenchContext) helper).getProject(); - JSPFileVisitor visitor = new JSPFileVisitor(reporter); - try { - // collect all jsp files for the project - project.accept(visitor, IResource.DEPTH_INFINITE); - } catch (CoreException e) { - if (DEBUG) { - e.printStackTrace(); - } - } - IFile[] files = visitor.getFiles(); - for (int i = 0; i < files.length && !reporter.isCancelled(); i++) { - if (shouldValidate(files[i])) { - int percent = (i * 100) / files.length + 1; - Message message = new LocalizedMessage(IMessage.LOW_SEVERITY, percent + "% " + files[i].getFullPath().toString()); - reporter.displaySubtask(this, message); - validateFile(files[i], reporter); - } - if (DEBUG) { - System.out.println("validating: [" + files[i] + "]"); //$NON-NLS-1$ //$NON-NLS-2$ - } - } - } - } - } - - protected class JSPFileVisitor implements IResourceProxyVisitor { - private IContentType[] fContentTypes = null; - private List fFiles = new ArrayList(); - private IReporter fReporter = null; - - public JSPFileVisitor(IReporter reporter) { - fReporter = reporter; - } - - public final IFile[] getFiles() { - return (IFile[]) fFiles.toArray(new IFile[fFiles.size()]); - } - - - public boolean visit(IResourceProxy proxy) throws CoreException { - // check validation - if (fReporter.isCancelled()) { - return false; - } - if (proxy.getType() == IResource.FILE) { - if (Util.isJsType(proxy.getName())) { - IFile file = (IFile) proxy.requestResource(); - if (file.exists()) { - if (DEBUG) { - System.out.println("(+) JSPValidator adding file: " + file.getName()); //$NON-NLS-1$ - } - fFiles.add(file); - // don't search deeper for files - return false; - } - } - } - return true; - } - } - public void cleanup(IReporter reporter) { - // nothing to do - } - /** - * Validate one file. It's assumed that the file has JSP content type. - * - * @param f - * @param reporter - */ - - protected void validateFile(IFile f, IReporter reporter) { - if (JsValidator.DEBUG) { - Logger.log(Logger.INFO, getClass().getName() + " validating: " + f); //$NON-NLS-1$ - } - IStructuredModel model = null; - try { - // get jsp model, get tranlsation - model = StructuredModelManager.getModelManager().getExistingModelForRead(f); - if(model==null) { - model = StructuredModelManager.getModelManager().getModelForRead(f); - } - if (!reporter.isCancelled() && model != null) { - // get jsp model, get translation - if (model instanceof IDOMModel) { - //WorkbenchReporter.removeAllMessages(f.getProject(), jsdtValidator, f.toString()); - //reporter.removeAllMessages(fMessageOriginator, f); - performValidation(f, reporter, model, false); - } - } - } catch (IOException e) { - Logger.logException(e); - } catch (CoreException e) { - Logger.logException(e); - } finally { - if (model != null) { - model.releaseFromRead(); - } - } - } -} diff --git a/bundles/org.eclipse.wst.jsdt.web.core/src/org/eclipse/wst/jsdt/web/core/internal/validation/Util.java b/bundles/org.eclipse.wst.jsdt.web.core/src/org/eclipse/wst/jsdt/web/core/internal/validation/Util.java deleted file mode 100644 index a1ca6562e9..0000000000 --- a/bundles/org.eclipse.wst.jsdt.web.core/src/org/eclipse/wst/jsdt/web/core/internal/validation/Util.java +++ /dev/null @@ -1,45 +0,0 @@ -/** - * - */ -package org.eclipse.wst.jsdt.web.core.internal.validation; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; - -import org.eclipse.core.runtime.Platform; -import org.eclipse.core.runtime.content.IContentType; -import org.eclipse.wst.jsdt.web.core.internal.provisional.contenttype.ContentTypeIdForEmbededJs; - -/** - * @author childsb - * - */ -public class Util { - - public static boolean isJsType(String fileName) { - boolean valid = false; - IContentType[] types =getJavascriptContentTypes(); - int i = 0; - while (types!=null && i < types.length && !valid) { - valid = types[i]!=null && types[i].isAssociatedWith(fileName); - ++i; - } - return valid; - - } - - public static IContentType[] getJavascriptContentTypes() { - - String[] contentTypeIds = ContentTypeIdForEmbededJs.ContentTypeIds; - ArrayList fContentTypes = new ArrayList(); - - - for(int i = 0;i<contentTypeIds.length;i++) { - IContentType ct = Platform.getContentTypeManager().getContentType(contentTypeIds[i]); - if(ct!=null) fContentTypes.add(ct); - } - - return (IContentType[])fContentTypes.toArray(new IContentType[fContentTypes.size()]); - } -} diff --git a/bundles/org.eclipse.wst.jsdt.web.core/src/org/eclipse/wst/jsdt/web/core/text/IJsPartitions.java b/bundles/org.eclipse.wst.jsdt.web.core/src/org/eclipse/wst/jsdt/web/core/text/IJsPartitions.java deleted file mode 100644 index 92068a22a7..0000000000 --- a/bundles/org.eclipse.wst.jsdt.web.core/src/org/eclipse/wst/jsdt/web/core/text/IJsPartitions.java +++ /dev/null @@ -1,15 +0,0 @@ -package org.eclipse.wst.jsdt.web.core.text; - -import org.eclipse.wst.html.core.text.IHTMLPartitions; - -/** - * This interface is not intended to be implemented. It defines the partition - * types for JSP. Clients should reference the partition type Strings defined - * here directly. - * - * @since 1.1 - */ -public interface IJsPartitions { - String HtmlJsPartition = IHTMLPartitions.SCRIPT; - //$NON-NLS-1$ -} |