Author: akazakov
Date: 2008-02-26 13:18:13 -0500 (Tue, 26 Feb 2008)
New Revision: 6586
Added:
trunk/seam/tests/org.jboss.tools.seam.core.test/projects/SeamWebWarTestProject/src/action/org/domain/SeamWebWarTestProject/session/SubclassTestComponent.java
trunk/seam/tests/org.jboss.tools.seam.core.test/projects/SeamWebWarTestProject/src/action/org/domain/SeamWebWarTestProject/session/SuperclassTestComponent.java
trunk/seam/tests/org.jboss.tools.seam.core.test/projects/SeamWebWarTestProject/src/action/org/domain/SeamWebWarTestProject/session/SuperclassTestComponent.withRemove
Modified:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/validation/SeamCoreValidator.java
trunk/seam/tests/org.jboss.tools.seam.core.test/src/org/jboss/tools/seam/core/test/SeamValidatorsTest.java
Log:
http://jira.jboss.com/jira/browse/JBIDE-1696 Fixed
Modified:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/validation/SeamCoreValidator.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/validation/SeamCoreValidator.java 2008-02-26
18:05:45 UTC (rev 6585)
+++
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/validation/SeamCoreValidator.java 2008-02-26
18:18:13 UTC (rev 6586)
@@ -23,10 +23,12 @@
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.jdt.core.Flags;
import org.eclipse.jdt.core.IMember;
import org.eclipse.jdt.core.IMethod;
import org.eclipse.jdt.core.IType;
+import org.eclipse.jdt.core.ITypeHierarchy;
import org.eclipse.jdt.core.JavaModelException;
import org.eclipse.osgi.util.NLS;
import org.eclipse.wst.validation.internal.core.ValidationException;
@@ -354,10 +356,24 @@
for (ISeamComponentDeclaration declaration : declarations) {
if(declaration instanceof ISeamJavaComponentDeclaration) {
ISeamJavaComponentDeclaration jd = (ISeamJavaComponentDeclaration)declaration;
- boolean sourceJavaDeclaration = !((IType)jd.getSourceMember()).isBinary();
+ IType type = (IType)jd.getSourceMember();
+ boolean sourceJavaDeclaration = !type.isBinary();
if(sourceJavaDeclaration) {
// Save link between component name and java source file.
validationContext.addLinkedCoreResource(componentName,
declaration.getSourcePath());
+ // Save link between component name and all supers of java declaration.
+ try {
+ ITypeHierarchy typeHierarchy = type.newSupertypeHierarchy(new
NullProgressMonitor());
+ IType[] superTypes = typeHierarchy == null ? null :
typeHierarchy.getAllSupertypes(type);
+ for (int i = 0; superTypes != null && i < superTypes.length; i++) {
+ if(!superTypes[i].isBinary()) {
+ IPath path = superTypes[i].getResource().getFullPath();
+ validationContext.addLinkedCoreResource(componentName, path);
+ }
+ }
+ } catch (JavaModelException e) {
+ SeamCorePlugin.getPluginLog().logError(e);
+ }
}
if(declaration!=firstJavaDeclaration) {
// Validate @Name
Added:
trunk/seam/tests/org.jboss.tools.seam.core.test/projects/SeamWebWarTestProject/src/action/org/domain/SeamWebWarTestProject/session/SubclassTestComponent.java
===================================================================
---
trunk/seam/tests/org.jboss.tools.seam.core.test/projects/SeamWebWarTestProject/src/action/org/domain/SeamWebWarTestProject/session/SubclassTestComponent.java
(rev 0)
+++
trunk/seam/tests/org.jboss.tools.seam.core.test/projects/SeamWebWarTestProject/src/action/org/domain/SeamWebWarTestProject/session/SubclassTestComponent.java 2008-02-26
18:18:13 UTC (rev 6586)
@@ -0,0 +1,28 @@
+/*******************************************************************************
+ * Copyright (c) 2007 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.domain.SeamWebWarTestProject.session;
+
+import javax.ejb.Stateful;
+
+import org.jboss.seam.annotations.Destroy;
+import org.jboss.seam.annotations.Name;
+
+/**
+ * Test component for JBIDE-1696
+ * @author Alexey Kazakov
+ */
+@Stateful
+@Name("testComponentJBIDE1696")
+public class SubclassTestComponent extends SuperclassTestComponent {
+
+ @Destroy public void foo1() {}
+}
\ No newline at end of file
Added:
trunk/seam/tests/org.jboss.tools.seam.core.test/projects/SeamWebWarTestProject/src/action/org/domain/SeamWebWarTestProject/session/SuperclassTestComponent.java
===================================================================
---
trunk/seam/tests/org.jboss.tools.seam.core.test/projects/SeamWebWarTestProject/src/action/org/domain/SeamWebWarTestProject/session/SuperclassTestComponent.java
(rev 0)
+++
trunk/seam/tests/org.jboss.tools.seam.core.test/projects/SeamWebWarTestProject/src/action/org/domain/SeamWebWarTestProject/session/SuperclassTestComponent.java 2008-02-26
18:18:13 UTC (rev 6586)
@@ -0,0 +1,20 @@
+ /*******************************************************************************
+ * Copyright (c) 2007 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.domain.SeamWebWarTestProject.session;
+
+/**
+ * Test component for JBIDE-1696
+ * @author Alexey Kazakov
+ */
+public class SuperclassTestComponent {
+
+}
\ No newline at end of file
Added:
trunk/seam/tests/org.jboss.tools.seam.core.test/projects/SeamWebWarTestProject/src/action/org/domain/SeamWebWarTestProject/session/SuperclassTestComponent.withRemove
===================================================================
---
trunk/seam/tests/org.jboss.tools.seam.core.test/projects/SeamWebWarTestProject/src/action/org/domain/SeamWebWarTestProject/session/SuperclassTestComponent.withRemove
(rev 0)
+++
trunk/seam/tests/org.jboss.tools.seam.core.test/projects/SeamWebWarTestProject/src/action/org/domain/SeamWebWarTestProject/session/SuperclassTestComponent.withRemove 2008-02-26
18:18:13 UTC (rev 6586)
@@ -0,0 +1,23 @@
+ /*******************************************************************************
+ * Copyright (c) 2007 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.domain.SeamWebWarTestProject.session;
+
+import javax.ejb.Remove;
+
+/**
+ * Test component for JBIDE-1696
+ * @author Alexey Kazakov
+ */
+public class SuperclassTestComponent {
+
+ @Remove void foo() {}
+}
\ No newline at end of file
Modified:
trunk/seam/tests/org.jboss.tools.seam.core.test/src/org/jboss/tools/seam/core/test/SeamValidatorsTest.java
===================================================================
---
trunk/seam/tests/org.jboss.tools.seam.core.test/src/org/jboss/tools/seam/core/test/SeamValidatorsTest.java 2008-02-26
18:05:45 UTC (rev 6585)
+++
trunk/seam/tests/org.jboss.tools.seam.core.test/src/org/jboss/tools/seam/core/test/SeamValidatorsTest.java 2008-02-26
18:18:13 UTC (rev 6586)
@@ -83,13 +83,31 @@
assertTrue("Problem marker was found in varAttributes.xhtml file. Validator did
not recognize 'var' attribute.", number == 0);
}
+ public void testJiraJbide1696() throws CoreException {
+ getSeamProject(project);
+
+ // Test for
http://jira.jboss.com/jira/browse/JBIDE-1696
+ IFile subclassComponentFile =
project.getFile("src/action/org/domain/SeamWebWarTestProject/session/SubclassTestComponent.java");
+ assertMarkerIsCreated(subclassComponentFile, null, "Stateful component
\"testComponentJBIDE1696\" must have a method marked @Remove", 25);
+ IFile superclassComponentFile =
project.getFile("src/action/org/domain/SeamWebWarTestProject/session/SuperclassTestComponent.java");
+ IFile superclassComponentFileWithRemove =
project.getFile("src/action/org/domain/SeamWebWarTestProject/session/SuperclassTestComponent.withRemove");
+ try{
+ superclassComponentFile.setContents(superclassComponentFileWithRemove.getContents(),
true, false, new NullProgressMonitor());
+ }catch(Exception e){
+ JUnitUtils.fail("Error during changing 'SuperclassTestComponent.java'
content to 'SuperclassTestComponent.withRemove'", e);
+ }
+ refreshProject(project);
+ int number = getMarkersNumber(subclassComponentFile);
+ assertTrue("We changed super class of component but it still don't see
changes.", number == 0);
+ }
+
public void testJiraJbide1631() throws CoreException {
// Test for
http://jira.jboss.com/jira/browse/JBIDE-1631
IFile jbide1631XHTMLFile = project.getFile("WebContent/JBIDE-1631.xhtml");
assertMarkerIsCreated(jbide1631XHTMLFile, null, "\"foo1\" cannot be
resolved", 16 );
assertMarkerIsCreated(jbide1631XHTMLFile, null, "\"foo2\" cannot be
resolved", 17 );
}
-
+
public void testComponentsValidator() {
ISeamProject seamProject = getSeamProject(project);