JBoss Tools SVN: r42751 - in trunk/as: plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/resolvers and 6 other directories.
by jbosstools-commits@lists.jboss.org
Author: rob.stryker(a)jboss.com
Date: 2012-07-27 04:56:30 -0400 (Fri, 27 Jul 2012)
New Revision: 42751
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.classpath.core/src/org/jboss/ide/eclipse/as/classpath/core/ejb3/EJB3ClasspathContainer.java
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/resolvers/ConfigNameResolver.java
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/UnitedServerListenerManager.java
trunk/as/tests/org.jboss.tools.as.test.core/src/org/jboss/tools/as/test/core/MySuite.java
trunk/as/tests/org.jboss.tools.as.test.core/src/org/jboss/tools/as/test/core/internal/utils/ServerCreationTestUtils.java
trunk/as/tests/org.jboss.tools.as.test.core/src/org/jboss/tools/as/test/core/parametized/server/CreateRuntimeTwiceTest.java
trunk/as/tests/org.jboss.tools.as.test.core/src/org/jboss/tools/as/test/core/parametized/server/CreateServerCheckDefaultsTest.java
trunk/as/tests/org.jboss.tools.as.test.core/src/org/jboss/tools/as/test/core/parametized/server/ParametizedSuite.java
trunk/as/tests/org.jboss.tools.as.test.core/src/org/jboss/tools/as/test/core/parametized/server/publishing/AbstractComponentPublishingTest.java
trunk/as/tests/org.jboss.tools.as.test.core/src/org/jboss/tools/as/test/core/parametized/server/publishing/DeploymentAssemblyArchivePathVarNestedWarTest.java
trunk/as/tests/org.jboss.tools.as.test.core/src/org/jboss/tools/as/test/core/parametized/server/publishing/DeploymentAssemblyArchivePathVarTest.java
trunk/as/tests/org.jboss.tools.as.test.core/src/org/jboss/tools/as/test/core/parametized/server/publishing/DeploymentAssemblyArchivePathVarWarTest.java
trunk/as/tests/org.jboss.tools.as.test.core/src/org/jboss/tools/as/test/core/parametized/server/publishing/PublishingSuite.java
trunk/as/tests/org.jboss.tools.as.test.core/src/org/jboss/tools/as/test/core/utiltests/ExpressionResolverUtilTest.java
Log:
JBIDE-12377 and JBIDE-12363 to trunk - much more to do
Modified: trunk/as/plugins/org.jboss.ide.eclipse.as.classpath.core/src/org/jboss/ide/eclipse/as/classpath/core/ejb3/EJB3ClasspathContainer.java
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.as.classpath.core/src/org/jboss/ide/eclipse/as/classpath/core/ejb3/EJB3ClasspathContainer.java 2012-07-27 05:31:58 UTC (rev 42750)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.classpath.core/src/org/jboss/ide/eclipse/as/classpath/core/ejb3/EJB3ClasspathContainer.java 2012-07-27 08:56:30 UTC (rev 42751)
@@ -58,8 +58,8 @@
this.path = path;
this.javaProject = project;
String configName = path.segment(1);
- IProject p = project.getProject();
- if( configName == null && p.exists() && p.isOpen())
+ IProject p = project == null ? null : project.getProject();
+ if( configName == null && p != null && p.exists() && p.isOpen())
configName = findLegacyConfigName(project);
IServer foundServer = findServer(configName);
jbossServer = ServerConverter.getJBossServer(foundServer);
Modified: trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/resolvers/ConfigNameResolver.java
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/resolvers/ConfigNameResolver.java 2012-07-27 05:31:58 UTC (rev 42750)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/resolvers/ConfigNameResolver.java 2012-07-27 08:56:30 UTC (rev 42751)
@@ -35,7 +35,12 @@
public static final String JBOSS_CONFIG = "jboss_config"; //$NON-NLS-1$
public static final String JBOSS_CONFIG_DIR = "jboss_config_dir"; //$NON-NLS-1$
public static final String JBOSS_AS7_CONFIG_FILE = "jboss_config_file"; //$NON-NLS-1$
+ public static final String[] ALL_VARIABLES = new String[] {
+ JBOSS_CONFIG, JBOSS_CONFIG_DIR, JBOSS_AS7_CONFIG_FILE
+ };
+
+
/*
* entry points to fill out the server name in these variable substitutions
*/
Modified: trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/UnitedServerListenerManager.java
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/UnitedServerListenerManager.java 2012-07-27 05:31:58 UTC (rev 42750)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/UnitedServerListenerManager.java 2012-07-27 08:56:30 UTC (rev 42751)
@@ -23,6 +23,7 @@
import org.eclipse.wst.server.core.IServerListener;
import org.eclipse.wst.server.core.ServerCore;
import org.eclipse.wst.server.core.ServerEvent;
+import org.jboss.ide.eclipse.as.core.util.ServerConverter;
/**
* The UnitedServerListenerManager keeps an array of
@@ -59,19 +60,9 @@
return (UnitedServerListener[]) list.toArray(new UnitedServerListener[list.size()]);
}
+ @Deprecated
public static boolean isJBossServer(IServer server) {
- if (server == null) {
- return false;
- }
- IRuntime rt = server.getRuntime();
- if (rt == null) {
- return false;
- }
- IJBossServerRuntime jbsrt = (IJBossServerRuntime)rt.loadAdapter(IJBossServerRuntime.class, new NullProgressMonitor());
- if (jbsrt == null) {
- return false;
- }
- return true;
+ return ServerConverter.getJBossServer(server) != null;
}
Modified: trunk/as/tests/org.jboss.tools.as.test.core/src/org/jboss/tools/as/test/core/MySuite.java
===================================================================
--- trunk/as/tests/org.jboss.tools.as.test.core/src/org/jboss/tools/as/test/core/MySuite.java 2012-07-27 05:31:58 UTC (rev 42750)
+++ trunk/as/tests/org.jboss.tools.as.test.core/src/org/jboss/tools/as/test/core/MySuite.java 2012-07-27 08:56:30 UTC (rev 42751)
@@ -1,13 +1,17 @@
package org.jboss.tools.as.test.core;
+import org.jboss.tools.as.test.core.classpath.ClasspathSuite;
import org.jboss.tools.as.test.core.parametized.server.ParametizedSuite;
+import org.jboss.tools.as.test.core.utiltests.UtilsSuite;
import org.junit.runner.RunWith;
import org.junit.runners.Suite;
import org.junit.runners.Suite.SuiteClasses;
@RunWith(Suite.class)
@SuiteClasses({
- ParametizedSuite.class
+ ParametizedSuite.class,
+ UtilsSuite.class,
+ ClasspathSuite.class
})
public class MySuite {
}
Modified: trunk/as/tests/org.jboss.tools.as.test.core/src/org/jboss/tools/as/test/core/internal/utils/ServerCreationTestUtils.java
===================================================================
--- trunk/as/tests/org.jboss.tools.as.test.core/src/org/jboss/tools/as/test/core/internal/utils/ServerCreationTestUtils.java 2012-07-27 05:31:58 UTC (rev 42750)
+++ trunk/as/tests/org.jboss.tools.as.test.core/src/org/jboss/tools/as/test/core/internal/utils/ServerCreationTestUtils.java 2012-07-27 08:56:30 UTC (rev 42751)
@@ -4,6 +4,8 @@
import java.io.IOException;
import java.util.HashMap;
+import junit.framework.Assert;
+
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.NullProgressMonitor;
@@ -30,7 +32,7 @@
* 2) Creating IServer objects out of either mock folders or legitimate installations
*
*/
-public class ServerCreationTestUtils {
+public class ServerCreationTestUtils extends Assert {
private static final IPath mockedServers = ASMatrixTests.getDefault().getStateLocation().append("mockedServers");
private static HashMap<String, String> asSystemJar = new HashMap<String, String>();
@@ -123,7 +125,10 @@
}
public static IServer createServerWithRuntime(String serverType, String name) throws CoreException {
+ if( serverType.equals(IJBossToolingConstants.DEPLOY_ONLY_SERVER))
+ return createDeployOnlyServer();
String loc = TestConstants.getServerHome(serverType);
+ assertNotNull("Runtime location for server type " + serverType + " not set in test suite", loc);
File locFile = new Path(loc).toFile();
return createServerWithRuntime(serverType, name, locFile);
}
Modified: trunk/as/tests/org.jboss.tools.as.test.core/src/org/jboss/tools/as/test/core/parametized/server/CreateRuntimeTwiceTest.java
===================================================================
--- trunk/as/tests/org.jboss.tools.as.test.core/src/org/jboss/tools/as/test/core/parametized/server/CreateRuntimeTwiceTest.java 2012-07-27 05:31:58 UTC (rev 42750)
+++ trunk/as/tests/org.jboss.tools.as.test.core/src/org/jboss/tools/as/test/core/parametized/server/CreateRuntimeTwiceTest.java 2012-07-27 08:56:30 UTC (rev 42751)
@@ -52,8 +52,8 @@
}
@Test
- private void createRuntimes(String serverTypeId) throws CoreException {
- IServerType type = ServerCore.findServerType(serverTypeId);
+ public void createRuntimes() throws CoreException {
+ IServerType type = ServerCore.findServerType(serverType);
IRuntimeType runtimeType = type.getRuntimeType();
IRuntimeWorkingCopy firstRuntime = runtimeType.createRuntime(null, new NullProgressMonitor());
@@ -62,7 +62,7 @@
IRuntimeWorkingCopy secondRuntime = runtimeType.createRuntime(null, new NullProgressMonitor());
IRuntime secondSavedRuntime = secondRuntime.save(true, new NullProgressMonitor());
- assertEquals(savedRuntime.getName(), secondSavedRuntime.getName());
+ assertNotSame(savedRuntime.getName(), secondSavedRuntime.getName());
assertNotSame(savedRuntime, secondSavedRuntime);
assertFalse("Why are two different runtimes " + runtimeType.getId() + " created with the same ID ?!", savedRuntime.getId().equals(secondSavedRuntime.getId()));
}
Modified: trunk/as/tests/org.jboss.tools.as.test.core/src/org/jboss/tools/as/test/core/parametized/server/CreateServerCheckDefaultsTest.java
===================================================================
--- trunk/as/tests/org.jboss.tools.as.test.core/src/org/jboss/tools/as/test/core/parametized/server/CreateServerCheckDefaultsTest.java 2012-07-27 05:31:58 UTC (rev 42750)
+++ trunk/as/tests/org.jboss.tools.as.test.core/src/org/jboss/tools/as/test/core/parametized/server/CreateServerCheckDefaultsTest.java 2012-07-27 08:56:30 UTC (rev 42751)
@@ -1,10 +1,14 @@
package org.jboss.tools.as.test.core.parametized.server;
import java.io.File;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.nio.charset.MalformedInputException;
import java.util.Collection;
import junit.framework.TestCase;
+import org.eclipse.core.runtime.Path;
import org.eclipse.wst.server.core.IRuntime;
import org.eclipse.wst.server.core.IServer;
import org.jboss.ide.eclipse.archives.webtools.filesets.Fileset;
@@ -12,9 +16,13 @@
import org.jboss.ide.eclipse.as.core.JBossServerCorePlugin;
import org.jboss.ide.eclipse.as.core.extensions.descriptors.XPathCategory;
import org.jboss.ide.eclipse.as.core.extensions.descriptors.XPathModel;
+import org.jboss.ide.eclipse.as.core.extensions.descriptors.XPathQuery;
import org.jboss.ide.eclipse.as.core.server.IJBossServerRuntime;
+import org.jboss.ide.eclipse.as.core.server.internal.ExtendedServerPropertiesAdapterFactory;
+import org.jboss.ide.eclipse.as.core.server.internal.extendedproperties.ServerExtendedProperties;
import org.jboss.ide.eclipse.as.core.server.internal.v7.LocalJBoss7ServerRuntime;
import org.jboss.ide.eclipse.as.core.util.IJBossToolingConstants;
+import org.jboss.ide.eclipse.as.core.util.RuntimeUtils;
import org.jboss.tools.as.test.core.internal.utils.ServerCreationTestUtils;
import org.jboss.tools.test.util.JobUtils;
import org.junit.After;
@@ -61,8 +69,14 @@
assertFalse("Server name should not be empty", server.getName() == null || "".equals(server.getName()));
assertFalse("Runtime name should not be empty", server.getRuntime().getName() == null || "".equals(server.getRuntime().getName()));
+ String typeId = server.getServerType().getId();
+ if( typeId.equals(IJBossToolingConstants.DEPLOY_ONLY_SERVER)) {
+ return;
+ }
+
+
IJBossServerRuntime rt = getJBossRuntime(server);
- assertNotNull("Created server does not adapt to IJBossServerRuntime", rt);
+ assertNotNull("Created server of type " + server.getServerType().getId() + " does not adapt to IJBossServerRuntime", rt);
assertNotNull(rt.getVM());
assertNotNull(rt.getExecutionEnvironment());
@@ -72,6 +86,20 @@
} else {
assertEquals("default", rt.getJBossConfiguration());
}
+
+ ServerExtendedProperties props = ExtendedServerPropertiesAdapterFactory.getServerExtendedProperties(server);
+ assertNotNull(props);
+ assertTrue(props.verifyServerStructure().isOK());
+ if( props.canVerifyRemoteModuleState())
+ assertNotNull(props.getModuleStateVerifier());
+ if( props.hasWelcomePage()) {
+ String s = props.getWelcomePageUrl();
+ try {
+ URL url = new URL(s);
+ } catch(MalformedURLException murle) {
+ fail(serverType + " has an invalid welcome page url: " + murle.getMessage());
+ }
+ }
}
@Test
@@ -79,8 +107,13 @@
JobUtils.waitForIdle();
IServer s = server;
XPathCategory[] cats = XPathModel.getDefault().getCategories(s);
+ String typeId = server.getServerType().getId();
+ if( typeId.equals(IJBossToolingConstants.DEPLOY_ONLY_SERVER)) {
+ assertTrue("Deploy-only Servers should have no default xpaths.", cats == null || cats.length == 0);
+ return;
+ }
assertFalse("Server has no xpath categories automatically added", cats == null || cats.length == 0);
- assertNotNull("Server has no 'ports' xpath category. ", XPathModel.getDefault().getCategory(s, "Ports"));
+ assertNotNull("Server has no 'ports' xpath category. ", XPathModel.getDefault().getCategory(s, XPathModel.PORTS_CATEGORY_NAME));
File xpathFile = JBossServerCorePlugin.getServerStateLocation(s).append(IJBossToolingConstants.XPATH_FILE_NAME).toFile();
try {
assertTrue("The XPath File has not been created. Xpaths will be lost on workspace restart. " + xpathFile.getAbsolutePath(), xpathFile.exists());
@@ -88,17 +121,40 @@
t.printStackTrace();
throw t;
}
+
+ // Take this chance to test some xpath model
+ // Can maybe be moved out to their own test
+ assertNull(XPathModel.getDefault().getQuery(null, null));
+ assertNull(XPathModel.getDefault().getQuery(s, null));
+ assertNull(XPathModel.getDefault().getQuery(s, new Path(XPathModel.PORTS_CATEGORY_NAME)));
+ XPathCategory cat = XPathModel.getDefault().getCategory(s, XPathModel.PORTS_CATEGORY_NAME);
+ XPathQuery[] qs = cat.getQueries();
+ assertFalse(qs == null || qs.length == 0);
+ String name = qs[0].getName();
+ assertNotNull(name);
+ XPathQuery q = XPathModel.getDefault().getQuery(s, new Path(XPathModel.PORTS_CATEGORY_NAME).append(name));
+ assertNotNull(q);
+ q = XPathModel.getDefault().getQuery(s, new Path("GaRbAgE").append(name));
+ assertNull(q);
+ assertTrue(XPathModel.getDefault().containsCategory(s, XPathModel.PORTS_CATEGORY_NAME));
+ assertFalse(XPathModel.getDefault().containsCategory(s, "GaRbAgE"));
}
@Test
public void testDefaultFilesetsAdded() {
Fileset[] fs = FilesetUtil.loadFilesets(server);
+ String typeId = server.getServerType().getId();
+ if( typeId.equals(IJBossToolingConstants.DEPLOY_ONLY_SERVER)) {
+ assertTrue("Deploy-only Servers should have no default filesets.",
+ fs == null || fs.length == 0);
+ return;
+ }
+
assertNotNull("No filesets created", fs);
assertTrue("0 filesets added for server " + server.getName(), fs.length > 0);
}
private IJBossServerRuntime getJBossRuntime(IServer s) {
- IRuntime rt = s.getRuntime();
- return (IJBossServerRuntime) rt.loadAdapter(IJBossServerRuntime.class, null);
+ return RuntimeUtils.getJBossServerRuntime(s.getRuntime());
}
}
Modified: trunk/as/tests/org.jboss.tools.as.test.core/src/org/jboss/tools/as/test/core/parametized/server/ParametizedSuite.java
===================================================================
--- trunk/as/tests/org.jboss.tools.as.test.core/src/org/jboss/tools/as/test/core/parametized/server/ParametizedSuite.java 2012-07-27 05:31:58 UTC (rev 42750)
+++ trunk/as/tests/org.jboss.tools.as.test.core/src/org/jboss/tools/as/test/core/parametized/server/ParametizedSuite.java 2012-07-27 08:56:30 UTC (rev 42751)
@@ -7,11 +7,11 @@
@RunWith(Suite.class)
@SuiteClasses({
-// ServerHomeTest.class,
-// ServerBeanLoader3Test.class,
-// CreateServerCheckDefaultsTest.class,
-// ProjectRuntimeClasspathTest.class,
-// CreateRuntimeTwiceTest.class,
+ ServerHomeTest.class,
+ ServerBeanLoader3Test.class,
+ CreateServerCheckDefaultsTest.class,
+ ProjectRuntimeClasspathTest.class,
+ CreateRuntimeTwiceTest.class,
PublishingSuite.class
})
public class ParametizedSuite {
Modified: trunk/as/tests/org.jboss.tools.as.test.core/src/org/jboss/tools/as/test/core/parametized/server/publishing/AbstractComponentPublishingTest.java
===================================================================
--- trunk/as/tests/org.jboss.tools.as.test.core/src/org/jboss/tools/as/test/core/parametized/server/publishing/AbstractComponentPublishingTest.java 2012-07-27 05:31:58 UTC (rev 42750)
+++ trunk/as/tests/org.jboss.tools.as.test.core/src/org/jboss/tools/as/test/core/parametized/server/publishing/AbstractComponentPublishingTest.java 2012-07-27 08:56:30 UTC (rev 42751)
@@ -12,10 +12,21 @@
public class AbstractComponentPublishingTest extends AbstractPublishingTest {
public static Collection<Object[]> componentJarData() {
+ return componentJarData(false);
+ }
+ public static Collection<Object[]> fullComponentJarData() {
+ return componentJarData(true);
+ }
+ public static Collection<Object[]> componentJarData(boolean complete) {
Object[] servers = ServerParameterUtils.getPublishServerTypes();
Object[] zipOption = ServerParameterUtils.getServerZipOptions();
Object[] defaultDeployLoc = ServerParameterUtils.getDefaultDeployOptions();
Object[] perModOverrides = ServerParameterUtils.getPerModuleOverrideOptions();
+ if( !complete ) {
+ // simplify these options
+ defaultDeployLoc = new Object[]{defaultDeployLoc[0]};
+ perModOverrides = new Object[]{perModOverrides[0]};
+ }
Object[] junitName = new String[] { "junit.jar", "otherOut.jar"};
Object[] outFolder = new String[] { "lib", "otherFolder", "deep/nested", ""};
Object[][] allOptions = new Object[][] {
@@ -24,6 +35,7 @@
};
return MatrixUtils.toMatrix(allOptions);
}
+
protected String jarFolder;
protected String jarName;
Modified: trunk/as/tests/org.jboss.tools.as.test.core/src/org/jboss/tools/as/test/core/parametized/server/publishing/DeploymentAssemblyArchivePathVarNestedWarTest.java
===================================================================
--- trunk/as/tests/org.jboss.tools.as.test.core/src/org/jboss/tools/as/test/core/parametized/server/publishing/DeploymentAssemblyArchivePathVarNestedWarTest.java 2012-07-27 05:31:58 UTC (rev 42750)
+++ trunk/as/tests/org.jboss.tools.as.test.core/src/org/jboss/tools/as/test/core/parametized/server/publishing/DeploymentAssemblyArchivePathVarNestedWarTest.java 2012-07-27 08:56:30 UTC (rev 42751)
@@ -11,6 +11,7 @@
package org.jboss.tools.as.test.core.parametized.server.publishing;
import java.util.ArrayList;
+import java.util.Collection;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.IPath;
@@ -27,12 +28,17 @@
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
+import org.junit.runners.Parameterized.Parameters;
@RunWith(value = Parameterized.class)
public class DeploymentAssemblyArchivePathVarNestedWarTest extends DeploymentAssemblyArchivePathVarTest {
private static String PROJECT_PREFIX = "qEar";
private static String PROJECT_NESTED_PREFIX = "qWar";
private static int PROJECT_ID = 1;
+ @Parameters
+ public static Collection<Object[]> params() {
+ return componentJarData();
+ }
public DeploymentAssemblyArchivePathVarNestedWarTest(String serverType, String zip,
String deployLoc, String perMod, String refName, String refFolder) {
super(serverType, zip, deployLoc, perMod, refName, refFolder);
Modified: trunk/as/tests/org.jboss.tools.as.test.core/src/org/jboss/tools/as/test/core/parametized/server/publishing/DeploymentAssemblyArchivePathVarTest.java
===================================================================
--- trunk/as/tests/org.jboss.tools.as.test.core/src/org/jboss/tools/as/test/core/parametized/server/publishing/DeploymentAssemblyArchivePathVarTest.java 2012-07-27 05:31:58 UTC (rev 42750)
+++ trunk/as/tests/org.jboss.tools.as.test.core/src/org/jboss/tools/as/test/core/parametized/server/publishing/DeploymentAssemblyArchivePathVarTest.java 2012-07-27 08:56:30 UTC (rev 42751)
@@ -44,7 +44,7 @@
private static int PROJECT_ID = 1;
@Parameters
public static Collection<Object[]> params() {
- return componentJarData();
+ return fullComponentJarData();
}
public DeploymentAssemblyArchivePathVarTest(String serverType, String zip,
String deployLoc, String perMod, String refName, String refFolder) {
Modified: trunk/as/tests/org.jboss.tools.as.test.core/src/org/jboss/tools/as/test/core/parametized/server/publishing/DeploymentAssemblyArchivePathVarWarTest.java
===================================================================
--- trunk/as/tests/org.jboss.tools.as.test.core/src/org/jboss/tools/as/test/core/parametized/server/publishing/DeploymentAssemblyArchivePathVarWarTest.java 2012-07-27 05:31:58 UTC (rev 42750)
+++ trunk/as/tests/org.jboss.tools.as.test.core/src/org/jboss/tools/as/test/core/parametized/server/publishing/DeploymentAssemblyArchivePathVarWarTest.java 2012-07-27 08:56:30 UTC (rev 42751)
@@ -10,6 +10,8 @@
******************************************************************************/
package org.jboss.tools.as.test.core.parametized.server.publishing;
+import java.util.Collection;
+
import org.eclipse.wst.common.componentcore.internal.operation.AddReferenceDataModelProvider;
import org.eclipse.wst.common.frameworks.datamodel.IDataModel;
import org.eclipse.wst.common.frameworks.datamodel.IDataModelProvider;
@@ -17,11 +19,17 @@
import org.jboss.tools.as.test.core.internal.utils.wtp.JavaEEFacetConstants;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
+import org.junit.runners.Parameterized.Parameters;
@RunWith(value = Parameterized.class)
public class DeploymentAssemblyArchivePathVarWarTest extends DeploymentAssemblyArchivePathVarTest {
private static String PROJECT_PREFIX = "pWar";
private static int PROJECT_ID = 1;
+ @Parameters
+ public static Collection<Object[]> params() {
+ return componentJarData();
+ }
+
public DeploymentAssemblyArchivePathVarWarTest(String serverType, String zip,
String deployLoc, String perMod, String refName, String refFolder) {
super(serverType, zip, deployLoc, perMod, refName, refFolder);
Modified: trunk/as/tests/org.jboss.tools.as.test.core/src/org/jboss/tools/as/test/core/parametized/server/publishing/PublishingSuite.java
===================================================================
--- trunk/as/tests/org.jboss.tools.as.test.core/src/org/jboss/tools/as/test/core/parametized/server/publishing/PublishingSuite.java 2012-07-27 05:31:58 UTC (rev 42750)
+++ trunk/as/tests/org.jboss.tools.as.test.core/src/org/jboss/tools/as/test/core/parametized/server/publishing/PublishingSuite.java 2012-07-27 08:56:30 UTC (rev 42751)
@@ -1,24 +1,25 @@
package org.jboss.tools.as.test.core.parametized.server.publishing;
+import org.jboss.tools.as.test.core.parametized.server.publishing.defect.RepublishDefectTest;
import org.junit.runner.RunWith;
import org.junit.runners.Suite;
import org.junit.runners.Suite.SuiteClasses;
@RunWith(Suite.class)
@SuiteClasses({
-// DeploymentAssemblyArchivePathVarTest.class,
-// DeploymentAssemblyArchivePathVarWarTest.class,
-// DeploymentAssemblyArchivePathVarNestedWarTest.class,
-// DeploymentAssemblyExternalArchiveVarTest.class,
-// DeploymentAssemblyExternalArchiveVarWarTest.class,
-// DeploymentAssemblyExternalArchiveVarNestedWarTest.class,
-// DeploymentAssemblyWorkspaceArchiveVarTest.class,
-// DeploymentAssemblyWorkspaceArchiveVarWarTest.class,
-// DeploymentAssemblyWorkspaceArchiveVarNestedWarTest.class,
+ DeploymentAssemblyArchivePathVarTest.class,
+ DeploymentAssemblyArchivePathVarWarTest.class,
+ DeploymentAssemblyArchivePathVarNestedWarTest.class,
+ DeploymentAssemblyExternalArchiveVarTest.class,
+ DeploymentAssemblyExternalArchiveVarWarTest.class,
+ DeploymentAssemblyExternalArchiveVarNestedWarTest.class,
+ DeploymentAssemblyWorkspaceArchiveVarTest.class,
+ DeploymentAssemblyWorkspaceArchiveVarWarTest.class,
+ DeploymentAssemblyWorkspaceArchiveVarNestedWarTest.class,
DeploymentAssemblyFilesetReferenceTest.class,
-// RepublishDefectTest.class,
-// SingleDeployableFileTest.class,
-// SingleDeployableFolderTest.class
+ RepublishDefectTest.class,
+ SingleDeployableFileTest.class,
+ SingleDeployableFolderTest.class
})
public class PublishingSuite {
}
Modified: trunk/as/tests/org.jboss.tools.as.test.core/src/org/jboss/tools/as/test/core/utiltests/ExpressionResolverUtilTest.java
===================================================================
--- trunk/as/tests/org.jboss.tools.as.test.core/src/org/jboss/tools/as/test/core/utiltests/ExpressionResolverUtilTest.java 2012-07-27 05:31:58 UTC (rev 42750)
+++ trunk/as/tests/org.jboss.tools.as.test.core/src/org/jboss/tools/as/test/core/utiltests/ExpressionResolverUtilTest.java 2012-07-27 08:56:30 UTC (rev 42751)
@@ -1,20 +1,30 @@
package org.jboss.tools.as.test.core.utiltests;
+import junit.framework.TestCase;
+
import org.jboss.ide.eclipse.as.core.util.ExpressionResolverUtil;
+import org.junit.Test;
-import junit.framework.TestCase;
-
public class ExpressionResolverUtilTest extends TestCase {
+ @Test
public void testExpressionResolver() {
- assertEquals("aaa", ExpressionResolverUtil.safeReplaceProperties("aaa"));
- assertEquals("t9", ExpressionResolverUtil.safeReplaceProperties("t${something:9}"));
- assertEquals("t9a", ExpressionResolverUtil.safeReplaceProperties("t${something:9}a"));
+ assertEquals("aaa", re("aaa"));
+ assertEquals("t9", re("t${something:9}"));
+ assertEquals("t9a", re("t${something:9}a"));
// NO recursive checking
- assertEquals("5:notfound}", ExpressionResolverUtil.safeReplaceProperties("${twoPoint${someNumber:5}:notfound}"));
+ assertEquals("5:notfound}", re("${twoPoint${someNumber:5}:notfound}"));
// unresolvable, so no change
- assertEquals("t${something}", ExpressionResolverUtil.safeReplaceProperties("t${something}"));
- assertEquals("t${something}a", ExpressionResolverUtil.safeReplaceProperties("t${something}a"));
+ assertEquals("t${something}", re("t${something}"));
+ assertEquals("t${something}a", re("t${something}a"));
+ assertEquals("t$ablah", re("t$ablah"));
+
+ // custom handling
+ assertEquals("t$stuff", re("t$$stuff"));
}
+
+ private String re(String s) {
+ return ExpressionResolverUtil.safeReplaceProperties(s);
+ }
}
11 years, 9 months
JBoss Tools SVN: r42750 - trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/extensions/descriptors.
by jbosstools-commits@lists.jboss.org
Author: rob.stryker(a)jboss.com
Date: 2012-07-27 01:31:58 -0400 (Fri, 27 Jul 2012)
New Revision: 42750
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/extensions/descriptors/XPathModel.java
Log:
JBIDE-12377 add null check for unit tests
Modified: trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/extensions/descriptors/XPathModel.java
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/extensions/descriptors/XPathModel.java 2012-07-27 05:30:39 UTC (rev 42749)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/extensions/descriptors/XPathModel.java 2012-07-27 05:31:58 UTC (rev 42750)
@@ -101,6 +101,8 @@
public XPathQuery getQuery(IServer server, IPath path) {
+ if( server == null || path == null || path.segmentCount() != 2)
+ return null;
XPathCategory cat = getCategory(server, path.segment(0));
if( cat != null )
return cat.getQuery(path.segment(1));
11 years, 9 months
JBoss Tools SVN: r42749 - trunk/as/plugins/org.jboss.ide.eclipse.as.classpath.core/src/org/jboss/ide/eclipse/as/classpath/core/ejb3.
by jbosstools-commits@lists.jboss.org
Author: rob.stryker(a)jboss.com
Date: 2012-07-27 01:30:39 -0400 (Fri, 27 Jul 2012)
New Revision: 42749
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.classpath.core/src/org/jboss/ide/eclipse/as/classpath/core/ejb3/EJB30SupportVerifier.java
trunk/as/plugins/org.jboss.ide.eclipse.as.classpath.core/src/org/jboss/ide/eclipse/as/classpath/core/ejb3/EJB3ClasspathContainer.java
Log:
JBIDE-12377 code cleanup
Modified: trunk/as/plugins/org.jboss.ide.eclipse.as.classpath.core/src/org/jboss/ide/eclipse/as/classpath/core/ejb3/EJB30SupportVerifier.java
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.as.classpath.core/src/org/jboss/ide/eclipse/as/classpath/core/ejb3/EJB30SupportVerifier.java 2012-07-27 04:45:58 UTC (rev 42748)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.classpath.core/src/org/jboss/ide/eclipse/as/classpath/core/ejb3/EJB30SupportVerifier.java 2012-07-27 05:30:39 UTC (rev 42749)
@@ -33,6 +33,8 @@
}
public static boolean verify(IRuntime rt) {
+ if( rt == null ) // deploy only server protection
+ return false;
IJBossServerRuntime jbRuntime = (IJBossServerRuntime)rt.loadAdapter(IJBossServerRuntime.class, null);
if( jbRuntime == null )
return false;
Modified: trunk/as/plugins/org.jboss.ide.eclipse.as.classpath.core/src/org/jboss/ide/eclipse/as/classpath/core/ejb3/EJB3ClasspathContainer.java
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.as.classpath.core/src/org/jboss/ide/eclipse/as/classpath/core/ejb3/EJB3ClasspathContainer.java 2012-07-27 04:45:58 UTC (rev 42748)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.classpath.core/src/org/jboss/ide/eclipse/as/classpath/core/ejb3/EJB3ClasspathContainer.java 2012-07-27 05:30:39 UTC (rev 42749)
@@ -32,6 +32,7 @@
import org.jboss.ide.eclipse.as.classpath.core.Messages;
import org.jboss.ide.eclipse.as.core.server.IJBossServerConstants;
import org.jboss.ide.eclipse.as.core.server.internal.JBossServer;
+import org.jboss.ide.eclipse.as.core.util.ServerConverter;
/**
* @author Marshall
@@ -57,39 +58,50 @@
this.path = path;
this.javaProject = project;
String configName = path.segment(1);
- IServer servers[] = ServerCore.getServers();
IProject p = project.getProject();
- if( p.exists() && p.isOpen() /* && Deprecated : p.isLocal(IResource.DEPTH_INFINITE)*/) {
- try {
- if (configName == null) {
- // old classpath container, try finding the persisten property
- configName = project.getProject().getPersistentProperty(JBOSS_EJB3_CONFIGURATION);
- if (configName != null) {
- // go ahead and remove the persistent property
- project.getProject().setPersistentProperty(JBOSS_EJB3_CONFIGURATION, null);
- }
- }
- } catch( CoreException ce ) {
- // This should never occur. If it does, it regards legacy situations.
- // The project is opened and accessible. There are no reasons for this
- // to ever occur.
+ if( configName == null && p.exists() && p.isOpen())
+ configName = findLegacyConfigName(project);
+ IServer foundServer = findServer(configName);
+ jbossServer = ServerConverter.getJBossServer(foundServer);
+ if( jbossServer != null ) {
+ try {
+ homePath = jbossServer.getServer().getRuntime().getLocation();
+ configPath = new Path(jbossServer.getConfigDirectory());
+ } catch( Exception e ) {
+ IStatus status = new Status(IStatus.ERROR, ClasspathCorePlugin.PLUGIN_ID,Messages.EJB3ClasspathContainer_could_not_determine_home, e);
+ ClasspathCorePlugin.getDefault().getLog().log(status);
+ }
+ }
+ }
+
+ private String findLegacyConfigName(IJavaProject project) {
+ if( project == null )
+ return null;
+ String configName = null;
+ try {
+ // old classpath container, try finding the persisten property
+ configName = project.getProject().getPersistentProperty(JBOSS_EJB3_CONFIGURATION);
+ if (configName != null) {
+ // go ahead and remove the persistent property
+ project.getProject().setPersistentProperty(JBOSS_EJB3_CONFIGURATION, null);
+ }
+ } catch( CoreException ce ) {
+ // This should never occur. If it does, it regards legacy situations.
+ // The project is opened and accessible. There are no reasons for this
+ // to ever occur.
+ }
+ return configName;
+ }
+ private IServer findServer(String serverName) {
+ IServer[] servers = ServerCore.getServers();
+ for (int i = 0; i < servers.length; i++) {
+ if (servers[i].getName().equals(serverName)) {
+ return servers[i];
}
- }
- for (int i = 0; i < servers.length; i++) {
- if (servers[i].getName().equals(configName)) {
- jbossServer = (JBossServer) servers[i].loadAdapter(JBossServer.class, new NullProgressMonitor());
- try {
- homePath = jbossServer.getServer().getRuntime().getLocation();
- configPath = new Path(jbossServer.getConfigDirectory());
- } catch( Exception e ) {
- IStatus status = new Status(IStatus.ERROR, ClasspathCorePlugin.PLUGIN_ID,Messages.EJB3ClasspathContainer_could_not_determine_home, e);
- ClasspathCorePlugin.getDefault().getLog().log(status);
- }
- break;
- }
- }
+ }
+ return null;
}
-
+
public String getDescription() {
return Messages.EJB3ClasspathContainer_ejb30_description;
}
@@ -111,14 +123,16 @@
}
public IClasspathEntry[] getClasspathEntries() {
- try {
- String id = jbossServer.getServer().getServerType().getRuntimeType().getId();
- if( id.equals(AS_40)) return get40Jars(homePath, configPath);
- if( id.equals(AS_42)) return get42Jars(homePath, configPath);
- if( id.equals(AS_50)) return get50Jars(homePath, configPath);
- if( id.equals(AS_51)) return get51Jars(homePath, configPath);
- if( id.equals(AS_60)) return get60Jars(homePath, configPath);
- } catch( FileNotFoundException fnfe ) {}
+ if( jbossServer != null ) {
+ try {
+ String id = jbossServer.getServer().getServerType().getRuntimeType().getId();
+ if( id.equals(AS_40)) return get40Jars(homePath, configPath);
+ if( id.equals(AS_42)) return get42Jars(homePath, configPath);
+ if( id.equals(AS_50)) return get50Jars(homePath, configPath);
+ if( id.equals(AS_51)) return get51Jars(homePath, configPath);
+ if( id.equals(AS_60)) return get60Jars(homePath, configPath);
+ } catch( FileNotFoundException fnfe ) {}
+ }
return new IClasspathEntry[]{};
}
11 years, 9 months
JBoss Tools SVN: r42748 - trunk/as/plugins/org.jboss.ide.eclipse.as.classpath.core/src/org/jboss/ide/eclipse/as/classpath/core/runtime.
by jbosstools-commits@lists.jboss.org
Author: rob.stryker(a)jboss.com
Date: 2012-07-27 00:45:58 -0400 (Fri, 27 Jul 2012)
New Revision: 42748
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.classpath.core/src/org/jboss/ide/eclipse/as/classpath/core/runtime/RuntimeKey.java
Log:
JBIDE-12377 unused internal code removed. A usage scan on all of jbt reveals these methods (getter/setter) are unused. The RuntimeKey is used only for .equals and hashcode methods to ensure a unique RuntimeKey
Modified: trunk/as/plugins/org.jboss.ide.eclipse.as.classpath.core/src/org/jboss/ide/eclipse/as/classpath/core/runtime/RuntimeKey.java
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.as.classpath.core/src/org/jboss/ide/eclipse/as/classpath/core/runtime/RuntimeKey.java 2012-07-27 04:41:22 UTC (rev 42747)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.classpath.core/src/org/jboss/ide/eclipse/as/classpath/core/runtime/RuntimeKey.java 2012-07-27 04:45:58 UTC (rev 42748)
@@ -23,30 +23,6 @@
this.id = id;
}
- public IPath getLocation() {
- return location;
- }
-
- public void setLocation(IPath location) {
- this.location = location;
- }
-
- public IPath getConfigPath() {
- return configPath;
- }
-
- public void setConfigPath(IPath configPath) {
- this.configPath = configPath;
- }
-
- public String getId() {
- return id;
- }
-
- public void setId(String id) {
- this.id = id;
- }
-
@Override
public int hashCode() {
final int prime = 31;
11 years, 9 months
JBoss Tools SVN: r42747 - trunk/as/plugins/org.jboss.ide.eclipse.as.classpath.core/src/org/jboss/ide/eclipse/as/classpath/core/runtime.
by jbosstools-commits@lists.jboss.org
Author: rob.stryker(a)jboss.com
Date: 2012-07-27 00:41:22 -0400 (Fri, 27 Jul 2012)
New Revision: 42747
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.classpath.core/src/org/jboss/ide/eclipse/as/classpath/core/runtime/ClientAllRuntimeClasspathProvider.java
Log:
JBIDE-12377 unused internal code removed
Modified: trunk/as/plugins/org.jboss.ide.eclipse.as.classpath.core/src/org/jboss/ide/eclipse/as/classpath/core/runtime/ClientAllRuntimeClasspathProvider.java
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.as.classpath.core/src/org/jboss/ide/eclipse/as/classpath/core/runtime/ClientAllRuntimeClasspathProvider.java 2012-07-26 23:56:51 UTC (rev 42746)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.classpath.core/src/org/jboss/ide/eclipse/as/classpath/core/runtime/ClientAllRuntimeClasspathProvider.java 2012-07-27 04:41:22 UTC (rev 42747)
@@ -139,52 +139,7 @@
protected IClasspathEntry getEntry(Entry entry) {
return JavaRuntime.newArchiveRuntimeClasspathEntry(entry.getPath()).getClasspathEntry();
}
-
- protected void addPaths(IPath folder, Set<Entry> list) {
- addPaths(folder, list, false);
- }
- protected class SimpleFileFilter implements FileFilter {
- private List<String> ignore;
- public SimpleFileFilter(String[] ignore) {
- this.ignore = Arrays.asList(ignore);
- }
- public boolean accept(File pathname) {
- if( !pathname.getName().endsWith(EXT_JAR)) return false;
- boolean contains = ignore.contains(pathname.getName());
- return !contains;
- }
- }
-
- protected void addPaths(IPath folder, Set<Entry> list, boolean recurse) {
- addPaths(folder, list, recurse, new SimpleFileFilter(new String[]{"jaxb-xjc.jar"})); //$NON-NLS-1$
- }
-
- protected void addPaths(IPath folder, Set<Entry> list, boolean recurse, FileFilter filter) {
- if( folder.toFile().exists()) {
- File f = folder.toFile();
- if(f.isDirectory()) {
- File[] asFiles = f.listFiles();
- for( int i = 0; i < asFiles.length; i++ ) {
- if( filter == null || filter.accept(folder.append(asFiles[i].getName()).toFile())) {
- addSinglePath(folder.append(asFiles[i].getName()), list);
- } else if( recurse && asFiles[i].isDirectory()) {
- addPaths(folder.append(asFiles[i].getName()), list, true, filter);
- }
- }
- } else { // item is a file, not a folder
- if( filter == null || filter.accept(folder.toFile()))
- addSinglePath(folder, list);
- }
- }
- }
-
- protected void addSinglePath(IPath p, Set<Entry> list) {
- if (!p.toFile().exists()) {
- return;
- }
- list.add(new Entry(p, p.lastSegment(), p.toFile().length()));
- }
protected void addSinglePath(IPath p, ArrayList<Entry> list) {
if (!p.toFile().exists()) {
return;
11 years, 9 months
JBoss Tools SVN: r42746 - trunk/jst/plugins/org.jboss.tools.jst.web.ui/src/org/jboss/tools/jst/web/ui/action.
by jbosstools-commits@lists.jboss.org
Author: dazarov
Date: 2012-07-26 19:56:51 -0400 (Thu, 26 Jul 2012)
New Revision: 42746
Modified:
trunk/jst/plugins/org.jboss.tools.jst.web.ui/src/org/jboss/tools/jst/web/ui/action/JSPProblemMarkerResolutionGenerator.java
Log:
Make Quick Fix "Add tag library definition" work with KB Model instead of using plain tag library list https://issues.jboss.org/browse/JBIDE-12304
Modified: trunk/jst/plugins/org.jboss.tools.jst.web.ui/src/org/jboss/tools/jst/web/ui/action/JSPProblemMarkerResolutionGenerator.java
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.web.ui/src/org/jboss/tools/jst/web/ui/action/JSPProblemMarkerResolutionGenerator.java 2012-07-26 23:17:26 UTC (rev 42745)
+++ trunk/jst/plugins/org.jboss.tools.jst.web.ui/src/org/jboss/tools/jst/web/ui/action/JSPProblemMarkerResolutionGenerator.java 2012-07-26 23:56:51 UTC (rev 42746)
@@ -99,6 +99,10 @@
if(prefix == null)
return new IJavaCompletionProposal[]{};
+ String tagName = getTagName(message);
+ if(tagName == null)
+ return new IJavaCompletionProposal[]{};
+
IFile file = MarkerResolutionUtils.getFile();
if(file == null)
return new IJavaCompletionProposal[]{};
@@ -126,22 +130,24 @@
ITagLibrary[] libraries = kbProject.getTagLibraries();
ArrayList<String> names = new ArrayList<String>();
+ boolean worked = false;
for(ITagLibrary l : libraries){
if(l instanceof TLDLibrary){
((TLDLibrary) l).createDefaultNameSpace();
}
INameSpace ns = l.getDefaultNameSpace();
if(ns != null && ns.getPrefix() != null && ns.getPrefix().equals(prefix)){
+ worked = true;
String uri = ns.getURI();
String resolutionName = getResolutionName(xmlDocument != null && xmlDocument.isXMLType(), true, prefix, uri);
- if(resolutionName != null && !names.contains(resolutionName)){
+ if(resolutionName != null && !names.contains(resolutionName) && l.getComponent(tagName) != null){
proposals.add(new AddTLDMarkerResolution(resolutionName, start, end, uri, prefix));
names.add(resolutionName);
}
}
}
- if(proposals.size() == 0 && libs.containsKey(prefix)){
+ if(proposals.size() == 0 && libs.containsKey(prefix) && !worked){
String uri = libs.get(prefix);
String resolutionName = getResolutionName(xmlDocument != null && xmlDocument.isXMLType(), true, prefix, uri);
if(resolutionName != null){
@@ -183,6 +189,10 @@
if(prefix == null)
return new IMarkerResolution[]{};
+ String tagName = getTagName(message);
+ if(tagName == null)
+ return new IMarkerResolution[]{};
+
IFile file = (IFile)marker.getResource();
ELContext context = PageContextFactory.createPageContext(file);
@@ -203,22 +213,24 @@
ITagLibrary[] libraries = kbProject.getTagLibraries();
ArrayList<String> names = new ArrayList<String>();
+ boolean worked = false;
for(ITagLibrary l : libraries){
if(l instanceof TLDLibrary){
((TLDLibrary) l).createDefaultNameSpace();
}
INameSpace ns = l.getDefaultNameSpace();
if(ns != null && ns.getPrefix() != null && ns.getPrefix().equals(prefix)){
+ worked = true;
String uri = ns.getURI();
String resolutionName = getResolutionName(marker.getType().equals(HTML_VALIDATOR_MARKER) || marker.isSubtypeOf(HTML_VALIDATOR_MARKER), marker.getType().equals(JSP_VALIDATOR_MARKER) || marker.isSubtypeOf(JSP_VALIDATOR_MARKER), prefix, uri);
- if(resolutionName != null && !names.contains(resolutionName)){
+ if(resolutionName != null && !names.contains(resolutionName) && l.getComponent(tagName) != null){
resolutions.add(new AddTLDMarkerResolution(file, resolutionName, start, end, uri, prefix));
names.add(resolutionName);
}
}
}
- if(resolutions.size() == 0 && libs.containsKey(prefix)){
+ if(resolutions.size() == 0 && libs.containsKey(prefix) && !worked){
String uri = libs.get(prefix);
String resolutionName = getResolutionName(marker.getType().equals(HTML_VALIDATOR_MARKER) || marker.isSubtypeOf(HTML_VALIDATOR_MARKER), marker.getType().equals(JSP_VALIDATOR_MARKER) || marker.isSubtypeOf(JSP_VALIDATOR_MARKER), prefix, uri);
if(resolutionName != null){
@@ -244,6 +256,22 @@
return prefix;
}
+ public static String getTagName(String message){
+ String tagName=""; //$NON-NLS-1$
+
+ int start = message.indexOf(":"); //$NON-NLS-1$
+ if(start < 0)
+ return null;
+
+ int end = message.indexOf(")", start); //$NON-NLS-1$
+ if(end < 0)
+ return null;
+
+ tagName = message.substring(start+1, end);
+
+ return tagName;
+ }
+
@Override
public boolean hasResolutions(IMarker marker) {
try{
11 years, 9 months
JBoss Tools SVN: r42745 - trunk/jst/plugins/org.jboss.tools.jst.web.ui/src/org/jboss/tools/jst/web/ui/action.
by jbosstools-commits@lists.jboss.org
Author: dazarov
Date: 2012-07-26 19:17:26 -0400 (Thu, 26 Jul 2012)
New Revision: 42745
Modified:
trunk/jst/plugins/org.jboss.tools.jst.web.ui/src/org/jboss/tools/jst/web/ui/action/JSPProblemMarkerResolutionGenerator.java
Log:
Make Quick Fix "Add tag library definition" work with KB Model instead of using plain tag library list https://issues.jboss.org/browse/JBIDE-12304
Modified: trunk/jst/plugins/org.jboss.tools.jst.web.ui/src/org/jboss/tools/jst/web/ui/action/JSPProblemMarkerResolutionGenerator.java
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.web.ui/src/org/jboss/tools/jst/web/ui/action/JSPProblemMarkerResolutionGenerator.java 2012-07-26 22:27:16 UTC (rev 42744)
+++ trunk/jst/plugins/org.jboss.tools.jst.web.ui/src/org/jboss/tools/jst/web/ui/action/JSPProblemMarkerResolutionGenerator.java 2012-07-26 23:17:26 UTC (rev 42745)
@@ -12,6 +12,9 @@
import java.util.ArrayList;
import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IMarker;
@@ -27,10 +30,13 @@
import org.eclipse.wst.sse.ui.internal.reconcile.TemporaryAnnotation;
import org.eclipse.wst.xml.core.internal.provisional.document.IDOMDocument;
import org.eclipse.wst.xml.core.internal.provisional.document.IDOMModel;
+import org.jboss.tools.common.el.core.resolver.ELContext;
import org.jboss.tools.common.quickfix.IQuickFixGenerator;
import org.jboss.tools.common.refactoring.MarkerResolutionUtils;
import org.jboss.tools.jst.web.kb.IKbProject;
import org.jboss.tools.jst.web.kb.KbProjectFactory;
+import org.jboss.tools.jst.web.kb.PageContextFactory;
+import org.jboss.tools.jst.web.kb.internal.XmlContextImpl;
import org.jboss.tools.jst.web.kb.internal.taglib.TLDLibrary;
import org.jboss.tools.jst.web.kb.taglib.INameSpace;
import org.jboss.tools.jst.web.kb.taglib.ITagLibrary;
@@ -93,15 +99,29 @@
if(prefix == null)
return new IJavaCompletionProposal[]{};
+ IFile file = MarkerResolutionUtils.getFile();
+ if(file == null)
+ return new IJavaCompletionProposal[]{};
+
+ ELContext context = PageContextFactory.createPageContext(file);
+ if(context instanceof XmlContextImpl){
+ Map<String, List<INameSpace>> nameSpaces = ((XmlContextImpl) context).getNameSpaces(start);
+ Iterator<List<INameSpace>> iterator = nameSpaces.values().iterator();
+ while(iterator.hasNext()){
+ List<INameSpace> list = iterator.next();
+ for(INameSpace ns : list){
+ if(prefix.equals(ns.getPrefix())){
+ return new IJavaCompletionProposal[]{};
+ }
+ }
+ }
+ }
+
Object additionalInfo = ta.getAdditionalFixInfo();
if(additionalInfo instanceof IDocument){
IStructuredModel model = StructuredModelManager.getModelManager().getModelForRead((IStructuredDocument)additionalInfo);
IDOMDocument xmlDocument = (model instanceof IDOMModel) ? ((IDOMModel) model).getDocument() : null;
- IFile file = MarkerResolutionUtils.getFile();
- if(file == null)
- return new IJavaCompletionProposal[]{};
-
IKbProject kbProject = KbProjectFactory.getKbProject(file.getProject(), true);
ITagLibrary[] libraries = kbProject.getTagLibraries();
@@ -163,9 +183,22 @@
if(prefix == null)
return new IMarkerResolution[]{};
-
IFile file = (IFile)marker.getResource();
+ ELContext context = PageContextFactory.createPageContext(file);
+ if(context instanceof XmlContextImpl){
+ Map<String, List<INameSpace>> nameSpaces = ((XmlContextImpl) context).getNameSpaces(start);
+ Iterator<List<INameSpace>> iterator = nameSpaces.values().iterator();
+ while(iterator.hasNext()){
+ List<INameSpace> list = iterator.next();
+ for(INameSpace ns : list){
+ if(prefix.equals(ns.getPrefix())){
+ return new IMarkerResolution[]{};
+ }
+ }
+ }
+ }
+
IKbProject kbProject = KbProjectFactory.getKbProject(file.getProject(), true);
ITagLibrary[] libraries = kbProject.getTagLibraries();
11 years, 9 months
JBoss Tools SVN: r42744 - trunk/jst/plugins/org.jboss.tools.jst.web.ui/src/org/jboss/tools/jst/web/ui/action.
by jbosstools-commits@lists.jboss.org
Author: dazarov
Date: 2012-07-26 18:27:16 -0400 (Thu, 26 Jul 2012)
New Revision: 42744
Modified:
trunk/jst/plugins/org.jboss.tools.jst.web.ui/src/org/jboss/tools/jst/web/ui/action/AddTLDMarkerResolution.java
Log:
Make Quick Fix "Add tag library definition" work with KB Model instead of using plain tag library list https://issues.jboss.org/browse/JBIDE-12304
Modified: trunk/jst/plugins/org.jboss.tools.jst.web.ui/src/org/jboss/tools/jst/web/ui/action/AddTLDMarkerResolution.java
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.web.ui/src/org/jboss/tools/jst/web/ui/action/AddTLDMarkerResolution.java 2012-07-26 22:11:05 UTC (rev 42743)
+++ trunk/jst/plugins/org.jboss.tools.jst.web.ui/src/org/jboss/tools/jst/web/ui/action/AddTLDMarkerResolution.java 2012-07-26 22:27:16 UTC (rev 42744)
@@ -32,6 +32,7 @@
import org.jboss.tools.common.model.ui.ModelUIImages;
import org.jboss.tools.common.model.ui.views.palette.PaletteInsertHelper;
import org.jboss.tools.common.quickfix.IBaseMarkerResolution;
+import org.jboss.tools.common.ui.CommonUIPlugin;
import org.jboss.tools.jst.jsp.jspeditor.dnd.JSPPaletteInsertHelper;
import org.jboss.tools.jst.jsp.jspeditor.dnd.PaletteTaglibInserter;
import org.jboss.tools.jst.web.ui.Messages;
@@ -134,7 +135,7 @@
@Override
public Image getImage() {
- return ModelUIImages.getImageDescriptor(ModelUIImages.TAGLIB_FILE).createImage();
+ return CommonUIPlugin.getImageDescriptorRegistry().get(ModelUIImages.getImageDescriptor(ModelUIImages.TAGLIB_FILE));
}
@Override
11 years, 9 months
JBoss Tools SVN: r42743 - trunk/jst/plugins/org.jboss.tools.jst.web.ui/src/org/jboss/tools/jst/web/ui/action.
by jbosstools-commits@lists.jboss.org
Author: dazarov
Date: 2012-07-26 18:11:05 -0400 (Thu, 26 Jul 2012)
New Revision: 42743
Modified:
trunk/jst/plugins/org.jboss.tools.jst.web.ui/src/org/jboss/tools/jst/web/ui/action/JSPProblemMarkerResolutionGenerator.java
Log:
Make Quick Fix "Add tag library definition" work with KB Model instead of using plain tag library list https://issues.jboss.org/browse/JBIDE-12304
Modified: trunk/jst/plugins/org.jboss.tools.jst.web.ui/src/org/jboss/tools/jst/web/ui/action/JSPProblemMarkerResolutionGenerator.java
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.web.ui/src/org/jboss/tools/jst/web/ui/action/JSPProblemMarkerResolutionGenerator.java 2012-07-26 21:44:16 UTC (rev 42742)
+++ trunk/jst/plugins/org.jboss.tools.jst.web.ui/src/org/jboss/tools/jst/web/ui/action/JSPProblemMarkerResolutionGenerator.java 2012-07-26 22:11:05 UTC (rev 42743)
@@ -105,6 +105,7 @@
IKbProject kbProject = KbProjectFactory.getKbProject(file.getProject(), true);
ITagLibrary[] libraries = kbProject.getTagLibraries();
+ ArrayList<String> names = new ArrayList<String>();
for(ITagLibrary l : libraries){
if(l instanceof TLDLibrary){
((TLDLibrary) l).createDefaultNameSpace();
@@ -113,8 +114,9 @@
if(ns != null && ns.getPrefix() != null && ns.getPrefix().equals(prefix)){
String uri = ns.getURI();
String resolutionName = getResolutionName(xmlDocument != null && xmlDocument.isXMLType(), true, prefix, uri);
- if(resolutionName != null){
+ if(resolutionName != null && !names.contains(resolutionName)){
proposals.add(new AddTLDMarkerResolution(resolutionName, start, end, uri, prefix));
+ names.add(resolutionName);
}
}
}
@@ -167,6 +169,7 @@
IKbProject kbProject = KbProjectFactory.getKbProject(file.getProject(), true);
ITagLibrary[] libraries = kbProject.getTagLibraries();
+ ArrayList<String> names = new ArrayList<String>();
for(ITagLibrary l : libraries){
if(l instanceof TLDLibrary){
((TLDLibrary) l).createDefaultNameSpace();
@@ -175,8 +178,9 @@
if(ns != null && ns.getPrefix() != null && ns.getPrefix().equals(prefix)){
String uri = ns.getURI();
String resolutionName = getResolutionName(marker.getType().equals(HTML_VALIDATOR_MARKER) || marker.isSubtypeOf(HTML_VALIDATOR_MARKER), marker.getType().equals(JSP_VALIDATOR_MARKER) || marker.isSubtypeOf(JSP_VALIDATOR_MARKER), prefix, uri);
- if(resolutionName != null){
+ if(resolutionName != null && !names.contains(resolutionName)){
resolutions.add(new AddTLDMarkerResolution(file, resolutionName, start, end, uri, prefix));
+ names.add(resolutionName);
}
}
}
11 years, 9 months
JBoss Tools SVN: r42742 - in trunk: jst/plugins/org.jboss.tools.jst.web.ui/src/org/jboss/tools/jst/web/ui/action and 1 other directory.
by jbosstools-commits@lists.jboss.org
Author: dazarov
Date: 2012-07-26 17:44:16 -0400 (Thu, 26 Jul 2012)
New Revision: 42742
Modified:
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/ModelUIImages.java
trunk/jst/plugins/org.jboss.tools.jst.web.ui/src/org/jboss/tools/jst/web/ui/action/AddTLDMarkerResolution.java
trunk/jst/plugins/org.jboss.tools.jst.web.ui/src/org/jboss/tools/jst/web/ui/action/JSPProblemMarkerResolutionGenerator.java
Log:
Make Quick Fix "Add tag library definition" work with KB Model instead of using plain tag library list https://issues.jboss.org/browse/JBIDE-12304
Modified: trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/ModelUIImages.java
===================================================================
--- trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/ModelUIImages.java 2012-07-26 19:09:05 UTC (rev 42741)
+++ trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/ModelUIImages.java 2012-07-26 21:44:16 UTC (rev 42742)
@@ -39,6 +39,8 @@
public static String JAVA_CLASS = "java/class.gif"; //$NON-NLS-1$
public static String JAVA_INTERFACE = "java/interface.gif"; //$NON-NLS-1$
public static String JAVA_PACKAGE = "java/package.gif"; //$NON-NLS-1$
+
+ public static String TAGLIB_FILE = "editors/taglibs_file.gif"; //$NON-NLS-1$
// this blok staye witout changes for compatibility
private static ModelUIImages INSTANCE;
Modified: trunk/jst/plugins/org.jboss.tools.jst.web.ui/src/org/jboss/tools/jst/web/ui/action/AddTLDMarkerResolution.java
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.web.ui/src/org/jboss/tools/jst/web/ui/action/AddTLDMarkerResolution.java 2012-07-26 19:09:05 UTC (rev 42741)
+++ trunk/jst/plugins/org.jboss.tools.jst.web.ui/src/org/jboss/tools/jst/web/ui/action/AddTLDMarkerResolution.java 2012-07-26 21:44:16 UTC (rev 42742)
@@ -29,6 +29,7 @@
import org.eclipse.ui.part.FileEditorInput;
import org.eclipse.ui.texteditor.DocumentProviderRegistry;
import org.eclipse.ui.texteditor.IDocumentProvider;
+import org.jboss.tools.common.model.ui.ModelUIImages;
import org.jboss.tools.common.model.ui.views.palette.PaletteInsertHelper;
import org.jboss.tools.common.quickfix.IBaseMarkerResolution;
import org.jboss.tools.jst.jsp.jspeditor.dnd.JSPPaletteInsertHelper;
@@ -44,16 +45,18 @@
*/
public class AddTLDMarkerResolution implements IBaseMarkerResolution, IJavaCompletionProposal{
private IFile file;
- private Properties properties;
private String resolutionName;
private int start, end;
private String uri, prefix;
- public AddTLDMarkerResolution(IFile file, String name, Properties properties){
+ public AddTLDMarkerResolution(IFile file, String name, int start, int end, String uri, String prefix){
this.file = file;
- this.properties = properties;
this.resolutionName = name;
+ this.start = start;
+ this.end = end;
+ this.uri = uri;
+ this.prefix = prefix;
}
public AddTLDMarkerResolution(String name, int start, int end, String uri, String prefix){
@@ -63,6 +66,35 @@
this.uri = uri;
this.prefix = prefix;
}
+
+ private Properties getProperties(){
+ Properties properties = new Properties();
+ properties.put(JSPPaletteInsertHelper.PROPOPERTY_ADD_TAGLIB, "true"); //$NON-NLS-1$
+ properties.put(PaletteInsertHelper.PROPOPERTY_START_TEXT, ""); //$NON-NLS-1$
+ properties.put(JSPPaletteInsertHelper.PROPOPERTY_TAGLIBRARY_URI, uri);
+ properties.put(JSPPaletteInsertHelper.PROPOPERTY_DEFAULT_PREFIX, prefix);
+ properties.put(PaletteInsertHelper.PROPOPERTY_SELECTION_PROVIDER, new ISelectionProvider() {
+
+ @Override
+ public void setSelection(ISelection selection) {
+ }
+
+ @Override
+ public void removeSelectionChangedListener(
+ ISelectionChangedListener listener) {
+ }
+
+ @Override
+ public ISelection getSelection() {
+ return new TextSelection(start, end-start);
+ }
+
+ @Override
+ public void addSelectionChangedListener(ISelectionChangedListener listener) {
+ }
+ });
+ return properties;
+ }
@Override
public String getLabel() {
@@ -81,7 +113,7 @@
IDocument document = provider.getDocument(input);
PaletteTaglibInserter inserter = new PaletteTaglibInserter();
- inserter.inserTaglib(document, properties);
+ inserter.inserTaglib(document, getProperties());
if(!dirty){
provider.aboutToChange(input);
@@ -102,39 +134,15 @@
@Override
public Image getImage() {
- return null;//ImageDescriptor.createFromFile(AddTLDMarkerResolution.class, "images/xstudio/editors/taglibs_file.gif").createImage(); //$NON-NLS-1$
+ return ModelUIImages.getImageDescriptor(ModelUIImages.TAGLIB_FILE).createImage();
}
@Override
public void apply(IDocument document) {
- properties = new Properties();
- properties.put(JSPPaletteInsertHelper.PROPOPERTY_ADD_TAGLIB, "true"); //$NON-NLS-1$
- properties.put(PaletteInsertHelper.PROPOPERTY_START_TEXT, ""); //$NON-NLS-1$
- properties.put(JSPPaletteInsertHelper.PROPOPERTY_TAGLIBRARY_URI, uri);
- properties.put(JSPPaletteInsertHelper.PROPOPERTY_DEFAULT_PREFIX, prefix);
- properties.put(PaletteInsertHelper.PROPOPERTY_SELECTION_PROVIDER, new ISelectionProvider() {
-
- @Override
- public void setSelection(ISelection selection) {
- }
-
- @Override
- public void removeSelectionChangedListener(
- ISelectionChangedListener listener) {
- }
-
- @Override
- public ISelection getSelection() {
- return new TextSelection(start, end-start);
- }
-
- @Override
- public void addSelectionChangedListener(ISelectionChangedListener listener) {
- }
- });
+ Properties properties = getProperties();
- Properties p = PaletteTaglibInserter.getPrefixes(document, properties);
+ PaletteTaglibInserter.getPrefixes(document, properties);
PaletteTaglibInserter inserter = new PaletteTaglibInserter();
inserter.inserTaglib(document, properties);
Modified: trunk/jst/plugins/org.jboss.tools.jst.web.ui/src/org/jboss/tools/jst/web/ui/action/JSPProblemMarkerResolutionGenerator.java
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.web.ui/src/org/jboss/tools/jst/web/ui/action/JSPProblemMarkerResolutionGenerator.java 2012-07-26 19:09:05 UTC (rev 42741)
+++ trunk/jst/plugins/org.jboss.tools.jst.web.ui/src/org/jboss/tools/jst/web/ui/action/JSPProblemMarkerResolutionGenerator.java 2012-07-26 21:44:16 UTC (rev 42742)
@@ -12,33 +12,28 @@
import java.util.ArrayList;
import java.util.HashMap;
-import java.util.Properties;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IMarker;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.jdt.ui.text.java.IJavaCompletionProposal;
import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.TextSelection;
import org.eclipse.jface.text.source.Annotation;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.ISelectionChangedListener;
-import org.eclipse.jface.viewers.ISelectionProvider;
import org.eclipse.ui.IMarkerResolution;
import org.eclipse.ui.IMarkerResolutionGenerator2;
-import org.eclipse.ui.part.FileEditorInput;
-import org.eclipse.ui.texteditor.DocumentProviderRegistry;
-import org.eclipse.ui.texteditor.IDocumentProvider;
import org.eclipse.wst.sse.core.internal.provisional.IStructuredModel;
import org.eclipse.wst.sse.core.internal.provisional.StructuredModelManager;
import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocument;
import org.eclipse.wst.sse.ui.internal.reconcile.TemporaryAnnotation;
import org.eclipse.wst.xml.core.internal.provisional.document.IDOMDocument;
import org.eclipse.wst.xml.core.internal.provisional.document.IDOMModel;
-import org.jboss.tools.common.model.ui.views.palette.PaletteInsertHelper;
import org.jboss.tools.common.quickfix.IQuickFixGenerator;
-import org.jboss.tools.jst.jsp.jspeditor.dnd.JSPPaletteInsertHelper;
-import org.jboss.tools.jst.jsp.jspeditor.dnd.PaletteTaglibInserter;
+import org.jboss.tools.common.refactoring.MarkerResolutionUtils;
+import org.jboss.tools.jst.web.kb.IKbProject;
+import org.jboss.tools.jst.web.kb.KbProjectFactory;
+import org.jboss.tools.jst.web.kb.internal.taglib.TLDLibrary;
+import org.jboss.tools.jst.web.kb.taglib.INameSpace;
+import org.jboss.tools.jst.web.kb.taglib.ITagLibrary;
import org.jboss.tools.jst.web.ui.WebUiPlugin;
/**
@@ -66,142 +61,134 @@
libs.put("c", "http://java.sun.com/jstl/core"); //$NON-NLS-1$ //$NON-NLS-2$
}
- private IFile file;
- private Properties properties;
- private String resolutionName;
-
@Override
public IMarkerResolution[] getResolutions(IMarker marker) {
try{
- if(isOurCase(marker)){
- return new IMarkerResolution[] {
- new AddTLDMarkerResolution(file, resolutionName, properties)
- };
- }
+ return isOurCase(marker);
}catch(CoreException ex){
WebUiPlugin.getPluginLog().logError(ex);
}
return new IMarkerResolution[]{};
}
- private IJavaCompletionProposal isOurCase(Annotation annotation){
+ private IJavaCompletionProposal[] isOurCase(Annotation annotation){
+ ArrayList<IJavaCompletionProposal> proposals = new ArrayList<IJavaCompletionProposal>();
if(!(annotation instanceof TemporaryAnnotation)){
- return null;
+ return new IJavaCompletionProposal[]{};
}
TemporaryAnnotation ta = (TemporaryAnnotation)annotation;
-
String message = annotation.getText();
if(ta.getPosition() == null)
- return null;
+ return new IJavaCompletionProposal[]{};
final int start = ta.getPosition().getOffset();
final int end = ta.getPosition().getOffset()+ta.getPosition().getLength();
if(!message.startsWith(UNKNOWN_TAG))
- return null;
+ return new IJavaCompletionProposal[]{};
String prefix = getPrifix(message);
if(prefix == null)
- return null;
+ return new IJavaCompletionProposal[]{};
- if(!libs.containsKey(prefix))
- return null;
-
Object additionalInfo = ta.getAdditionalFixInfo();
if(additionalInfo instanceof IDocument){
IStructuredModel model = StructuredModelManager.getModelManager().getModelForRead((IStructuredDocument)additionalInfo);
IDOMDocument xmlDocument = (model instanceof IDOMModel) ? ((IDOMModel) model).getDocument() : null;
- if(xmlDocument != null && xmlDocument.isXMLType()){
- resolutionName = "xmlns: "+prefix+" = \""+libs.get(prefix)+"\""; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- }else{
- resolutionName = "<%@ taglib uri = \""+libs.get(prefix)+"\" prefix=\""+prefix+"\" %>"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+
+ IFile file = MarkerResolutionUtils.getFile();
+ if(file == null)
+ return new IJavaCompletionProposal[]{};
+
+ IKbProject kbProject = KbProjectFactory.getKbProject(file.getProject(), true);
+
+ ITagLibrary[] libraries = kbProject.getTagLibraries();
+ for(ITagLibrary l : libraries){
+ if(l instanceof TLDLibrary){
+ ((TLDLibrary) l).createDefaultNameSpace();
+ }
+ INameSpace ns = l.getDefaultNameSpace();
+ if(ns != null && ns.getPrefix() != null && ns.getPrefix().equals(prefix)){
+ String uri = ns.getURI();
+ String resolutionName = getResolutionName(xmlDocument != null && xmlDocument.isXMLType(), true, prefix, uri);
+ if(resolutionName != null){
+ proposals.add(new AddTLDMarkerResolution(resolutionName, start, end, uri, prefix));
+ }
+ }
}
+ if(proposals.size() == 0 && libs.containsKey(prefix)){
+ String uri = libs.get(prefix);
+ String resolutionName = getResolutionName(xmlDocument != null && xmlDocument.isXMLType(), true, prefix, uri);
+ if(resolutionName != null){
+ proposals.add(new AddTLDMarkerResolution(resolutionName, start, end, uri, prefix));
+ }
+ }
}
-
-
- return new AddTLDMarkerResolution(resolutionName, start, end, libs.get(prefix), prefix);
+ return proposals.toArray(new IJavaCompletionProposal[]{});
}
- private boolean isOurCase(IMarker marker) throws CoreException{
+ private String getResolutionName(boolean xml, boolean noXML, String prefix, String uri){
+ if(xml){
+ return "xmlns: "+prefix+" = \""+uri+"\""; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ }else if(noXML){
+ return "<%@ taglib uri = \""+uri+"\" prefix=\""+prefix+"\" %>"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ }
+ return null;
+ }
+
+ private IMarkerResolution[] isOurCase(IMarker marker) throws CoreException{
+ ArrayList<IMarkerResolution> resolutions = new ArrayList<IMarkerResolution>();
String message = (String)marker.getAttribute(IMarker.MESSAGE);
Integer attribute = ((Integer)marker.getAttribute(IMarker.CHAR_START));
if(attribute == null)
- return false;
+ return new IMarkerResolution[]{};
final int start = attribute.intValue();
attribute = ((Integer)marker.getAttribute(IMarker.CHAR_END));
if(attribute == null)
- return false;
+ return new IMarkerResolution[]{};
final int end = attribute.intValue();
if(!message.startsWith(UNKNOWN_TAG))
- return false;
+ return new IMarkerResolution[]{};
String prefix = getPrifix(message);
if(prefix == null)
- return false;
+ return new IMarkerResolution[]{};
- if(!libs.containsKey(prefix))
- return false;
- file = (IFile)marker.getResource();
+ IFile file = (IFile)marker.getResource();
- FileEditorInput input = new FileEditorInput(file);
- IDocumentProvider provider = DocumentProviderRegistry.getDefault().getDocumentProvider(input);
- try {
- provider.connect(input);
- } catch (CoreException e) {
- WebUiPlugin.getPluginLog().logError(e);
- }
+ IKbProject kbProject = KbProjectFactory.getKbProject(file.getProject(), true);
- IDocument document = provider.getDocument(input);
-
- properties = new Properties();
- properties.put(JSPPaletteInsertHelper.PROPOPERTY_ADD_TAGLIB, "true"); //$NON-NLS-1$
- properties.put(PaletteInsertHelper.PROPOPERTY_START_TEXT, ""); //$NON-NLS-1$
- properties.put(JSPPaletteInsertHelper.PROPOPERTY_TAGLIBRARY_URI, libs.get(prefix));
- properties.put(JSPPaletteInsertHelper.PROPOPERTY_DEFAULT_PREFIX, prefix);
- properties.put(PaletteInsertHelper.PROPOPERTY_SELECTION_PROVIDER, new ISelectionProvider() {
-
- @Override
- public void setSelection(ISelection selection) {
+ ITagLibrary[] libraries = kbProject.getTagLibraries();
+ for(ITagLibrary l : libraries){
+ if(l instanceof TLDLibrary){
+ ((TLDLibrary) l).createDefaultNameSpace();
}
-
- @Override
- public void removeSelectionChangedListener(
- ISelectionChangedListener listener) {
+ INameSpace ns = l.getDefaultNameSpace();
+ if(ns != null && ns.getPrefix() != null && ns.getPrefix().equals(prefix)){
+ String uri = ns.getURI();
+ String resolutionName = getResolutionName(marker.getType().equals(HTML_VALIDATOR_MARKER) || marker.isSubtypeOf(HTML_VALIDATOR_MARKER), marker.getType().equals(JSP_VALIDATOR_MARKER) || marker.isSubtypeOf(JSP_VALIDATOR_MARKER), prefix, uri);
+ if(resolutionName != null){
+ resolutions.add(new AddTLDMarkerResolution(file, resolutionName, start, end, uri, prefix));
+ }
}
-
- @Override
- public ISelection getSelection() {
- return new TextSelection(start, end-start);
- }
-
- @Override
- public void addSelectionChangedListener(ISelectionChangedListener listener) {
- }
- });
-
-
- Properties p = PaletteTaglibInserter.getPrefixes(document, properties);
-
- provider.disconnect(input);
-
- if(p.containsValue(prefix))
- return false;
-
- if(marker.getType().equals(HTML_VALIDATOR_MARKER) || marker.isSubtypeOf(HTML_VALIDATOR_MARKER)){
- resolutionName = "xmlns: "+prefix+" = \""+libs.get(prefix)+"\""; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- }else if(marker.getType().equals(JSP_VALIDATOR_MARKER) || marker.isSubtypeOf(JSP_VALIDATOR_MARKER)){
- resolutionName = "<%@ taglib uri = \""+libs.get(prefix)+"\" prefix=\""+prefix+"\" %>"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
}
- return true;
+ if(resolutions.size() == 0 && libs.containsKey(prefix)){
+ String uri = libs.get(prefix);
+ String resolutionName = getResolutionName(marker.getType().equals(HTML_VALIDATOR_MARKER) || marker.isSubtypeOf(HTML_VALIDATOR_MARKER), marker.getType().equals(JSP_VALIDATOR_MARKER) || marker.isSubtypeOf(JSP_VALIDATOR_MARKER), prefix, uri);
+ if(resolutionName != null){
+ resolutions.add(new AddTLDMarkerResolution(file, resolutionName, start, end, uri, prefix));
+ }
+ }
+ return resolutions.toArray(new IMarkerResolution[]{});
}
public static String getPrifix(String message){
@@ -239,11 +226,6 @@
@Override
public IJavaCompletionProposal[] getProposals(Annotation annotation) {
- ArrayList<IJavaCompletionProposal> proposals = new ArrayList<IJavaCompletionProposal>();
- IJavaCompletionProposal proposal = isOurCase(annotation);
- if(proposal != null){
- proposals.add(proposal);
- }
- return proposals.toArray(new IJavaCompletionProposal[]{});
+ return isOurCase(annotation);
}
}
\ No newline at end of file
11 years, 9 months