JBoss Tools SVN: r37452 - in trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test: rest and 2 other directories.
by jbosstools-commits@lists.jboss.org
Author: jjankovi
Date: 2011-12-20 04:23:49 -0500 (Tue, 20 Dec 2011)
New Revision: 37452
Added:
trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/rest/
trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/rest/explorer/
trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/rest/explorer/test/
trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/rest/explorer/test/RESTfulExplorerValidationTest.java
Modified:
trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/WSAllBotTests.java
trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/WSTestBase.java
Log:
RestfulExplorerValidationTest added
Modified: trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/WSAllBotTests.java
===================================================================
--- trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/WSAllBotTests.java 2011-12-20 09:23:16 UTC (rev 37451)
+++ trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/WSAllBotTests.java 2011-12-20 09:23:49 UTC (rev 37452)
@@ -11,6 +11,7 @@
package org.jboss.tools.ws.ui.bot.test;
import org.jboss.tools.ui.bot.ext.RequirementAwareSuite;
+import org.jboss.tools.ws.ui.bot.test.rest.explorer.test.RESTfulExplorerValidationTest;
import org.jboss.tools.ws.ui.bot.test.sample.test.SampleRESTWebServiceTest;
import org.jboss.tools.ws.ui.bot.test.sample.test.SampleSoapWebServiceTest;
import org.jboss.tools.ws.ui.bot.test.sample.test.SimpleRESTWebServiceTest;
@@ -49,6 +50,7 @@
SampleRESTWebServiceTest.class,
SimpleSoapWebServiceTest.class,
SimpleRESTWebServiceTest.class,
+ RESTfulExplorerValidationTest.class,
BottomUpWSTest.class,
TopDownWSTest.class,
WsClientTest.class,
Modified: trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/WSTestBase.java
===================================================================
--- trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/WSTestBase.java 2011-12-20 09:23:16 UTC (rev 37451)
+++ trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/WSTestBase.java 2011-12-20 09:23:49 UTC (rev 37452)
@@ -45,10 +45,10 @@
protected static final Logger LOGGER = Logger
.getLogger(WSTestBase.class.getName());
- protected static ResourceHelper resourceHelper = new ResourceHelper();
- protected static ProjectHelper projectHelper = new ProjectHelper();
- protected static DeploymentHelper deploymentHelper = new DeploymentHelper();
- protected static WebServiceClientHelper clientHelper = new WebServiceClientHelper();
+ protected static final ResourceHelper resourceHelper = new ResourceHelper();
+ protected static final ProjectHelper projectHelper = new ProjectHelper();
+ protected static final DeploymentHelper deploymentHelper = new DeploymentHelper();
+ protected static final WebServiceClientHelper clientHelper = new WebServiceClientHelper();
@Before
public void setup() {
Added: trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/rest/explorer/test/RESTfulExplorerValidationTest.java
===================================================================
--- trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/rest/explorer/test/RESTfulExplorerValidationTest.java (rev 0)
+++ trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/rest/explorer/test/RESTfulExplorerValidationTest.java 2011-12-20 09:23:49 UTC (rev 37452)
@@ -0,0 +1,79 @@
+/*******************************************************************************
+ * Copyright (c) 2007-2011 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is 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
+ *
+ * Contributor:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+
+package org.jboss.tools.ws.ui.bot.test.rest.explorer.test;
+
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotTree;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem;
+import org.jboss.tools.ui.bot.ext.Timing;
+import org.jboss.tools.ws.ui.bot.test.WSTestBase;
+import org.jboss.tools.ws.ui.bot.test.utils.NodeContextUtil;
+import org.junit.Before;
+import org.junit.Test;
+
+/**
+ *
+ * @author jjankovi
+ *
+ */
+public class RESTfulExplorerValidationTest extends WSTestBase {
+
+ private static final String CONFIGURE_MENU_LABEL = "Configure";
+ private static final String REST_SUPPORT_MENU_LABEL_ADD = "Add JAX-RS 1.1 support...";
+ private static final String REST_SUPPORT_MENU_LABEL_REMOVE = "Remove JAX-RS 1.1 support...";
+ private static final String REST_EXPLORER_LABEL = "JAX-RS REST Web Services";
+
+ protected String getWsProjectName() {
+ return "RestExplorerTest";
+ }
+
+ protected String getWsPackage() {
+ return "org.rest.explorer.validation.test";
+ }
+
+ protected String getWsName() {
+ return "RestService";
+ }
+
+ @Before
+ public void setup() {
+ if (!projectExists(getWsProjectName())) {
+ projectHelper.createProject(getWsProjectName());
+ }
+ }
+
+
+ @Test
+ public void testSupportJAX_RS1_1_Explorer() {
+
+ addRestSupport(getWsProjectName());
+
+ projectExplorer.selectProject(getWsProjectName());
+ SWTBotTree tree = projectExplorer.bot().tree();
+ SWTBotTreeItem item = tree.getTreeItem(getWsProjectName());
+ assertTrue(NodeContextUtil.nodeContextMenu(tree, item, CONFIGURE_MENU_LABEL,
+ REST_SUPPORT_MENU_LABEL_REMOVE).isVisible());
+ assertTrue(projectExplorer.isFilePresent(getWsProjectName(), REST_EXPLORER_LABEL));
+
+ }
+
+ private void addRestSupport(String wsProjectName) {
+ projectExplorer.selectProject(wsProjectName);
+ SWTBotTree tree = projectExplorer.bot().tree();
+ SWTBotTreeItem item = tree.getTreeItem(wsProjectName);
+ item.expand();
+ NodeContextUtil.nodeContextMenu(tree, item, CONFIGURE_MENU_LABEL,
+ REST_SUPPORT_MENU_LABEL_ADD).click();
+ bot.sleep(Timing.time2S());
+ util.waitForNonIgnoredJobs();
+ }
+
+}
14 years
JBoss Tools SVN: r37451 - trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/utils.
by jbosstools-commits@lists.jboss.org
Author: jjankovi
Date: 2011-12-20 04:23:16 -0500 (Tue, 20 Dec 2011)
New Revision: 37451
Added:
trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/utils/NodeContextUtil.java
Log:
NodeContextUtil for WS bot test added
Added: trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/utils/NodeContextUtil.java
===================================================================
--- trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/utils/NodeContextUtil.java (rev 0)
+++ trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/utils/NodeContextUtil.java 2011-12-20 09:23:16 UTC (rev 37451)
@@ -0,0 +1,44 @@
+/*******************************************************************************
+ * Copyright (c) 2010 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is 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:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+
+package org.jboss.tools.ws.ui.bot.test.utils;
+
+import org.eclipse.swtbot.swt.finder.finders.UIThreadRunnable;
+import org.eclipse.swtbot.swt.finder.results.Result;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotMenu;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotTree;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem;
+import org.jboss.tools.ui.bot.ext.helper.ContextMenuHelper;
+
+public class NodeContextUtil {
+
+ private NodeContextUtil() {
+ throw new AssertionError();
+ }
+
+ public static SWTBotMenu nodeContextMenu(final SWTBotTree tree,
+ SWTBotTreeItem item, final String... menu) {
+ assert menu.length > 0;
+ ContextMenuHelper.prepareTreeItemForContextMenu(tree, item);
+ return UIThreadRunnable.syncExec(new Result<SWTBotMenu>() {
+
+ public SWTBotMenu run() {
+ SWTBotMenu m = new SWTBotMenu(ContextMenuHelper.getContextMenu(
+ tree, menu[0], false));
+ for (int i = 1; i < menu.length; i++) {
+ m = m.menu(menu[i]);
+ }
+ return m;
+ }
+ });
+ }
+
+}
14 years
JBoss Tools SVN: r37450 - trunk/openshift/docs/reference/en-US.
by jbosstools-commits@lists.jboss.org
Author: irooskov(a)redhat.com
Date: 2011-12-19 23:10:04 -0500 (Mon, 19 Dec 2011)
New Revision: 37450
Modified:
trunk/openshift/docs/reference/en-US/Book_Info.xml
Log:
updated for brew
Modified: trunk/openshift/docs/reference/en-US/Book_Info.xml
===================================================================
--- trunk/openshift/docs/reference/en-US/Book_Info.xml 2011-12-20 04:01:54 UTC (rev 37449)
+++ trunk/openshift/docs/reference/en-US/Book_Info.xml 2011-12-20 04:10:04 UTC (rev 37450)
@@ -13,7 +13,7 @@
<edition>5.0.0</edition>
- <pubsnumber>2</pubsnumber>
+ <pubsnumber>3</pubsnumber>
<abstract>
<para>
14 years
JBoss Tools SVN: r37449 - trunk/openshift/docs/reference/en-US.
by jbosstools-commits@lists.jboss.org
Author: irooskov(a)redhat.com
Date: 2011-12-19 23:01:54 -0500 (Mon, 19 Dec 2011)
New Revision: 37449
Modified:
trunk/openshift/docs/reference/en-US/Creating_an_OpenShift_Express_Application.xml
Log:
updated with new screen and info for openshift app creation wizard
Modified: trunk/openshift/docs/reference/en-US/Creating_an_OpenShift_Express_Application.xml
===================================================================
--- trunk/openshift/docs/reference/en-US/Creating_an_OpenShift_Express_Application.xml 2011-12-20 03:47:17 UTC (rev 37448)
+++ trunk/openshift/docs/reference/en-US/Creating_an_OpenShift_Express_Application.xml 2011-12-20 04:01:54 UTC (rev 37449)
@@ -97,13 +97,34 @@
</mediaobject>
</figure>
<para>
- You will need to specify a name for the application and the platform to deploy for, from the <guilabel>Cartdige</guilabel> drop-down list. Click <guibutton>Finish</guibutton> to create the application.
+ You will need to specify a name for the application and the platform to deploy for, from the <guilabel>Cartdige</guilabel> drop-down list. Click the <guibutton>Next</guibutton> to embedd cartridges or click <guibutton>Finish</guibutton> to create the application.
</para>
<note>
<para>
No underscores or special characters are allowed in the application name.
</para>
</note>
+ <para>
+ If you clicked <guibutton>Next</guibutton>, you will now see the <guilabel>Embed Cartridges</guilabel> screen. From here you can choose to embed any numbe rof cartridges, or none. Once you have finished your selection click <guibutton>Finish</guibutton>.
+ </para>
+ <note>
+ <para>
+ The <guilabel>Embed Cartridges</guilabel> screen can also be access by highlighting a project in the <guilabel>Available Applications</guilabel> section of the <guilabel>Application Selection</guilabel> screen and clicking on the <guibutton>Edit</guibutton> button. To embed your application with a cartridge is to grant the capability to your application. For example, embedding the <guilabel>mysql</guilabel> cartridge will grant your application the capability to use a MySQL database.
+ </para>
+ </note>
+ <figure id="application_creation_05a">
+ <title>Embed Cartridges</title>
+ <mediaobject>
+ <imageobject>
+ <imagedata fileref="images/Creating_an_OpenShift_Express_Application/application_creation_05a.png" format="PNG" />
+ </imageobject>
+ <textobject>
+ <phrase>
+ Choosing which cartridges to embed within the application.
+ </phrase>
+ </textobject>
+ </mediaobject>
+ </figure>
<figure id="application_creation_06">
<title>Created application availability</title>
<mediaobject>
14 years
JBoss Tools SVN: r37448 - trunk/openshift/docs/reference/en-US/images/Creating_an_OpenShift_Express_Application.
by jbosstools-commits@lists.jboss.org
Author: irooskov(a)redhat.com
Date: 2011-12-19 22:47:17 -0500 (Mon, 19 Dec 2011)
New Revision: 37448
Added:
trunk/openshift/docs/reference/en-US/images/Creating_an_OpenShift_Express_Application/application_creation_05a.png
Modified:
trunk/openshift/docs/reference/en-US/images/Creating_an_OpenShift_Express_Application/application_creation_03.png
trunk/openshift/docs/reference/en-US/images/Creating_an_OpenShift_Express_Application/application_creation_06.png
trunk/openshift/docs/reference/en-US/images/Creating_an_OpenShift_Express_Application/application_creation_07.png
trunk/openshift/docs/reference/en-US/images/Creating_an_OpenShift_Express_Application/application_creation_08.png
Log:
adding updated images
Modified: trunk/openshift/docs/reference/en-US/images/Creating_an_OpenShift_Express_Application/application_creation_03.png
===================================================================
(Binary files differ)
Added: trunk/openshift/docs/reference/en-US/images/Creating_an_OpenShift_Express_Application/application_creation_05a.png
===================================================================
(Binary files differ)
Property changes on: trunk/openshift/docs/reference/en-US/images/Creating_an_OpenShift_Express_Application/application_creation_05a.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Modified: trunk/openshift/docs/reference/en-US/images/Creating_an_OpenShift_Express_Application/application_creation_06.png
===================================================================
(Binary files differ)
Modified: trunk/openshift/docs/reference/en-US/images/Creating_an_OpenShift_Express_Application/application_creation_07.png
===================================================================
(Binary files differ)
Modified: trunk/openshift/docs/reference/en-US/images/Creating_an_OpenShift_Express_Application/application_creation_08.png
===================================================================
(Binary files differ)
14 years
JBoss Tools SVN: r37447 - in trunk: cdi/plugins/org.jboss.tools.cdi.seam.text.ext/src/org/jboss/tools/cdi/seam/text/ext/hyperlink and 6 other directories.
by jbosstools-commits@lists.jboss.org
Author: dazarov
Date: 2011-12-19 21:11:31 -0500 (Mon, 19 Dec 2011)
New Revision: 37447
Added:
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/refactoring/CDIMarkerResolutionUtils.java
trunk/common/plugins/org.jboss.tools.common/src/org/jboss/tools/common/refactoring/
trunk/common/plugins/org.jboss.tools.common/src/org/jboss/tools/common/refactoring/MarkerResolutionUtils.java
Removed:
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/refactoring/MarkerResolutionUtils.java
Modified:
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/refactoring/AddQualifiersToBeanProcessor.java
trunk/cdi/plugins/org.jboss.tools.cdi.seam.text.ext/src/org/jboss/tools/cdi/seam/text/ext/hyperlink/CDISeamResourceLoadingHyperlinkDetector.java
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/marker/AddAnnotationMarkerResolution.java
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/marker/AddLocalBeanMarkerResolution.java
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/marker/AddRetentionAnnotationMarkerResolution.java
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/marker/AddSerializableInterfaceMarkerResolution.java
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/marker/AddTargetAnnotationMarkerResolution.java
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/marker/CDIProblemMarkerResolutionGenerator.java
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/marker/ChangeAnnotationMarkerResolution.java
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/marker/CreateCDIElementMarkerResolution.java
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/marker/DeleteAllDisposerDuplicantMarkerResolution.java
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/marker/DeleteAllInjectedConstructorsMarkerResolution.java
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/marker/DeleteAnnotationMarkerResolution.java
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/marker/MakeBeanScopedDependentMarkerResolution.java
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/marker/MakeFieldProtectedMarkerResolution.java
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/marker/MakeFieldStaticMarkerResolution.java
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/marker/MakeInjectedPointUnambiguousMarkerResolution.java
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/marker/MakeMethodBusinessMarkerResolution.java
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/marker/MakeMethodPublicMarkerResolution.java
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/marker/SelectBeanMarkerResolution.java
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/wizard/SelectBeanWizard.java
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/wizard/xpl/AddQualifiersToBeanComposite.java
trunk/common/plugins/org.jboss.tools.common/META-INF/MANIFEST.MF
Log:
Java Seam and CDI quick fixes: after quick fix, editor is scrolled to the beginning. If Undo/Redo commands are used, the entire file content gets selected https://issues.jboss.org/browse/JBIDE-10536
Modified: trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/refactoring/AddQualifiersToBeanProcessor.java
===================================================================
--- trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/refactoring/AddQualifiersToBeanProcessor.java 2011-12-20 01:59:12 UTC (rev 37446)
+++ trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/refactoring/AddQualifiersToBeanProcessor.java 2011-12-20 02:11:31 UTC (rev 37447)
@@ -95,7 +95,7 @@
MultiTextEdit edit = new MultiTextEdit();
- MarkerResolutionUtils.addQualifiersToBean(qualifiers, selectedBean, compilationUnit, edit);
+ CDIMarkerResolutionUtils.addQualifiersToBean(qualifiers, selectedBean, compilationUnit, edit);
IFile file2 = (IFile)injectionPoint.getClassBean().getResource();
ICompilationUnit original2 = injectionPoint.getClassBean().getBeanClass().getCompilationUnit();
@@ -118,7 +118,7 @@
compilationUnit2 = compilationUnit;
}
- MarkerResolutionUtils.addQualifiersToInjectionPoint(qualifiers, injectionPoint, compilationUnit2, edit);
+ CDIMarkerResolutionUtils.addQualifiersToInjectionPoint(qualifiers, injectionPoint, compilationUnit2, edit);
if(edit.getChildrenSize() > 0){
fileChange.setEdit(edit);
Copied: trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/refactoring/CDIMarkerResolutionUtils.java (from rev 37434, trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/refactoring/MarkerResolutionUtils.java)
===================================================================
--- trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/refactoring/CDIMarkerResolutionUtils.java (rev 0)
+++ trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/refactoring/CDIMarkerResolutionUtils.java 2011-12-20 02:11:31 UTC (rev 37447)
@@ -0,0 +1,413 @@
+/*******************************************************************************
+ * Copyright (c) 2010 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is 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:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.cdi.internal.core.refactoring;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.jdt.core.IAnnotation;
+import org.eclipse.jdt.core.IBuffer;
+import org.eclipse.jdt.core.ICompilationUnit;
+import org.eclipse.jdt.core.IField;
+import org.eclipse.jdt.core.IJavaElement;
+import org.eclipse.jdt.core.ILocalVariable;
+import org.eclipse.jdt.core.IMethod;
+import org.eclipse.jdt.core.ISourceRange;
+import org.eclipse.jdt.core.ISourceReference;
+import org.eclipse.jdt.core.IType;
+import org.eclipse.jdt.core.JavaModelException;
+import org.eclipse.jdt.core.Signature;
+import org.eclipse.text.edits.InsertEdit;
+import org.eclipse.text.edits.MultiTextEdit;
+import org.eclipse.text.edits.ReplaceEdit;
+import org.eclipse.text.edits.TextEdit;
+import org.jboss.tools.cdi.core.CDIConstants;
+import org.jboss.tools.cdi.core.CDICorePlugin;
+import org.jboss.tools.cdi.core.IBean;
+import org.jboss.tools.cdi.core.IBeanField;
+import org.jboss.tools.cdi.core.IBeanMethod;
+import org.jboss.tools.cdi.core.IInjectionPoint;
+import org.jboss.tools.cdi.core.IInjectionPointField;
+import org.jboss.tools.cdi.core.IInjectionPointParameter;
+import org.jboss.tools.cdi.core.IQualifier;
+import org.jboss.tools.cdi.core.IQualifierDeclaration;
+import org.jboss.tools.common.refactoring.MarkerResolutionUtils;
+import org.jboss.tools.common.util.BeanUtil;
+
+/**
+ * @author Daniel Azarov
+ */
+public class CDIMarkerResolutionUtils extends MarkerResolutionUtils{
+
+ public static void addQualifier(String qualifiedName, String value, ICompilationUnit compilationUnit, IJavaElement element, MultiTextEdit rootEdit) throws JavaModelException{
+ if(!(element instanceof ISourceReference))
+ return;
+ IAnnotation annotation = findAnnotation(element, qualifiedName);
+ if(annotation != null && annotation.exists())
+ return;
+
+ boolean duplicateShortName = addImport(qualifiedName, compilationUnit, rootEdit);
+
+ String lineDelim = SPACE;
+
+ IBuffer buffer = compilationUnit.getBuffer();
+ String shortName = getShortName(qualifiedName);
+
+ if(!value.isEmpty())
+ value = "(\""+value+"\")";
+
+ if(duplicateShortName)
+ shortName = qualifiedName;
+
+ annotation = findAnnotation(element, CDIConstants.INJECT_ANNOTATION_TYPE_NAME);
+
+ if(rootEdit != null){
+ if(annotation != null && annotation.exists()){
+ TextEdit edit = new InsertEdit(annotation.getSourceRange().getOffset()+annotation.getSourceRange().getLength(), lineDelim+AT+shortName+value);
+ rootEdit.addChild(edit);
+ }else{
+ TextEdit edit = new InsertEdit(((ISourceReference)element).getSourceRange().getOffset(), AT+shortName+value+lineDelim);
+ rootEdit.addChild(edit);
+ }
+ }else{
+ if(annotation != null && annotation.exists()){
+ buffer.replace(annotation.getSourceRange().getOffset()+annotation.getSourceRange().getLength(), 0, lineDelim+AT+shortName+value);
+ }else{
+ buffer.replace(((ISourceReference)element).getSourceRange().getOffset(), 0, AT+shortName+value+lineDelim);
+ }
+
+ synchronized(compilationUnit) {
+ compilationUnit.reconcile(ICompilationUnit.NO_AST, true, null, null);
+ }
+ }
+ }
+
+ public static void updateQualifier(String qualifiedName, String value, ICompilationUnit compilationUnit, IJavaElement element, MultiTextEdit rootEdit) throws JavaModelException{
+ if(!(element instanceof ISourceReference))
+ return;
+ IAnnotation annotation = findAnnotation(element, qualifiedName);
+ if(annotation == null || !annotation.exists())
+ return;
+
+ boolean duplicateShortName = addImport(qualifiedName, compilationUnit, rootEdit);
+
+ IBuffer buffer = compilationUnit.getBuffer();
+ String shortName = getShortName(qualifiedName);
+
+ if(!value.isEmpty())
+ value = "(\""+value+"\")";
+
+ if(duplicateShortName)
+ shortName = qualifiedName;
+
+ String newValue = AT+shortName+value;
+
+ if(!annotation.getSource().equals(newValue)){
+ if(rootEdit != null){
+ TextEdit edit = new ReplaceEdit(annotation.getSourceRange().getOffset(), annotation.getSourceRange().getLength(), newValue);
+ rootEdit.addChild(edit);
+ }else{
+ buffer.replace(annotation.getSourceRange().getOffset(), annotation.getSourceRange().getLength(), newValue);
+
+ synchronized(compilationUnit) {
+ compilationUnit.reconcile(ICompilationUnit.NO_AST, true, null, null);
+ }
+ }
+ }
+ }
+
+ private static boolean contains(IQualifierDeclaration declaration, List<ValuedQualifier> declarations){
+ for(ValuedQualifier d : declarations){
+ if(declaration.getQualifier().getSourceType().getFullyQualifiedName().equals(d.getQualifier().getSourceType().getFullyQualifiedName()))
+ return true;
+ }
+ return false;
+ }
+
+ private static List<IQualifier> findQualifiersToDelete(IInjectionPoint injectionPoint, List<ValuedQualifier> qualifiers){
+ ArrayList<IQualifier> list = new ArrayList<IQualifier>();
+ Set<IQualifierDeclaration> declarations = injectionPoint.getQualifierDeclarations();
+ for(IQualifierDeclaration declaration : declarations){
+ if(!contains(declaration, qualifiers))
+ list.add(declaration.getQualifier());
+ }
+ return list;
+ }
+
+ private static void addQualifiersToParameter(ICompilationUnit compilationUnit, IInjectionPoint injectionPoint, List<ValuedQualifier> declarations, MultiTextEdit rootEdit){
+ HashMap<IQualifier, Boolean> duplicants = new HashMap<IQualifier, Boolean>();
+ if(!(injectionPoint instanceof IInjectionPointParameter))
+ return;
+ try{
+ for(ValuedQualifier declaration : declarations){
+ String qualifierName = declaration.getQualifier().getSourceType().getFullyQualifiedName();
+ boolean duplicant = false;
+ if(!qualifierName.equals(CDIConstants.ANY_QUALIFIER_TYPE_NAME) &&
+ !qualifierName.equals(CDIConstants.DEFAULT_QUALIFIER_TYPE_NAME)){
+ duplicant = addImport(qualifierName, compilationUnit, rootEdit);
+ }
+ duplicants.put(declaration.getQualifier(), new Boolean(duplicant));
+ }
+
+ String paramName = ((IInjectionPointParameter)injectionPoint).getName();
+ IMethod method = ((IInjectionPointParameter)injectionPoint).getBeanMethod().getMethod();
+ IType type = method.getDeclaringType();
+ IType t = compilationUnit.getType(type.getElementName());
+ IMethod m = t.getMethod(method.getElementName(), method.getParameterTypes());
+
+ IBuffer buffer = compilationUnit.getBuffer();
+
+ ILocalVariable[] parameters = m.getParameters();
+ for(int index = 0; index < parameters.length; index++){
+ if(parameters[index].getElementName().equals(paramName)){
+ StringBuffer b = new StringBuffer();
+ if(index > 0)
+ b.append(SPACE);
+ for(ValuedQualifier declaration : declarations){
+ String qualifierName = declaration.getQualifier().getSourceType().getFullyQualifiedName();
+ String value = declaration.getValue();
+
+ if(!value.isEmpty())
+ value = "(\""+value+"\")";
+
+ if(!qualifierName.equals(CDIConstants.ANY_QUALIFIER_TYPE_NAME) && !qualifierName.equals(CDIConstants.DEFAULT_QUALIFIER_TYPE_NAME)){
+ boolean duplicant = duplicants.get(declaration.getQualifier()).booleanValue();
+ String annotation = getShortName(qualifierName);
+ if(duplicant)
+ annotation = qualifierName;
+ b.append(AT+annotation+value+SPACE);
+ }
+ }
+ b.append(Signature.getSignatureSimpleName(parameters[index].getTypeSignature())+SPACE);
+ b.append(parameters[index].getElementName());
+
+ String newValue = b.toString();
+
+ if(!parameters[index].getSource().equals(newValue)){
+ if(rootEdit != null){
+ TextEdit edit = new ReplaceEdit(parameters[index].getSourceRange().getOffset(), parameters[index].getSourceRange().getLength(), b.toString());
+ rootEdit.addChild(edit);
+ }else{
+ buffer.replace(parameters[index].getSourceRange().getOffset(), parameters[index].getSourceRange().getLength(), b.toString());
+
+ synchronized(compilationUnit) {
+ compilationUnit.reconcile(ICompilationUnit.NO_AST, true, null, null);
+ }
+ }
+ }
+ }
+ }
+
+ }catch(JavaModelException ex){
+ CDICorePlugin.getDefault().logError(ex);
+ }
+ }
+
+ public static ISourceRange getParameterRegion(IInjectionPointParameter injectionParameter){
+ try{
+ String paramName = injectionParameter.getName();
+ IMethod method = injectionParameter.getBeanMethod().getMethod();
+
+ for(ILocalVariable parameter : method.getParameters()){
+ if(parameter.getElementName().equals(paramName)){
+ return parameter.getSourceRange();
+ }
+ }
+ }catch(JavaModelException ex){
+ CDICorePlugin.getDefault().logError(ex);
+ }
+ return null;
+ }
+
+ public static void addQualifiersToInjectionPoint(List<ValuedQualifier> deployed, IInjectionPoint injectionPoint, ICompilationUnit compilationUnit, MultiTextEdit edit){
+ try{
+ if(injectionPoint instanceof IInjectionPointParameter){
+ addQualifiersToParameter(compilationUnit, injectionPoint, deployed, edit);
+ }else{
+ IJavaElement element = getInjectedJavaElement(compilationUnit, injectionPoint);
+ if(element == null || !element.exists())
+ return;
+
+ // delete unneeded qualifiers
+ List<IQualifier> toDelete = findQualifiersToDelete(injectionPoint, deployed);
+
+ for(IQualifier qualifier : toDelete){
+ deleteAnnotation(qualifier.getSourceType().getFullyQualifiedName(), compilationUnit, element, edit);
+ }
+
+ for(ValuedQualifier declaration : deployed){
+ String qualifierName = declaration.getQualifier().getSourceType().getFullyQualifiedName();
+ String value = declaration.getValue();
+ if(!qualifierName.equals(CDIConstants.ANY_QUALIFIER_TYPE_NAME) && !qualifierName.equals(CDIConstants.DEFAULT_QUALIFIER_TYPE_NAME)){
+ addQualifier(qualifierName, value, compilationUnit, element, edit);
+ updateQualifier(qualifierName, value, compilationUnit, element, edit);
+ }
+ }
+ }
+ }catch(CoreException ex){
+ CDICorePlugin.getDefault().logError(ex);
+ }
+
+ }
+
+ public static void addQualifiersToBean(List<ValuedQualifier> deployed, IBean bean, ICompilationUnit compilationUnit, MultiTextEdit edit){
+ IJavaElement beanElement = null;
+ if(bean instanceof IBeanField){
+ beanElement = ((IBeanField) bean).getField();
+ }else if(bean instanceof IBeanMethod){
+ beanElement = ((IBeanMethod) bean).getMethod();
+ }else{
+ beanElement = bean.getBeanClass();
+ }
+
+ try{
+ for(IQualifierDeclaration declaration : bean.getQualifierDeclarations()){
+ IQualifier qualifier = declaration.getQualifier();
+ String qualifierName = qualifier.getSourceType().getFullyQualifiedName();
+ if(!isQualifierNeeded(deployed, qualifier)){
+ deleteAnnotation(qualifierName, compilationUnit, beanElement, edit);
+ }
+ }
+
+ for(ValuedQualifier vq : deployed){
+ String qualifierName = vq.getQualifier().getSourceType().getFullyQualifiedName();
+ String value = vq.getValue();
+ String elName = getELName(bean);
+
+ if(!value.isEmpty() && (!value.equals(elName) || !qualifierName.equals(CDIConstants.NAMED_QUALIFIER_TYPE_NAME))){
+ value = "(\""+value+"\")";
+ }else{
+ value = "";
+ }
+
+ if(!qualifierName.equals(CDIConstants.ANY_QUALIFIER_TYPE_NAME) && !qualifierName.equals(CDIConstants.DEFAULT_QUALIFIER_TYPE_NAME)){
+ addAnnotation(qualifierName, compilationUnit, beanElement, value, edit);
+ updateAnnotation(qualifierName, compilationUnit, beanElement, value, edit);
+ }
+
+ }
+ }catch(CoreException ex){
+ CDICorePlugin.getDefault().logError(ex);
+ }
+
+ }
+
+ private static boolean isQualifierNeeded(List<ValuedQualifier> vQualifiers, IQualifier qualifier){
+ for(ValuedQualifier vq : vQualifiers){
+ if(vq.getQualifier().equals(qualifier))
+ return true;
+ }
+ return false;
+ }
+
+ private static IJavaElement getInjectedJavaElement(ICompilationUnit compilationUnit, IInjectionPoint injectionPoint){
+ if(injectionPoint instanceof IInjectionPointField){
+ IField field = ((IInjectionPointField)injectionPoint).getField();
+ IType type = field.getDeclaringType();
+ IType t = compilationUnit.getType(type.getElementName());
+ IField f = t.getField(field.getElementName());
+
+ return f;
+ }else if(injectionPoint instanceof IInjectionPointParameter){
+ IMethod method = ((IInjectionPointParameter)injectionPoint).getBeanMethod().getMethod();
+ IType type = method.getDeclaringType();
+ IType t = compilationUnit.getType(type.getElementName());
+ IMethod m = t.getMethod(method.getElementName(), method.getParameterTypes());
+ // Why method? Why not Java element for parameter?
+ return m;
+ }
+ return null;
+ }
+
+ public static boolean checkBeanQualifiers(IBean selectedBean, IBean bean, Set<IQualifier> qualifiers){
+ HashSet<ValuedQualifier> valuedQualifiers = new HashSet<ValuedQualifier>();
+ for(IQualifier qualifier : qualifiers){
+ valuedQualifiers.add(new ValuedQualifier(qualifier));
+ }
+ return checkValuedQualifiers(selectedBean, bean, valuedQualifiers);
+ }
+
+ public static boolean checkValuedQualifiers(IBean selectedBean, IBean bean, Set<ValuedQualifier> qualifiers){
+ for(ValuedQualifier qualifier : qualifiers){
+ if(!isBeanContainQualifier(bean, qualifier)){
+ return false;
+ }
+ }
+ if(bean.getQualifiers().size() == qualifiers.size())
+ return true;
+ return false;
+ }
+
+ private static boolean isBeanContainQualifier(IBean bean, ValuedQualifier valuedQualifier){
+
+ Set<IQualifier> qualifiers = bean.getQualifiers();
+ for(IQualifier q : qualifiers){
+ if(q.getSourceType().getFullyQualifiedName().equals(valuedQualifier.getQualifier().getSourceType().getFullyQualifiedName()))
+ return true;
+ }
+ return false;
+ }
+
+ public static String findQualifierValue(IBean bean, IQualifier qualifier){
+ IQualifierDeclaration declaration = findQualifierDeclaration(bean, qualifier);
+ if(declaration == null)
+ return "";
+
+ return findQualifierValue(bean, declaration);
+ }
+
+ public static String findQualifierValue(IBean bean, IQualifierDeclaration declaration){
+ Object value = declaration.getMemberValue(null);
+
+ String result = value == null ? "" : value.toString();
+
+ if("".equals(result) && declaration.getQualifier().getSourceType().getFullyQualifiedName().equals(CDIConstants.NAMED_QUALIFIER_TYPE_NAME))
+ result = getELName(bean);
+
+ return result;
+ }
+
+ public static IQualifierDeclaration findQualifierDeclaration(IBean bean, IQualifier qualifier){
+ Set<IQualifierDeclaration> declarations = bean.getQualifierDeclarations();
+
+ if(declarations == null)
+ return null;
+
+ for(IQualifierDeclaration declaration : declarations){
+ if(declaration.getQualifier().getSourceType().getFullyQualifiedName().equals(qualifier.getSourceType().getFullyQualifiedName()))
+ return declaration;
+ }
+ return null;
+ }
+
+ public static String getELName(IBean bean){
+ String name;
+ if(bean instanceof IBeanField){
+ name = ((IBeanField) bean).getField().getElementName();
+ }else if(bean instanceof IBeanMethod){
+ name = ((IBeanMethod) bean).getMethod().getElementName();
+ if(BeanUtil.isGetter(((IBeanMethod) bean).getMethod())) {
+ return BeanUtil.getPropertyName(name);
+ }
+ }else{
+ name = bean.getBeanClass().getElementName();
+ if(name.length() > 0) {
+ name = name.substring(0, 1).toLowerCase() + name.substring(1);
+ }
+ }
+
+ return name;
+ }
+}
Property changes on: trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/refactoring/CDIMarkerResolutionUtils.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Deleted: trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/refactoring/MarkerResolutionUtils.java
===================================================================
--- trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/refactoring/MarkerResolutionUtils.java 2011-12-20 01:59:12 UTC (rev 37446)
+++ trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/refactoring/MarkerResolutionUtils.java 2011-12-20 02:11:31 UTC (rev 37447)
@@ -1,887 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010 Red Hat, Inc.
- * Distributed under license by Red Hat, Inc. All rights reserved.
- * This program is 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:
- * Red Hat, Inc. - initial API and implementation
- ******************************************************************************/
-package org.jboss.tools.cdi.internal.core.refactoring;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.NullProgressMonitor;
-import org.eclipse.jdt.core.Flags;
-import org.eclipse.jdt.core.IAnnotatable;
-import org.eclipse.jdt.core.IAnnotation;
-import org.eclipse.jdt.core.IBuffer;
-import org.eclipse.jdt.core.ICompilationUnit;
-import org.eclipse.jdt.core.IField;
-import org.eclipse.jdt.core.IImportContainer;
-import org.eclipse.jdt.core.IImportDeclaration;
-import org.eclipse.jdt.core.IJavaElement;
-import org.eclipse.jdt.core.ILocalVariable;
-import org.eclipse.jdt.core.IMember;
-import org.eclipse.jdt.core.IMethod;
-import org.eclipse.jdt.core.IPackageDeclaration;
-import org.eclipse.jdt.core.ISourceRange;
-import org.eclipse.jdt.core.ISourceReference;
-import org.eclipse.jdt.core.IType;
-import org.eclipse.jdt.core.ITypeParameter;
-import org.eclipse.jdt.core.JavaModelException;
-import org.eclipse.jdt.core.Signature;
-import org.eclipse.text.edits.DeleteEdit;
-import org.eclipse.text.edits.InsertEdit;
-import org.eclipse.text.edits.MultiTextEdit;
-import org.eclipse.text.edits.ReplaceEdit;
-import org.eclipse.text.edits.TextEdit;
-import org.jboss.tools.cdi.core.CDIConstants;
-import org.jboss.tools.cdi.core.CDICorePlugin;
-import org.jboss.tools.cdi.core.IBean;
-import org.jboss.tools.cdi.core.IBeanField;
-import org.jboss.tools.cdi.core.IBeanMethod;
-import org.jboss.tools.cdi.core.IInjectionPoint;
-import org.jboss.tools.cdi.core.IInjectionPointField;
-import org.jboss.tools.cdi.core.IInjectionPointParameter;
-import org.jboss.tools.cdi.core.IQualifier;
-import org.jboss.tools.cdi.core.IQualifierDeclaration;
-import org.jboss.tools.common.model.util.EclipseJavaUtil;
-import org.jboss.tools.common.util.BeanUtil;
-
-/**
- * @author Daniel Azarov
- */
-public class MarkerResolutionUtils {
- public static final String DOT = "."; //$NON-NLS-1$
- public static final String COMMA = ","; //$NON-NLS-1$
- public static final String SEMICOLON = ";"; //$NON-NLS-1$
- public static final String SPACE = " "; //$NON-NLS-1$
- public static final String AT = "@"; //$NON-NLS-1$
- public static final String IMPLEMENTS = "implements"; //$NON-NLS-1$
- public static final String IMPORT = "import"; //$NON-NLS-1$
- public static final String EXTENDS = "extends"; //$NON-NLS-1$
- public static final String OPEN_BRACE = "{"; //$NON-NLS-1$
- public static final String CLOSE_BRACE = "}"; //$NON-NLS-1$
-
- static final HashSet<String> primitives = new HashSet<String>();
- static{
- primitives.add("void"); //$NON-NLS-1$
- primitives.add("int"); //$NON-NLS-1$
- primitives.add("java.lang.Integer"); //$NON-NLS-1$
- primitives.add("char"); //$NON-NLS-1$
- primitives.add("java.lang.Character"); //$NON-NLS-1$
- primitives.add("boolean"); //$NON-NLS-1$
- primitives.add("java.lang.Boolean"); //$NON-NLS-1$
- primitives.add("short"); //$NON-NLS-1$
- primitives.add("java.lang.Short"); //$NON-NLS-1$
- primitives.add("long"); //$NON-NLS-1$
- primitives.add("java.lang.Long"); //$NON-NLS-1$
- primitives.add("float"); //$NON-NLS-1$
- primitives.add("java.lang.Float"); //$NON-NLS-1$
- primitives.add("double"); //$NON-NLS-1$
- primitives.add("java.lang.Double"); //$NON-NLS-1$
- primitives.add("byte"); //$NON-NLS-1$
- primitives.add("java.lang.Byte"); //$NON-NLS-1$
- primitives.add("java.lang.String"); //$NON-NLS-1$
- }
-
- /**
- *
- * @param qualifiedName
- * @param compilationUnit
- * @return true if there is import in compilation unit with the same short name
- * @throws JavaModelException
- */
- public static boolean addImport(String qualifiedName, ICompilationUnit compilationUnit) throws JavaModelException{
- return addImport(qualifiedName, compilationUnit, false, null);
- }
-
- public static boolean addImport(String qualifiedName, ICompilationUnit compilationUnit, MultiTextEdit rootEdit) throws JavaModelException{
- return addImport(qualifiedName, compilationUnit, false, rootEdit);
- }
-
- /**
- *
- * @param qualifiedName
- * @param compilationUnit
- * @param staticFlag
- * @return true if there is import in compilation unit with the same short name
- * @throws JavaModelException
- */
- public static boolean addImport(String qualifiedName, ICompilationUnit compilationUnit, boolean staticFlag) throws JavaModelException{
- return addImport(qualifiedName, compilationUnit, staticFlag, null);
- }
-
- public static boolean addImport(String qualifiedName, ICompilationUnit compilationUnit, boolean staticFlag, MultiTextEdit rootEdit) throws JavaModelException{
- if(primitives.contains(qualifiedName))
- return false;
-
- if(qualifiedName != null){
- String shortName = getShortName(qualifiedName);
-
- IPackageDeclaration[] packages = compilationUnit.getPackageDeclarations();
-
- // local classes do not need to be imported
- if(qualifiedName.indexOf(DOT) >= 0){
- String typePackage = qualifiedName.substring(0,qualifiedName.lastIndexOf(DOT));
-
- for(IPackageDeclaration packageDeclaration : packages){
- if(packageDeclaration.getElementName().equals(typePackage))
- return false;
- }
-
- for(IPackageDeclaration packageDeclaration : packages){
- IType type = compilationUnit.getJavaProject().findType(packageDeclaration.getElementName()+DOT+shortName);
- if(type != null && type.exists())
- return true;
- }
- }
-
- IImportDeclaration[] importDeclarations = compilationUnit.getImports();
-
- for(IImportDeclaration importDeclaration : importDeclarations){
- String importName = importDeclaration.getElementName();
- String elementShort = getShortName(importName);
- if(importDeclaration.isOnDemand()){
- int importLastDot = importName.lastIndexOf(DOT);
- if(importLastDot == -1) return false; // invalid import declaration
- int elementLastDot = qualifiedName.lastIndexOf(DOT);
- if(elementLastDot == -1) return false; // invalid import declaration
-
- if(qualifiedName.substring(0, elementLastDot).equals(importName.substring(0, importLastDot)))
- return false;
- }
-
- if(importName.equals(qualifiedName))
- return false;
- if(elementShort.equals(shortName))
- return true;
-
- }
- if(rootEdit == null){
- if(staticFlag){
- compilationUnit.createImport(qualifiedName, null, Flags.AccStatic, new NullProgressMonitor());
- }else{
- compilationUnit.createImport(qualifiedName, null, new NullProgressMonitor());
- }
- }else{
- String text = compilationUnit.findRecommendedLineSeparator()+IMPORT+SPACE+qualifiedName+SEMICOLON;
- if(!isDuplicate(rootEdit, text)){
- int importPosition = findPositionForImport(compilationUnit);
- TextEdit edit = new InsertEdit(importPosition, text);
- rootEdit.addChild(edit);
- }
- }
- }
- return false;
- }
-
-
- private static int findPositionForImport(ICompilationUnit compilationUnit) throws JavaModelException{
- if(compilationUnit.getImportContainer().exists()){
- return compilationUnit.getImportContainer().getSourceRange().getOffset()+compilationUnit.getImportContainer().getSourceRange().getLength();
- }else{
- IPackageDeclaration[] packageDeclarations = compilationUnit.getPackageDeclarations();
- if(packageDeclarations.length == 0){
- return 0;
- }
- int position = 0;
- for(IPackageDeclaration declaration : packageDeclarations){
- position = declaration.getSourceRange().getOffset()+declaration.getSourceRange().getLength();
- }
- return position;
- }
- }
-
- private static boolean isDuplicate(MultiTextEdit rootEdit, String text){
- for(TextEdit edit : rootEdit.getChildren()){
- if(edit instanceof InsertEdit && ((InsertEdit) edit).getText().equals(text))
- return true;
- }
- return false;
- }
-
- public static void addAnnotation(String qualifiedName, ICompilationUnit compilationUnit, IJavaElement element) throws JavaModelException{
- addAnnotation(qualifiedName, compilationUnit, element, "");
- }
- public static void updateAnnotation(String qualifiedName, ICompilationUnit compilationUnit, IJavaElement element, String params) throws JavaModelException{
- updateAnnotation(qualifiedName, compilationUnit, element, params, null);
- }
-
- public static void updateAnnotation(String qualifiedName, ICompilationUnit compilationUnit, IJavaElement element, String params, MultiTextEdit rootEdit) throws JavaModelException{
- IJavaElement workingCopyElement = findWorkingCopy(compilationUnit, element);
- if(workingCopyElement == null){
- return;
- }
-
- if(!(workingCopyElement instanceof IMember))
- return;
-
- IMember workingCopyMember = (IMember) workingCopyElement;
-
- IAnnotation annotation = findAnnotation(workingCopyMember, qualifiedName);
- if(annotation == null || !annotation.exists())
- return;
-
- boolean duplicateShortName = addImport(qualifiedName, compilationUnit, null);
-
- IBuffer buffer = compilationUnit.getBuffer();
- String shortName = getShortName(qualifiedName);
-
- if(duplicateShortName)
- shortName = qualifiedName;
-
- String newValue = AT+shortName+params;
-
- if(!annotation.getSource().equals(newValue)){
- if(rootEdit != null){
- TextEdit edit = new ReplaceEdit(annotation.getSourceRange().getOffset(), annotation.getSourceRange().getLength(), newValue);
- rootEdit.addChild(edit);
- }else{
- buffer.replace(annotation.getSourceRange().getOffset(), annotation.getSourceRange().getLength(), newValue);
-
- synchronized(compilationUnit) {
- compilationUnit.reconcile(ICompilationUnit.NO_AST, true, null, null);
- }
- }
- }
-
- }
-
- public static void addAnnotation(String qualifiedName, ICompilationUnit compilationUnit, IJavaElement element, String params) throws JavaModelException{
- addAnnotation(qualifiedName, compilationUnit, element, params, null);
- }
-
- public static void addAnnotation(String qualifiedName, ICompilationUnit compilationUnit, IJavaElement element, String params, MultiTextEdit rootEdit) throws JavaModelException{
- IJavaElement workingCopyElement = findWorkingCopy(compilationUnit, element);
- if(workingCopyElement == null){
- return;
- }
-
- if(!(workingCopyElement instanceof IMember))
- return;
-
- IMember workingCopyMember = (IMember) workingCopyElement;
-
- IAnnotation annotation = findAnnotation(workingCopyMember, qualifiedName);
- if(annotation != null && annotation.exists())
- return;
-
- boolean duplicateShortName = addImport(qualifiedName, compilationUnit, rootEdit);
-
- IBuffer buffer = compilationUnit.getBuffer();
- String shortName = getShortName(qualifiedName);
-
- if(duplicateShortName)
- shortName = qualifiedName;
-
- String str = AT+shortName+params;
-
- if(workingCopyMember instanceof IType){
- str += compilationUnit.findRecommendedLineSeparator();
- }else{
- str += SPACE;
- }
-
- if(rootEdit != null){
- TextEdit edit = new InsertEdit(workingCopyMember.getSourceRange().getOffset(), str);
- rootEdit.addChild(edit);
- }else{
- buffer.replace(workingCopyMember.getSourceRange().getOffset(), 0, str);
-
- synchronized(compilationUnit) {
- compilationUnit.reconcile(ICompilationUnit.NO_AST, true, null, null);
- }
- }
-
-
-
- }
-
- public static void addQualifier(String qualifiedName, String value, ICompilationUnit compilationUnit, IJavaElement element, MultiTextEdit rootEdit) throws JavaModelException{
- if(!(element instanceof ISourceReference))
- return;
- IAnnotation annotation = findAnnotation(element, qualifiedName);
- if(annotation != null && annotation.exists())
- return;
-
- boolean duplicateShortName = addImport(qualifiedName, compilationUnit, rootEdit);
-
- String lineDelim = SPACE;
-
- IBuffer buffer = compilationUnit.getBuffer();
- String shortName = getShortName(qualifiedName);
-
- if(!value.isEmpty())
- value = "(\""+value+"\")";
-
- if(duplicateShortName)
- shortName = qualifiedName;
-
- annotation = findAnnotation(element, CDIConstants.INJECT_ANNOTATION_TYPE_NAME);
-
- if(rootEdit != null){
- if(annotation != null && annotation.exists()){
- TextEdit edit = new InsertEdit(annotation.getSourceRange().getOffset()+annotation.getSourceRange().getLength(), lineDelim+AT+shortName+value);
- rootEdit.addChild(edit);
- }else{
- TextEdit edit = new InsertEdit(((ISourceReference)element).getSourceRange().getOffset(), AT+shortName+value+lineDelim);
- rootEdit.addChild(edit);
- }
- }else{
- if(annotation != null && annotation.exists()){
- buffer.replace(annotation.getSourceRange().getOffset()+annotation.getSourceRange().getLength(), 0, lineDelim+AT+shortName+value);
- }else{
- buffer.replace(((ISourceReference)element).getSourceRange().getOffset(), 0, AT+shortName+value+lineDelim);
- }
-
- synchronized(compilationUnit) {
- compilationUnit.reconcile(ICompilationUnit.NO_AST, true, null, null);
- }
- }
- }
-
- public static void updateQualifier(String qualifiedName, String value, ICompilationUnit compilationUnit, IJavaElement element, MultiTextEdit rootEdit) throws JavaModelException{
- if(!(element instanceof ISourceReference))
- return;
- IAnnotation annotation = findAnnotation(element, qualifiedName);
- if(annotation == null || !annotation.exists())
- return;
-
- boolean duplicateShortName = addImport(qualifiedName, compilationUnit, rootEdit);
-
- IBuffer buffer = compilationUnit.getBuffer();
- String shortName = getShortName(qualifiedName);
-
- if(!value.isEmpty())
- value = "(\""+value+"\")";
-
- if(duplicateShortName)
- shortName = qualifiedName;
-
- String newValue = AT+shortName+value;
-
- if(!annotation.getSource().equals(newValue)){
- if(rootEdit != null){
- TextEdit edit = new ReplaceEdit(annotation.getSourceRange().getOffset(), annotation.getSourceRange().getLength(), newValue);
- rootEdit.addChild(edit);
- }else{
- buffer.replace(annotation.getSourceRange().getOffset(), annotation.getSourceRange().getLength(), newValue);
-
- synchronized(compilationUnit) {
- compilationUnit.reconcile(ICompilationUnit.NO_AST, true, null, null);
- }
- }
- }
- }
-
- public static String getShortName(String qualifiedName){
- int lastDot = qualifiedName.lastIndexOf(DOT);
- String name;
- if(lastDot < 0)
- name = qualifiedName;
- else
- name = qualifiedName.substring(lastDot+1);
- return name;
- }
-
- public static String getPackageName(String qualifiedName){
- int lastDot = qualifiedName.lastIndexOf(DOT);
- String name;
- if(lastDot < 0)
- name = "";
- else
- name = qualifiedName.substring(0, lastDot);
- return name;
- }
-
- public static String[] getShortNames(String[] qualifiedNames){
- String[] shortNames = new String[qualifiedNames.length];
- for(int i = 0; i < qualifiedNames.length; i++){
- shortNames[i] = getShortName(qualifiedNames[i]);
- }
- return shortNames;
- }
-
- public static String getTotalList(String[] names){
- String list = "";
- for(int i = 0; i < names.length; i++){
- if(i != 0)
- list += ", ";
- list += names[i];
- }
- return list;
- }
-
- public static IAnnotation findAnnotation(IJavaElement element, String qualifiedName){
- if(element instanceof IAnnotatable){
- String name = getShortName(qualifiedName);
- IAnnotation annotation = ((IAnnotatable)element).getAnnotation(qualifiedName);
- if (!annotation.exists()) {
- annotation = ((IAnnotatable)element).getAnnotation(name);
- } else {
- return annotation;
- }
- if(annotation.exists()) {
- IType type=null;
- if(element instanceof IType){
- type = (IType)element;
- }else if(element instanceof IMember){
- type = ((IMember)element).getDeclaringType();
- }else if(element instanceof ITypeParameter){
- type = ((ITypeParameter)element).getDeclaringMember().getDeclaringType();
- }else if(element instanceof ILocalVariable){
- type = ((ILocalVariable)element).getDeclaringMember().getDeclaringType();
- }
- if (type != null && annotation != null && qualifiedName.equals(EclipseJavaUtil.resolveType(type, name))) {
- return annotation;
- }
- }
- }
- return null;
- }
-
- private static boolean contains(IQualifierDeclaration declaration, List<ValuedQualifier> declarations){
- for(ValuedQualifier d : declarations){
- if(declaration.getQualifier().getSourceType().getFullyQualifiedName().equals(d.getQualifier().getSourceType().getFullyQualifiedName()))
- return true;
- }
- return false;
- }
-
- private static List<IQualifier> findQualifiersToDelete(IInjectionPoint injectionPoint, List<ValuedQualifier> qualifiers){
- ArrayList<IQualifier> list = new ArrayList<IQualifier>();
- Set<IQualifierDeclaration> declarations = injectionPoint.getQualifierDeclarations();
- for(IQualifierDeclaration declaration : declarations){
- if(!contains(declaration, qualifiers))
- list.add(declaration.getQualifier());
- }
- return list;
- }
-
- private static void addQualifiersToParameter(ICompilationUnit compilationUnit, IInjectionPoint injectionPoint, List<ValuedQualifier> declarations, MultiTextEdit rootEdit){
- HashMap<IQualifier, Boolean> duplicants = new HashMap<IQualifier, Boolean>();
- if(!(injectionPoint instanceof IInjectionPointParameter))
- return;
- try{
- for(ValuedQualifier declaration : declarations){
- String qualifierName = declaration.getQualifier().getSourceType().getFullyQualifiedName();
- boolean duplicant = false;
- if(!qualifierName.equals(CDIConstants.ANY_QUALIFIER_TYPE_NAME) &&
- !qualifierName.equals(CDIConstants.DEFAULT_QUALIFIER_TYPE_NAME)){
- duplicant = addImport(qualifierName, compilationUnit, rootEdit);
- }
- duplicants.put(declaration.getQualifier(), new Boolean(duplicant));
- }
-
- String paramName = ((IInjectionPointParameter)injectionPoint).getName();
- IMethod method = ((IInjectionPointParameter)injectionPoint).getBeanMethod().getMethod();
- IType type = method.getDeclaringType();
- IType t = compilationUnit.getType(type.getElementName());
- IMethod m = t.getMethod(method.getElementName(), method.getParameterTypes());
-
- IBuffer buffer = compilationUnit.getBuffer();
-
- ILocalVariable[] parameters = m.getParameters();
- for(int index = 0; index < parameters.length; index++){
- if(parameters[index].getElementName().equals(paramName)){
- StringBuffer b = new StringBuffer();
- if(index > 0)
- b.append(SPACE);
- for(ValuedQualifier declaration : declarations){
- String qualifierName = declaration.getQualifier().getSourceType().getFullyQualifiedName();
- String value = declaration.getValue();
-
- if(!value.isEmpty())
- value = "(\""+value+"\")";
-
- if(!qualifierName.equals(CDIConstants.ANY_QUALIFIER_TYPE_NAME) && !qualifierName.equals(CDIConstants.DEFAULT_QUALIFIER_TYPE_NAME)){
- boolean duplicant = duplicants.get(declaration.getQualifier()).booleanValue();
- String annotation = getShortName(qualifierName);
- if(duplicant)
- annotation = qualifierName;
- b.append(AT+annotation+value+SPACE);
- }
- }
- b.append(Signature.getSignatureSimpleName(parameters[index].getTypeSignature())+SPACE);
- b.append(parameters[index].getElementName());
-
- String newValue = b.toString();
-
- if(!parameters[index].getSource().equals(newValue)){
- if(rootEdit != null){
- TextEdit edit = new ReplaceEdit(parameters[index].getSourceRange().getOffset(), parameters[index].getSourceRange().getLength(), b.toString());
- rootEdit.addChild(edit);
- }else{
- buffer.replace(parameters[index].getSourceRange().getOffset(), parameters[index].getSourceRange().getLength(), b.toString());
-
- synchronized(compilationUnit) {
- compilationUnit.reconcile(ICompilationUnit.NO_AST, true, null, null);
- }
- }
- }
- }
- }
-
- }catch(JavaModelException ex){
- CDICorePlugin.getDefault().logError(ex);
- }
- }
-
- public static ISourceRange getParameterRegion(IInjectionPointParameter injectionParameter){
- try{
- String paramName = injectionParameter.getName();
- IMethod method = injectionParameter.getBeanMethod().getMethod();
-
- for(ILocalVariable parameter : method.getParameters()){
- if(parameter.getElementName().equals(paramName)){
- return parameter.getSourceRange();
- }
- }
- }catch(JavaModelException ex){
- CDICorePlugin.getDefault().logError(ex);
- }
- return null;
- }
-
- public static void addQualifiersToInjectionPoint(List<ValuedQualifier> deployed, IInjectionPoint injectionPoint, ICompilationUnit compilationUnit, MultiTextEdit edit){
- try{
- if(injectionPoint instanceof IInjectionPointParameter){
- addQualifiersToParameter(compilationUnit, injectionPoint, deployed, edit);
- }else{
- IJavaElement element = getInjectedJavaElement(compilationUnit, injectionPoint);
- if(element == null || !element.exists())
- return;
-
- // delete unneeded qualifiers
- List<IQualifier> toDelete = findQualifiersToDelete(injectionPoint, deployed);
-
- for(IQualifier qualifier : toDelete){
- deleteAnnotation(qualifier.getSourceType().getFullyQualifiedName(), compilationUnit, element, edit);
- }
-
- for(ValuedQualifier declaration : deployed){
- String qualifierName = declaration.getQualifier().getSourceType().getFullyQualifiedName();
- String value = declaration.getValue();
- if(!qualifierName.equals(CDIConstants.ANY_QUALIFIER_TYPE_NAME) && !qualifierName.equals(CDIConstants.DEFAULT_QUALIFIER_TYPE_NAME)){
- addQualifier(qualifierName, value, compilationUnit, element, edit);
- updateQualifier(qualifierName, value, compilationUnit, element, edit);
- }
- }
- }
- }catch(CoreException ex){
- CDICorePlugin.getDefault().logError(ex);
- }
-
- }
-
- public static void addQualifiersToBean(List<ValuedQualifier> deployed, IBean bean, ICompilationUnit compilationUnit, MultiTextEdit edit){
- IJavaElement beanElement = null;
- if(bean instanceof IBeanField){
- beanElement = ((IBeanField) bean).getField();
- }else if(bean instanceof IBeanMethod){
- beanElement = ((IBeanMethod) bean).getMethod();
- }else{
- beanElement = bean.getBeanClass();
- }
-
- try{
- for(IQualifierDeclaration declaration : bean.getQualifierDeclarations()){
- IQualifier qualifier = declaration.getQualifier();
- String qualifierName = qualifier.getSourceType().getFullyQualifiedName();
- if(!isQualifierNeeded(deployed, qualifier)){
- deleteAnnotation(qualifierName, compilationUnit, beanElement, edit);
- }
- }
-
- for(ValuedQualifier vq : deployed){
- String qualifierName = vq.getQualifier().getSourceType().getFullyQualifiedName();
- String value = vq.getValue();
- String elName = getELName(bean);
-
- if(!value.isEmpty() && (!value.equals(elName) || !qualifierName.equals(CDIConstants.NAMED_QUALIFIER_TYPE_NAME))){
- value = "(\""+value+"\")";
- }else{
- value = "";
- }
-
- if(!qualifierName.equals(CDIConstants.ANY_QUALIFIER_TYPE_NAME) && !qualifierName.equals(CDIConstants.DEFAULT_QUALIFIER_TYPE_NAME)){
- addAnnotation(qualifierName, compilationUnit, beanElement, value, edit);
- updateAnnotation(qualifierName, compilationUnit, beanElement, value, edit);
- }
-
- }
- }catch(CoreException ex){
- CDICorePlugin.getDefault().logError(ex);
- }
-
- }
-
- private static boolean isQualifierNeeded(List<ValuedQualifier> vQualifiers, IQualifier qualifier){
- for(ValuedQualifier vq : vQualifiers){
- if(vq.getQualifier().equals(qualifier))
- return true;
- }
- return false;
- }
-
- public static void addInterfaceToClass(ICompilationUnit compilationUnit, IType type, String qualifiedName) throws JavaModelException{
- String shortName = getShortName(qualifiedName);
-
- IType[] types = compilationUnit.getTypes();
- IType workingType = null;
- for(IType t : types){
- if(t.getElementName().equals(type.getElementName())){
- workingType = t;
- break;
- }
- }
-
- if(workingType != null){
- addImport(qualifiedName, compilationUnit, null);
-
- IBuffer buffer = compilationUnit.getBuffer();
-
- String text = buffer.getText(workingType.getSourceRange().getOffset(), workingType.getSourceRange().getLength());
-
- int namePosition = text.indexOf(workingType.getElementName());
- if(namePosition >= 0){
- int implementsPosition = text.indexOf(IMPLEMENTS,namePosition);
- if(implementsPosition > 0){
- buffer.replace(workingType.getSourceRange().getOffset()+implementsPosition+IMPLEMENTS.length(),0,SPACE+shortName+COMMA);
- }else{
- int extedsPosition = text.indexOf(EXTENDS,namePosition);
- if(extedsPosition > 0){
- int bracePosition = text.indexOf(OPEN_BRACE, extedsPosition);
- String str = IMPLEMENTS+SPACE+shortName+SPACE;
- if(!text.substring(bracePosition-1,bracePosition).equals(SPACE))
- str = SPACE+str;
- buffer.replace(workingType.getSourceRange().getOffset()+bracePosition,0,str);
- }else{
- buffer.replace(workingType.getSourceRange().getOffset()+namePosition+workingType.getElementName().length(),0,SPACE+IMPLEMENTS+SPACE+shortName);
- }
- }
- }
- }
-
- }
-
- private static IJavaElement getInjectedJavaElement(ICompilationUnit compilationUnit, IInjectionPoint injectionPoint){
- if(injectionPoint instanceof IInjectionPointField){
- IField field = ((IInjectionPointField)injectionPoint).getField();
- IType type = field.getDeclaringType();
- IType t = compilationUnit.getType(type.getElementName());
- IField f = t.getField(field.getElementName());
-
- return f;
- }else if(injectionPoint instanceof IInjectionPointParameter){
- IMethod method = ((IInjectionPointParameter)injectionPoint).getBeanMethod().getMethod();
- IType type = method.getDeclaringType();
- IType t = compilationUnit.getType(type.getElementName());
- IMethod m = t.getMethod(method.getElementName(), method.getParameterTypes());
- // Why method? Why not Java element for parameter?
- return m;
- }
- return null;
- }
-
- @SuppressWarnings("unchecked")
- public static <T extends IJavaElement> T findWorkingCopy(ICompilationUnit compilationUnit, T element) throws JavaModelException{
- if(element instanceof IAnnotation){
- IJavaElement parent = findWorkingCopy(compilationUnit, element.getParent());
- if(parent instanceof IAnnotatable){
- for(IAnnotation a : ((IAnnotatable)parent).getAnnotations()){
- if(a.getElementName().equals(element.getElementName()))
- return (T)a;
- }
- }
- }else if(element instanceof ILocalVariable && ((ILocalVariable) element).isParameter()){
- IJavaElement parent = findWorkingCopy(compilationUnit, element.getParent());
- if(parent instanceof IMethod){
- for(ILocalVariable parameter : ((IMethod)parent).getParameters()){
- if(parameter.getElementName().equals(element.getElementName()) && parameter.getTypeSignature().equals(((ILocalVariable)element).getTypeSignature()))
- return (T)parameter;
- }
- }
- }else{
- IJavaElement[] elements = compilationUnit.findElements(element);
- if(elements != null){
- for(IJavaElement e : elements){
- if(e.getClass().equals(element.getClass()))
- return (T)e;
- }
- }
- }
- return null;
- }
-
- public static void deleteAnnotation(String qualifiedName, ICompilationUnit compilationUnit, IJavaElement element) throws JavaModelException{
- deleteAnnotation(qualifiedName, compilationUnit, element, null);
- }
-
- public static void deleteAnnotation(String qualifiedName, ICompilationUnit compilationUnit, IJavaElement element, MultiTextEdit rootEdit) throws JavaModelException{
- IJavaElement workingCopyElement = findWorkingCopy(compilationUnit, element);
- if(workingCopyElement == null){
- return;
- }
-
- IAnnotation annotation = findAnnotation(workingCopyElement, qualifiedName);
- if(annotation != null){
- IBuffer buffer = compilationUnit.getBuffer();
-
- int position = annotation.getSourceRange().getOffset() + annotation.getSourceRange().getLength();
- int numberOfSpaces = 0;
- if(position < buffer.getLength()-1){
- char c = buffer.getChar(position);
- while((c == ' ' || c == '\t' || c == '\n' || c == '\r') && position < buffer.getLength()-1){
- numberOfSpaces++;
- position++;
- c = buffer.getChar(position);
- }
- }
-
- // delete annotation
- if(rootEdit != null){
- TextEdit edit = new DeleteEdit(annotation.getSourceRange().getOffset(), annotation.getSourceRange().getLength());
- rootEdit.addChild(edit);
- }else{
- buffer.replace(annotation.getSourceRange().getOffset(), annotation.getSourceRange().getLength()+numberOfSpaces, "");
- }
-
- // check and delete import
- IImportDeclaration importDeclaration = compilationUnit.getImport(qualifiedName);
- IImportContainer importContainer = compilationUnit.getImportContainer();
- if(importDeclaration.exists() && importContainer.exists()){
- int importSize = importContainer.getSourceRange().getOffset()+importContainer.getSourceRange().getLength();
-
- if(rootEdit != null){
- int annotationStart = annotation.getSourceRange().getOffset();
- int annotationEnd = annotationStart+annotation.getSourceRange().getLength();
- String textBefore = buffer.getText(importSize, annotationStart-importSize);
- String textAfter = buffer.getText(annotationEnd, buffer.getLength()-annotationEnd);
- if(checkImport(textBefore, qualifiedName) && checkImport(textAfter, qualifiedName)){
- TextEdit edit = new DeleteEdit(importDeclaration.getSourceRange().getOffset(), importDeclaration.getSourceRange().getLength());
- rootEdit.addChild(edit);
- }
- }else{
- String text = buffer.getText(importSize, buffer.getLength()-importSize);
- if(checkImport(text, qualifiedName)){
- importDeclaration.delete(false, new NullProgressMonitor());
- }
- }
- }
-
- if(rootEdit == null){
- synchronized(compilationUnit) {
- compilationUnit.reconcile(ICompilationUnit.NO_AST, true, null, null);
- }
- }
- }
- }
-
- private static boolean checkImport(String text, String qualifiedName){
- String name = getShortName(qualifiedName);
-
- Pattern p = Pattern.compile(".*\\W"+name+"\\W.*",Pattern.DOTALL); //$NON-NLS-1$ //$NON-NLS-2$
- Matcher m = p.matcher(text);
- return !m.matches();
- }
-
- public static IMember getJavaMember(IJavaElement element){
- while(element != null){
- if(element instanceof IMember)
- return (IMember)element;
- element = element.getParent();
- }
- return null;
- }
-
- public static boolean checkBeanQualifiers(IBean selectedBean, IBean bean, Set<IQualifier> qualifiers){
- HashSet<ValuedQualifier> valuedQualifiers = new HashSet<ValuedQualifier>();
- for(IQualifier qualifier : qualifiers){
- valuedQualifiers.add(new ValuedQualifier(qualifier));
- }
- return checkValuedQualifiers(selectedBean, bean, valuedQualifiers);
- }
-
- public static boolean checkValuedQualifiers(IBean selectedBean, IBean bean, Set<ValuedQualifier> qualifiers){
- for(ValuedQualifier qualifier : qualifiers){
- if(!isBeanContainQualifier(bean, qualifier)){
- return false;
- }
- }
- if(bean.getQualifiers().size() == qualifiers.size())
- return true;
- return false;
- }
-
- private static boolean isBeanContainQualifier(IBean bean, ValuedQualifier valuedQualifier){
-
- Set<IQualifier> qualifiers = bean.getQualifiers();
- for(IQualifier q : qualifiers){
- if(q.getSourceType().getFullyQualifiedName().equals(valuedQualifier.getQualifier().getSourceType().getFullyQualifiedName()))
- return true;
- }
- return false;
- }
-
- public static String findQualifierValue(IBean bean, IQualifier qualifier){
- IQualifierDeclaration declaration = findQualifierDeclaration(bean, qualifier);
- if(declaration == null)
- return "";
-
- return findQualifierValue(bean, declaration);
- }
-
- public static String findQualifierValue(IBean bean, IQualifierDeclaration declaration){
- Object value = declaration.getMemberValue(null);
-
- String result = value == null ? "" : value.toString();
-
- if("".equals(result) && declaration.getQualifier().getSourceType().getFullyQualifiedName().equals(CDIConstants.NAMED_QUALIFIER_TYPE_NAME))
- result = getELName(bean);
-
- return result;
- }
-
- public static IQualifierDeclaration findQualifierDeclaration(IBean bean, IQualifier qualifier){
- Set<IQualifierDeclaration> declarations = bean.getQualifierDeclarations();
-
- if(declarations == null)
- return null;
-
- for(IQualifierDeclaration declaration : declarations){
- if(declaration.getQualifier().getSourceType().getFullyQualifiedName().equals(qualifier.getSourceType().getFullyQualifiedName()))
- return declaration;
- }
- return null;
- }
-
- public static String getELName(IBean bean){
- String name;
- if(bean instanceof IBeanField){
- name = ((IBeanField) bean).getField().getElementName();
- }else if(bean instanceof IBeanMethod){
- name = ((IBeanMethod) bean).getMethod().getElementName();
- if(BeanUtil.isGetter(((IBeanMethod) bean).getMethod())) {
- return BeanUtil.getPropertyName(name);
- }
- }else{
- name = bean.getBeanClass().getElementName();
- if(name.length() > 0) {
- name = name.substring(0, 1).toLowerCase() + name.substring(1);
- }
- }
-
- return name;
- }
-}
Modified: trunk/cdi/plugins/org.jboss.tools.cdi.seam.text.ext/src/org/jboss/tools/cdi/seam/text/ext/hyperlink/CDISeamResourceLoadingHyperlinkDetector.java
===================================================================
--- trunk/cdi/plugins/org.jboss.tools.cdi.seam.text.ext/src/org/jboss/tools/cdi/seam/text/ext/hyperlink/CDISeamResourceLoadingHyperlinkDetector.java 2011-12-20 01:59:12 UTC (rev 37446)
+++ trunk/cdi/plugins/org.jboss.tools.cdi.seam.text.ext/src/org/jboss/tools/cdi/seam/text/ext/hyperlink/CDISeamResourceLoadingHyperlinkDetector.java 2011-12-20 02:11:31 UTC (rev 37447)
@@ -31,7 +31,7 @@
import org.eclipse.jface.text.hyperlink.AbstractHyperlinkDetector;
import org.eclipse.jface.text.hyperlink.IHyperlink;
import org.eclipse.ui.texteditor.ITextEditor;
-import org.jboss.tools.cdi.internal.core.refactoring.MarkerResolutionUtils;
+import org.jboss.tools.cdi.internal.core.refactoring.CDIMarkerResolutionUtils;
import org.jboss.tools.cdi.seam.text.ext.CDISeamExtPlugin;
import org.jboss.tools.common.EclipseUtil;
@@ -74,7 +74,7 @@
IJavaElement element = cu.getElementAt(offset);
if(element != null){
if(element instanceof IField){
- IAnnotation annotation = MarkerResolutionUtils.findAnnotation(element, RESOURCE_ANNOTATION);
+ IAnnotation annotation = CDIMarkerResolutionUtils.findAnnotation(element, RESOURCE_ANNOTATION);
if(annotation != null && annotation.exists()){
IRegion annotationRegion = getAnnotationRegion(document, annotation);
String text = getValue(annotation);
Modified: trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/marker/AddAnnotationMarkerResolution.java
===================================================================
--- trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/marker/AddAnnotationMarkerResolution.java 2011-12-20 01:59:12 UTC (rev 37446)
+++ trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/marker/AddAnnotationMarkerResolution.java 2011-12-20 02:11:31 UTC (rev 37447)
@@ -20,11 +20,13 @@
import org.eclipse.jdt.core.IMethod;
import org.eclipse.jdt.core.IType;
import org.eclipse.jdt.core.JavaModelException;
+import org.eclipse.jdt.core.refactoring.CompilationUnitChange;
import org.eclipse.osgi.util.NLS;
import org.eclipse.swt.graphics.Image;
+import org.eclipse.text.edits.MultiTextEdit;
import org.eclipse.ui.IMarkerResolution2;
import org.jboss.tools.cdi.core.CDIImages;
-import org.jboss.tools.cdi.internal.core.refactoring.MarkerResolutionUtils;
+import org.jboss.tools.cdi.internal.core.refactoring.CDIMarkerResolutionUtils;
import org.jboss.tools.cdi.ui.CDIUIMessages;
import org.jboss.tools.cdi.ui.CDIUIPlugin;
@@ -37,7 +39,7 @@
public AddAnnotationMarkerResolution(IJavaElement element, String qualifiedName){
this.element = element;
this.qualifiedName = qualifiedName;
- String shortName = MarkerResolutionUtils.getShortName(qualifiedName);
+ String shortName = CDIMarkerResolutionUtils.getShortName(qualifiedName);
String type = "";
if(element instanceof IType){
try {
@@ -63,28 +65,41 @@
label = NLS.bind(CDIUIMessages.ADD_ANNOTATION_MARKER_RESOLUTION_TITLE, new String[]{shortName, element.getElementName(), type});
}
+ @Override
public String getLabel() {
return label;
}
+ @Override
public void run(IMarker marker) {
try{
- ICompilationUnit original = MarkerResolutionUtils.getJavaMember(element).getCompilationUnit();
+ ICompilationUnit original = CDIMarkerResolutionUtils.getJavaMember(element).getCompilationUnit();
ICompilationUnit compilationUnit = original.getWorkingCopy(new NullProgressMonitor());
- MarkerResolutionUtils.addAnnotation(qualifiedName, compilationUnit, element);
+ CompilationUnitChange change = new CompilationUnitChange("", compilationUnit);
- compilationUnit.commitWorkingCopy(false, new NullProgressMonitor());
+ MultiTextEdit edit = new MultiTextEdit();
+
+ change.setEdit(edit);
+
+ CDIMarkerResolutionUtils.addAnnotation(qualifiedName, compilationUnit, element, "", edit);
+
+ if(edit.hasChildren()){
+ change.perform(new NullProgressMonitor());
+ original.reconcile(ICompilationUnit.NO_AST, false, null, new NullProgressMonitor());
+ }
compilationUnit.discardWorkingCopy();
}catch(CoreException ex){
CDIUIPlugin.getDefault().logError(ex);
}
}
+ @Override
public String getDescription() {
return label;
}
+ @Override
public Image getImage() {
return CDIImages.QUICKFIX_ADD;
}
Modified: trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/marker/AddLocalBeanMarkerResolution.java
===================================================================
--- trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/marker/AddLocalBeanMarkerResolution.java 2011-12-20 01:59:12 UTC (rev 37446)
+++ trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/marker/AddLocalBeanMarkerResolution.java 2011-12-20 02:11:31 UTC (rev 37447)
@@ -53,10 +53,12 @@
this.file = file;
}
+ @Override
public String getLabel() {
return label;
}
+ @Override
public void run(IMarker marker) {
try{
ICompilationUnit original = EclipseUtil.getCompilationUnit(file);
@@ -121,10 +123,12 @@
}
+ @Override
public String getDescription() {
return label;
}
+ @Override
public Image getImage() {
return CDIImages.QUICKFIX_ADD;
}
Modified: trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/marker/AddRetentionAnnotationMarkerResolution.java
===================================================================
--- trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/marker/AddRetentionAnnotationMarkerResolution.java 2011-12-20 01:59:12 UTC (rev 37446)
+++ trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/marker/AddRetentionAnnotationMarkerResolution.java 2011-12-20 02:11:31 UTC (rev 37447)
@@ -15,12 +15,14 @@
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.jdt.core.ICompilationUnit;
import org.eclipse.jdt.core.IType;
+import org.eclipse.jdt.core.refactoring.CompilationUnitChange;
import org.eclipse.osgi.util.NLS;
import org.eclipse.swt.graphics.Image;
+import org.eclipse.text.edits.MultiTextEdit;
import org.eclipse.ui.IMarkerResolution2;
import org.jboss.tools.cdi.core.CDIConstants;
import org.jboss.tools.cdi.core.CDIImages;
-import org.jboss.tools.cdi.internal.core.refactoring.MarkerResolutionUtils;
+import org.jboss.tools.cdi.internal.core.refactoring.CDIMarkerResolutionUtils;
import org.jboss.tools.cdi.ui.CDIUIMessages;
import org.jboss.tools.cdi.ui.CDIUIPlugin;
@@ -34,30 +36,43 @@
label = NLS.bind(CDIUIMessages.ADD_RETENTION_MARKER_RESOLUTION_TITLE, type.getElementName());
}
+ @Override
public String getLabel() {
return label;
}
+ @Override
public void run(IMarker marker) {
try{
ICompilationUnit original = type.getCompilationUnit();
ICompilationUnit compilationUnit = original.getWorkingCopy(new NullProgressMonitor());
- MarkerResolutionUtils.addImport(CDIConstants.RETENTION_POLICY_RUNTIME_TYPE_NAME, compilationUnit, true);
+ CompilationUnitChange change = new CompilationUnitChange("", compilationUnit);
- MarkerResolutionUtils.addAnnotation(CDIConstants.RETENTION_ANNOTATION_TYPE_NAME, compilationUnit, type, "(RUNTIME)");
+ MultiTextEdit edit = new MultiTextEdit();
- compilationUnit.commitWorkingCopy(false, new NullProgressMonitor());
+ change.setEdit(edit);
+
+ CDIMarkerResolutionUtils.addImport(CDIConstants.RETENTION_POLICY_RUNTIME_TYPE_NAME, compilationUnit, true, edit);
+
+ CDIMarkerResolutionUtils.addAnnotation(CDIConstants.RETENTION_ANNOTATION_TYPE_NAME, compilationUnit, type, "(RUNTIME)", edit);
+
+ if(edit.hasChildren()){
+ change.perform(new NullProgressMonitor());
+ original.reconcile(ICompilationUnit.NO_AST, false, null, new NullProgressMonitor());
+ }
compilationUnit.discardWorkingCopy();
}catch(CoreException ex){
CDIUIPlugin.getDefault().logError(ex);
}
}
+ @Override
public String getDescription() {
return label;
}
+ @Override
public Image getImage() {
return CDIImages.QUICKFIX_ADD;
}
Modified: trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/marker/AddSerializableInterfaceMarkerResolution.java
===================================================================
--- trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/marker/AddSerializableInterfaceMarkerResolution.java 2011-12-20 01:59:12 UTC (rev 37446)
+++ trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/marker/AddSerializableInterfaceMarkerResolution.java 2011-12-20 02:11:31 UTC (rev 37447)
@@ -18,10 +18,12 @@
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.jdt.core.ICompilationUnit;
import org.eclipse.jdt.core.IType;
+import org.eclipse.jdt.core.refactoring.CompilationUnitChange;
import org.eclipse.swt.graphics.Image;
+import org.eclipse.text.edits.MultiTextEdit;
import org.eclipse.ui.IMarkerResolution2;
import org.jboss.tools.cdi.core.CDIImages;
-import org.jboss.tools.cdi.internal.core.refactoring.MarkerResolutionUtils;
+import org.jboss.tools.cdi.internal.core.refactoring.CDIMarkerResolutionUtils;
import org.jboss.tools.cdi.ui.CDIUIMessages;
import org.jboss.tools.cdi.ui.CDIUIPlugin;
import org.jboss.tools.common.EclipseUtil;
@@ -54,11 +56,19 @@
ICompilationUnit original = EclipseUtil.getCompilationUnit(file);
ICompilationUnit compilationUnit = original.getWorkingCopy(new NullProgressMonitor());
- MarkerResolutionUtils.addInterfaceToClass(compilationUnit, type, SERIALIZABLE);
+ CompilationUnitChange change = new CompilationUnitChange("", compilationUnit);
- compilationUnit.commitWorkingCopy(false, new NullProgressMonitor());
+ MultiTextEdit edit = new MultiTextEdit();
+
+ change.setEdit(edit);
+
+ CDIMarkerResolutionUtils.addInterfaceToClass(compilationUnit, type, SERIALIZABLE, edit);
+
+ if(edit.hasChildren()){
+ change.perform(new NullProgressMonitor());
+ original.reconcile(ICompilationUnit.NO_AST, false, null, new NullProgressMonitor());
+ }
compilationUnit.discardWorkingCopy();
-
}catch(CoreException ex){
CDIUIPlugin.getDefault().logError(ex);
}
Modified: trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/marker/AddTargetAnnotationMarkerResolution.java
===================================================================
--- trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/marker/AddTargetAnnotationMarkerResolution.java 2011-12-20 01:59:12 UTC (rev 37446)
+++ trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/marker/AddTargetAnnotationMarkerResolution.java 2011-12-20 02:11:31 UTC (rev 37447)
@@ -15,12 +15,14 @@
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.jdt.core.ICompilationUnit;
import org.eclipse.jdt.core.IType;
+import org.eclipse.jdt.core.refactoring.CompilationUnitChange;
import org.eclipse.osgi.util.NLS;
import org.eclipse.swt.graphics.Image;
+import org.eclipse.text.edits.MultiTextEdit;
import org.eclipse.ui.IMarkerResolution2;
import org.jboss.tools.cdi.core.CDIConstants;
import org.jboss.tools.cdi.core.CDIImages;
-import org.jboss.tools.cdi.internal.core.refactoring.MarkerResolutionUtils;
+import org.jboss.tools.cdi.internal.core.refactoring.CDIMarkerResolutionUtils;
import org.jboss.tools.cdi.ui.CDIUIMessages;
import org.jboss.tools.cdi.ui.CDIUIPlugin;
@@ -35,27 +37,37 @@
public AddTargetAnnotationMarkerResolution(IType type, String[] typeNames){
this.qualifiedNames = typeNames;
this.type = type;
- shortNames = MarkerResolutionUtils.getShortNames(qualifiedNames);
- totalList = MarkerResolutionUtils.OPEN_BRACE+MarkerResolutionUtils.getTotalList(shortNames)+MarkerResolutionUtils.CLOSE_BRACE;
+ shortNames = CDIMarkerResolutionUtils.getShortNames(qualifiedNames);
+ totalList = CDIMarkerResolutionUtils.OPEN_BRACE+CDIMarkerResolutionUtils.getTotalList(shortNames)+CDIMarkerResolutionUtils.CLOSE_BRACE;
label = NLS.bind(CDIUIMessages.ADD_TARGET_MARKER_RESOLUTION_TITLE, totalList, type.getElementName());
}
+ @Override
public String getLabel() {
return label;
}
+ @Override
public void run(IMarker marker) {
try{
ICompilationUnit original = type.getCompilationUnit();
ICompilationUnit compilationUnit = original.getWorkingCopy(new NullProgressMonitor());
+ CompilationUnitChange change = new CompilationUnitChange("", compilationUnit);
+
+ MultiTextEdit edit = new MultiTextEdit();
+
+ change.setEdit(edit);
for(String qualifiedName : qualifiedNames){
- MarkerResolutionUtils.addImport(qualifiedName, compilationUnit, true);
+ CDIMarkerResolutionUtils.addImport(qualifiedName, compilationUnit, true, edit);
}
- MarkerResolutionUtils.addAnnotation(CDIConstants.TARGET_ANNOTATION_TYPE_NAME, compilationUnit, type, "("+totalList+")");
+ CDIMarkerResolutionUtils.addAnnotation(CDIConstants.TARGET_ANNOTATION_TYPE_NAME, compilationUnit, type, "("+totalList+")", edit);
- compilationUnit.commitWorkingCopy(false, new NullProgressMonitor());
+ if(edit.hasChildren()){
+ change.perform(new NullProgressMonitor());
+ original.reconcile(ICompilationUnit.NO_AST, false, null, new NullProgressMonitor());
+ }
compilationUnit.discardWorkingCopy();
}catch(CoreException ex){
CDIUIPlugin.getDefault().logError(ex);
@@ -64,10 +76,12 @@
+ @Override
public String getDescription() {
return label;
}
+ @Override
public Image getImage() {
return CDIImages.QUICKFIX_ADD;
}
Modified: trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/marker/CDIProblemMarkerResolutionGenerator.java
===================================================================
--- trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/marker/CDIProblemMarkerResolutionGenerator.java 2011-12-20 01:59:12 UTC (rev 37446)
+++ trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/marker/CDIProblemMarkerResolutionGenerator.java 2011-12-20 02:11:31 UTC (rev 37447)
@@ -50,7 +50,7 @@
import org.jboss.tools.cdi.core.IStereotype;
import org.jboss.tools.cdi.core.IStereotyped;
import org.jboss.tools.cdi.internal.core.impl.CDIProject;
-import org.jboss.tools.cdi.internal.core.refactoring.MarkerResolutionUtils;
+import org.jboss.tools.cdi.internal.core.refactoring.CDIMarkerResolutionUtils;
import org.jboss.tools.cdi.internal.core.validation.CDIValidationErrorManager;
import org.jboss.tools.cdi.ui.CDIUIPlugin;
import org.jboss.tools.common.EclipseUtil;
@@ -67,6 +67,7 @@
private static final String XML_EXTENSION = "xml"; //$NON-NLS-1$
private static final int MARKER_RESULUTION_NUMBER_LIMIT = 7;
+ @Override
public IMarkerResolution[] getResolutions(IMarker marker) {
try {
return findResolutions(marker);
@@ -662,7 +663,7 @@
String injectionPointTypeName = injectionPoint.getClassBean().getBeanClass().getFullyQualifiedName();
String injectionPointPackage = null;
- int dotLastIndex = injectionPointTypeName.lastIndexOf(MarkerResolutionUtils.DOT);
+ int dotLastIndex = injectionPointTypeName.lastIndexOf(CDIMarkerResolutionUtils.DOT);
if(dotLastIndex < 0)
injectionPointPackage = "";
@@ -681,7 +682,7 @@
String beanTypeName = bean.getBeanClass().getFullyQualifiedName();
String beanPackage = null;
- dotLastIndex = beanTypeName.lastIndexOf(MarkerResolutionUtils.DOT);
+ dotLastIndex = beanTypeName.lastIndexOf(CDIMarkerResolutionUtils.DOT);
if(dotLastIndex < 0)
beanPackage = "";
@@ -744,7 +745,7 @@
if(javaElement != null && javaElement instanceof IType){
IType type = (IType)javaElement;
if(!type.isBinary()){
- String shortName = MarkerResolutionUtils.getShortName(AddSerializableInterfaceMarkerResolution.SERIALIZABLE);
+ String shortName = CDIMarkerResolutionUtils.getShortName(AddSerializableInterfaceMarkerResolution.SERIALIZABLE);
String[] interfaces = type.getSuperInterfaceNames();
for(String name : interfaces){
if(name.equals(shortName))
@@ -859,6 +860,7 @@
return null;
}
+ @Override
public boolean hasResolutions(IMarker marker) {
try {
return getMessageID(marker) >= 0;
@@ -870,7 +872,7 @@
private IAnnotation getAnnotation(IJavaElement element, String annotationQualifiedName){
if(element instanceof IAnnotatable){
- String shortName = MarkerResolutionUtils.getShortName(annotationQualifiedName);
+ String shortName = CDIMarkerResolutionUtils.getShortName(annotationQualifiedName);
IAnnotation[] annotations;
try {
annotations = ((IAnnotatable)element).getAnnotations();
Modified: trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/marker/ChangeAnnotationMarkerResolution.java
===================================================================
--- trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/marker/ChangeAnnotationMarkerResolution.java 2011-12-20 01:59:12 UTC (rev 37446)
+++ trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/marker/ChangeAnnotationMarkerResolution.java 2011-12-20 02:11:31 UTC (rev 37447)
@@ -14,15 +14,18 @@
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.jdt.core.IAnnotation;
-import org.eclipse.jdt.core.IBuffer;
import org.eclipse.jdt.core.ICompilationUnit;
import org.eclipse.jdt.core.JavaModelException;
+import org.eclipse.jdt.core.refactoring.CompilationUnitChange;
import org.eclipse.osgi.util.NLS;
import org.eclipse.swt.graphics.Image;
+import org.eclipse.text.edits.MultiTextEdit;
+import org.eclipse.text.edits.ReplaceEdit;
+import org.eclipse.text.edits.TextEdit;
import org.eclipse.ui.IMarkerResolution2;
import org.jboss.tools.cdi.core.CDIConstants;
import org.jboss.tools.cdi.core.CDIImages;
-import org.jboss.tools.cdi.internal.core.refactoring.MarkerResolutionUtils;
+import org.jboss.tools.cdi.internal.core.refactoring.CDIMarkerResolutionUtils;
import org.jboss.tools.cdi.ui.CDIUIMessages;
import org.jboss.tools.cdi.ui.CDIUIPlugin;
@@ -31,7 +34,7 @@
private IAnnotation annotation;
private String sourceString = "";
- private String changeString = MarkerResolutionUtils.AT;
+ private String changeString = CDIMarkerResolutionUtils.AT;
private boolean useBraces = true;
private String[] qualifiedNames = new String[0];
@@ -52,7 +55,7 @@
this(annotation);
qualifiedNames = new String[]{parameter};
- String shortName = MarkerResolutionUtils.getShortName(parameter);
+ String shortName = CDIMarkerResolutionUtils.getShortName(parameter);
changeString += "("+shortName+")";
}
@@ -61,10 +64,10 @@
this(annotation);
this.qualifiedNames = typeNames;
- String[] shortNames = MarkerResolutionUtils.getShortNames(qualifiedNames);
- String totalList = MarkerResolutionUtils.getTotalList(shortNames);
+ String[] shortNames = CDIMarkerResolutionUtils.getShortNames(qualifiedNames);
+ String totalList = CDIMarkerResolutionUtils.getTotalList(shortNames);
if(useBraces)
- totalList = MarkerResolutionUtils.OPEN_BRACE+totalList+MarkerResolutionUtils.CLOSE_BRACE;
+ totalList = CDIMarkerResolutionUtils.OPEN_BRACE+totalList+CDIMarkerResolutionUtils.CLOSE_BRACE;
changeString += "("+totalList+")";
}
@@ -74,38 +77,52 @@
this.useBraces = useBraces;
}
+ @Override
public String getLabel() {
return NLS.bind(CDIUIMessages.CHANGE_ANNOTATION_MARKER_RESOLUTION_TITLE, sourceString, changeString);
}
+ @Override
public void run(IMarker marker) {
try{
- ICompilationUnit original = MarkerResolutionUtils.getJavaMember(annotation).getCompilationUnit();
+ ICompilationUnit original = CDIMarkerResolutionUtils.getJavaMember(annotation).getCompilationUnit();
ICompilationUnit compilationUnit = original.getWorkingCopy(new NullProgressMonitor());
+
+ CompilationUnitChange change = new CompilationUnitChange("", compilationUnit);
- MarkerResolutionUtils.addImport(CDIConstants.TARGET_ANNOTATION_TYPE_NAME, compilationUnit);
+ MultiTextEdit edit = new MultiTextEdit();
+ change.setEdit(edit);
+ CDIMarkerResolutionUtils.addImport(CDIConstants.TARGET_ANNOTATION_TYPE_NAME, compilationUnit, edit);
+
for(String qualifiedName : qualifiedNames){
- MarkerResolutionUtils.addImport(qualifiedName, compilationUnit, true);
+ CDIMarkerResolutionUtils.addImport(qualifiedName, compilationUnit, true, edit);
}
- IAnnotation workingCopyAnnotation = MarkerResolutionUtils.findWorkingCopy(compilationUnit, annotation);
+ IAnnotation workingCopyAnnotation = CDIMarkerResolutionUtils.findWorkingCopy(compilationUnit, annotation);
- IBuffer buffer = compilationUnit.getBuffer();
+ //IBuffer buffer = compilationUnit.getBuffer();
+ TextEdit re = new ReplaceEdit(workingCopyAnnotation.getSourceRange().getOffset(), workingCopyAnnotation.getSourceRange().getLength(), changeString);
+ edit.addChild(re);
- buffer.replace(workingCopyAnnotation.getSourceRange().getOffset(), workingCopyAnnotation.getSourceRange().getLength(), changeString);
+ //buffer.replace(workingCopyAnnotation.getSourceRange().getOffset(), workingCopyAnnotation.getSourceRange().getLength(), changeString);
- compilationUnit.commitWorkingCopy(false, new NullProgressMonitor());
+ if(edit.hasChildren()){
+ change.perform(new NullProgressMonitor());
+ original.reconcile(ICompilationUnit.NO_AST, false, null, new NullProgressMonitor());
+ }
compilationUnit.discardWorkingCopy();
}catch(CoreException ex){
CDIUIPlugin.getDefault().logError(ex);
}
}
+ @Override
public String getDescription() {
return NLS.bind(CDIUIMessages.CHANGE_ANNOTATION_MARKER_RESOLUTION_TITLE, sourceString, changeString);
}
+ @Override
public Image getImage() {
return CDIImages.QUICKFIX_CHANGE;
}
Modified: trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/marker/CreateCDIElementMarkerResolution.java
===================================================================
--- trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/marker/CreateCDIElementMarkerResolution.java 2011-12-20 01:59:12 UTC (rev 37446)
+++ trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/marker/CreateCDIElementMarkerResolution.java 2011-12-20 02:11:31 UTC (rev 37447)
@@ -20,7 +20,7 @@
import org.eclipse.ui.IMarkerResolution2;
import org.eclipse.ui.PlatformUI;
import org.jboss.tools.cdi.core.CDIImages;
-import org.jboss.tools.cdi.internal.core.refactoring.MarkerResolutionUtils;
+import org.jboss.tools.cdi.internal.core.refactoring.CDIMarkerResolutionUtils;
import org.jboss.tools.cdi.ui.CDIUIMessages;
import org.jboss.tools.cdi.ui.wizard.NewBeanCreationWizard;
import org.jboss.tools.cdi.ui.wizard.NewCDIElementWizard;
@@ -62,6 +62,7 @@
return "";
}
+ @Override
public void run(IMarker marker){
internal_run(marker, false);
}
@@ -91,7 +92,7 @@
}
NewTypeWizardAdapter adapter = new NewTypeWizardAdapter(project);
- adapter.setRawPackageName(MarkerResolutionUtils.getPackageName(qualifiedName));
+ adapter.setRawPackageName(CDIMarkerResolutionUtils.getPackageName(qualifiedName));
adapter.setRawClassName(qualifiedName);
adapter.setRawSuperClassName(OBJECT);
wizard.setAdapter(adapter);
Modified: trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/marker/DeleteAllDisposerDuplicantMarkerResolution.java
===================================================================
--- trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/marker/DeleteAllDisposerDuplicantMarkerResolution.java 2011-12-20 01:59:12 UTC (rev 37446)
+++ trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/marker/DeleteAllDisposerDuplicantMarkerResolution.java 2011-12-20 02:11:31 UTC (rev 37447)
@@ -38,11 +38,13 @@
this.file = file;
}
+ @Override
public String getLabel() {
return label;
}
+ @Override
public void run(IMarker marker) {
DeleteAllDisposerAnnotationsProcessor processor = new DeleteAllDisposerAnnotationsProcessor(file, method, label);
ProcessorBasedRefactoring refactoring = new ProcessorBasedRefactoring(processor);
@@ -51,14 +53,17 @@
wizard.showWizard();
}
+ @Override
public RefactoringProcessor getRefactoringProcessor(){
return new DeleteAllDisposerAnnotationsProcessor(file, method, label);
}
+ @Override
public String getDescription() {
return label;
}
+ @Override
public Image getImage() {
return CDIImages.QUICKFIX_REMOVE;
}
Modified: trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/marker/DeleteAllInjectedConstructorsMarkerResolution.java
===================================================================
--- trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/marker/DeleteAllInjectedConstructorsMarkerResolution.java 2011-12-20 01:59:12 UTC (rev 37446)
+++ trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/marker/DeleteAllInjectedConstructorsMarkerResolution.java 2011-12-20 02:11:31 UTC (rev 37447)
@@ -48,11 +48,13 @@
this.file = file;
}
+ @Override
public String getLabel() {
return label;
}
+ @Override
public void run(IMarker marker) {
DeleteAllInjectedConstructorsProcessor processor = new DeleteAllInjectedConstructorsProcessor(file, method, label);
ProcessorBasedRefactoring refactoring = new ProcessorBasedRefactoring(processor);
@@ -61,14 +63,17 @@
wizard.showWizard();
}
+ @Override
public RefactoringProcessor getRefactoringProcessor(){
return new DeleteAllInjectedConstructorsProcessor(file, method, label);
}
+ @Override
public String getDescription() {
return label;
}
+ @Override
public Image getImage() {
return CDIImages.QUICKFIX_REMOVE;
}
Modified: trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/marker/DeleteAnnotationMarkerResolution.java
===================================================================
--- trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/marker/DeleteAnnotationMarkerResolution.java 2011-12-20 01:59:12 UTC (rev 37446)
+++ trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/marker/DeleteAnnotationMarkerResolution.java 2011-12-20 02:11:31 UTC (rev 37447)
@@ -20,11 +20,13 @@
import org.eclipse.jdt.core.IMethod;
import org.eclipse.jdt.core.IType;
import org.eclipse.jdt.core.JavaModelException;
+import org.eclipse.jdt.core.refactoring.CompilationUnitChange;
import org.eclipse.osgi.util.NLS;
import org.eclipse.swt.graphics.Image;
+import org.eclipse.text.edits.MultiTextEdit;
import org.eclipse.ui.IMarkerResolution2;
import org.jboss.tools.cdi.core.CDIImages;
-import org.jboss.tools.cdi.internal.core.refactoring.MarkerResolutionUtils;
+import org.jboss.tools.cdi.internal.core.refactoring.CDIMarkerResolutionUtils;
import org.jboss.tools.cdi.ui.CDIUIMessages;
import org.jboss.tools.cdi.ui.CDIUIPlugin;
@@ -37,7 +39,7 @@
public DeleteAnnotationMarkerResolution(IJavaElement element, String qualifiedName){
this.element = element;
this.qualifiedName = qualifiedName;
- String shortName = MarkerResolutionUtils.getShortName(qualifiedName);
+ String shortName = CDIMarkerResolutionUtils.getShortName(qualifiedName);
String type = "";
if(element instanceof IType){
try {
@@ -63,28 +65,41 @@
label = NLS.bind(CDIUIMessages.DELETE_ANNOTATION_MARKER_RESOLUTION_TITLE, new String[]{shortName, element.getElementName(), type});
}
+ @Override
public String getLabel() {
return label;
}
+ @Override
public void run(IMarker marker) {
try{
- ICompilationUnit original = MarkerResolutionUtils.getJavaMember(element).getCompilationUnit();
+ ICompilationUnit original = CDIMarkerResolutionUtils.getJavaMember(element).getCompilationUnit();
ICompilationUnit compilationUnit = original.getWorkingCopy(new NullProgressMonitor());
+
+ CompilationUnitChange change = new CompilationUnitChange("", compilationUnit);
- MarkerResolutionUtils.deleteAnnotation(qualifiedName, compilationUnit, element);
+ MultiTextEdit edit = new MultiTextEdit();
- compilationUnit.commitWorkingCopy(false, new NullProgressMonitor());
+ change.setEdit(edit);
+
+ CDIMarkerResolutionUtils.deleteAnnotation(qualifiedName, compilationUnit, element, edit);
+
+ if(edit.hasChildren()){
+ change.perform(new NullProgressMonitor());
+ original.reconcile(ICompilationUnit.NO_AST, false, null, new NullProgressMonitor());
+ }
compilationUnit.discardWorkingCopy();
}catch(CoreException ex){
CDIUIPlugin.getDefault().logError(ex);
}
}
+ @Override
public String getDescription() {
return label;
}
+ @Override
public Image getImage() {
return CDIImages.QUICKFIX_REMOVE;
}
Modified: trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/marker/MakeBeanScopedDependentMarkerResolution.java
===================================================================
--- trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/marker/MakeBeanScopedDependentMarkerResolution.java 2011-12-20 01:59:12 UTC (rev 37446)
+++ trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/marker/MakeBeanScopedDependentMarkerResolution.java 2011-12-20 02:11:31 UTC (rev 37447)
@@ -26,13 +26,18 @@
import org.eclipse.jdt.core.IImportContainer;
import org.eclipse.jdt.core.IImportDeclaration;
import org.eclipse.jdt.core.IType;
+import org.eclipse.jdt.core.refactoring.CompilationUnitChange;
import org.eclipse.swt.graphics.Image;
+import org.eclipse.text.edits.DeleteEdit;
+import org.eclipse.text.edits.MultiTextEdit;
+import org.eclipse.text.edits.ReplaceEdit;
+import org.eclipse.text.edits.TextEdit;
import org.eclipse.ui.IMarkerResolution2;
import org.jboss.tools.cdi.core.CDIConstants;
import org.jboss.tools.cdi.core.CDIImages;
import org.jboss.tools.cdi.core.IBean;
import org.jboss.tools.cdi.core.IScopeDeclaration;
-import org.jboss.tools.cdi.internal.core.refactoring.MarkerResolutionUtils;
+import org.jboss.tools.cdi.internal.core.refactoring.CDIMarkerResolutionUtils;
import org.jboss.tools.cdi.ui.CDIUIMessages;
import org.jboss.tools.cdi.ui.CDIUIPlugin;
import org.jboss.tools.common.EclipseUtil;
@@ -65,20 +70,29 @@
ICompilationUnit original = EclipseUtil.getCompilationUnit(file);
ICompilationUnit compilationUnit = original.getWorkingCopy(new NullProgressMonitor());
- MarkerResolutionUtils.addImport(CDIConstants.DEPENDENT_ANNOTATION_TYPE_NAME, compilationUnit);
+ CompilationUnitChange change = new CompilationUnitChange("", compilationUnit);
+ MultiTextEdit edit = new MultiTextEdit();
+
+ change.setEdit(edit);
+
+ CDIMarkerResolutionUtils.addImport(CDIConstants.DEPENDENT_ANNOTATION_TYPE_NAME, compilationUnit, edit);
+
IAnnotation workingCopyAnnotation = getWorkingCopyAnnotation(originalAnnotation, compilationUnit);
if(workingCopyAnnotation != null){
- String shortName = MarkerResolutionUtils.getShortName(CDIConstants.DEPENDENT_ANNOTATION_TYPE_NAME);
+ String shortName = CDIMarkerResolutionUtils.getShortName(CDIConstants.DEPENDENT_ANNOTATION_TYPE_NAME);
+ TextEdit re = new ReplaceEdit(workingCopyAnnotation.getSourceRange().getOffset(), workingCopyAnnotation.getSourceRange().getLength(), CDIMarkerResolutionUtils.AT+shortName);
+ edit.addChild(re);
+
IBuffer buffer = compilationUnit.getBuffer();
- buffer.replace(workingCopyAnnotation.getSourceRange().getOffset(), workingCopyAnnotation.getSourceRange().getLength(), MarkerResolutionUtils.AT+shortName);
+ //buffer.replace(workingCopyAnnotation.getSourceRange().getOffset(), workingCopyAnnotation.getSourceRange().getLength(), CDIMarkerResolutionUtils.AT+shortName);
- synchronized(compilationUnit) {
- compilationUnit.reconcile(ICompilationUnit.NO_AST, true, null, null);
- }
+ //synchronized(compilationUnit) {
+ // compilationUnit.reconcile(ICompilationUnit.NO_AST, true, null, null);
+ //}
// delete import
String qualifiedName = getFullyQualifiedName();
@@ -88,13 +102,19 @@
if(importDeclaration != null && importContainer != null){
int importSize = importContainer.getSourceRange().getOffset()+importContainer.getSourceRange().getLength();
String text = buffer.getText(importSize, buffer.getLength()-importSize);
- if(checkImport(text, originalAnnotation.getElementName()))
- importDeclaration.delete(false, new NullProgressMonitor());
+ if(checkImport(text, originalAnnotation.getElementName())){
+ TextEdit de = new DeleteEdit(importDeclaration.getSourceRange().getOffset(), importDeclaration.getSourceRange().getLength());
+ edit.addChild(de);
+ //importDeclaration.delete(false, new NullProgressMonitor());
+ }
}
}
}
- compilationUnit.commitWorkingCopy(false, new NullProgressMonitor());
+ if(edit.hasChildren()){
+ change.perform(new NullProgressMonitor());
+ original.reconcile(ICompilationUnit.NO_AST, false, null, new NullProgressMonitor());
+ }
compilationUnit.discardWorkingCopy();
}catch(CoreException ex){
CDIUIPlugin.getDefault().logError(ex);
Modified: trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/marker/MakeFieldProtectedMarkerResolution.java
===================================================================
--- trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/marker/MakeFieldProtectedMarkerResolution.java 2011-12-20 01:59:12 UTC (rev 37446)
+++ trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/marker/MakeFieldProtectedMarkerResolution.java 2011-12-20 02:11:31 UTC (rev 37447)
@@ -20,9 +20,13 @@
import org.eclipse.jdt.core.IBuffer;
import org.eclipse.jdt.core.ICompilationUnit;
import org.eclipse.jdt.core.IField;
+import org.eclipse.jdt.core.refactoring.CompilationUnitChange;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.widgets.Shell;
+import org.eclipse.text.edits.MultiTextEdit;
+import org.eclipse.text.edits.ReplaceEdit;
+import org.eclipse.text.edits.TextEdit;
import org.eclipse.ui.IMarkerResolution2;
import org.eclipse.ui.PlatformUI;
import org.jboss.tools.cdi.core.CDIImages;
@@ -72,7 +76,12 @@
try{
ICompilationUnit original = EclipseUtil.getCompilationUnit(file);
ICompilationUnit compilationUnit = original.getWorkingCopy(new NullProgressMonitor());
+
+ CompilationUnitChange change = new CompilationUnitChange("", compilationUnit);
+ MultiTextEdit edit = new MultiTextEdit();
+
+ change.setEdit(edit);
IBuffer buffer = compilationUnit.getBuffer();
int flag = field.getFlags();
@@ -82,10 +91,15 @@
int position = field.getSourceRange().getOffset();
if((flag & Flags.AccPublic) != 0){
position += text.indexOf(PUBLIC);
- buffer.replace(position, PUBLIC.length(), PROTECTED);
+ TextEdit re = new ReplaceEdit(position, PUBLIC.length(), PROTECTED);
+ edit.addChild(re);
+ //buffer.replace(position, PUBLIC.length(), PROTECTED);
}
- compilationUnit.commitWorkingCopy(false, new NullProgressMonitor());
+ if(edit.hasChildren()){
+ change.perform(new NullProgressMonitor());
+ original.reconcile(ICompilationUnit.NO_AST, false, null, new NullProgressMonitor());
+ }
compilationUnit.discardWorkingCopy();
}catch(CoreException ex){
CDIUIPlugin.getDefault().logError(ex);
Modified: trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/marker/MakeFieldStaticMarkerResolution.java
===================================================================
--- trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/marker/MakeFieldStaticMarkerResolution.java 2011-12-20 01:59:12 UTC (rev 37446)
+++ trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/marker/MakeFieldStaticMarkerResolution.java 2011-12-20 02:11:31 UTC (rev 37447)
@@ -21,7 +21,10 @@
import org.eclipse.jdt.core.ICompilationUnit;
import org.eclipse.jdt.core.IField;
import org.eclipse.jdt.core.Signature;
+import org.eclipse.jdt.core.refactoring.CompilationUnitChange;
import org.eclipse.swt.graphics.Image;
+import org.eclipse.text.edits.InsertEdit;
+import org.eclipse.text.edits.MultiTextEdit;
import org.eclipse.ui.IMarkerResolution2;
import org.jboss.tools.cdi.core.CDIImages;
import org.jboss.tools.cdi.ui.CDIUIMessages;
@@ -48,15 +51,22 @@
this.file = file;
}
+ @Override
public String getLabel() {
return label;
}
+ @Override
public void run(IMarker marker) {
try{
ICompilationUnit original = EclipseUtil.getCompilationUnit(file);
ICompilationUnit compilationUnit = original.getWorkingCopy(new NullProgressMonitor());
+
+ CompilationUnitChange change = new CompilationUnitChange("", compilationUnit);
+ MultiTextEdit edit = new MultiTextEdit();
+
+ change.setEdit(edit);
IBuffer buffer = compilationUnit.getBuffer();
int flag = field.getFlags();
@@ -66,30 +76,43 @@
int position = field.getSourceRange().getOffset();
if((flag & Flags.AccPublic) != 0){
position += text.indexOf(PUBLIC)+PUBLIC.length();
- buffer.replace(position, 0, SPACE+STATIC);
+ InsertEdit ie = new InsertEdit(position, SPACE+STATIC);
+ edit.addChild(ie);
+ //buffer.replace(position, 0, SPACE+STATIC);
}else if((flag & Flags.AccPrivate) != 0){
position += text.indexOf(PRIVATE)+PRIVATE.length();
- buffer.replace(position, 0, SPACE+STATIC);
+ InsertEdit ie = new InsertEdit(position, SPACE+STATIC);
+ edit.addChild(ie);
+ //buffer.replace(position, 0, SPACE+STATIC);
}else if((flag & Flags.AccProtected) != 0){
position += text.indexOf(PROTECTED)+PROTECTED.length();
- buffer.replace(position, 0, SPACE+STATIC);
+ InsertEdit ie = new InsertEdit(position, SPACE+STATIC);
+ edit.addChild(ie);
+ //buffer.replace(position, 0, SPACE+STATIC);
}else{
String type = Signature.getSignatureSimpleName(field.getTypeSignature());
position += text.indexOf(type);
- buffer.replace(position, 0, STATIC+SPACE);
+ InsertEdit ie = new InsertEdit(position, SPACE+STATIC);
+ edit.addChild(ie);
+ //buffer.replace(position, 0, STATIC+SPACE);
}
- compilationUnit.commitWorkingCopy(false, new NullProgressMonitor());
+ if(edit.hasChildren()){
+ change.perform(new NullProgressMonitor());
+ original.reconcile(ICompilationUnit.NO_AST, false, null, new NullProgressMonitor());
+ }
compilationUnit.discardWorkingCopy();
}catch(CoreException ex){
CDIUIPlugin.getDefault().logError(ex);
}
}
+ @Override
public String getDescription() {
return label;
}
+ @Override
public Image getImage() {
return CDIImages.QUICKFIX_EDIT;
}
Modified: trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/marker/MakeInjectedPointUnambiguousMarkerResolution.java
===================================================================
--- trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/marker/MakeInjectedPointUnambiguousMarkerResolution.java 2011-12-20 01:59:12 UTC (rev 37446)
+++ trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/marker/MakeInjectedPointUnambiguousMarkerResolution.java 2011-12-20 02:11:31 UTC (rev 37447)
@@ -40,14 +40,17 @@
this.label = MessageFormat.format(CDIUIMessages.MAKE_INJECTED_POINT_UNAMBIGUOUS_TITLE, new Object[]{selectedBean.getElementName()});
}
+ @Override
public String getLabel() {
return label;
}
+ @Override
public void runForTest(IMarker marker){
internal_run(marker, true);
}
+ @Override
public void run(IMarker marker) {
internal_run(marker, false);
}
@@ -75,10 +78,12 @@
// }
+ @Override
public String getDescription() {
return label;
}
+ @Override
public Image getImage() {
return CDIImages.QUICKFIX_EDIT;
}
Modified: trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/marker/MakeMethodBusinessMarkerResolution.java
===================================================================
--- trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/marker/MakeMethodBusinessMarkerResolution.java 2011-12-20 01:59:12 UTC (rev 37446)
+++ trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/marker/MakeMethodBusinessMarkerResolution.java 2011-12-20 02:11:31 UTC (rev 37447)
@@ -26,7 +26,7 @@
import org.eclipse.swt.graphics.Image;
import org.eclipse.ui.IMarkerResolution2;
import org.jboss.tools.cdi.core.CDIImages;
-import org.jboss.tools.cdi.internal.core.refactoring.MarkerResolutionUtils;
+import org.jboss.tools.cdi.internal.core.refactoring.CDIMarkerResolutionUtils;
import org.jboss.tools.cdi.ui.CDIUIMessages;
import org.jboss.tools.cdi.ui.CDIUIPlugin;
import org.jboss.tools.common.EclipseUtil;
@@ -54,10 +54,12 @@
this.file = file;
}
+ @Override
public String getLabel() {
return label;
}
+ @Override
public void run(IMarker marker) {
try{
ICompilationUnit original = EclipseUtil.getCompilationUnit(file);
@@ -138,14 +140,16 @@
private void addImport(IType originalType, String simpleName, ICompilationUnit compilationUnit) throws JavaModelException{
String qualifiedName = EclipseJavaUtil.resolveType(originalType, simpleName);
- MarkerResolutionUtils.addImport(qualifiedName, compilationUnit);
+ CDIMarkerResolutionUtils.addImport(qualifiedName, compilationUnit);
}
+ @Override
public String getDescription() {
return label;
}
+ @Override
public Image getImage() {
return CDIImages.QUICKFIX_ADD;
}
Modified: trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/marker/MakeMethodPublicMarkerResolution.java
===================================================================
--- trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/marker/MakeMethodPublicMarkerResolution.java 2011-12-20 01:59:12 UTC (rev 37446)
+++ trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/marker/MakeMethodPublicMarkerResolution.java 2011-12-20 02:11:31 UTC (rev 37447)
@@ -21,9 +21,14 @@
import org.eclipse.jdt.core.ICompilationUnit;
import org.eclipse.jdt.core.IMethod;
import org.eclipse.jdt.core.Signature;
+import org.eclipse.jdt.core.refactoring.CompilationUnitChange;
import org.eclipse.swt.graphics.Image;
+import org.eclipse.text.edits.InsertEdit;
+import org.eclipse.text.edits.MultiTextEdit;
+import org.eclipse.text.edits.ReplaceEdit;
import org.eclipse.ui.IMarkerResolution2;
import org.jboss.tools.cdi.core.CDIImages;
+import org.jboss.tools.cdi.internal.core.refactoring.CDIMarkerResolutionUtils;
import org.jboss.tools.cdi.ui.CDIUIMessages;
import org.jboss.tools.cdi.ui.CDIUIPlugin;
import org.jboss.tools.common.EclipseUtil;
@@ -47,48 +52,68 @@
this.file = file;
}
+ @Override
public String getLabel() {
return label;
}
+ @Override
public void run(IMarker marker) {
try{
ICompilationUnit original = EclipseUtil.getCompilationUnit(file);
ICompilationUnit compilationUnit = original.getWorkingCopy(new NullProgressMonitor());
+
+ CompilationUnitChange change = new CompilationUnitChange("", compilationUnit);
+ MultiTextEdit edit = new MultiTextEdit();
+
+ change.setEdit(edit);
IBuffer buffer = compilationUnit.getBuffer();
- int flag = method.getFlags();
-
- String text = buffer.getText(method.getSourceRange().getOffset(), method.getSourceRange().getLength());
-
- // make method public
- int position = method.getSourceRange().getOffset();
- if((flag & Flags.AccPublic) != 0){
- // do nothing
- }else if((flag & Flags.AccPrivate) != 0){
- position += text.indexOf(PRIVATE);
- buffer.replace(position, PRIVATE.length(), PUBLIC);
- }else if((flag & Flags.AccProtected) != 0){
- position += text.indexOf(PROTECTED);
- buffer.replace(position, PROTECTED.length(), PUBLIC);
- }else{
- String type = Signature.getSignatureSimpleName(method.getReturnType());
- position += text.indexOf(type);
- buffer.replace(position, 0, PUBLIC+SPACE);
+ IMethod workingCopyMethod = CDIMarkerResolutionUtils.findWorkingCopy(compilationUnit, method);
+ if(workingCopyMethod != null){
+ int flag = workingCopyMethod.getFlags();
+
+ String text = buffer.getText(workingCopyMethod.getSourceRange().getOffset(), workingCopyMethod.getSourceRange().getLength());
+
+ // make method public
+ int position = workingCopyMethod.getSourceRange().getOffset();
+ if((flag & Flags.AccPublic) != 0){
+ // do nothing
+ }else if((flag & Flags.AccPrivate) != 0){
+ position += text.indexOf(PRIVATE);
+ ReplaceEdit re = new ReplaceEdit(position, PRIVATE.length(), PUBLIC);
+ edit.addChild(re);
+ //buffer.replace(position, PRIVATE.length(), PUBLIC);
+ }else if((flag & Flags.AccProtected) != 0){
+ position += text.indexOf(PROTECTED);
+ ReplaceEdit re = new ReplaceEdit(position, PROTECTED.length(), PUBLIC);
+ edit.addChild(re);
+ //buffer.replace(position, PROTECTED.length(), PUBLIC);
+ }else{
+ String type = Signature.getSignatureSimpleName(workingCopyMethod.getReturnType());
+ position += text.indexOf(type);
+ InsertEdit ie = new InsertEdit(position, PUBLIC+SPACE);
+ edit.addChild(ie);
+ //buffer.replace(position, 0, PUBLIC+SPACE);
+ }
}
-
- compilationUnit.commitWorkingCopy(false, new NullProgressMonitor());
+ if(edit.hasChildren()){
+ change.perform(new NullProgressMonitor());
+ original.reconcile(ICompilationUnit.NO_AST, false, null, new NullProgressMonitor());
+ }
compilationUnit.discardWorkingCopy();
}catch(CoreException ex){
CDIUIPlugin.getDefault().logError(ex);
}
}
+ @Override
public String getDescription() {
return label;
}
+ @Override
public Image getImage() {
return CDIImages.QUICKFIX_EDIT;
}
Modified: trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/marker/SelectBeanMarkerResolution.java
===================================================================
--- trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/marker/SelectBeanMarkerResolution.java 2011-12-20 01:59:12 UTC (rev 37446)
+++ trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/marker/SelectBeanMarkerResolution.java 2011-12-20 02:11:31 UTC (rev 37447)
@@ -37,14 +37,17 @@
this.beans = beans;;
}
+ @Override
public String getLabel() {
return label;
}
+ @Override
public void runForTest(IMarker marker){
internal_run(marker, true);
}
+ @Override
public void run(IMarker marker) {
internal_run(marker, false);
}
@@ -117,10 +120,12 @@
// MarkerResolutionUtils.addQualifiersToInjectionPoint(injectionPoint, selectedBean, rootChange);
}
+ @Override
public String getDescription() {
return label;
}
+ @Override
public Image getImage() {
return CDIImages.QUICKFIX_EDIT;
}
Modified: trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/wizard/SelectBeanWizard.java
===================================================================
--- trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/wizard/SelectBeanWizard.java 2011-12-20 01:59:12 UTC (rev 37446)
+++ trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/wizard/SelectBeanWizard.java 2011-12-20 02:11:31 UTC (rev 37447)
@@ -42,7 +42,7 @@
import org.jboss.tools.cdi.core.CDIImages;
import org.jboss.tools.cdi.core.IBean;
import org.jboss.tools.cdi.core.IQualifier;
-import org.jboss.tools.cdi.internal.core.refactoring.MarkerResolutionUtils;
+import org.jboss.tools.cdi.internal.core.refactoring.CDIMarkerResolutionUtils;
import org.jboss.tools.cdi.internal.core.refactoring.ValuedQualifier;
import org.jboss.tools.cdi.ui.CDIUIMessages;
import org.jboss.tools.common.model.ui.ModelUIImages;
@@ -229,7 +229,7 @@
if(element instanceof IBean){
IBean bean = (IBean)element;
String beanTypeName = bean.getBeanClass().getFullyQualifiedName();
- String beanPackage = beanTypeName.substring(0,beanTypeName.lastIndexOf(MarkerResolutionUtils.DOT));
+ String beanPackage = beanTypeName.substring(0,beanTypeName.lastIndexOf(CDIMarkerResolutionUtils.DOT));
String name = bean.getElementName();
return name+" - "+beanPackage;
Modified: trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/wizard/xpl/AddQualifiersToBeanComposite.java
===================================================================
--- trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/wizard/xpl/AddQualifiersToBeanComposite.java 2011-12-20 01:59:12 UTC (rev 37446)
+++ trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/wizard/xpl/AddQualifiersToBeanComposite.java 2011-12-20 02:11:31 UTC (rev 37447)
@@ -77,7 +77,7 @@
import org.jboss.tools.cdi.core.IInjectionPoint;
import org.jboss.tools.cdi.core.IQualifier;
import org.jboss.tools.cdi.core.IQualifierDeclaration;
-import org.jboss.tools.cdi.internal.core.refactoring.MarkerResolutionUtils;
+import org.jboss.tools.cdi.internal.core.refactoring.CDIMarkerResolutionUtils;
import org.jboss.tools.cdi.internal.core.refactoring.ValuedQualifier;
import org.jboss.tools.cdi.ui.CDIUIMessages;
import org.jboss.tools.cdi.ui.CDIUIPlugin;
@@ -134,13 +134,13 @@
public void init(IBean bean){
this.bean = bean;
- String beanName = MarkerResolutionUtils.getELName(bean);
+ String beanName = CDIMarkerResolutionUtils.getELName(bean);
originalQualifiers.clear();
deployed.clear();
for(IQualifier q : bean.getQualifiers()){
- IQualifierDeclaration declaration = MarkerResolutionUtils.findQualifierDeclaration(bean, q);
+ IQualifierDeclaration declaration = CDIMarkerResolutionUtils.findQualifierDeclaration(bean, q);
if(declaration != null){
- String value = MarkerResolutionUtils.findQualifierValue(bean, declaration);
+ String value = CDIMarkerResolutionUtils.findQualifierValue(bean, declaration);
ValuedQualifier vq = new ValuedQualifier(q, value);
deployed.add(vq);
}else{
@@ -177,15 +177,15 @@
}
private ValuedQualifier loadAvailableQualifiers(){
- String beanName = MarkerResolutionUtils.getELName(bean);
+ String beanName = CDIMarkerResolutionUtils.getELName(bean);
ValuedQualifier lastQualifier = null;
String beanTypeName = bean.getBeanClass().getFullyQualifiedName();
- String beanPackage = beanTypeName.substring(0,beanTypeName.lastIndexOf(MarkerResolutionUtils.DOT));
+ String beanPackage = beanTypeName.substring(0,beanTypeName.lastIndexOf(CDIMarkerResolutionUtils.DOT));
IJavaProject beanJavaProject = bean.getBeanClass().getJavaProject();
String injectionPointTypeName = injectionPoint.getClassBean().getBeanClass().getFullyQualifiedName();
- String injectionPointPackage = injectionPointTypeName.substring(0,injectionPointTypeName.lastIndexOf(MarkerResolutionUtils.DOT));
+ String injectionPointPackage = injectionPointTypeName.substring(0,injectionPointTypeName.lastIndexOf(CDIMarkerResolutionUtils.DOT));
IJavaProject injectionPointJavaProject = injectionPoint.getBean().getBeanClass().getJavaProject();
boolean samePackage = beanPackage.equals(injectionPointPackage);
@@ -199,7 +199,7 @@
boolean isPublic = Flags.isPublic(q.getSourceType().getFlags());
String qualifierTypeName = q.getSourceType().getFullyQualifiedName();
- String qualifierPackage = qualifierTypeName.substring(0,qualifierTypeName.lastIndexOf(MarkerResolutionUtils.DOT));
+ String qualifierPackage = qualifierTypeName.substring(0,qualifierTypeName.lastIndexOf(CDIMarkerResolutionUtils.DOT));
if((isPublic || (samePackage && injectionPointPackage.equals(qualifierPackage))) ){
if(beanJavaProject.findType(qualifierTypeName) != null && injectionPointJavaProject.findType(qualifierTypeName) != null){
if(q.getSourceType().getFullyQualifiedName().equals(CDIConstants.NAMED_QUALIFIER_TYPE_NAME))
@@ -247,7 +247,7 @@
for(IBean b: beans){
if(b.equals(bean))
continue;
- if(MarkerResolutionUtils.checkValuedQualifiers(bean, b, qfs))
+ if(CDIMarkerResolutionUtils.checkValuedQualifiers(bean, b, qfs))
return false;
}
@@ -726,7 +726,7 @@
if(element instanceof ValuedQualifier){
ValuedQualifier vq = (ValuedQualifier)element;
String qualifierTypeName = vq.getQualifier().getSourceType().getFullyQualifiedName();
- String qualifierPackage = qualifierTypeName.substring(0,qualifierTypeName.lastIndexOf(MarkerResolutionUtils.DOT));
+ String qualifierPackage = qualifierTypeName.substring(0,qualifierTypeName.lastIndexOf(CDIMarkerResolutionUtils.DOT));
String name = vq.getQualifier().getSourceType().getElementName();
return name+" - "+qualifierPackage;
Modified: trunk/common/plugins/org.jboss.tools.common/META-INF/MANIFEST.MF
===================================================================
--- trunk/common/plugins/org.jboss.tools.common/META-INF/MANIFEST.MF 2011-12-20 01:59:12 UTC (rev 37446)
+++ trunk/common/plugins/org.jboss.tools.common/META-INF/MANIFEST.MF 2011-12-20 02:11:31 UTC (rev 37447)
@@ -12,11 +12,12 @@
org.jboss.tools.common.jobs,
org.jboss.tools.common.log,
org.jboss.tools.common.preferences,
+ org.jboss.tools.common.refactoring,
org.jboss.tools.common.reporting,
org.jboss.tools.common.text,
org.jboss.tools.common.util,
+ org.jboss.tools.common.web,
org.jboss.tools.common.xml,
- org.jboss.tools.common.web,
org.jboss.tools.common.zip
Require-Bundle: org.eclipse.core.runtime;bundle-version="3.7.0",
org.eclipse.wst.xml.core;bundle-version="1.1.600";visibility:=reexport,
@@ -37,7 +38,8 @@
org.eclipse.ui.workbench.texteditor;bundle-version="3.7.0",
org.eclipse.jface.text;bundle-version="3.7.0",
org.apache.commons.httpclient;bundle-version="3.1.0",
- org.eclipse.ui.editors;bundle-version="3.7.0"
+ org.eclipse.ui.editors;bundle-version="3.7.0",
+ org.eclipse.jpt.common.core;bundle-version="1.0.0"
Bundle-Version: 3.3.0.qualifier
Bundle-ActivationPolicy: lazy
Bundle-ManifestVersion: 2
Added: trunk/common/plugins/org.jboss.tools.common/src/org/jboss/tools/common/refactoring/MarkerResolutionUtils.java
===================================================================
--- trunk/common/plugins/org.jboss.tools.common/src/org/jboss/tools/common/refactoring/MarkerResolutionUtils.java (rev 0)
+++ trunk/common/plugins/org.jboss.tools.common/src/org/jboss/tools/common/refactoring/MarkerResolutionUtils.java 2011-12-20 02:11:31 UTC (rev 37447)
@@ -0,0 +1,558 @@
+/*******************************************************************************
+ * Copyright (c) 2010 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is 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:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.common.refactoring;
+
+import java.util.HashSet;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.jdt.core.Flags;
+import org.eclipse.jdt.core.IAnnotatable;
+import org.eclipse.jdt.core.IAnnotation;
+import org.eclipse.jdt.core.IBuffer;
+import org.eclipse.jdt.core.ICompilationUnit;
+import org.eclipse.jdt.core.IImportContainer;
+import org.eclipse.jdt.core.IImportDeclaration;
+import org.eclipse.jdt.core.IJavaElement;
+import org.eclipse.jdt.core.ILocalVariable;
+import org.eclipse.jdt.core.IMember;
+import org.eclipse.jdt.core.IMethod;
+import org.eclipse.jdt.core.IPackageDeclaration;
+import org.eclipse.jdt.core.IType;
+import org.eclipse.jdt.core.ITypeParameter;
+import org.eclipse.jdt.core.JavaModelException;
+import org.eclipse.jdt.core.dom.ASTNode;
+import org.eclipse.jdt.core.dom.CompilationUnit;
+import org.eclipse.jdt.internal.core.JavaElement;
+import org.eclipse.jpt.common.core.internal.utility.jdt.ASTTools;
+import org.eclipse.text.edits.DeleteEdit;
+import org.eclipse.text.edits.InsertEdit;
+import org.eclipse.text.edits.MultiTextEdit;
+import org.eclipse.text.edits.ReplaceEdit;
+import org.eclipse.text.edits.TextEdit;
+import org.jboss.tools.common.util.EclipseJavaUtil;
+
+public class MarkerResolutionUtils {
+ public static final String DOT = "."; //$NON-NLS-1$
+ public static final String COMMA = ","; //$NON-NLS-1$
+ public static final String SEMICOLON = ";"; //$NON-NLS-1$
+ public static final String SPACE = " "; //$NON-NLS-1$
+ public static final String AT = "@"; //$NON-NLS-1$
+ public static final String IMPLEMENTS = "implements"; //$NON-NLS-1$
+ public static final String IMPORT = "import"; //$NON-NLS-1$
+ public static final String STATIC = "static"; //$NON-NLS-1$
+ public static final String EXTENDS = "extends"; //$NON-NLS-1$
+ public static final String OPEN_BRACE = "{"; //$NON-NLS-1$
+ public static final String CLOSE_BRACE = "}"; //$NON-NLS-1$
+
+ public static final char C_SPACE = ' '; //$NON-NLS-1$
+ public static final char C_TAB = '\t';
+ public static final char C_CARRIAGE_RETURN = '\r';
+ public static final char C_NEW_LINE = '\n';
+
+ static final HashSet<String> primitives = new HashSet<String>();
+ static{
+ primitives.add("void"); //$NON-NLS-1$
+ primitives.add("int"); //$NON-NLS-1$
+ primitives.add("java.lang.Integer"); //$NON-NLS-1$
+ primitives.add("char"); //$NON-NLS-1$
+ primitives.add("java.lang.Character"); //$NON-NLS-1$
+ primitives.add("boolean"); //$NON-NLS-1$
+ primitives.add("java.lang.Boolean"); //$NON-NLS-1$
+ primitives.add("short"); //$NON-NLS-1$
+ primitives.add("java.lang.Short"); //$NON-NLS-1$
+ primitives.add("long"); //$NON-NLS-1$
+ primitives.add("java.lang.Long"); //$NON-NLS-1$
+ primitives.add("float"); //$NON-NLS-1$
+ primitives.add("java.lang.Float"); //$NON-NLS-1$
+ primitives.add("double"); //$NON-NLS-1$
+ primitives.add("java.lang.Double"); //$NON-NLS-1$
+ primitives.add("byte"); //$NON-NLS-1$
+ primitives.add("java.lang.Byte"); //$NON-NLS-1$
+ primitives.add("java.lang.String"); //$NON-NLS-1$
+ primitives.add("java.lang.SuppressWarnings"); //$NON-NLS-1$
+ }
+ /**
+ *
+ * @param qualifiedName
+ * @param compilationUnit
+ * @return true if there is import in compilation unit with the same short name
+ * @throws JavaModelException
+ */
+ public static boolean addImport(String qualifiedName, ICompilationUnit compilationUnit) throws JavaModelException{
+ return addImport(qualifiedName, compilationUnit, false, null);
+ }
+
+ public static boolean addImport(String qualifiedName, ICompilationUnit compilationUnit, MultiTextEdit rootEdit) throws JavaModelException{
+ return addImport(qualifiedName, compilationUnit, false, rootEdit);
+ }
+
+ /**
+ *
+ * @param qualifiedName
+ * @param compilationUnit
+ * @param staticFlag
+ * @return true if there is import in compilation unit with the same short name
+ * @throws JavaModelException
+ */
+ public static boolean addImport(String qualifiedName, ICompilationUnit compilationUnit, boolean staticFlag) throws JavaModelException{
+ return addImport(qualifiedName, compilationUnit, staticFlag, null);
+ }
+
+ private static int findPositionForImport(ICompilationUnit compilationUnit) throws JavaModelException{
+ if(compilationUnit.getImportContainer().exists()){
+ return compilationUnit.getImportContainer().getSourceRange().getOffset()+compilationUnit.getImportContainer().getSourceRange().getLength();
+ }else{
+ IPackageDeclaration[] packageDeclarations = compilationUnit.getPackageDeclarations();
+ if(packageDeclarations.length == 0){
+ return 0;
+ }
+ int position = 0;
+ for(IPackageDeclaration declaration : packageDeclarations){
+ position = declaration.getSourceRange().getOffset()+declaration.getSourceRange().getLength();
+ }
+ return position;
+ }
+ }
+
+ private static boolean isDuplicate(MultiTextEdit rootEdit, String text){
+ for(TextEdit edit : rootEdit.getChildren()){
+ if(edit instanceof InsertEdit && ((InsertEdit) edit).getText().equals(text))
+ return true;
+ }
+ return false;
+ }
+
+ public static boolean addImport(String qualifiedName, ICompilationUnit compilationUnit, boolean staticFlag, MultiTextEdit rootEdit) throws JavaModelException{
+ if(primitives.contains(qualifiedName))
+ return false;
+
+ if(qualifiedName != null){
+ String shortName = getShortName(qualifiedName);
+
+ IPackageDeclaration[] packages = compilationUnit.getPackageDeclarations();
+
+ // local classes do not need to be imported
+ if(qualifiedName.indexOf(DOT) >= 0){
+ String typePackage = qualifiedName.substring(0,qualifiedName.lastIndexOf(DOT));
+
+ for(IPackageDeclaration packageDeclaration : packages){
+ if(packageDeclaration.getElementName().equals(typePackage))
+ return false;
+ }
+
+ for(IPackageDeclaration packageDeclaration : packages){
+ IType type = compilationUnit.getJavaProject().findType(packageDeclaration.getElementName()+DOT+shortName);
+ if(type != null && type.exists())
+ return true;
+ }
+ }
+
+ IImportDeclaration[] importDeclarations = compilationUnit.getImports();
+
+ for(IImportDeclaration importDeclaration : importDeclarations){
+ String importName = importDeclaration.getElementName();
+ String elementShort = getShortName(importName);
+ if(importDeclaration.isOnDemand()){
+ int importLastDot = importName.lastIndexOf(DOT);
+ if(importLastDot == -1) return false; // invalid import declaration
+ int elementLastDot = qualifiedName.lastIndexOf(DOT);
+ if(elementLastDot == -1) return false; // invalid import declaration
+
+ if(qualifiedName.substring(0, elementLastDot).equals(importName.substring(0, importLastDot)))
+ return false;
+ }
+
+ if(importName.equals(qualifiedName))
+ return false;
+ if(elementShort.equals(shortName))
+ return true;
+
+ }
+ if(rootEdit == null){
+ if(staticFlag){
+ compilationUnit.createImport(qualifiedName, null, Flags.AccStatic, new NullProgressMonitor());
+ }else{
+ compilationUnit.createImport(qualifiedName, null, new NullProgressMonitor());
+ }
+ }else{
+ String staticStr = "";
+ if(staticFlag){
+ staticStr = STATIC+SPACE;
+ }
+ String text = compilationUnit.findRecommendedLineSeparator()+IMPORT+SPACE+staticStr+qualifiedName+SEMICOLON;
+ if(!isDuplicate(rootEdit, text)){
+ int importPosition = findPositionForImport(compilationUnit);
+ TextEdit edit = new InsertEdit(importPosition, text);
+ rootEdit.addChild(edit);
+ }
+ }
+ }
+ return false;
+ }
+
+ public static String getShortName(String qualifiedName){
+ int lastDot = qualifiedName.lastIndexOf(DOT);
+ String name;
+ if(lastDot < 0)
+ name = qualifiedName;
+ else
+ name = qualifiedName.substring(lastDot+1);
+ return name;
+ }
+
+ public static String getPackageName(String qualifiedName){
+ int lastDot = qualifiedName.lastIndexOf(DOT);
+ String name;
+ if(lastDot < 0)
+ name = "";
+ else
+ name = qualifiedName.substring(0, lastDot);
+ return name;
+ }
+
+ public static String[] getShortNames(String[] qualifiedNames){
+ String[] shortNames = new String[qualifiedNames.length];
+ for(int i = 0; i < qualifiedNames.length; i++){
+ shortNames[i] = getShortName(qualifiedNames[i]);
+ }
+ return shortNames;
+ }
+
+ public static String getTotalList(String[] names){
+ String list = "";
+ for(int i = 0; i < names.length; i++){
+ if(i != 0)
+ list += ", ";
+ list += names[i];
+ }
+ return list;
+ }
+
+ public static void addAnnotation(String qualifiedName, ICompilationUnit compilationUnit, IJavaElement element) throws JavaModelException{
+ addAnnotation(qualifiedName, compilationUnit, element, "");
+ }
+
+ public static void updateAnnotation(String qualifiedName, ICompilationUnit compilationUnit, IJavaElement element, String params) throws JavaModelException{
+ updateAnnotation(qualifiedName, compilationUnit, element, params, null);
+ }
+
+ public static void updateAnnotation(String qualifiedName, ICompilationUnit compilationUnit, IJavaElement element, String params, MultiTextEdit rootEdit) throws JavaModelException{
+ IJavaElement workingCopyElement = findWorkingCopy(compilationUnit, element);
+ if(workingCopyElement == null){
+ return;
+ }
+
+ if(!(workingCopyElement instanceof IMember))
+ return;
+
+ IMember workingCopyMember = (IMember) workingCopyElement;
+
+ IAnnotation annotation = findAnnotation(workingCopyMember, qualifiedName);
+ if(annotation == null || !annotation.exists())
+ return;
+
+ boolean duplicateShortName = addImport(qualifiedName, compilationUnit, null);
+
+ IBuffer buffer = compilationUnit.getBuffer();
+ String shortName = getShortName(qualifiedName);
+
+ if(duplicateShortName)
+ shortName = qualifiedName;
+
+ String newValue = AT+shortName+params;
+
+ if(!annotation.getSource().equals(newValue)){
+ if(rootEdit != null){
+ TextEdit edit = new ReplaceEdit(annotation.getSourceRange().getOffset(), annotation.getSourceRange().getLength(), newValue);
+ rootEdit.addChild(edit);
+ }else{
+ buffer.replace(annotation.getSourceRange().getOffset(), annotation.getSourceRange().getLength(), newValue);
+
+ synchronized(compilationUnit) {
+ compilationUnit.reconcile(ICompilationUnit.NO_AST, true, null, null);
+ }
+ }
+ }
+
+ }
+
+ public static void addAnnotation(String qualifiedName, ICompilationUnit compilationUnit, IJavaElement element, String params) throws JavaModelException{
+ addAnnotation(qualifiedName, compilationUnit, element, params, null);
+ }
+
+ public static void addAnnotation(String qualifiedName, ICompilationUnit compilationUnit, IJavaElement element, String params, MultiTextEdit rootEdit) throws JavaModelException{
+ IJavaElement workingCopyElement = findWorkingCopy(compilationUnit, element);
+ if(workingCopyElement == null){
+ return;
+ }
+
+ if(!(workingCopyElement instanceof IMember))
+ return;
+
+ IMember workingCopyMember = (IMember) workingCopyElement;
+
+ IAnnotation annotation = findAnnotation(workingCopyMember, qualifiedName);
+ if(annotation != null && annotation.exists())
+ return;
+
+ CompilationUnit cuNode = ASTTools.buildASTRoot(compilationUnit);
+
+ ASTNode elementNode = null;
+ if(workingCopyElement instanceof JavaElement){
+ elementNode = ((JavaElement) workingCopyElement).findNode(cuNode);
+ }
+
+ boolean duplicateShortName = addImport(qualifiedName, compilationUnit, rootEdit);
+
+ IBuffer buffer = compilationUnit.getBuffer();
+ String shortName = getShortName(qualifiedName);
+
+ if(duplicateShortName)
+ shortName = qualifiedName;
+
+ String str = AT+shortName+params;
+
+ int position = workingCopyMember.getSourceRange().getOffset();
+
+ if(elementNode != null){
+ position = elementNode.getStartPosition();
+ }
+
+ if(!(workingCopyMember instanceof ILocalVariable)){
+
+ str += compilationUnit.findRecommendedLineSeparator();
+
+ int index = position;
+ while(index >= 0){
+ char c = buffer.getChar(index);
+ if(c == C_CARRIAGE_RETURN || c == C_NEW_LINE)
+ break;
+ index--;
+ }
+ index++;
+ if(index != position){
+ String spaces = buffer.getText(index, position-index);
+ str += spaces;
+ }
+
+ }else{
+ str += SPACE;
+ }
+
+ if(rootEdit != null){
+ TextEdit edit = new InsertEdit(position, str);
+ rootEdit.addChild(edit);
+ }else{
+ buffer.replace(position, 0, str);
+
+ synchronized(compilationUnit) {
+ compilationUnit.reconcile(ICompilationUnit.NO_AST, true, null, null);
+ }
+ }
+ }
+
+ @SuppressWarnings("unchecked")
+ public static <T extends IJavaElement> T findWorkingCopy(ICompilationUnit compilationUnit, T element) throws JavaModelException{
+ if(element instanceof IAnnotation){
+ IJavaElement parent = findWorkingCopy(compilationUnit, element.getParent());
+ if(parent instanceof IAnnotatable){
+ for(IAnnotation a : ((IAnnotatable)parent).getAnnotations()){
+ if(a.getElementName().equals(element.getElementName()))
+ return (T)a;
+ }
+ }
+ }else if(element instanceof ILocalVariable && ((ILocalVariable) element).isParameter()){
+ IJavaElement parent = findWorkingCopy(compilationUnit, element.getParent());
+ if(parent instanceof IMethod){
+ for(ILocalVariable parameter : ((IMethod)parent).getParameters()){
+ if(parameter.getElementName().equals(element.getElementName()) && parameter.getTypeSignature().equals(((ILocalVariable)element).getTypeSignature()))
+ return (T)parameter;
+ }
+ }
+ }else{
+ IJavaElement[] elements = compilationUnit.findElements(element);
+ if(elements != null){
+ for(IJavaElement e : elements){
+ if(e.getClass().equals(element.getClass()))
+ return (T)e;
+ }
+ }
+ }
+ return null;
+ }
+
+ public static IAnnotation findAnnotation(IJavaElement element, String qualifiedName){
+ if(element instanceof IAnnotatable){
+ String name = getShortName(qualifiedName);
+ IAnnotation annotation = ((IAnnotatable)element).getAnnotation(qualifiedName);
+ if (!annotation.exists()) {
+ annotation = ((IAnnotatable)element).getAnnotation(name);
+ } else {
+ return annotation;
+ }
+ if(annotation.exists()) {
+ IType type=null;
+ if(element instanceof IType){
+ type = (IType)element;
+ }else if(element instanceof IMember){
+ type = ((IMember)element).getDeclaringType();
+ }else if(element instanceof ITypeParameter){
+ type = ((ITypeParameter)element).getDeclaringMember().getDeclaringType();
+ }else if(element instanceof ILocalVariable){
+ type = ((ILocalVariable)element).getDeclaringMember().getDeclaringType();
+ }
+ if (type != null && annotation != null && qualifiedName.equals(EclipseJavaUtil.resolveType(type, name))) {
+ return annotation;
+ }
+ }
+ }
+ return null;
+ }
+
+ public static void addInterfaceToClass(ICompilationUnit compilationUnit, IType type, String qualifiedName, MultiTextEdit rootEdit) throws JavaModelException{
+ String shortName = getShortName(qualifiedName);
+
+ IType[] types = compilationUnit.getTypes();
+ IType workingType = null;
+ for(IType t : types){
+ if(t.getElementName().equals(type.getElementName())){
+ workingType = t;
+ break;
+ }
+ }
+
+ if(workingType != null){
+ addImport(qualifiedName, compilationUnit, rootEdit);
+
+ IBuffer buffer = compilationUnit.getBuffer();
+
+ String text = buffer.getText(workingType.getSourceRange().getOffset(), workingType.getSourceRange().getLength());
+
+ int namePosition = text.indexOf(workingType.getElementName());
+ if(namePosition >= 0){
+ int implementsPosition = text.indexOf(IMPLEMENTS,namePosition);
+ if(implementsPosition > 0){
+ if(rootEdit != null){
+ TextEdit edit = new InsertEdit(workingType.getSourceRange().getOffset()+implementsPosition+IMPLEMENTS.length(), SPACE+shortName+COMMA);
+ rootEdit.addChild(edit);
+ }else{
+ buffer.replace(workingType.getSourceRange().getOffset()+implementsPosition+IMPLEMENTS.length(),0,SPACE+shortName+COMMA);
+ }
+ }else{
+ int extedsPosition = text.indexOf(EXTENDS,namePosition);
+ if(extedsPosition > 0){
+ int bracePosition = text.indexOf(OPEN_BRACE, extedsPosition);
+ String str = IMPLEMENTS+SPACE+shortName+SPACE;
+ if(!text.substring(bracePosition-1,bracePosition).equals(SPACE))
+ str = SPACE+str;
+ if(rootEdit != null){
+ TextEdit edit = new InsertEdit(workingType.getSourceRange().getOffset()+bracePosition, str);
+ rootEdit.addChild(edit);
+ }else{
+ buffer.replace(workingType.getSourceRange().getOffset()+bracePosition,0,str);
+ }
+ }else{
+ if(rootEdit != null){
+ TextEdit edit = new InsertEdit(workingType.getSourceRange().getOffset()+namePosition+workingType.getElementName().length(), SPACE+IMPLEMENTS+SPACE+shortName);
+ rootEdit.addChild(edit);
+ }else{
+ buffer.replace(workingType.getSourceRange().getOffset()+namePosition+workingType.getElementName().length(),0,SPACE+IMPLEMENTS+SPACE+shortName);
+ }
+ }
+ }
+ }
+ }
+ }
+
+ public static void deleteAnnotation(String qualifiedName, ICompilationUnit compilationUnit, IJavaElement element) throws JavaModelException{
+ deleteAnnotation(qualifiedName, compilationUnit, element, null);
+ }
+
+ public static void deleteAnnotation(String qualifiedName, ICompilationUnit compilationUnit, IJavaElement element, MultiTextEdit rootEdit) throws JavaModelException{
+ IJavaElement workingCopyElement = findWorkingCopy(compilationUnit, element);
+ if(workingCopyElement == null){
+ return;
+ }
+
+ IAnnotation annotation = findAnnotation(workingCopyElement, qualifiedName);
+ if(annotation != null){
+ IBuffer buffer = compilationUnit.getBuffer();
+
+ int position = annotation.getSourceRange().getOffset() + annotation.getSourceRange().getLength();
+ int numberOfSpaces = 0;
+ if(position < buffer.getLength()-1){
+ char c = buffer.getChar(position);
+ while((c == C_SPACE || c == C_TAB || c == C_NEW_LINE || c == C_CARRIAGE_RETURN) && position < buffer.getLength()-1){
+ numberOfSpaces++;
+ position++;
+ c = buffer.getChar(position);
+ }
+ }
+
+ // delete annotation
+ if(rootEdit != null){
+ TextEdit edit = new DeleteEdit(annotation.getSourceRange().getOffset(), annotation.getSourceRange().getLength()+numberOfSpaces);
+ rootEdit.addChild(edit);
+ }else{
+ buffer.replace(annotation.getSourceRange().getOffset(), annotation.getSourceRange().getLength()+numberOfSpaces, "");
+ }
+
+ // check and delete import
+ IImportDeclaration importDeclaration = compilationUnit.getImport(qualifiedName);
+ IImportContainer importContainer = compilationUnit.getImportContainer();
+ if(importDeclaration.exists() && importContainer.exists()){
+ int importSize = importContainer.getSourceRange().getOffset()+importContainer.getSourceRange().getLength();
+
+ if(rootEdit != null){
+ int annotationStart = annotation.getSourceRange().getOffset();
+ int annotationEnd = annotationStart+annotation.getSourceRange().getLength();
+ String textBefore = buffer.getText(importSize, annotationStart-importSize);
+ String textAfter = buffer.getText(annotationEnd, buffer.getLength()-annotationEnd);
+ if(checkImport(textBefore, qualifiedName) && checkImport(textAfter, qualifiedName)){
+ TextEdit edit = new DeleteEdit(importDeclaration.getSourceRange().getOffset(), importDeclaration.getSourceRange().getLength());
+ rootEdit.addChild(edit);
+ }
+ }else{
+ String text = buffer.getText(importSize, buffer.getLength()-importSize);
+ if(checkImport(text, qualifiedName)){
+ importDeclaration.delete(false, new NullProgressMonitor());
+ }
+ }
+ }
+
+ if(rootEdit == null){
+ synchronized(compilationUnit) {
+ compilationUnit.reconcile(ICompilationUnit.NO_AST, true, null, null);
+ }
+ }
+ }
+ }
+
+ private static boolean checkImport(String text, String qualifiedName){
+ String name = getShortName(qualifiedName);
+
+ Pattern p = Pattern.compile(".*\\W"+name+"\\W.*",Pattern.DOTALL); //$NON-NLS-1$ //$NON-NLS-2$
+ Matcher m = p.matcher(text);
+ return !m.matches();
+ }
+
+ public static IMember getJavaMember(IJavaElement element){
+ while(element != null){
+ if(element instanceof IMember)
+ return (IMember)element;
+ element = element.getParent();
+ }
+ return null;
+ }
+
+}
Property changes on: trunk/common/plugins/org.jboss.tools.common/src/org/jboss/tools/common/refactoring/MarkerResolutionUtils.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
14 years
JBoss Tools SVN: r37446 - in trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common: model/ui/attribute/editor and 3 other directories.
by jbosstools-commits@lists.jboss.org
Author: scabanovich
Date: 2011-12-19 20:59:12 -0500 (Mon, 19 Dec 2011)
New Revision: 37446
Modified:
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/editor/form/SamplePropertyForm.java
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/attribute/editor/NoteFieldEditor.java
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/forms/ExpandableForm.java
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/widgets/TextAndReferenceComponent.java
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/propertieseditor/PropertiesEditor.java
Log:
JBIDE-10226
https://issues.jboss.org/browse/JBIDE-10226
Font leaks prevented.
Modified: trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/editor/form/SamplePropertyForm.java
===================================================================
--- trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/editor/form/SamplePropertyForm.java 2011-12-20 01:51:14 UTC (rev 37445)
+++ trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/editor/form/SamplePropertyForm.java 2011-12-20 01:59:12 UTC (rev 37446)
@@ -32,6 +32,7 @@
import org.jboss.tools.common.model.ui.widgets.DefaultSettings;
import org.jboss.tools.common.model.ui.widgets.IWidgetSettings;
import org.jboss.tools.common.model.ui.widgets.WhiteSettings;
+import org.jboss.tools.common.util.SwtUtil;
public class SamplePropertyForm extends ExpandableForm implements PropertyChangeListener {
private XAttributeSupport support;
@@ -85,7 +86,9 @@
Font f = label.getFont();
FontData[] d = f.getFontData();
for (int i = 0; i < d.length; i++) d[i].setStyle(SWT.BOLD);
- label.setFont(new Font(null, d));
+ f = new Font(null, d);
+ label.setFont(f);
+ SwtUtil.bindDisposal(f, label);
}
updateEnablement();
Modified: trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/attribute/editor/NoteFieldEditor.java
===================================================================
--- trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/attribute/editor/NoteFieldEditor.java 2011-12-20 01:51:14 UTC (rev 37445)
+++ trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/attribute/editor/NoteFieldEditor.java 2011-12-20 01:59:12 UTC (rev 37446)
@@ -48,6 +48,7 @@
import org.jboss.tools.common.model.ui.widgets.IWidgetSettings;
import org.jboss.tools.common.model.ui.widgets.ScrolledComposite;
import org.jboss.tools.common.model.ui.widgets.border.Border;
+import org.jboss.tools.common.util.SwtUtil;
public class NoteFieldEditor extends ExtendedFieldEditor implements IFieldEditor, IPropertyFieldEditor, IPropertyChangeListener, PropertyChangeListener {
protected IPropertyEditor propertyEditor;
@@ -208,6 +209,7 @@
try {
font = new Font(null, data);
textField.setFont(font);
+ SwtUtil.bindDisposal(font, textField);
} catch (SWTException e) {
ModelUIPlugin.getPluginLog().logError(e);
}
Modified: trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/forms/ExpandableForm.java
===================================================================
--- trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/forms/ExpandableForm.java 2011-12-20 01:51:14 UTC (rev 37445)
+++ trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/forms/ExpandableForm.java 2011-12-20 01:59:12 UTC (rev 37446)
@@ -11,12 +11,7 @@
package org.jboss.tools.common.model.ui.forms;
-import java.util.HashMap;
-
import org.eclipse.swt.SWT;
-import org.eclipse.swt.graphics.Device;
-import org.eclipse.swt.graphics.Font;
-import org.eclipse.swt.graphics.FontData;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
@@ -118,23 +113,9 @@
// section.setClient(composite);
section.setClient(client);
- section.setFont(getFontFromMap(section.getFont().getDevice(), section.getFont().getFontData()));
-
return control;
}
- private HashMap<FontData[], Font> fonts = new HashMap<FontData[], Font>();
-
- private Font getFontFromMap(Device device, FontData[] fontData){
- if(fonts.containsKey(fontData))
- return fonts.get(fontData);
- else{
- Font font = new Font(device, fontData);
- fonts.put(fontData, font);
- return font;
- }
- }
-
protected void reflow() {
if (control==null) return;
Composite parent = control.getParent();
Modified: trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/widgets/TextAndReferenceComponent.java
===================================================================
--- trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/widgets/TextAndReferenceComponent.java 2011-12-20 01:51:14 UTC (rev 37445)
+++ trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/widgets/TextAndReferenceComponent.java 2011-12-20 01:59:12 UTC (rev 37446)
@@ -27,6 +27,7 @@
import org.eclipse.swt.widgets.Canvas;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Display;
+import org.jboss.tools.common.util.SwtUtil;
public class TextAndReferenceComponent extends Canvas implements PaintListener, MouseMoveListener {
int defaultWidth = 100;
@@ -48,6 +49,7 @@
plain = getFont();
FontData d = plain.getFontData()[0];
bold = new Font(null, d.getName(), d.getHeight(), d.getStyle() | SWT.BOLD);
+ SwtUtil.bindDisposal(bold, this);
}
public void mouseMove(MouseEvent e) {
Modified: trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/propertieseditor/PropertiesEditor.java
===================================================================
--- trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/propertieseditor/PropertiesEditor.java 2011-12-20 01:51:14 UTC (rev 37445)
+++ trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/propertieseditor/PropertiesEditor.java 2011-12-20 01:59:12 UTC (rev 37446)
@@ -78,6 +78,7 @@
import org.jboss.tools.common.model.ui.objecteditor.XChildrenEditor;
import org.jboss.tools.common.model.ui.texteditors.TextActionHelper;
import org.jboss.tools.common.model.util.AbstractTableHelper;
+import org.jboss.tools.common.util.SwtUtil;
public class PropertiesEditor extends XChildrenEditor implements ITextEditor, ITextOperationTarget {
static final String ENT_PROPERTY = "Property"; //$NON-NLS-1$
@@ -227,6 +228,7 @@
data[0].setHeight(data[0].getHeight() - 2);
font = new Font(font.getDevice(), data);
caseSensitive.setFont(font);
+ SwtUtil.bindDisposal(font, caseSensitive);
}
caseSensitive.setLayoutData(fd);
@@ -254,6 +256,7 @@
data[0].setHeight(data[0].getHeight() - 2);
font = new Font(font.getDevice(), data);
fake.setFont(font);
+ SwtUtil.bindDisposal(font, fake);
}
fake.setLayoutData(fd);
14 years
JBoss Tools SVN: r37445 - in trunk/cdi/tests/org.jboss.tools.cdi.core.test: src/org/jboss/tools/cdi/core/test/tck/validation and 1 other directory.
by jbosstools-commits@lists.jboss.org
Author: akazakov
Date: 2011-12-19 20:51:14 -0500 (Mon, 19 Dec 2011)
New Revision: 37445
Modified:
trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/jbt/validation/suppresswarnings/AnotherFish.java
trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/jbt/validation/suppresswarnings/Fish.java
trunk/cdi/tests/org.jboss.tools.cdi.core.test/src/org/jboss/tools/cdi/core/test/tck/validation/SuppressWarningsTests.java
Log:
https://issues.jboss.org/browse/JBIDE-10187 Add support for a @SuppressWarnings
Modified: trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/jbt/validation/suppresswarnings/AnotherFish.java
===================================================================
--- trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/jbt/validation/suppresswarnings/AnotherFish.java 2011-12-20 01:41:39 UTC (rev 37444)
+++ trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/jbt/validation/suppresswarnings/AnotherFish.java 2011-12-20 01:51:14 UTC (rev 37445)
@@ -30,7 +30,12 @@
@Inject Fish fish3BROKEN;
- public void useEL() {
+ public void useELBROKEN() {
String s = "#{fishDulipcatedNameSecond.abc}";
}
+
+ @Produces
+ @Named("fishDulipcatedNameSecond")
+ public void setFish3BROLEN(Fish fishOK) {
+ }
}
\ No newline at end of file
Modified: trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/jbt/validation/suppresswarnings/Fish.java
===================================================================
--- trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/jbt/validation/suppresswarnings/Fish.java 2011-12-20 01:41:39 UTC (rev 37444)
+++ trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/jbt/validation/suppresswarnings/Fish.java 2011-12-20 01:51:14 UTC (rev 37445)
@@ -31,11 +31,17 @@
public void setFish3(Fish fishBROKEN) {
}
- @SuppressWarnings("cdi-ambiguous-dependency")
+ @SuppressWarnings("all")
@Inject Fish fish3OK;
@SuppressWarnings("el-unresolved")
public void useELOK() {
String s = "#{fishDulipcatedName.abc}";
}
+
+ @SuppressWarnings("cdi-ambiguous-dependency")
+ @Produces
+ @Named("fishDulipcatedName")
+ public void setFish3OK(Fish fishOK) {
+ }
}
\ No newline at end of file
Modified: trunk/cdi/tests/org.jboss.tools.cdi.core.test/src/org/jboss/tools/cdi/core/test/tck/validation/SuppressWarningsTests.java
===================================================================
--- trunk/cdi/tests/org.jboss.tools.cdi.core.test/src/org/jboss/tools/cdi/core/test/tck/validation/SuppressWarningsTests.java 2011-12-20 01:41:39 UTC (rev 37444)
+++ trunk/cdi/tests/org.jboss.tools.cdi.core.test/src/org/jboss/tools/cdi/core/test/tck/validation/SuppressWarningsTests.java 2011-12-20 01:51:14 UTC (rev 37445)
@@ -55,7 +55,7 @@
AbstractResourceMarkerTest.assertMarkerIsNotCreated(file, MessageFormat.format(CDIValidationMessages.DUPLCICATE_EL_NAME, ".*"), 8);
file = tckProject.getFile("JavaSource/org/jboss/jsr299/tck/tests/jbt/validation/suppresswarnings/AnotherFish.java");
- AbstractResourceMarkerTest.assertMarkerIsCreated(file, MessageFormat.format(CDIValidationMessages.DUPLCICATE_EL_NAME, ".*"), 7, 12);
+ AbstractResourceMarkerTest.assertMarkerIsCreated(file, MessageFormat.format(CDIValidationMessages.DUPLCICATE_EL_NAME, ".*"), 7, 12, 38);
}
public void testFieldWithSuppressInParentElement() throws Exception {
@@ -112,7 +112,7 @@
ResourcesUtils.setBuildAutomatically(saveAutoBuild);
}
- public void testShortName() throws Exception {
+ public void testNameAll() throws Exception {
IFile file = tckProject.getFile("JavaSource/org/jboss/jsr299/tck/tests/jbt/validation/suppresswarnings/Fish.java");
AbstractResourceMarkerTest.assertMarkerIsNotCreated(file, CDIValidationMessages.AMBIGUOUS_INJECTION_POINTS, 35);
14 years
JBoss Tools SVN: r37444 - in trunk: cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/core/preferences and 18 other directories.
by jbosstools-commits@lists.jboss.org
Author: akazakov
Date: 2011-12-19 20:41:39 -0500 (Mon, 19 Dec 2011)
New Revision: 37444
Added:
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/validation/CDISuppressWarningsMap.java
trunk/cdi/plugins/org.jboss.tools.cdi.seam.solder.core/src/org/jboss/tools/cdi/seam/solder/core/validation/SolderSuppressWarningsMap.java
trunk/common/plugins/org.jboss.tools.common.validation/schema/warnings.exsd
trunk/common/plugins/org.jboss.tools.common.validation/src/org/jboss/tools/common/validation/IWarningNameMap.java
trunk/common/plugins/org.jboss.tools.common.validation/src/org/jboss/tools/common/validation/ValidationSeverityPreferences.java
trunk/common/plugins/org.jboss.tools.common.validation/src/org/jboss/tools/common/validation/WarningNameManager.java
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/validation/ELSuppressWarningsMap.java
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/validation/SeamSuppressWarningsMap.java
Modified:
trunk/cdi/plugins/org.jboss.tools.cdi.core/plugin.xml
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/core/preferences/CDIPreferences.java
trunk/cdi/plugins/org.jboss.tools.cdi.seam.config.core/src/org/jboss/tools/cdi/seam/config/core/CDISeamConfigPreferences.java
trunk/cdi/plugins/org.jboss.tools.cdi.seam.solder.core/plugin.xml
trunk/cdi/plugins/org.jboss.tools.cdi.seam.solder.core/src/org/jboss/tools/cdi/seam/solder/core/CDISeamSolderPreferences.java
trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/jbt/validation/suppresswarnings/Fish.java
trunk/common/plugins/org.jboss.tools.common.validation/plugin.xml
trunk/common/plugins/org.jboss.tools.common.validation/src/org/jboss/tools/common/validation/ValidationErrorManager.java
trunk/common/plugins/org.jboss.tools.common/src/org/jboss/tools/common/util/EclipseJavaUtil.java
trunk/jst/plugins/org.jboss.tools.jst.web.kb/plugin.xml
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/preferences/ELSeverityPreferences.java
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/preferences/KBSeverityPreferences.java
trunk/seam/plugins/org.jboss.tools.seam.core/plugin.xml
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/SeamPreferences.java
trunk/seam/plugins/org.jboss.tools.seam.ui/META-INF/MANIFEST.MF
trunk/seam/tests/org.jboss.tools.seam.ui.test/META-INF/MANIFEST.MF
Log:
https://issues.jboss.org/browse/JBIDE-10187 Add support for a @SuppressWarnings
Modified: trunk/cdi/plugins/org.jboss.tools.cdi.core/plugin.xml
===================================================================
--- trunk/cdi/plugins/org.jboss.tools.cdi.core/plugin.xml 2011-12-20 01:36:33 UTC (rev 37443)
+++ trunk/cdi/plugins/org.jboss.tools.cdi.core/plugin.xml 2011-12-20 01:41:39 UTC (rev 37444)
@@ -163,6 +163,16 @@
</extension>
<extension
+ id="CDIWarnings"
+ point="org.jboss.tools.common.validation.warnings">
+ <map
+ class="org.jboss.tools.cdi.internal.core.validation.CDISuppressWarningsMap"
+ warningGroupID="cdi"
+ preferenceGroupID="org.jboss.tools.cdi.core.validator.problem">
+ </map>
+ </extension>
+
+ <extension
id="CDIELValidationDelegate"
point="org.jboss.tools.jst.web.kb.elValidationDelegate">
<delegate
Modified: trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/core/preferences/CDIPreferences.java
===================================================================
--- trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/core/preferences/CDIPreferences.java 2011-12-20 01:36:33 UTC (rev 37443)
+++ trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/core/preferences/CDIPreferences.java 2011-12-20 01:41:39 UTC (rev 37444)
@@ -15,82 +15,85 @@
import org.eclipse.core.resources.IProject;
import org.jboss.tools.cdi.core.CDICorePlugin;
-import org.jboss.tools.common.preferences.SeverityPreferences;
+import org.jboss.tools.common.validation.ValidationSeverityPreferences;
/**
* @author Alexey Kazakov
*/
-public class CDIPreferences extends SeverityPreferences {
+public class CDIPreferences extends ValidationSeverityPreferences {
public static final Set<String> SEVERITY_OPTION_NAMES = new HashSet<String>();
private static CDIPreferences INSTANCE = new CDIPreferences();
+ public static final String WARNING_GROUP_ID = "cdi";
+
//Name group
-
+
// - stereotype declares a non-empty @Named annotation (2.7.1.3)
- public static final String STEREOTYPE_DECLARES_NON_EMPTY_NAME = INSTANCE.createSeverityOption("stereotypeDeclaresNonEmptyName"); //$NON-NLS-1$
+ public static final String STEREOTYPE_DECLARES_NON_EMPTY_NAME = INSTANCE.createSeverityOption("stereotypeDeclaresNonEmptyName", "non-empty-named"); //$NON-NLS-1$
+
// - producer field declaration specifies an EL name (together with one of
// @Resource, @PersistenceContext, @PersistenceUnit, @EJB, @WebServiceRef) (3.5.1)
- public static final String RESOURCE_PRODUCER_FIELD_SETS_EL_NAME = INSTANCE.createSeverityOption("resourceProducerFieldSetsElName"); //$NON-NLS-1$
+ public static final String RESOURCE_PRODUCER_FIELD_SETS_EL_NAME = INSTANCE.createSeverityOption("resourceProducerFieldSetsElName", "named-producer"); //$NON-NLS-1$
// - injection point other than injected field declares a @Named annotation that
// does not specify the value member
- public static final String PARAM_INJECTION_DECLARES_EMPTY_NAME = INSTANCE.createSeverityOption("paramInjectionDeclaresEmptyName"); //$NON-NLS-1$
+ public static final String PARAM_INJECTION_DECLARES_EMPTY_NAME = INSTANCE.createSeverityOption("paramInjectionDeclaresEmptyName", "empty-named"); //$NON-NLS-1$
// - interceptor or decorator has a name (2.5.3 non-portable)
- public static final String INTERCEPTOR_OR_DECORATOR_HAS_NAME = INSTANCE.createSeverityOption("interceptorHasName"); //$NON-NLS-1$
+ public static final String INTERCEPTOR_OR_DECORATOR_HAS_NAME = INSTANCE.createSeverityOption("interceptorHasName", "named"); //$NON-NLS-1$
// 5.3.1. Ambiguous EL names
// - All unresolvable ambiguous EL names are detected by the container when the application is initialized. Suppose two beans are both available for injection in a certain war, and either:
// • the two beans have the same EL name and the name is not resolvable, or
// • the EL name of one bean is of the form x.y, where y is a valid bean EL name, and x is the EL name of the other bean,
// the container automatically detects the problem and treats it as a deployment problem.
- public static final String AMBIGUOUS_EL_NAMES = INSTANCE.createSeverityOption("ambiguousElNames"); //$NON-NLS-1$
+ public static final String AMBIGUOUS_EL_NAMES = INSTANCE.createSeverityOption("ambiguousElNames", "ambiguous-name"); //$NON-NLS-1$
//Type group
// 5.2.1. Unsatisfied and ambiguous dependencies
// - If an unsatisfied or unresolvable ambiguous dependency exists, the container automatically detects the problem and
// treats it as a deployment problem.
- public static final String UNSATISFIED_OR_AMBIGUOUS_INJECTION_POINTS = INSTANCE.createSeverityOption("unsatisfiedInjectionPoints"); //$NON-NLS-1$
+ public static final String UNSATISFIED_OR_AMBIGUOUS_INJECTION_POINTS = INSTANCE.createSeverityOption("unsatisfiedInjectionPoints", "ambiguous-dependency"); //$NON-NLS-1$
// 5.4.1. Unproxyable bean types
// - If an injection point whose declared type cannot be proxied by the container resolves to a bean with a normal scope,
// the container automatically detects the problem and treats it as a deployment problem.
- public static final String UNPROXYABLE_BEAN_TYPE = INSTANCE.createSeverityOption("unproxyableBeanType"); //$NON-NLS-1$
+ public static final String UNPROXYABLE_BEAN_TYPE = INSTANCE.createSeverityOption("unproxyableBeanType", "ambiguous-dependency"); //$NON-NLS-1$
// - bean class or producer method or field specifies a @Typed annotation,
// and the value member specifies a class which does not correspond to a type
// in the unrestricted set of bean types of a bean (2.2.2)
- public static final String ILLEGAL_TYPE_IN_TYPED_DECLARATION = INSTANCE.createSeverityOption("illegalTypeInTypedDeclaration"); //$NON-NLS-1$
+ public static final String ILLEGAL_TYPE_IN_TYPED_DECLARATION = INSTANCE.createSeverityOption("illegalTypeInTypedDeclaration", "typed"); //$NON-NLS-1$
// - producer field/method return type contains a wildcard type parameter (3.3, 3.4)
// - producer field/method return type is a type variable (3.3, 3.4)
- public static final String PRODUCER_METHOD_RETURN_TYPE_HAS_WILDCARD_OR_VARIABLE = INSTANCE.createSeverityOption("producerMethodReturnTypeHasWildcard"); //$NON-NLS-1$
+ public static final String PRODUCER_METHOD_RETURN_TYPE_HAS_WILDCARD_OR_VARIABLE = INSTANCE.createSeverityOption("producerMethodReturnTypeHasWildcard", "typed-producer"); //$NON-NLS-1$
// - an injection point of primitive type resolves to a bean that may have null values, such as a producer method with a non-primitive return type or a producer field with a non-primitive type
- public static final String INJECT_RESOLVES_TO_NULLABLE_BEAN = INSTANCE.createSeverityOption("injectResolvesToNullableBean"); //$NON-NLS-1$
+ public static final String INJECT_RESOLVES_TO_NULLABLE_BEAN = INSTANCE.createSeverityOption("injectResolvesToNullableBean", "nullable"); //$NON-NLS-1$
// - matching object in the Java EE component environment is not of the same type
// as the producer field declaration (3.5.1)
- public static final String PRODUCER_FIELD_TYPE_DOES_NOT_MATCH_JAVA_EE_OBJECT = INSTANCE.createSeverityOption("producerFieldTypeDoesNotMatchJavaEeObject"); //$NON-NLS-1$
+ public static final String PRODUCER_FIELD_TYPE_DOES_NOT_MATCH_JAVA_EE_OBJECT = INSTANCE.createSeverityOption("producerFieldTypeDoesNotMatchJavaEeObject", "not-match-object"); //$NON-NLS-1$
// - injection point type is a type variable (5.2.2)
- public static final String INJECTION_TYPE_IS_VARIABLE = INSTANCE.createSeverityOption("injectionTypeIsVariable"); //$NON-NLS-1$
+ public static final String INJECTION_TYPE_IS_VARIABLE = INSTANCE.createSeverityOption("injectionTypeIsVariable", "type-variable"); //$NON-NLS-1$
// - stereotype is annotated @Typed (2.7.1.3 non-portable)
- public static final String STEREOTYPE_IS_ANNOTATED_TYPED = INSTANCE.createSeverityOption("stereotypeIsAnnotatedTyped"); //$NON-NLS-1$
+ public static final String STEREOTYPE_IS_ANNOTATED_TYPED = INSTANCE.createSeverityOption("stereotypeIsAnnotatedTyped", "typed"); //$NON-NLS-1$
// - array-valued or annotation-valued member of a qualifier type is not annotated @Nonbinding (5.2.5 non-portable)
- public static final String MISSING_NONBINDING_IN_QUALIFIER_TYPE_MEMBER = INSTANCE.createSeverityOption("missingNonbindingInQualifierTypeMember"); //$NON-NLS-1$
+ public static final String MISSING_NONBINDING_IN_QUALIFIER_TYPE_MEMBER = INSTANCE.createSeverityOption("missingNonbindingInQualifierTypeMember", "nonbinding"); //$NON-NLS-1$
// - array-valued or annotation-valued member of an interceptor binding type
// is not annotated @Nonbinding (9.5.2 non-portable)
- public static final String MISSING_NONBINDING_IN_INTERCEPTOR_BINDING_TYPE_MEMBER = INSTANCE.createSeverityOption("missingNonbindingInInterceptorBindingTypeMember"); //$NON-NLS-1$
+ public static final String MISSING_NONBINDING_IN_INTERCEPTOR_BINDING_TYPE_MEMBER = INSTANCE.createSeverityOption("missingNonbindingInInterceptorBindingTypeMember", "nonbinding"); //$NON-NLS-1$
- public static final String MISSING_OR_INCORRECT_TARGET_OR_RETENTION_IN_ANNOTATION_TYPE = INSTANCE.createSeverityOption("missingOrIncorrectTargetOrRetentionInAnnotationType"); //$NON-NLS-1$
+ public static final String MISSING_OR_INCORRECT_TARGET_OR_RETENTION_IN_ANNOTATION_TYPE = INSTANCE.createSeverityOption("missingOrIncorrectTargetOrRetentionInAnnotationType", "target"); //$NON-NLS-1$
// Section 6.6.4 - Validation of passivation capable beans and dependencies
// - If a managed bean which declares a passivating scope is not passivation capable, then the container automatically detects the problem and treats it as a deployment problem.
- public static final String NOT_PASSIVATION_CAPABLE_BEAN = INSTANCE.createSeverityOption("notPassivationCapableBean"); //$NON-NLS-1$
-
+ public static final String NOT_PASSIVATION_CAPABLE_BEAN = INSTANCE.createSeverityOption("notPassivationCapableBean", "not-passivation-capable"); //$NON-NLS-1$
+
//Scope group
// - bean class or producer method or field specifies multiple scope type annotations (2.4.3)
- public static final String MULTIPLE_SCOPE_TYPE_ANNOTATIONS = INSTANCE.createSeverityOption("multipleScopeTypeAnnotations"); //$NON-NLS-1$
+ public static final String MULTIPLE_SCOPE_TYPE_ANNOTATIONS = INSTANCE.createSeverityOption("multipleScopeTypeAnnotations", "multiple-scopes"); //$NON-NLS-1$
// - bean does not explicitly declare a scope when there is no default scope
// (there are two different stereotypes declared by the bean that declare different default scopes) (2.4.4)
- public static final String MISSING_SCOPE_WHEN_THERE_IS_NO_DEFAULT_SCOPE = INSTANCE.createSeverityOption("missingScopeWhenThereIsNoDefaultScope"); //$NON-NLS-1$
+ public static final String MISSING_SCOPE_WHEN_THERE_IS_NO_DEFAULT_SCOPE = INSTANCE.createSeverityOption("missingScopeWhenThereIsNoDefaultScope", "default-scope"); //$NON-NLS-1$
// - stereotype declares more than one scope (2.7.1.1)
- public static final String STEREOTYPE_DECLARES_MORE_THAN_ONE_SCOPE = INSTANCE.createSeverityOption("stereotypeDeclaresMoreThanOneScope"); //$NON-NLS-1$
+ public static final String STEREOTYPE_DECLARES_MORE_THAN_ONE_SCOPE = INSTANCE.createSeverityOption("stereotypeDeclaresMoreThanOneScope", "multiple-scopes"); //$NON-NLS-1$
// - managed bean with a public field declares any scope other than @Dependent (3.1)
// - managed bean with a parameterized bean class declares any scope other than @Dependent (3.1)
//
@@ -104,101 +107,101 @@
// any scope other than @Dependent (3.3)
// - producer field with a parameterized type with a type variable declares any
// scope other than @Dependent (3.4)
- public static final String ILLEGAL_SCOPE_FOR_BEAN = INSTANCE.createSeverityOption("illegalScopeForManagedBean"); //$NON-NLS-1$
+ public static final String ILLEGAL_SCOPE_FOR_BEAN = INSTANCE.createSeverityOption("illegalScopeForManagedBean", "scope"); //$NON-NLS-1$
// - bean that declares any scope other than @Dependent has an injection point of type
// InjectionPoint and qualifier @Default (5.5.7)
- public static final String ILLEGAL_SCOPE_WHEN_TYPE_INJECTIONPOINT_IS_INJECTED = INSTANCE.createSeverityOption("illegalScopeWhenTypeInjectionPointIsInjected"); //$NON-NLS-1$
+ public static final String ILLEGAL_SCOPE_WHEN_TYPE_INJECTIONPOINT_IS_INJECTED = INSTANCE.createSeverityOption("illegalScopeWhenTypeInjectionPointIsInjected", "scope"); //$NON-NLS-1$
// - interceptor or decorator has any scope other than @Dependent (2.4.1 non-portable)
- public static final String ILLEGAL_SCOPE_FOR_INTERCEPTOR_OR_DECORATOR = INSTANCE.createSeverityOption("illegalScopeForInterceptor"); //$NON-NLS-1$
+ public static final String ILLEGAL_SCOPE_FOR_INTERCEPTOR_OR_DECORATOR = INSTANCE.createSeverityOption("illegalScopeForInterceptor", "scope"); //$NON-NLS-1$
//Member group
// - producer method is annotated @Inject (3.3.2)
// - producer field is annotated @Inject (3.4.2) = - injected field is annotated @Produces (3.8.1)
- public static final String PRODUCER_ANNOTATED_INJECT = INSTANCE.createSeverityOption("producerAnnotatedInject"); //$NON-NLS-1$
+ public static final String PRODUCER_ANNOTATED_INJECT = INSTANCE.createSeverityOption("producerAnnotatedInject", "annotated-inject"); //$NON-NLS-1$
// - producer method has a parameter annotated @Disposes or @Observes (3.3.2)
- public static final String PRODUCER_PARAMETER_ILLEGALLY_ANNOTATED = INSTANCE.createSeverityOption("producerParameterIllegallyAnnotated"); //$NON-NLS-1$
+ public static final String PRODUCER_PARAMETER_ILLEGALLY_ANNOTATED = INSTANCE.createSeverityOption("producerParameterIllegallyAnnotated", "annotated-parameter"); //$NON-NLS-1$
// - observer method is annotated [@Produces or] @Inject (10.4.2)
- public static final String OBSERVER_ANNOTATED_INJECT = INSTANCE.createSeverityOption("observerAnnotatedInject"); //$NON-NLS-1$
+ public static final String OBSERVER_ANNOTATED_INJECT = INSTANCE.createSeverityOption("observerAnnotatedInject", "annotated-observer"); //$NON-NLS-1$
// - has a parameter annotated @Disposes (10.4.2)
- public static final String OBSERVER_PARAMETER_ILLEGALLY_ANNOTATED = INSTANCE.createSeverityOption("observerParameterIllegallyAnnotated"); //$NON-NLS-1$
+ public static final String OBSERVER_PARAMETER_ILLEGALLY_ANNOTATED = INSTANCE.createSeverityOption("observerParameterIllegallyAnnotated", "annotated-parameter"); //$NON-NLS-1$
// - non-static method of a session bean class is annotated @Produces, and the method
// is not a business method of the session bean (3.3.2)
// - non-static field of a session bean class is annotated @Produces (3.4.2)
- public static final String ILLEGAL_PRODUCER_METHOD_IN_SESSION_BEAN = INSTANCE.createSeverityOption("illegalProducerMethodInSessionBean"); //$NON-NLS-1$
+ public static final String ILLEGAL_PRODUCER_METHOD_IN_SESSION_BEAN = INSTANCE.createSeverityOption("illegalProducerMethodInSessionBean", "annotated-produces"); //$NON-NLS-1$
// - method has more than one parameter annotated @Disposes (3.3.6)
- public static final String MULTIPLE_DISPOSING_PARAMETERS = INSTANCE.createSeverityOption("multipleDisposingParameters"); //$NON-NLS-1$
+ public static final String MULTIPLE_DISPOSING_PARAMETERS = INSTANCE.createSeverityOption("multipleDisposingParameters", "multiple-disposes"); //$NON-NLS-1$
// - disposer method is annotated [@Produces or] @Inject [or has a parameter annotated @Observes] (3.3.6)
- public static final String DISPOSER_ANNOTATED_INJECT = INSTANCE.createSeverityOption("disposerAnnotatedInject"); //$NON-NLS-1$
+ public static final String DISPOSER_ANNOTATED_INJECT = INSTANCE.createSeverityOption("disposerAnnotatedInject", "annotated-disposer"); //$NON-NLS-1$
// - non-static method of a session bean class has a parameter annotated @Disposes, and
// the method is not a business method of the session bean (3.3.6)
- public static final String ILLEGAL_DISPOSER_IN_SESSION_BEAN = INSTANCE.createSeverityOption("illegalDisposerInSessionBean"); //$NON-NLS-1$
+ public static final String ILLEGAL_DISPOSER_IN_SESSION_BEAN = INSTANCE.createSeverityOption("illegalDisposerInSessionBean", "annotated-disposer"); //$NON-NLS-1$
// - there is no producer method declared by the (same) bean class that is assignable
// to the disposed parameter of a disposer method (3.3.7)
- public static final String NO_PRODUCER_MATCHING_DISPOSER = INSTANCE.createSeverityOption("noProducerMatchingDisposer"); //$NON-NLS-1$
+ public static final String NO_PRODUCER_MATCHING_DISPOSER = INSTANCE.createSeverityOption("noProducerMatchingDisposer", "missing-producer"); //$NON-NLS-1$
// - there are multiple disposer methods for a single producer method (3.3.7)
- public static final String MULTIPLE_DISPOSERS_FOR_PRODUCER = INSTANCE.createSeverityOption("multipleDisposersForProducer"); //$NON-NLS-1$
+ public static final String MULTIPLE_DISPOSERS_FOR_PRODUCER = INSTANCE.createSeverityOption("multipleDisposersForProducer", "multiple-disposers"); //$NON-NLS-1$
// - bean class has more than one constructor annotated @Inject (3.7.1)
- public static final String MULTIPLE_INJECTION_CONSTRUCTORS = INSTANCE.createSeverityOption("multipleInjectionConstructors"); //$NON-NLS-1$
+ public static final String MULTIPLE_INJECTION_CONSTRUCTORS = INSTANCE.createSeverityOption("multipleInjectionConstructors", "constructor"); //$NON-NLS-1$
// - bean constructor has a parameter annotated @Disposes, or @Observes (3.7.1)
- public static final String CONSTRUCTOR_PARAMETER_ILLEGALLY_ANNOTATED = INSTANCE.createSeverityOption("constructorParameterIllegallyAnnotated"); //$NON-NLS-1$
+ public static final String CONSTRUCTOR_PARAMETER_ILLEGALLY_ANNOTATED = INSTANCE.createSeverityOption("constructorParameterIllegallyAnnotated", "constructor"); //$NON-NLS-1$
// - generic method of a bean is annotated @Inject (initializer method is a non-abstract,
// non-static, non-generic method of a bean class) (3.9.1)
- public static final String GENERIC_METHOD_ANNOTATED_INJECT = INSTANCE.createSeverityOption("genericMethodAnnotatedInject"); //$NON-NLS-1$
+ public static final String GENERIC_METHOD_ANNOTATED_INJECT = INSTANCE.createSeverityOption("genericMethodAnnotatedInject", "generic"); //$NON-NLS-1$
// - method has more than one parameter annotated @Observes (10.4.2)
- public static final String MULTIPLE_OBSERVING_PARAMETERS = INSTANCE.createSeverityOption("multipleObservingParameters"); //$NON-NLS-1$
+ public static final String MULTIPLE_OBSERVING_PARAMETERS = INSTANCE.createSeverityOption("multipleObservingParameters", "multiple-observers"); //$NON-NLS-1$
// - non-static method of a session bean class has a parameter annotated @Observes,
// and the method is not a business method of the EJB (10.4.2)
- public static final String ILLEGAL_OBSERVER_IN_SESSION_BEAN = INSTANCE.createSeverityOption("illegalObserverInSessionBean"); //$NON-NLS-1$
+ public static final String ILLEGAL_OBSERVER_IN_SESSION_BEAN = INSTANCE.createSeverityOption("illegalObserverInSessionBean", "observer"); //$NON-NLS-1$
// - bean with scope @Dependent has an observer method declared receive=IF_EXISTS (10.4.3)
- public static final String ILLEGAL_CONDITIONAL_OBSERVER = INSTANCE.createSeverityOption("illegalConditionalObserver"); //$NON-NLS-1$
+ public static final String ILLEGAL_CONDITIONAL_OBSERVER = INSTANCE.createSeverityOption("illegalConditionalObserver", "observer"); //$NON-NLS-1$
//Interceptor & Decorator group
// - the bean class of a managed bean is annotated with both
// the @Interceptor and @Decorator stereotypes (3.1)
- public static final String BOTH_INTERCEPTOR_AND_DECORATOR = INSTANCE.createSeverityOption("bothInterceptorAndDecorator"); //$NON-NLS-1$
+ public static final String BOTH_INTERCEPTOR_AND_DECORATOR = INSTANCE.createSeverityOption("bothInterceptorAndDecorator", "interceptor-decorator"); //$NON-NLS-1$
// - bean class of a session bean is annotated @Interceptor or @Decorator (3.2)
- public static final String SESSION_BEAN_ANNOTATED_INTERCEPTOR_OR_DECORATOR = INSTANCE.createSeverityOption("sessionBeanAnnotatedInterceptorOrDecorator"); //$NON-NLS-1$
+ public static final String SESSION_BEAN_ANNOTATED_INTERCEPTOR_OR_DECORATOR = INSTANCE.createSeverityOption("sessionBeanAnnotatedInterceptorOrDecorator", "interceptor-decorator"); //$NON-NLS-1$
// - interceptor or decorator has a method annotated @Produces (3.3.2)
// - interceptor or decorator has a field annotated @Produces (3.4.2)
- public static final String PRODUCER_IN_INTERCEPTOR_OR_DECORATOR = INSTANCE.createSeverityOption("producerInInterceptorOrDecorator"); //$NON-NLS-1$
+ public static final String PRODUCER_IN_INTERCEPTOR_OR_DECORATOR = INSTANCE.createSeverityOption("producerInInterceptorOrDecorator", "producer"); //$NON-NLS-1$
// - interceptor or decorator has a method annotated @Disposes
- public static final String DISPOSER_IN_INTERCEPTOR_OR_DECORATOR = INSTANCE.createSeverityOption("disposerInInterceptorOrDecorator"); //$NON-NLS-1$
+ public static final String DISPOSER_IN_INTERCEPTOR_OR_DECORATOR = INSTANCE.createSeverityOption("disposerInInterceptorOrDecorator", "disposer"); //$NON-NLS-1$
// - decorator has more than one delegate injection point, or does not have a delegate injection point (8.1.2)
- public static final String MULTIPLE_OR_MISSING_DELEGATE = INSTANCE.createSeverityOption("multipleDelegate"); //$NON-NLS-1$
+ public static final String MULTIPLE_OR_MISSING_DELEGATE = INSTANCE.createSeverityOption("multipleDelegate", "ambiguous-delegate"); //$NON-NLS-1$
// - injection point that is not an injected field, initializer method parameter
// or bean constructor method parameter is annotated @Delegate (8.1.2)
- public static final String ILLEGAL_INJECTION_POINT_DELEGATE = INSTANCE.createSeverityOption("illegalInjectionPointDelegate"); //$NON-NLS-1$
+ public static final String ILLEGAL_INJECTION_POINT_DELEGATE = INSTANCE.createSeverityOption("illegalInjectionPointDelegate", "delegate"); //$NON-NLS-1$
// - bean class that is not a decorator has an injection point annotated @Delegate (8.1.2)
- public static final String ILLEGAL_BEAN_DECLARING_DELEGATE = INSTANCE.createSeverityOption("illegalBeanDeclaringDelegate"); //$NON-NLS-1$
+ public static final String ILLEGAL_BEAN_DECLARING_DELEGATE = INSTANCE.createSeverityOption("illegalBeanDeclaringDelegate", "delegate"); //$NON-NLS-1$
// - delegate type does not implement or extend a decorated type of the decorator,
// or specifies different type parameters (8.1.3)
- public static final String DELEGATE_HAS_ILLEGAL_TYPE = INSTANCE.createSeverityOption("delegateHasIllegalType"); //$NON-NLS-1$
+ public static final String DELEGATE_HAS_ILLEGAL_TYPE = INSTANCE.createSeverityOption("delegateHasIllegalType", "delegate-type"); //$NON-NLS-1$
// - interceptor for lifecycle callbacks declares an interceptor binding type
// that is defined @Target({TYPE, METHOD}) (9.2)
- public static final String ILLEGAL_LIFECYCLE_CALLBACK_INTERCEPTOR_BINDING = INSTANCE.createSeverityOption("illegalLifecycleCallbackInterceptorBinding"); //$NON-NLS-1$
+ public static final String ILLEGAL_LIFECYCLE_CALLBACK_INTERCEPTOR_BINDING = INSTANCE.createSeverityOption("illegalLifecycleCallbackInterceptorBinding", "interceptor"); //$NON-NLS-1$
// - managed bean has a class level interceptor binding and is declared final
// or has a non-static, non-private, final method (9.3)
// - non-static, non-private, final method of a managed bean has a method level
// interceptor binding (9.3)
- public static final String ILLEGAL_INTERCEPTOR_BINDING_METHOD = INSTANCE.createSeverityOption("illegalInterceptorBindingMethod"); //$NON-NLS-1$
+ public static final String ILLEGAL_INTERCEPTOR_BINDING_METHOD = INSTANCE.createSeverityOption("illegalInterceptorBindingMethod", "interceptor-binding"); //$NON-NLS-1$
// - the set of interceptor bindings of a bean or interceptor, including bindings
// inherited from stereotypes and other interceptor bindings, has two instances
// of a certain interceptor binding type and the instances have different values
// of some annotation member (9.5.2)
- public static final String CONFLICTING_INTERCEPTOR_BINDINGS = INSTANCE.createSeverityOption("conflictingInterceptorBindings"); //$NON-NLS-1$
+ public static final String CONFLICTING_INTERCEPTOR_BINDINGS = INSTANCE.createSeverityOption("conflictingInterceptorBindings", "ambiguous-interceptor-binding"); //$NON-NLS-1$
// - interceptor or decorator has a method with a parameter annotated @Observes (10.4.2)
- public static final String OBSERVER_IN_INTERCEPTOR_OR_DECORATOR = INSTANCE.createSeverityOption("observerInInterceptorOrDecorator"); //$NON-NLS-1$
+ public static final String OBSERVER_IN_INTERCEPTOR_OR_DECORATOR = INSTANCE.createSeverityOption("observerInInterceptorOrDecorator", "observer"); //$NON-NLS-1$
// - interceptor or decorator is an alternative (2.6.1 non-portable)
- public static final String INTERCEPTOR_OR_DECORATOR_IS_ALTERNATIVE = INSTANCE.createSeverityOption("interceptorOrDecoratorIsAlternative"); //$NON-NLS-1$
+ public static final String INTERCEPTOR_OR_DECORATOR_IS_ALTERNATIVE = INSTANCE.createSeverityOption("interceptorOrDecoratorIsAlternative", "alternative"); //$NON-NLS-1$
// - interceptor declared using @Interceptor does not declare any interceptor binding (9.2 non-portable)
- public static final String MISSING_INTERCEPTOR_BINDING = INSTANCE.createSeverityOption("missingInterceptorBinding"); //$NON-NLS-1$
+ public static final String MISSING_INTERCEPTOR_BINDING = INSTANCE.createSeverityOption("missingInterceptorBinding", "missing-interceptor-binding"); //$NON-NLS-1$
// 8.3. Decorator resolution
// - If a decorator matches a managed bean, and the managed bean class is declared final, the container automatically detects
// the problem and treats it as a deployment problem.
// - If a decorator matches a managed bean with a non-static, non-private, final method, and the decorator also implements that method, the container automatically detects the problem and treats it as a deployment problem.
- public static final String DECORATOR_RESOLVES_TO_FINAL_BEAN = INSTANCE.createSeverityOption("decoratorResolvesToFinalBean"); //$NON-NLS-1$
+ public static final String DECORATOR_RESOLVES_TO_FINAL_BEAN = INSTANCE.createSeverityOption("decoratorResolvesToFinalBean", "final"); //$NON-NLS-1$
//Specialization
@@ -209,30 +212,30 @@
// the bean class of another session bean (3.2.4)
//
// - method annotated @Specializes is static or does not directly override another producer method (3.3.3)
- public static final String ILLEGAL_SPECIALIZING_BEAN = INSTANCE.createSeverityOption("illegalSpecializingManagedBean"); //$NON-NLS-1$
+ public static final String ILLEGAL_SPECIALIZING_BEAN = INSTANCE.createSeverityOption("illegalSpecializingManagedBean", "static"); //$NON-NLS-1$
// - X specializes Y but does not have some bean type of Y (4.3.1)
- public static final String MISSING_TYPE_IN_SPECIALIZING_BEAN = INSTANCE.createSeverityOption("missingTypeInSpecializingBean"); //$NON-NLS-1$
+ public static final String MISSING_TYPE_IN_SPECIALIZING_BEAN = INSTANCE.createSeverityOption("missingTypeInSpecializingBean", "specializes"); //$NON-NLS-1$
// - X specializes Y and Y has a name and X declares a name explicitly, using @Named (4.3.1)
- public static final String CONFLICTING_NAME_IN_SPECIALIZING_BEAN = INSTANCE.createSeverityOption("conflictingNameInSpecializingBean"); //$NON-NLS-1$
+ public static final String CONFLICTING_NAME_IN_SPECIALIZING_BEAN = INSTANCE.createSeverityOption("conflictingNameInSpecializingBean", "specializes-named"); //$NON-NLS-1$
// - interceptor is annotated @Specializes (4.3.1 non-portable)
// - decorator is annotated @Specializes (4.3.1 non-portable)
- public static final String INTERCEPTOR_ANNOTATED_SPECIALIZES = INSTANCE.createSeverityOption("interceptorAnnotatedSpecializes"); //$NON-NLS-1$
+ public static final String INTERCEPTOR_ANNOTATED_SPECIALIZES = INSTANCE.createSeverityOption("interceptorAnnotatedSpecializes", "specializes"); //$NON-NLS-1$
// 5.1.3. Inconsistent specialization
// - Suppose an enabled bean X specializes a second bean Y. If there is another enabled bean that specializes Y we say that inconsistent
// specialization exists. The container automatically detects inconsistent specialization and treats it as a deployment problem.
- public static final String INCONSISTENT_SPECIALIZATION = INSTANCE.createSeverityOption("inconsistentSpecialization"); //$NON-NLS-1$
+ public static final String INCONSISTENT_SPECIALIZATION = INSTANCE.createSeverityOption("inconsistentSpecialization", "inconsistent-specialization"); //$NON-NLS-1$
//Miscellaneous
// - Java EE component class has an injection point of type UserTransaction
// and qualifier @Default, and may not validly make use of the JTA UserTransaction
// according to the Java EE platform specification (3.6)
- public static final String ILLEGAL_INJECTING_USERTRANSACTION_TYPE = INSTANCE.createSeverityOption("illegalInjectingUserTransactionType"); //$NON-NLS-1$
+ public static final String ILLEGAL_INJECTING_USERTRANSACTION_TYPE = INSTANCE.createSeverityOption("illegalInjectingUserTransactionType", "user-transaction"); //$NON-NLS-1$
// - Java EE component class supporting injection that is not a bean has an injection
// point of type InjectionPoint and qualifier @Default (5.5.7)
- public static final String ILLEGAL_INJECTING_INJECTIONPOINT_TYPE = INSTANCE.createSeverityOption("illegalInjectingInjectionPointType"); //$NON-NLS-1$
+ public static final String ILLEGAL_INJECTING_INJECTIONPOINT_TYPE = INSTANCE.createSeverityOption("illegalInjectingInjectionPointType", "injection-point"); //$NON-NLS-1$
// - stereotype declares any qualifier annotation other than @Named (2.7.1.3 non-portable)
- public static final String ILLEGAL_QUALIFIER_IN_STEREOTYPE = INSTANCE.createSeverityOption("illegalQualifierInStereotype"); //$NON-NLS-1$
+ public static final String ILLEGAL_QUALIFIER_IN_STEREOTYPE = INSTANCE.createSeverityOption("illegalQualifierInStereotype", "stereotype"); //$NON-NLS-1$
// - bean class is deployed in two different bean archives (12.1 non-portable)
// ? is it a definition problem
@@ -254,6 +257,15 @@
private CDIPreferences() {
}
+ /*
+ * (non-Javadoc)
+ * @see org.jboss.tools.common.validation.ValidationSeverityPreferences#getWarningGroupID()
+ */
+ @Override
+ public String getWarningGroupID() {
+ return WARNING_GROUP_ID;
+ }
+
/* (non-Javadoc)
* @see org.jboss.tools.common.preferences.SeverityPreferences#createSeverityOption(java.lang.String)
*/
@@ -295,5 +307,4 @@
public static int getMaxNumberOfProblemMarkersPerFile(IProject project) {
return INSTANCE.getMaxNumberOfProblemMarkersPerResource(project);
}
-
}
\ No newline at end of file
Added: trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/validation/CDISuppressWarningsMap.java
===================================================================
--- trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/validation/CDISuppressWarningsMap.java (rev 0)
+++ trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/validation/CDISuppressWarningsMap.java 2011-12-20 01:41:39 UTC (rev 37444)
@@ -0,0 +1,29 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is 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:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.cdi.internal.core.validation;
+
+import org.jboss.tools.cdi.core.preferences.CDIPreferences;
+import org.jboss.tools.common.validation.IWarningNameMap;
+
+/**
+ * @author Alexey Kazakov
+ */
+public class CDISuppressWarningsMap implements IWarningNameMap {
+
+ /*
+ * (non-Javadoc)
+ * @see org.jboss.tools.common.validation.IWarningNameMap#getWarningNames(java.lang.String)
+ */
+ @Override
+ public String[] getWarningNames(String preferenceID) {
+ return CDIPreferences.getInstance().getWarningNames(preferenceID);
+ }
+}
\ No newline at end of file
Property changes on: trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/validation/CDISuppressWarningsMap.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Modified: trunk/cdi/plugins/org.jboss.tools.cdi.seam.config.core/src/org/jboss/tools/cdi/seam/config/core/CDISeamConfigPreferences.java
===================================================================
--- trunk/cdi/plugins/org.jboss.tools.cdi.seam.config.core/src/org/jboss/tools/cdi/seam/config/core/CDISeamConfigPreferences.java 2011-12-20 01:36:33 UTC (rev 37443)
+++ trunk/cdi/plugins/org.jboss.tools.cdi.seam.config.core/src/org/jboss/tools/cdi/seam/config/core/CDISeamConfigPreferences.java 2011-12-20 01:41:39 UTC (rev 37444)
@@ -1,3 +1,13 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is 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:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
package org.jboss.tools.cdi.seam.config.core;
import java.util.HashSet;
@@ -42,5 +52,4 @@
protected String getPluginId() {
return CDISeamConfigCorePlugin.PLUGIN_ID;
}
-
-}
+}
\ No newline at end of file
Modified: trunk/cdi/plugins/org.jboss.tools.cdi.seam.solder.core/plugin.xml
===================================================================
--- trunk/cdi/plugins/org.jboss.tools.cdi.seam.solder.core/plugin.xml 2011-12-20 01:36:33 UTC (rev 37443)
+++ trunk/cdi/plugins/org.jboss.tools.cdi.seam.solder.core/plugin.xml 2011-12-20 01:41:39 UTC (rev 37444)
@@ -74,4 +74,14 @@
<initializer class="org.jboss.tools.cdi.seam.solder.core.CDISeamSolderPreferenceInitializer"/>
</extension>
+ <extension
+ id="SolderWarnings"
+ point="org.jboss.tools.common.validation.warnings">
+ <map
+ class="org.jboss.tools.cdi.seam.solder.core.validation.SolderSuppressWarningsMap"
+ warningGroupID="solder"
+ preferenceGroupID="org.jboss.tools.cdi.seam.solder.core.validator.problem">
+ </map>
+ </extension>
+
</plugin>
Modified: trunk/cdi/plugins/org.jboss.tools.cdi.seam.solder.core/src/org/jboss/tools/cdi/seam/solder/core/CDISeamSolderPreferences.java
===================================================================
--- trunk/cdi/plugins/org.jboss.tools.cdi.seam.solder.core/src/org/jboss/tools/cdi/seam/solder/core/CDISeamSolderPreferences.java 2011-12-20 01:36:33 UTC (rev 37443)
+++ trunk/cdi/plugins/org.jboss.tools.cdi.seam.solder.core/src/org/jboss/tools/cdi/seam/solder/core/CDISeamSolderPreferences.java 2011-12-20 01:41:39 UTC (rev 37444)
@@ -13,25 +13,29 @@
import java.util.HashSet;
import java.util.Set;
-import org.jboss.tools.common.preferences.SeverityPreferences;
+import org.jboss.tools.cdi.core.preferences.CDIPreferences;
+import org.jboss.tools.common.validation.ValidationSeverityPreferences;
/**
*
* @author Viacheslav Kabanovich
*
*/
-public class CDISeamSolderPreferences extends SeverityPreferences {
+public class CDISeamSolderPreferences extends ValidationSeverityPreferences {
+
public static final Set<String> SEVERITY_OPTION_NAMES = new HashSet<String>();
private static CDISeamSolderPreferences INSTANCE = new CDISeamSolderPreferences();
- public static final String AMBIGUOUS_GENERIC_CONFIGURATION_POINT = INSTANCE.createSeverityOption("ambiguousGenericConfigurationPoint");
- public static final String WRONG_TYPE_OF_GENERIC_CONFIGURATION_POINT = INSTANCE.createSeverityOption("wrongTypeOfGenericConfigurationPoint");
- public static final String WRONG_GENERIC_CONFIGURATION_ANNOTATION_REFERENCE = INSTANCE.createSeverityOption("wrongGenericConfigurationAnnotationReference");
- public static final String GENERIC_CONFIGURATION_TYPE_IS_A_GENERIC_BEAN = INSTANCE.createSeverityOption("genericConfigurationTypeIsGenericBean");
+ public static final String WARNING_GROUP_ID = "solder";
+
+ public static final String AMBIGUOUS_GENERIC_CONFIGURATION_POINT = INSTANCE.createSeverityOption("ambiguousGenericConfigurationPoint", "ambiguous-generic");
+ public static final String WRONG_TYPE_OF_GENERIC_CONFIGURATION_POINT = INSTANCE.createSeverityOption("wrongTypeOfGenericConfigurationPoint", "type");
+ public static final String WRONG_GENERIC_CONFIGURATION_ANNOTATION_REFERENCE = INSTANCE.createSeverityOption("wrongGenericConfigurationAnnotationReference", "annotation");
+ public static final String GENERIC_CONFIGURATION_TYPE_IS_A_GENERIC_BEAN = INSTANCE.createSeverityOption("genericConfigurationTypeIsGenericBean", "generic-bean");
- public static final String DEFAULT_PRODUCER_FIELD_ON_NORMAL_SCOPED_BEAN = INSTANCE.createSeverityOption("defaultProducerFieldOnNormalScopedBean");
- public static final String IDENTICAL_DEFAULT_BEANS = INSTANCE.createSeverityOption("identicalDefaultBeans");
+ public static final String DEFAULT_PRODUCER_FIELD_ON_NORMAL_SCOPED_BEAN = INSTANCE.createSeverityOption("defaultProducerFieldOnNormalScopedBean", "normal-scoped");
+ public static final String IDENTICAL_DEFAULT_BEANS = INSTANCE.createSeverityOption("identicalDefaultBeans", "default-bean");
public static CDISeamSolderPreferences getInstance() {
return INSTANCE;
@@ -40,6 +44,20 @@
private CDISeamSolderPreferences() {}
@Override
+ public String getWarningGroupID() {
+ return WARNING_GROUP_ID;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.jboss.tools.common.validation.ValidationSeverityPreferences#getParentWarningGroupIDs()
+ */
+ @Override
+ protected String[] getParentWarningGroupIDs() {
+ return new String[]{CDIPreferences.WARNING_GROUP_ID};
+ }
+
+ @Override
protected Set<String> getSeverityOptionNames() {
return SEVERITY_OPTION_NAMES;
}
@@ -55,5 +73,4 @@
protected String getPluginId() {
return CDISeamSolderCorePlugin.PLUGIN_ID;
}
-
-}
+}
\ No newline at end of file
Added: trunk/cdi/plugins/org.jboss.tools.cdi.seam.solder.core/src/org/jboss/tools/cdi/seam/solder/core/validation/SolderSuppressWarningsMap.java
===================================================================
--- trunk/cdi/plugins/org.jboss.tools.cdi.seam.solder.core/src/org/jboss/tools/cdi/seam/solder/core/validation/SolderSuppressWarningsMap.java (rev 0)
+++ trunk/cdi/plugins/org.jboss.tools.cdi.seam.solder.core/src/org/jboss/tools/cdi/seam/solder/core/validation/SolderSuppressWarningsMap.java 2011-12-20 01:41:39 UTC (rev 37444)
@@ -0,0 +1,29 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is 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:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.cdi.seam.solder.core.validation;
+
+import org.jboss.tools.cdi.seam.solder.core.CDISeamSolderPreferences;
+import org.jboss.tools.common.validation.IWarningNameMap;
+
+/**
+ * @author Alexey Kazakov
+ */
+public class SolderSuppressWarningsMap implements IWarningNameMap {
+
+ /*
+ * (non-Javadoc)
+ * @see org.jboss.tools.common.validation.IWarningNameMap#getWarningNames(java.lang.String)
+ */
+ @Override
+ public String[] getWarningNames(String preferenceID) {
+ return CDISeamSolderPreferences.getInstance().getWarningNames(preferenceID);
+ }
+}
\ No newline at end of file
Property changes on: trunk/cdi/plugins/org.jboss.tools.cdi.seam.solder.core/src/org/jboss/tools/cdi/seam/solder/core/validation/SolderSuppressWarningsMap.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Modified: trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/jbt/validation/suppresswarnings/Fish.java
===================================================================
--- trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/jbt/validation/suppresswarnings/Fish.java 2011-12-20 01:36:33 UTC (rev 37443)
+++ trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/jbt/validation/suppresswarnings/Fish.java 2011-12-20 01:41:39 UTC (rev 37444)
@@ -4,7 +4,7 @@
import javax.inject.Inject;
import javax.inject.Named;
-@SuppressWarnings("org.jboss.tools.cdi.core.validator.problem.ambiguousElNames")
+@SuppressWarnings("cdi-ambiguous-name")
@Named("fishDulipcatedName")
public class Fish {
@@ -13,16 +13,16 @@
@Named("fishDulipcatedName")
@Produces Fish fish2OK;
- @SuppressWarnings("org.jboss.tools.cdi.core.validator.problem.producerAnnotatedInject")
+ @SuppressWarnings("cdi-annotated-inject")
@Inject @Produces Fish iFishOK;
@Inject @Produces Fish iFish2BROKEN;
@Produces
- public void setFish(@SuppressWarnings("org.jboss.tools.cdi.core.validator.problem.unsatisfiedInjectionPoints") Fish fishOK) {
+ public void setFish(@SuppressWarnings("cdi-ambiguous-dependency") Fish fishOK) {
}
- @SuppressWarnings({"org.jboss.tools.cdi.core.validator.problem.producerAnnotatedInject", "org.jboss.tools.cdi.core.validator.problem.unsatisfiedInjectionPoints"})
+ @SuppressWarnings({"cdi-annotated-inject", "cdi-ambiguous-dependency"})
@Inject @Produces
public void setFish2OK(Fish fishOK) {
}
@@ -31,11 +31,11 @@
public void setFish3(Fish fishBROKEN) {
}
- @SuppressWarnings("unsatisfiedInjectionPoints")
+ @SuppressWarnings("cdi-ambiguous-dependency")
@Inject Fish fish3OK;
- @SuppressWarnings("unknownElVariablePropertyName")
- public void useEL() {
+ @SuppressWarnings("el-unresolved")
+ public void useELOK() {
String s = "#{fishDulipcatedName.abc}";
}
}
\ No newline at end of file
Modified: trunk/common/plugins/org.jboss.tools.common/src/org/jboss/tools/common/util/EclipseJavaUtil.java
===================================================================
--- trunk/common/plugins/org.jboss.tools.common/src/org/jboss/tools/common/util/EclipseJavaUtil.java 2011-12-20 01:36:33 UTC (rev 37443)
+++ trunk/common/plugins/org.jboss.tools.common/src/org/jboss/tools/common/util/EclipseJavaUtil.java 2011-12-20 01:41:39 UTC (rev 37444)
@@ -173,24 +173,6 @@
}
/**
- * Returns annotation by the full name declared for the given java member or its parents.
- * @param member
- * @param name
- * @param checkParents
- * @return
- * @throws JavaModelException
- */
- public static IAnnotation findAnnotationByFullName(IMember member, String name, boolean checkParents) throws JavaModelException {
- String shortName = name;
- int i = name.lastIndexOf('.');
- if(i>-1) {
- shortName = name.substring(i+1);
- }
- IAnnotation annotation = findAnnotationByShortName(member, shortName, checkParents);
- return annotation!=null && checkAnnotationByFulltName(annotation, name) ? annotation:null;
- }
-
- /**
* Returns true if the given annotation has the given full name
* @param annotation
* @param fullName
@@ -222,14 +204,19 @@
}
/**
- * Returns annotation by the short name declared for the given java member or its parents.
+ * Returns annotation by the short name declared for the given java member and its parents.
+ * Returns null if no annotation found.
* @param member
* @param name
* @param checkParents
* @return
* @throws JavaModelException
*/
- public static IAnnotation findAnnotationByShortName(IJavaElement element, String name, boolean checkParents) throws JavaModelException {
+ public static Set<IAnnotation> findAnnotationsByShortName(IJavaElement element, String name, boolean checkParents) throws JavaModelException {
+ return findAnnotationsByShortName(null, element, name, checkParents);
+ }
+
+ private static Set<IAnnotation> findAnnotationsByShortName(Set<IAnnotation> result, IJavaElement element, String name, boolean checkParents) throws JavaModelException {
if(element instanceof IAnnotatable) {
IAnnotation[] annotations = ((IAnnotatable)element).getAnnotations();
for (IAnnotation annotation : annotations) {
@@ -239,16 +226,20 @@
aName = aName.substring(i+1);
}
if(aName.equals(name)) {
- return annotation;
+ if(result==null) {
+ result = new HashSet<IAnnotation>();
+ }
+ result.add(annotation);
+ break;
}
}
}
if(checkParents) {
IJavaElement parent = element.getParent();
- if(parent instanceof IMember) {
- return findAnnotationByShortName((IMember)parent, name, true);
+ if(parent instanceof IAnnotatable) {
+ return findAnnotationsByShortName(result, parent, name, true);
}
}
- return null;
+ return result;
}
}
\ No newline at end of file
Modified: trunk/common/plugins/org.jboss.tools.common.validation/plugin.xml
===================================================================
--- trunk/common/plugins/org.jboss.tools.common.validation/plugin.xml 2011-12-20 01:36:33 UTC (rev 37443)
+++ trunk/common/plugins/org.jboss.tools.common.validation/plugin.xml 2011-12-20 01:41:39 UTC (rev 37444)
@@ -2,6 +2,7 @@
<?eclipse version="3.0"?>
<plugin>
<extension-point id="validator" name="KB Validator" schema="schema/validator.exsd"/>
+ <extension-point id="warnings" name="Warning names supported by @SuppressWarnings" schema="schema/warnings.exsd"/>
<extension
point="org.eclipse.wst.validation.validator"
@@ -71,4 +72,4 @@
</persistent>
</extension>
-</plugin>
\ No newline at end of file
+</plugin>
Added: trunk/common/plugins/org.jboss.tools.common.validation/schema/warnings.exsd
===================================================================
--- trunk/common/plugins/org.jboss.tools.common.validation/schema/warnings.exsd (rev 0)
+++ trunk/common/plugins/org.jboss.tools.common.validation/schema/warnings.exsd 2011-12-20 01:41:39 UTC (rev 37444)
@@ -0,0 +1,116 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<!-- Schema file written by PDE -->
+<schema targetNamespace="org.jboss.tools.common.validation" xmlns="http://www.w3.org/2001/XMLSchema">
+<annotation>
+ <appInfo>
+ <meta.schema plugin="org.jboss.tools.common.validation" id="warnings" name="Warning names supported by @SuppressWarnings"/>
+ </appInfo>
+ <documentation>
+ [Enter description of this extension point.]
+ </documentation>
+ </annotation>
+
+ <element name="extension">
+ <annotation>
+ <appInfo>
+ <meta.element />
+ </appInfo>
+ </annotation>
+ <complexType>
+ <sequence>
+ <element ref="map" minOccurs="1" maxOccurs="unbounded"/>
+ </sequence>
+ <attribute name="point" type="string" use="required">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="id" type="string">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="name" type="string">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ <appInfo>
+ <meta.attribute translatable="true"/>
+ </appInfo>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <element name="map">
+ <complexType>
+ <attribute name="class" type="string" use="required">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ <appInfo>
+ <meta.attribute kind="java" basedOn=":org.jboss.tools.common.validation.IWarningNameMap"/>
+ </appInfo>
+ </annotation>
+ </attribute>
+ <attribute name="warningGroupID" type="string">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="preferenceGroupID" type="string" use="required">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="since"/>
+ </appInfo>
+ <documentation>
+ [Enter the first release in which this extension point appears.]
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="examples"/>
+ </appInfo>
+ <documentation>
+ [Enter extension point usage example here.]
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="apiinfo"/>
+ </appInfo>
+ <documentation>
+ [Enter API information here.]
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="implementation"/>
+ </appInfo>
+ <documentation>
+ [Enter information about supplied implementation of this extension point.]
+ </documentation>
+ </annotation>
+
+
+</schema>
Property changes on: trunk/common/plugins/org.jboss.tools.common.validation/schema/warnings.exsd
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: trunk/common/plugins/org.jboss.tools.common.validation/src/org/jboss/tools/common/validation/IWarningNameMap.java
===================================================================
--- trunk/common/plugins/org.jboss.tools.common.validation/src/org/jboss/tools/common/validation/IWarningNameMap.java (rev 0)
+++ trunk/common/plugins/org.jboss.tools.common.validation/src/org/jboss/tools/common/validation/IWarningNameMap.java 2011-12-20 01:41:39 UTC (rev 37444)
@@ -0,0 +1,32 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is 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:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.common.validation;
+
+/**
+ * This interface represents a Map between the validation preference ID
+ * and all the available warning names which can be used in @SuppressWarnings("...")
+ * to suppress the corresponding validation.
+ * @author Alexey Kazakov
+ */
+public interface IWarningNameMap {
+
+ static final String EXTENSION_POINT_ID = "org.jboss.tools.common.validation.warnings"; //$NON-NLS-1$
+
+ /**
+ * Returns array of warning names which can be used in @SuppressWarnings("...")
+ * which are mapped to the full preference ID of the corresponding validation rule.
+ * The first name of the result array is preferred and the rest of names are optional.
+ * Returns null if no warning name found for this preference ID.
+ * @param preferenceID
+ * @return
+ */
+ String[] getWarningNames(String preferenceID);
+}
\ No newline at end of file
Property changes on: trunk/common/plugins/org.jboss.tools.common.validation/src/org/jboss/tools/common/validation/IWarningNameMap.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Modified: trunk/common/plugins/org.jboss.tools.common.validation/src/org/jboss/tools/common/validation/ValidationErrorManager.java
===================================================================
--- trunk/common/plugins/org.jboss.tools.common.validation/src/org/jboss/tools/common/validation/ValidationErrorManager.java 2011-12-20 01:36:33 UTC (rev 37443)
+++ trunk/common/plugins/org.jboss.tools.common.validation/src/org/jboss/tools/common/validation/ValidationErrorManager.java 2011-12-20 01:41:39 UTC (rev 37444)
@@ -178,54 +178,64 @@
private static final String SUPPRESS_WARNINGS_ANNOTATION_FULL = "java.lang.SuppressWarnings";
private static final String ALL_WARNINGS = "all";
- private static IAnnotation getSuppressWarningsAnnotation(String preferenceKey, IJavaElement element) throws JavaModelException {
+ private static boolean hasSuppressWarningsAnnotation(String preferenceKey, IJavaElement element) throws JavaModelException {
+ String[] names = WarningNameManager.getInstance().getWarningNames(preferenceKey);
+ if(names==null || names.length==1) {
+ return false;
+ }
// Does the element have @SuppressWarnings? Check it by the short name only.
- IAnnotation annotation = EclipseJavaUtil.findAnnotationByShortName(element, SUPPRESS_WARNINGS_ANNOTATION_SHORT, true);
- IAnnotation result = null;
- if(annotation!=null) {
- IMemberValuePair[] pairs = annotation.getMemberValuePairs();
- if(pairs.length==1) {
- Object v = pairs[0].getValue();
- Object[] warnings = null;
- if(v instanceof Object[]) {
- warnings = (Object[])v;
- } else if(v instanceof String) {
- warnings = new String[]{v.toString()};
- }
- String shortKey = null;
- int dot = preferenceKey.lastIndexOf('.');
- if(dot>-1) {
- shortKey = preferenceKey.substring(dot+1);
- }
- for (Object warning : warnings) {
- String trimed = warning.toString().trim();
- if(shortKey!=null && trimed.equals(shortKey) || trimed.equals(preferenceKey) || trimed.equals(ALL_WARNINGS)) {
- // Ok, we seem to have such a suppress. Let's make sure the full name of annotation is java.lang.SuppressWarnings
- if(EclipseJavaUtil.checkAnnotationByFulltName(annotation, SUPPRESS_WARNINGS_ANNOTATION_FULL)) {
- result = annotation;
- break;
+ Set<IAnnotation> annotations = EclipseJavaUtil.findAnnotationsByShortName(element, SUPPRESS_WARNINGS_ANNOTATION_SHORT, true);
+ if(annotations!=null) {
+ for (IAnnotation annotation : annotations) {
+ IMemberValuePair[] pairs = annotation.getMemberValuePairs();
+ if(pairs.length==1) {
+ Object v = pairs[0].getValue();
+ Object[] warnings = null;
+ if(v instanceof Object[]) {
+ warnings = (Object[])v;
+ } else if(v instanceof String) {
+ warnings = new String[]{v.toString()};
+ }
+ for (Object warning : warnings) {
+ String trimed = warning.toString().trim();
+ boolean found = false;
+ if(trimed.equals(ALL_WARNINGS)) {
+ found = true;
+ } else {
+ for (String name : names) {
+ if(warning.equals(name)) {
+ found = true;
+ break;
+ }
+ }
}
+ if(found) {
+ // Ok, we seem to have such a suppress. Let's make sure the full name of annotation is java.lang.SuppressWarnings
+ if(EclipseJavaUtil.checkAnnotationByFulltName(annotation, SUPPRESS_WARNINGS_ANNOTATION_FULL)) {
+ return true;
+ }
+ }
}
}
}
}
- return result;
+ return false;
}
private static boolean hasSuppressWarningsAnnotation(String preferenceKey, ITextSourceReference location) throws JavaModelException {
boolean result = false;
if(location instanceof IJavaSourceReference) {
IJavaElement element = ((IJavaSourceReference) location).getSourceElement();
- if(element==null) {
+ if(element!=null) {
+ result = hasSuppressWarningsAnnotation(preferenceKey, element);
+ } else {
// Check if it's really a java resource.
IResource resource = location.getResource();
if("java".equalsIgnoreCase(resource.getFileExtension())) {
throw new NullPointerException("IJavaSourceReference referenced to java source should not return null in getSourceElement()");
}
- return result;
}
- result = getSuppressWarningsAnnotation(preferenceKey, element)!=null;
}
return result;
Added: trunk/common/plugins/org.jboss.tools.common.validation/src/org/jboss/tools/common/validation/ValidationSeverityPreferences.java
===================================================================
--- trunk/common/plugins/org.jboss.tools.common.validation/src/org/jboss/tools/common/validation/ValidationSeverityPreferences.java (rev 0)
+++ trunk/common/plugins/org.jboss.tools.common.validation/src/org/jboss/tools/common/validation/ValidationSeverityPreferences.java 2011-12-20 01:41:39 UTC (rev 37444)
@@ -0,0 +1,60 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is 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:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.common.validation;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.jboss.tools.common.preferences.SeverityPreferences;
+
+/**
+ * @author Alexey Kazakov
+ */
+public abstract class ValidationSeverityPreferences extends SeverityPreferences implements IWarningNameMap {
+
+ private Map<String, String[]> warningNameMap = new HashMap<String, String[]>();
+
+ /* (non-Javadoc)
+ * @see org.jboss.tools.common.validation.IWarningNameMap#getNames(java.lang.String)
+ */
+ @Override
+ public String[] getWarningNames(String preferenceID) {
+ return warningNameMap.get(preferenceID);
+ }
+
+ protected String createSeverityOption(String shortName, String... shortWarningNames) {
+ String name = createSeverityOption(shortName);
+ String[] parentIDs = getParentWarningGroupIDs();
+ String[] allNames = new String[shortWarningNames.length + parentIDs.length + 1];
+ for (int i=0; i<shortWarningNames.length; i++) {
+ allNames[i] = getWarningGroupID() + "-" + shortWarningNames[i];
+ }
+ allNames[shortWarningNames.length] = getWarningGroupID();
+ for (int i = 0; i < parentIDs.length; i++) {
+ allNames[shortWarningNames.length + 1 + i] = parentIDs[i];
+ }
+ warningNameMap.put(name, allNames);
+ return name;
+ }
+
+ private static final String[] EMPTY_IDS = new String[0];
+
+ protected String[] getParentWarningGroupIDs() {
+ return EMPTY_IDS;
+ }
+
+ /**
+ * Returns the ID of the group of warnings managed by this map.
+ * The ID may not contain '-'.
+ * @return
+ */
+ public abstract String getWarningGroupID();
+}
\ No newline at end of file
Property changes on: trunk/common/plugins/org.jboss.tools.common.validation/src/org/jboss/tools/common/validation/ValidationSeverityPreferences.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: trunk/common/plugins/org.jboss.tools.common.validation/src/org/jboss/tools/common/validation/WarningNameManager.java
===================================================================
--- trunk/common/plugins/org.jboss.tools.common.validation/src/org/jboss/tools/common/validation/WarningNameManager.java (rev 0)
+++ trunk/common/plugins/org.jboss.tools.common.validation/src/org/jboss/tools/common/validation/WarningNameManager.java 2011-12-20 01:41:39 UTC (rev 37444)
@@ -0,0 +1,125 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is 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:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.common.validation;
+
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IConfigurationElement;
+import org.eclipse.core.runtime.IExtension;
+import org.eclipse.core.runtime.IExtensionPoint;
+import org.eclipse.core.runtime.IExtensionRegistry;
+import org.eclipse.core.runtime.Platform;
+
+/**
+ * Represents a map between warning name supported by @SuppressWarnings
+ * and the corresponding preference ID.
+ *
+ * @author Alexey Kazakov
+ */
+public class WarningNameManager implements IWarningNameMap {
+
+ private static final WarningNameManager INSTANCE = new WarningNameManager();
+
+ private Map<String, Set<IConfigurationElement>> allExtensions;
+ private Map<String, Set<IWarningNameMap>> maps;
+ private Map<String, String[]> warnings;
+
+ public static WarningNameManager getInstance() {
+ return INSTANCE;
+ }
+
+ private WarningNameManager() {
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.tools.common.validation.IWarningNameMap#getNames(java.lang.String)
+ */
+ @Override
+ public String[] getWarningNames(String preferenceID) {
+ init();
+ String[] names = null;
+ synchronized (warnings) {
+ names = warnings.get(preferenceID);
+ if(names==null) {
+ String preferenceGoupID = getPreferenceGroupID(preferenceID);
+ Set<IWarningNameMap> mapsByID = maps.get(preferenceGoupID);
+ if(mapsByID==null) {
+ mapsByID = new HashSet<IWarningNameMap>();
+ maps.put(preferenceGoupID, mapsByID);
+ Set<IConfigurationElement> extns = allExtensions.get(preferenceGoupID);
+ if(extns!=null) {
+ for (IConfigurationElement element : extns) {
+ try {
+ Object o = element.createExecutableExtension("class");
+ if(o instanceof IWarningNameMap) {
+ mapsByID.add((IWarningNameMap)o);
+ } else {
+ CommonValidationPlugin.getDefault().logError("Extension of " + IWarningNameMap.EXTENSION_POINT_ID + " should refer to an instance of " + IWarningNameMap.class + ". But the actuall class declared in " + element + " refers to " + o.getClass());
+ }
+ } catch (CoreException e) {
+ CommonValidationPlugin.getDefault().logError(e);
+ }
+ }
+ }
+ }
+ if(mapsByID.size()==1) {
+ names = mapsByID.iterator().next().getWarningNames(preferenceID);
+ } else {
+ Set<String> mapNameSet = new HashSet<String>();
+ for (IWarningNameMap map : mapsByID) {
+ String[] mapNames = map.getWarningNames(preferenceID);
+ for (String n : mapNames) {
+ mapNameSet.add(n);
+ }
+ }
+ names = mapNameSet.toArray(new String[mapNameSet.size()]);
+ }
+ warnings.put(preferenceID, names);
+ }
+ }
+ return names;
+ }
+
+ private String getPreferenceGroupID(String preferenceID) {
+ int dot = preferenceID.lastIndexOf('.');
+ return dot>-1?preferenceID.substring(0, dot):preferenceID;
+ }
+
+ private synchronized void init() {
+ if(allExtensions == null) {
+ maps = new HashMap<String, Set<IWarningNameMap>>();
+ warnings = new HashMap<String, String[]>();
+ allExtensions = new HashMap<String, Set<IConfigurationElement>>();
+ IExtensionRegistry registry = Platform.getExtensionRegistry();
+ IExtensionPoint extensionPoint = registry.getExtensionPoint(IWarningNameMap.EXTENSION_POINT_ID);
+ if (extensionPoint != null) {
+ IExtension[] extensions = extensionPoint.getExtensions();
+ for (int i=0; i<extensions.length; i++) {
+ IExtension extension = extensions[i];
+ IConfigurationElement[] elements = extension.getConfigurationElements();
+ for(int j=0; j<elements.length; j++) {
+ String preferenceGroupId = elements[j].getAttribute("preferenceGroupID");
+ Set<IConfigurationElement> els = allExtensions.get(preferenceGroupId);
+ if(els==null) {
+ els = new HashSet<IConfigurationElement>();
+ allExtensions.put(preferenceGroupId, els);
+ }
+ els.add(elements[j]);
+ }
+ }
+ }
+ }
+ }
+}
\ No newline at end of file
Property changes on: trunk/common/plugins/org.jboss.tools.common.validation/src/org/jboss/tools/common/validation/WarningNameManager.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Modified: trunk/jst/plugins/org.jboss.tools.jst.web.kb/plugin.xml
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.web.kb/plugin.xml 2011-12-20 01:36:33 UTC (rev 37443)
+++ trunk/jst/plugins/org.jboss.tools.jst.web.kb/plugin.xml 2011-12-20 01:41:39 UTC (rev 37444)
@@ -187,6 +187,16 @@
</validator>
</extension>
+ <extension
+ id="ELWarnings"
+ point="org.jboss.tools.common.validation.warnings">
+ <map
+ class="org.jboss.tools.jst.web.kb.internal.validation.ELSuppressWarningsMap"
+ warningGroupID="el"
+ preferenceGroupID="org.jboss.tools.jst.web.kb.validator.problem">
+ </map>
+ </extension>
+
<extension point="org.eclipse.wst.xml.core.catalogContributions">
<catalogContribution id="default">
<uri
Added: trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/validation/ELSuppressWarningsMap.java
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/validation/ELSuppressWarningsMap.java (rev 0)
+++ trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/validation/ELSuppressWarningsMap.java 2011-12-20 01:41:39 UTC (rev 37444)
@@ -0,0 +1,29 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is 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:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.jst.web.kb.internal.validation;
+
+import org.jboss.tools.common.validation.IWarningNameMap;
+import org.jboss.tools.jst.web.kb.preferences.ELSeverityPreferences;
+
+/**
+ * @author Alexey Kazakov
+ */
+public class ELSuppressWarningsMap implements IWarningNameMap {
+
+ /*
+ * (non-Javadoc)
+ * @see org.jboss.tools.common.validation.IWarningNameMap#getWarningNames(java.lang.String)
+ */
+ @Override
+ public String[] getWarningNames(String preferenceID) {
+ return ELSeverityPreferences.getInstance().getWarningNames(preferenceID);
+ }
+}
\ No newline at end of file
Property changes on: trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/validation/ELSuppressWarningsMap.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Modified: trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/preferences/ELSeverityPreferences.java
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/preferences/ELSeverityPreferences.java 2011-12-20 01:36:33 UTC (rev 37443)
+++ trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/preferences/ELSeverityPreferences.java 2011-12-20 01:41:39 UTC (rev 37444)
@@ -15,32 +15,35 @@
import org.eclipse.core.resources.IProject;
import org.jboss.tools.common.preferences.SeverityPreferences;
+import org.jboss.tools.common.validation.ValidationSeverityPreferences;
import org.jboss.tools.jst.web.kb.WebKbPlugin;
/**
* @author Alexey Kazakov
*/
-public class ELSeverityPreferences extends SeverityPreferences {
+public class ELSeverityPreferences extends ValidationSeverityPreferences {
public static final Set<String> SEVERITY_OPTION_NAMES = new HashSet<String>();
private static ELSeverityPreferences INSTANCE = new ELSeverityPreferences();
+ public static final String WARNING_GROUP_ID = "el";
+
// Expression Language
// Mark EL Variable name which we can't resolve.
- public static final String UNKNOWN_EL_VARIABLE_NAME = INSTANCE.createSeverityOption("unknownElVariableName"); //$NON-NLS-1$
+ public static final String UNKNOWN_EL_VARIABLE_NAME = INSTANCE.createSeverityOption("unknownElVariableName", "unresolved"); //$NON-NLS-1$
// Check "var" attributes.
public static final String CHECK_VARS = INSTANCE.createSeverityOption("checkVars"); //$NON-NLS-1$
// Re-validate unresolved ELs.
public static final String RE_VALIDATE_UNRESOLVED_EL = INSTANCE.createSeverityOption("revalidateUnresolvedEl"); //$NON-NLS-1$
// Mark EL Variable property name which we can't resolve.
- public static final String UNKNOWN_EL_VARIABLE_PROPERTY_NAME = INSTANCE.createSeverityOption("unknownElVariablePropertyName"); //$NON-NLS-1$
+ public static final String UNKNOWN_EL_VARIABLE_PROPERTY_NAME = INSTANCE.createSeverityOption("unknownElVariablePropertyName", "unresolved"); //$NON-NLS-1$
// If Expression use property of bean and this property has only setter(getter) without getter(setter) then mark it.
- public static final String UNPAIRED_GETTER_OR_SETTER = INSTANCE.createSeverityOption("unpairedGetterOrSetter"); //$NON-NLS-1$
+ public static final String UNPAIRED_GETTER_OR_SETTER = INSTANCE.createSeverityOption("unpairedGetterOrSetter", "unresolved"); //$NON-NLS-1$
- public static final String EL_SYNTAX_ERROR = INSTANCE.createSeverityOption("elSyntaxError"); //$NON-NLS-1$
-
+ public static final String EL_SYNTAX_ERROR = INSTANCE.createSeverityOption("elSyntaxError", "syntax"); //$NON-NLS-1$
+
public static final String NON_EXTERNALIZED_STRINGS = INSTANCE.createSeverityOption("nonExternalizedString"); //$NON-NLS-1$
/**
@@ -53,6 +56,15 @@
private ELSeverityPreferences() {
}
+ /*
+ * (non-Javadoc)
+ * @see org.jboss.tools.common.validation.ValidationSeverityPreferences#getWarningGroupID()
+ */
+ @Override
+ public String getWarningGroupID() {
+ return WARNING_GROUP_ID;
+ }
+
/* (non-Javadoc)
* @see org.jboss.tools.common.preferences.SeverityPreferences#createSeverityOption(java.lang.String)
*/
Modified: trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/preferences/KBSeverityPreferences.java
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/preferences/KBSeverityPreferences.java 2011-12-20 01:36:33 UTC (rev 37443)
+++ trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/preferences/KBSeverityPreferences.java 2011-12-20 01:41:39 UTC (rev 37444)
@@ -26,11 +26,7 @@
private static KBSeverityPreferences INSTANCE = new KBSeverityPreferences();
- // Expression Language
-
- // Mark EL Variable name which we can't resolve.
public static final String REQUIRED_KB_CAPABILITIES_ARE_MISSING = INSTANCE.createSeverityOption("requiredKbCapabilitiesAreMissing"); //$NON-NLS-1$
- // Check "var" attributes.
public static final String KB_CAPABILITIES_ARE_NOT_ENABLED_IN_JAVA_MODULE = INSTANCE.createSeverityOption("kbCapabilitiesAreNotEnabledInJavaModule"); //$NON-NLS-1$
/**
Modified: trunk/seam/plugins/org.jboss.tools.seam.core/plugin.xml
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.core/plugin.xml 2011-12-20 01:36:33 UTC (rev 37443)
+++ trunk/seam/plugins/org.jboss.tools.seam.core/plugin.xml 2011-12-20 01:41:39 UTC (rev 37444)
@@ -528,6 +528,16 @@
</extension>
<extension
+ id="SeamWarnings"
+ point="org.jboss.tools.common.validation.warnings">
+ <map
+ class="org.jboss.tools.seam.internal.core.validation.SeamSuppressWarningsMap"
+ warningGroupID="seam"
+ preferenceGroupID="org.jboss.tools.seam.core.validator.problem">
+ </map>
+ </extension>
+
+ <extension
id="SeamELValidationDelegate"
point="org.jboss.tools.jst.web.kb.elValidationDelegate">
<delegate
Modified: trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/SeamPreferences.java
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/SeamPreferences.java 2011-12-20 01:36:33 UTC (rev 37443)
+++ trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/SeamPreferences.java 2011-12-20 01:41:39 UTC (rev 37444)
@@ -14,7 +14,7 @@
import java.util.Set;
import org.eclipse.core.resources.IProject;
-import org.jboss.tools.common.preferences.SeverityPreferences;
+import org.jboss.tools.common.validation.ValidationSeverityPreferences;
/**
* Constants for names of seam preferences.
@@ -36,76 +36,78 @@
*
* @author Viacheslav Kabanovich
*/
-public class SeamPreferences extends SeverityPreferences {
+public class SeamPreferences extends ValidationSeverityPreferences {
public static final Set<String> SEVERITY_OPTION_NAMES = new HashSet<String>();
private static SeamPreferences INSTANCE = new SeamPreferences();
+ public static final String WARNING_GROUP_ID = "seam";
+
//Components
// Duplicate names found in @Name annotations will be marked
- public static final String NONUNIQUE_COMPONENT_NAME = INSTANCE.createSeverityOption("nonUniqueComponentName"); //$NON-NLS-1$
+ public static final String NONUNIQUE_COMPONENT_NAME = INSTANCE.createSeverityOption("nonUniqueComponentName", "duplicated-component"); //$NON-NLS-1$
// Components with @Stateful and without @Remove methods will be marked
- public static final String STATEFUL_COMPONENT_DOES_NOT_CONTENT_REMOVE = INSTANCE.createSeverityOption("statefulComponentDoesNotContainRemove"); //$NON-NLS-1$
+ public static final String STATEFUL_COMPONENT_DOES_NOT_CONTENT_REMOVE = INSTANCE.createSeverityOption("statefulComponentDoesNotContainRemove", "remove"); //$NON-NLS-1$
// Components with @Stateful and without @Destroy methods will be marked
- public static final String STATEFUL_COMPONENT_DOES_NOT_CONTENT_DESTROY = INSTANCE.createSeverityOption("statefulComponentDoesNotContainDestroy"); //$NON-NLS-1$
+ public static final String STATEFUL_COMPONENT_DOES_NOT_CONTENT_DESTROY = INSTANCE.createSeverityOption("statefulComponentDoesNotContainDestroy", "destroy"); //$NON-NLS-1$
// Components with @Stateful can't have PAGE or STATELESS scopes. If it has wrong scope then component will be marked.
- public static final String STATEFUL_COMPONENT_WRONG_SCOPE = INSTANCE.createSeverityOption("statefulComponentHasWrongScope"); //$NON-NLS-1$
+ public static final String STATEFUL_COMPONENT_WRONG_SCOPE = INSTANCE.createSeverityOption("statefulComponentHasWrongScope", "scope"); //$NON-NLS-1$
// If className ('component' element) contains unknown class name then component.xml will be marked.
- public static final String UNKNOWN_COMPONENT_CLASS_NAME = INSTANCE.createSeverityOption("unknownComponentClassName"); //$NON-NLS-1$
+ public static final String UNKNOWN_COMPONENT_CLASS_NAME = INSTANCE.createSeverityOption("unknownComponentClassName", "unknown-component"); //$NON-NLS-1$
- public static final String UNKNOWN_COMPONENT_CLASS_NAME_GUESS = INSTANCE.createSeverityOption("unknownComponentClassNameGuess"); //$NON-NLS-1$
+ public static final String UNKNOWN_COMPONENT_CLASS_NAME_GUESS = INSTANCE.createSeverityOption("unknownComponentClassNameGuess", "unknown-component"); //$NON-NLS-1$
// If component/property@name contains some property name which does not have setter then mark it.
- public static final String UNKNOWN_COMPONENT_PROPERTY = INSTANCE.createSeverityOption("unknownComponentProperty"); //$NON-NLS-1$
+ public static final String UNKNOWN_COMPONENT_PROPERTY = INSTANCE.createSeverityOption("unknownComponentProperty", "unknown-property"); //$NON-NLS-1$
//Entities
// Component marked as @Entity can't have STATELESS scope. If it has wrong scope mark it.
- public static final String ENTITY_COMPONENT_WRONG_SCOPE = INSTANCE.createSeverityOption("entityComponentHasWrongScope"); //$NON-NLS-1$
+ public static final String ENTITY_COMPONENT_WRONG_SCOPE = INSTANCE.createSeverityOption("entityComponentHasWrongScope", "entity"); //$NON-NLS-1$
// Mark any duplicated @Remove methods within one component.
- public static final String DUPLICATE_REMOVE = INSTANCE.createSeverityOption("duplicateRemove"); //$NON-NLS-1$
+ public static final String DUPLICATE_REMOVE = INSTANCE.createSeverityOption("duplicateRemove", "remove"); //$NON-NLS-1$
//Component life-cycle methods
// Mark duplicated @Destroy methods within one component.
- public static final String DUPLICATE_DESTROY = INSTANCE.createSeverityOption("duplicateDestroy"); //$NON-NLS-1$
+ public static final String DUPLICATE_DESTROY = INSTANCE.createSeverityOption("duplicateDestroy", "duplicated-method"); //$NON-NLS-1$
// Mark duplicated @Create methods within one component.
- public static final String DUPLICATE_CREATE = INSTANCE.createSeverityOption("duplicateCreate"); //$NON-NLS-1$
+ public static final String DUPLICATE_CREATE = INSTANCE.createSeverityOption("duplicateCreate", "duplicated-method"); //$NON-NLS-1$
// Mark duplicated @Unwrap methods within one component.
- public static final String DUPLICATE_UNWRAP = INSTANCE.createSeverityOption("duplicateUnwrap"); //$NON-NLS-1$
+ public static final String DUPLICATE_UNWRAP = INSTANCE.createSeverityOption("duplicateUnwrap", "duplicated-method"); //$NON-NLS-1$
// Mark all @Destroy methods which are not declared in components' classes.
- public static final String DESTROY_METHOD_BELONGS_TO_STATELESS_SESSION_BEAN = INSTANCE.createSeverityOption("destroyMethodBelongsToStatelessSessionBean"); //$NON-NLS-1$
+ public static final String DESTROY_METHOD_BELONGS_TO_STATELESS_SESSION_BEAN = INSTANCE.createSeverityOption("destroyMethodBelongsToStatelessSessionBean", "destroy"); //$NON-NLS-1$
// Mark all @Create methods which are not declared in components' classes.
- public static final String CREATE_DOESNT_BELONG_TO_COMPONENT = INSTANCE.createSeverityOption("createDoesNotBelongToComponent"); //$NON-NLS-1$
+ public static final String CREATE_DOESNT_BELONG_TO_COMPONENT = INSTANCE.createSeverityOption("createDoesNotBelongToComponent", "unused-method"); //$NON-NLS-1$
// Mark all @Unwrap methods which are not declared in components' classes.
- public static final String UNWRAP_DOESNT_BELONG_TO_COMPONENT = INSTANCE.createSeverityOption("unwrapDoesNotBelongToComponent"); //$NON-NLS-1$
+ public static final String UNWRAP_DOESNT_BELONG_TO_COMPONENT = INSTANCE.createSeverityOption("unwrapDoesNotBelongToComponent", "unused-method"); //$NON-NLS-1$
// Mark all @Observer methods which are not declared in components' classes.
- public static final String OBSERVER_DOESNT_BELONG_TO_COMPONENT = INSTANCE.createSeverityOption("observerDoesNotBelongToComponent"); //$NON-NLS-1$
+ public static final String OBSERVER_DOESNT_BELONG_TO_COMPONENT = INSTANCE.createSeverityOption("observerDoesNotBelongToComponent", "unused-method"); //$NON-NLS-1$
//Factories
// Factory method with a void return type must have an associated @Out/Databinder. Mark factory otherwise.
- public static final String UNKNOWN_FACTORY_NAME = INSTANCE.createSeverityOption("unknownFactoryName"); //$NON-NLS-1$
+ public static final String UNKNOWN_FACTORY_NAME = INSTANCE.createSeverityOption("unknownFactoryName", "factory"); //$NON-NLS-1$
//Bijections
// @DataModelSelection and @DataModelSelectionIndex without name requires the only one @DataModel in the component. Mark @DataModelSelection or @DataModelSelectionIndex otherwise.
- public static final String MULTIPLE_DATA_BINDER = INSTANCE.createSeverityOption("multipleDataBinder"); //$NON-NLS-1$
+ public static final String MULTIPLE_DATA_BINDER = INSTANCE.createSeverityOption("multipleDataBinder", "ambiguous-data"); //$NON-NLS-1$
// Mark @DataModelSelection or @DataModelSelectionIndex with unknown name. We should have @DataModel or @Out with the same name.
- public static final String UNKNOWN_DATA_MODEL = INSTANCE.createSeverityOption("unknownDataModel"); //$NON-NLS-1$
+ public static final String UNKNOWN_DATA_MODEL = INSTANCE.createSeverityOption("unknownDataModel", "ambiguous-data"); //$NON-NLS-1$
//Context variables
// If factory uses a name of any components (roles) or other factories then mark all these context variables' names.
- public static final String DUPLICATE_VARIABLE_NAME = INSTANCE.createSeverityOption("duplicateVariableName"); //$NON-NLS-1$
+ public static final String DUPLICATE_VARIABLE_NAME = INSTANCE.createSeverityOption("duplicateVariableName", "duplicated-variable"); //$NON-NLS-1$
// If @In uses a unknown context variable name then mark it.
- public static final String UNKNOWN_VARIABLE_NAME = INSTANCE.createSeverityOption("unknownVariableName"); //$NON-NLS-1$
+ public static final String UNKNOWN_VARIABLE_NAME = INSTANCE.createSeverityOption("unknownVariableName", "unresolved-variable"); //$NON-NLS-1$
//pages.xml
- public static final String UNRESOLVED_VIEW_ID = INSTANCE.createSeverityOption("unresolvedViewID"); //$NON-NLS-1$
-
+ public static final String UNRESOLVED_VIEW_ID = INSTANCE.createSeverityOption("unresolvedViewID", "unresolved-view"); //$NON-NLS-1$
+
// Seam project settings
// Mark seam project if it has any invalid seam setting.
@@ -122,6 +124,15 @@
private SeamPreferences() {
}
+ /*
+ * (non-Javadoc)
+ * @see org.jboss.tools.common.validation.ValidationSeverityPreferences#getWarningGroupID()
+ */
+ @Override
+ public String getWarningGroupID() {
+ return WARNING_GROUP_ID;
+ }
+
/* (non-Javadoc)
* @see org.jboss.tools.common.preferences.SeverityPreferences#createSeverityOption(java.lang.String)
*/
Added: trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/validation/SeamSuppressWarningsMap.java
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/validation/SeamSuppressWarningsMap.java (rev 0)
+++ trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/validation/SeamSuppressWarningsMap.java 2011-12-20 01:41:39 UTC (rev 37444)
@@ -0,0 +1,29 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is 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:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.seam.internal.core.validation;
+
+import org.jboss.tools.common.validation.IWarningNameMap;
+import org.jboss.tools.seam.core.SeamPreferences;
+
+/**
+ * @author Alexey Kazakov
+ */
+public class SeamSuppressWarningsMap implements IWarningNameMap {
+
+ /*
+ * (non-Javadoc)
+ * @see org.jboss.tools.common.validation.IWarningNameMap#getWarningNames(java.lang.String)
+ */
+ @Override
+ public String[] getWarningNames(String preferenceID) {
+ return SeamPreferences.getInstance().getWarningNames(preferenceID);
+ }
+}
\ No newline at end of file
Property changes on: trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/validation/SeamSuppressWarningsMap.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Modified: trunk/seam/plugins/org.jboss.tools.seam.ui/META-INF/MANIFEST.MF
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.ui/META-INF/MANIFEST.MF 2011-12-20 01:36:33 UTC (rev 37443)
+++ trunk/seam/plugins/org.jboss.tools.seam.ui/META-INF/MANIFEST.MF 2011-12-20 01:41:39 UTC (rev 37444)
@@ -41,7 +41,8 @@
org.eclipse.jst.j2ee.web;bundle-version="1.1.500",
org.jboss.tools.common.ui,
org.jboss.tools.common.el.ui,
- org.hibernate.eclipse.libs;bundle-version="3.4.0"
+ org.hibernate.eclipse.libs;bundle-version="3.4.0",
+ org.jboss.tools.common.validation
Bundle-ActivationPolicy: lazy
Export-Package: org.jboss.tools.seam.ui,
org.jboss.tools.seam.ui.actions,
Modified: trunk/seam/tests/org.jboss.tools.seam.ui.test/META-INF/MANIFEST.MF
===================================================================
--- trunk/seam/tests/org.jboss.tools.seam.ui.test/META-INF/MANIFEST.MF 2011-12-20 01:36:33 UTC (rev 37443)
+++ trunk/seam/tests/org.jboss.tools.seam.ui.test/META-INF/MANIFEST.MF 2011-12-20 01:41:39 UTC (rev 37444)
@@ -63,7 +63,8 @@
org.eclipse.ltk.ui.refactoring;bundle-version="3.5.100",
org.jboss.ide.eclipse.as.core,
org.jboss.tools.jsf,
- org.eclipse.jst.j2ee.web;bundle-version="1.1.500"
+ org.eclipse.jst.j2ee.web;bundle-version="1.1.500",
+ org.jboss.tools.common.validation
Export-Package: org.jboss.tools.seam.ui.test,
org.jboss.tools.seam.ui.test.ca,
org.jboss.tools.seam.ui.test.hyperlink,
14 years
JBoss Tools SVN: r37443 - trunk/maven/docs/maven_reference_guide/en-US.
by jbosstools-commits@lists.jboss.org
Author: irooskov(a)redhat.com
Date: 2011-12-19 20:36:33 -0500 (Mon, 19 Dec 2011)
New Revision: 37443
Modified:
trunk/maven/docs/maven_reference_guide/en-US/introduction.xml
Log:
updated to comment out some content that is no longer needed
Modified: trunk/maven/docs/maven_reference_guide/en-US/introduction.xml
===================================================================
--- trunk/maven/docs/maven_reference_guide/en-US/introduction.xml 2011-12-20 00:42:06 UTC (rev 37442)
+++ trunk/maven/docs/maven_reference_guide/en-US/introduction.xml 2011-12-20 01:36:33 UTC (rev 37443)
@@ -89,7 +89,7 @@
</section>
- <section id="requirements">
+<!-- <section id="requirements">
<title>Requirements</title>
<para><property>JBoss Maven Integration Tool </property>needs the following requirements: </para>
<itemizedlist>
@@ -131,6 +131,6 @@
</listitem>
</itemizedlist>
- </section>
+ </section> -->
</chapter>
14 years