JBoss Tools SVN: r42752 - in trunk/ws: plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/domain and 5 other directories.
by jbosstools-commits@lists.jboss.org
Author: xcoulon
Date: 2012-07-27 05:55:48 -0400 (Fri, 27 Jul 2012)
New Revision: 42752
Added:
trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/domain/JaxrsBuiltinHttpMethod.java
Modified:
trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/builder/JaxrsMetamodelBuilder.java
trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/builder/ResourceChangedProcessor.java
trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/domain/JaxrsElementFactory.java
trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/domain/JaxrsEndpoint.java
trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/domain/JaxrsHttpMethod.java
trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/domain/JaxrsJavaElement.java
trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/domain/JaxrsMetamodel.java
trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/domain/JaxrsResourceMethod.java
trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/jdt/Annotation.java
trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/jdt/JaxrsAnnotationsScanner.java
trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/metamodel/IJaxrsHttpMethod.java
trunk/ws/tests/org.jboss.tools.ws.jaxrs.core.test/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/builder/JaxrsMetamodelChangedProcessorTestCase.java
trunk/ws/tests/org.jboss.tools.ws.jaxrs.core.test/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/builder/ResourceChangedProcessorTestCase.java
trunk/ws/tests/org.jboss.tools.ws.jaxrs.core.test/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/domain/JaxrsElementFactoryTestCase.java
trunk/ws/tests/org.jboss.tools.ws.jaxrs.core.test/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/domain/JaxrsMetamodelTestCase.java
trunk/ws/tests/org.jboss.tools.ws.jaxrs.core.test/src/org/jboss/tools/ws/jaxrs/core/jdt/JaxrsAnnotationScannerTestCase.java
Log:
Fixed - JBIDE-12224
Building JAX-RS metamodel is very slow at times
Modified: trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/builder/JaxrsMetamodelBuilder.java
===================================================================
--- trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/builder/JaxrsMetamodelBuilder.java 2012-07-27 08:56:30 UTC (rev 42751)
+++ trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/builder/JaxrsMetamodelBuilder.java 2012-07-27 09:55:48 UTC (rev 42752)
@@ -96,20 +96,6 @@
* the progress monitor
*/
private void build(final int buildKind, final IProject project, final IProgressMonitor progressMonitor) {
- /*
- * progressMonitor.beginTask("Building JAX-RS Metamodel", 4 * SCALE);
- * Logger.debug("Building JAX-RS Metamodel for project {}...", project.getName()); // extract the relevant delta
- * bound to this built (some resources or entire project) final List<ResourceDelta> affectedResources =
- * extractAffectedResources(project, progressMonitor); progressMonitor.worked(SCALE); // compute changes on the
- * JAX-RS Application(s), HttpMethods, Resources, etc. final boolean withReset = (buildKind == FULL_BUILD ||
- * buildKind == CLEAN_BUILD); final JaxrsMetamodelDelta metamodelDelta = resourceChangedProcessor
- * .processAffectedResources(project, withReset, affectedResources, new SubProgressMonitor(progressMonitor,
- * SCALE)); progressMonitor.worked(SCALE); new
- * JaxrsMetamodelChangedProcessor().processAffectedMetamodel(metamodelDelta, new
- * SubProgressMonitor(progressMonitor, SCALE)); progressMonitor.worked(SCALE); new
- * JaxrsElementChangedPublisher().publish(metamodelDelta, new SubProgressMonitor(progressMonitor, SCALE));
- * progressMonitor.worked(SCALE);
- */
ResourceChangedBuildJob job = new ResourceChangedBuildJob(project, getResourceChangeEvent(project, buildKind));
job.setRule(MutexJobSchedulingRule.getInstance());
job.schedule();
Modified: trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/builder/ResourceChangedProcessor.java
===================================================================
--- trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/builder/ResourceChangedProcessor.java 2012-07-27 08:56:30 UTC (rev 42751)
+++ trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/builder/ResourceChangedProcessor.java 2012-07-27 09:55:48 UTC (rev 42752)
@@ -30,6 +30,7 @@
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.jdt.core.IJavaElement;
+import org.eclipse.jdt.core.IPackageFragmentRoot;
import org.eclipse.jdt.core.IType;
import org.eclipse.jdt.core.ITypeHierarchy;
import org.eclipse.jdt.core.JavaCore;
@@ -102,18 +103,18 @@
final JaxrsMetamodel metamodel = JaxrsMetamodel.create(JavaCore.create(project));
final JaxrsMetamodelDelta metamodelDelta = new JaxrsMetamodelDelta(metamodel, deltaKind);
try {
- progressMonitor.beginTask("Processing Project '" + project.getName() + "'...", 1);
- Logger.debug("Processing Project '" + project.getName() + "'...");
+ progressMonitor.beginTask("Processing project '" + project.getName() + "'...", 1);
+ Logger.debug("Processing project '" + project.getName() + "'...");
metamodelDelta.addAll(processEvent(new ResourceDelta(project, ADDED, 0), progressMonitor));
if(WtpUtils.hasWebDeploymentDescriptor(project)) {
processEvent(new ResourceDelta(WtpUtils.getWebDeploymentDescriptor(project), ADDED, 0), progressMonitor);
}
progressMonitor.worked(1);
} catch (CoreException e) {
- Logger.error("Failed while processing Resource results", e);
+ Logger.error("Failed while processing resource results", e);
} finally {
progressMonitor.done();
- Logger.debug("Done processing Resource results.");
+ Logger.debug("Done processing resource results.");
}
@@ -144,7 +145,6 @@
elementChanges.addAll(processEvent(event, progressMonitor));
progressMonitor.worked(1);
}
-
} catch (CoreException e) {
Logger.error("Failed while processing Resource results", e);
elementChanges.clear();
@@ -167,7 +167,9 @@
final IJavaElement scope = JavaCore.create(resource);
final JaxrsMetamodel metamodel = JaxrsMetamodelLocator.get(resource.getProject());
final int deltaKind = event.getDeltaKind();
- if (scope != null) {
+ if (scope != null &&
+ // ignore changes on binary files (added/removed/changed jars to improve builder performances)
+ !(scope.getElementType() == IJavaElement.PACKAGE_FRAGMENT_ROOT && ((IPackageFragmentRoot)scope).isArchive())) {
switch (deltaKind) {
case ADDED:
case CHANGED:
Added: trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/domain/JaxrsBuiltinHttpMethod.java
===================================================================
--- trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/domain/JaxrsBuiltinHttpMethod.java (rev 0)
+++ trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/domain/JaxrsBuiltinHttpMethod.java 2012-07-27 09:55:48 UTC (rev 42752)
@@ -0,0 +1,86 @@
+/*******************************************************************************
+ * Copyright (c) 2012 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.jaxrs.core.internal.metamodel.domain;
+
+import org.jboss.tools.ws.jaxrs.core.jdt.Annotation;
+
+/**
+ * Built-in Http Methods as part of the JAX-RS 1.1 specification
+ * @author Xavier Coulon
+ *
+ */
+public class JaxrsBuiltinHttpMethod extends JaxrsHttpMethod {
+
+ public static final JaxrsHttpMethod GET = new JaxrsBuiltinHttpMethod("javax.ws.rs.GET", "GET");
+ public static final JaxrsHttpMethod POST = new JaxrsBuiltinHttpMethod("javax.ws.rs.POST", "POST");
+ public static final JaxrsHttpMethod PUT = new JaxrsBuiltinHttpMethod("javax.ws.rs.PUT", "PUT");
+ public static final JaxrsHttpMethod DELETE = new JaxrsBuiltinHttpMethod("javax.ws.rs.DELETE", "DELETE");
+ public static final JaxrsHttpMethod OPTIONS = new JaxrsBuiltinHttpMethod("javax.ws.rs.OPTIONS", "OPTIONS");
+ public static final JaxrsHttpMethod HEAD = new JaxrsBuiltinHttpMethod("javax.ws.rs.HEAD", "HEAD");
+
+ private final String annotationName;
+ private final String httpVerb;
+
+ public JaxrsBuiltinHttpMethod(String annotationName, String annotationValue) {
+ super(null, new Annotation(null, annotationName, annotationValue, null), null);
+ this.annotationName = annotationName;
+ this.httpVerb = annotationValue;
+ }
+
+ @Override
+ public String getHttpVerb() {
+ return this.httpVerb;
+ }
+
+ @Override
+ public String getFullyQualifiedName() {
+ return annotationName;
+ }
+
+ /* (non-Javadoc)
+ * @see java.lang.Object#hashCode()
+ */
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = super.hashCode();
+ result = prime * result + ((annotationName == null) ? 0 : annotationName.hashCode());
+ return result;
+ }
+
+ /* (non-Javadoc)
+ * @see java.lang.Object#equals(java.lang.Object)
+ */
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (!super.equals(obj)) {
+ return false;
+ }
+ if (getClass() != obj.getClass()) {
+ return false;
+ }
+ JaxrsBuiltinHttpMethod other = (JaxrsBuiltinHttpMethod) obj;
+ if (annotationName == null) {
+ if (other.annotationName != null) {
+ return false;
+ }
+ } else if (!annotationName.equals(other.annotationName)) {
+ return false;
+ }
+ return true;
+ }
+
+
+
+}
Property changes on: trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/domain/JaxrsBuiltinHttpMethod.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Modified: trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/domain/JaxrsElementFactory.java
===================================================================
--- trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/domain/JaxrsElementFactory.java 2012-07-27 08:56:30 UTC (rev 42751)
+++ trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/domain/JaxrsElementFactory.java 2012-07-27 09:55:48 UTC (rev 42752)
@@ -213,7 +213,7 @@
JaxrsMetamodel metamodel, JaxrsResource parentResource) throws JavaModelException {
final List<String> httpMethodAnnotationNames = new ArrayList<String>();
for (IJaxrsHttpMethod httpMethod : metamodel.getAllHttpMethods()) {
- httpMethodAnnotationNames.add(httpMethod.getJavaElement().getFullyQualifiedName());
+ httpMethodAnnotationNames.add(httpMethod.getFullyQualifiedName());
}
final List<String> annotationNames = new ArrayList<String>();
annotationNames.addAll(Arrays.asList(PATH.qualifiedName, PRODUCES.qualifiedName, CONSUMES.qualifiedName));
Modified: trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/domain/JaxrsEndpoint.java
===================================================================
--- trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/domain/JaxrsEndpoint.java 2012-07-27 08:56:30 UTC (rev 42751)
+++ trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/domain/JaxrsEndpoint.java 2012-07-27 09:55:48 UTC (rev 42752)
@@ -376,7 +376,7 @@
@Override
public IJavaProject getJavaProject() {
- return this.httpMethod.getJavaElement().getJavaProject();
+ return this.metamodel.getJavaProject();
}
}
Modified: trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/domain/JaxrsHttpMethod.java
===================================================================
--- trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/domain/JaxrsHttpMethod.java 2012-07-27 08:56:30 UTC (rev 42751)
+++ trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/domain/JaxrsHttpMethod.java 2012-07-27 09:55:48 UTC (rev 42752)
@@ -93,9 +93,9 @@
return OTHER;
}
}
-
- public JaxrsHttpMethod(IType javaType, Annotation httpMehodAnnotation, JaxrsMetamodel metamodel) {
- super(javaType, httpMehodAnnotation, metamodel);
+
+ public JaxrsHttpMethod(IType javaType, Annotation httpMethodAnnotation, JaxrsMetamodel metamodel) {
+ super(javaType, httpMethodAnnotation, metamodel);
}
@Override
@@ -133,7 +133,7 @@
* ()
*/
@Override
- public final String getHttpVerb() {
+ public String getHttpVerb() {
final Annotation httpVerbAnnotation = getHttpMethodAnnotation();
if (httpVerbAnnotation != null) {
return httpVerbAnnotation.getValue("value");
@@ -155,8 +155,8 @@
* ()
*/
@Override
- public final String getSimpleName() {
- return getJavaElement().getElementName();
+ public String getFullyQualifiedName() {
+ return getJavaElement().getFullyQualifiedName();
}
/*
@@ -166,7 +166,7 @@
*/
@Override
public final String toString() {
- return "HttpMethod [@" + getSimpleName() + ":" + getHttpMethodAnnotation() + "]";
+ return "HttpMethod [@" + getFullyQualifiedName() + ":" + getHttpMethodAnnotation() + "]";
}
@Override
Modified: trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/domain/JaxrsJavaElement.java
===================================================================
--- trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/domain/JaxrsJavaElement.java 2012-07-27 08:56:30 UTC (rev 42751)
+++ trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/domain/JaxrsJavaElement.java 2012-07-27 09:55:48 UTC (rev 42752)
@@ -179,7 +179,7 @@
flag = F_PRODUCED_MEDIATYPES_VALUE;
} else {
for (IJaxrsHttpMethod httpMethod : metamodel.getAllHttpMethods()) {
- if (httpMethod.getJavaElement().getFullyQualifiedName().equals(annotationName)) {
+ if (httpMethod.getFullyQualifiedName().equals(annotationName)) {
flag = F_HTTP_METHOD_VALUE;
break;
}
@@ -224,7 +224,7 @@
flag = F_PRODUCED_MEDIATYPES_VALUE;
} else {
for (IJaxrsHttpMethod httpMethod : metamodel.getAllHttpMethods()) {
- if (httpMethod.getJavaElement().getFullyQualifiedName().equals(annotationName)) {
+ if (httpMethod.getFullyQualifiedName().equals(annotationName)) {
flag = F_HTTP_METHOD_VALUE;
break;
}
Modified: trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/domain/JaxrsMetamodel.java
===================================================================
--- trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/domain/JaxrsMetamodel.java 2012-07-27 08:56:30 UTC (rev 42751)
+++ trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/domain/JaxrsMetamodel.java 2012-07-27 09:55:48 UTC (rev 42752)
@@ -96,8 +96,26 @@
*/
private JaxrsMetamodel(final IJavaProject javaProject) throws CoreException {
this.javaProject = javaProject;
+ preloadHttpMethods();
}
+ /**
+ * Preload the HttpMethods collection with 6 items from the specification:
+ * <ul>
+ * <li>@GET</li>
+ * <li>@POST</li>
+ * <li>@PUT</li>
+ * <li>@DELETE</li>
+ * <li>@OPTIONS</li>
+ * <li>@HEAD</li>
+ * </ul>
+ */
+ private void preloadHttpMethods() {
+ httpMethods.addAll(Arrays.asList(JaxrsBuiltinHttpMethod.GET, JaxrsBuiltinHttpMethod.POST,
+ JaxrsBuiltinHttpMethod.PUT, JaxrsBuiltinHttpMethod.DELETE, JaxrsBuiltinHttpMethod.HEAD,
+ JaxrsBuiltinHttpMethod.OPTIONS));
+ }
+
/*
* (non-Javadoc)
* @see org.jboss.tools.ws.jaxrs.core.internal.metamodel.IMetamodel#getJavaProject ()
@@ -454,7 +472,7 @@
public JaxrsHttpMethod getHttpMethod(Annotation httpMethodAnnotation) {
if (httpMethodAnnotation != null) {
for (IJaxrsHttpMethod httpMethod : httpMethods) {
- final String handleIdentifier1 = httpMethod.getJavaElement().getFullyQualifiedName();
+ final String handleIdentifier1 = httpMethod.getFullyQualifiedName();
final String handleIdentifier2 = httpMethodAnnotation.getName();
if (handleIdentifier1.equals(handleIdentifier2)) {
return (JaxrsHttpMethod) httpMethod;
Modified: trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/domain/JaxrsResourceMethod.java
===================================================================
--- trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/domain/JaxrsResourceMethod.java 2012-07-27 08:56:30 UTC (rev 42751)
+++ trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/domain/JaxrsResourceMethod.java 2012-07-27 09:55:48 UTC (rev 42752)
@@ -413,7 +413,7 @@
public Annotation getHttpMethodAnnotation() {
for (IJaxrsHttpMethod httpMethod : getMetamodel().getAllHttpMethods()) {
final Annotation annotation = getAnnotation(httpMethod
- .getJavaElement().getFullyQualifiedName());
+ .getFullyQualifiedName());
if (annotation != null) {
return annotation;
}
Modified: trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/jdt/Annotation.java
===================================================================
--- trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/jdt/Annotation.java 2012-07-27 08:56:30 UTC (rev 42751)
+++ trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/jdt/Annotation.java 2012-07-27 09:55:48 UTC (rev 42752)
@@ -10,6 +10,7 @@
******************************************************************************/
package org.jboss.tools.ws.jaxrs.core.jdt;
+import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -32,16 +33,34 @@
* Full constructor
*
* @param annotation
- * @param name
+ * @param annotationName
* @param annotationElements
+ * @param sourceRange
*/
- public Annotation(IAnnotation annotation, String name, Map<String, List<String>> annotationElements,
+ public Annotation(final IAnnotation annotation, final String annotationName, final Map<String, List<String>> annotationElements,
final ISourceRange sourceRange) {
this.javaAnnotation = annotation;
- this.javaAnnotationName = name;
+ this.javaAnnotationName = annotationName;
this.javaAnnotationElements = new HashMap<String, List<String>>(annotationElements);
this.sourceRange = sourceRange;
}
+
+ /**
+ * Full constructor with a single unnamed 'value'
+ *
+ * @param annotation
+ * @param annotationName
+ * @param annotationValue
+ * @param sourceRange
+ */
+ public Annotation(final IAnnotation annotation, final String annotationName, final String annotationValue,
+ final ISourceRange sourceRange) {
+ this.javaAnnotation = annotation;
+ this.javaAnnotationName = annotationName;
+ this.javaAnnotationElements = new HashMap<String, List<String>>();
+ this.javaAnnotationElements.put("value", Arrays.asList(annotationValue));
+ this.sourceRange = sourceRange;
+ }
public boolean update(Annotation annotation) {
assert annotation != null;
Modified: trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/jdt/JaxrsAnnotationsScanner.java
===================================================================
--- trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/jdt/JaxrsAnnotationsScanner.java 2012-07-27 08:56:30 UTC (rev 42751)
+++ trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/jdt/JaxrsAnnotationsScanner.java 2012-07-27 09:55:48 UTC (rev 42752)
@@ -140,8 +140,8 @@
throws CoreException {
IJavaSearchScope searchScope = null;
if (scope instanceof IJavaProject) {
- IJavaProject javaProject = (IJavaProject) scope;
- searchScope = SearchEngine.createJavaSearchScope(javaProject.getPackageFragmentRoots());
+ searchScope = SearchEngine.createJavaSearchScope(new IJavaElement[] { scope },
+ IJavaSearchScope.SOURCES | IJavaSearchScope.REFERENCED_PROJECTS);
} else {
searchScope = SearchEngine.createJavaSearchScope(new IJavaElement[] { scope });
}
@@ -195,7 +195,7 @@
List<String> annotations = new ArrayList<String>(httpMethods.size() + 1);
annotations.add(PATH.qualifiedName);
for (IJaxrsHttpMethod httpMethod : httpMethods) {
- annotations.add(httpMethod.getJavaElement().getFullyQualifiedName());
+ annotations.add(httpMethod.getFullyQualifiedName());
}
return searchForAnnotatedMethods(annotations, searchScope, progressMonitor);
}
Modified: trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/metamodel/IJaxrsHttpMethod.java
===================================================================
--- trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/metamodel/IJaxrsHttpMethod.java 2012-07-27 08:56:30 UTC (rev 42751)
+++ trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/metamodel/IJaxrsHttpMethod.java 2012-07-27 09:55:48 UTC (rev 42752)
@@ -19,7 +19,7 @@
String getHttpVerb();
/** @return the name */
- String getSimpleName();
+ String getFullyQualifiedName();
Annotation getHttpMethodAnnotation();
Modified: trunk/ws/tests/org.jboss.tools.ws.jaxrs.core.test/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/builder/JaxrsMetamodelChangedProcessorTestCase.java
===================================================================
--- trunk/ws/tests/org.jboss.tools.ws.jaxrs.core.test/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/builder/JaxrsMetamodelChangedProcessorTestCase.java 2012-07-27 08:56:30 UTC (rev 42751)
+++ trunk/ws/tests/org.jboss.tools.ws.jaxrs.core.test/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/builder/JaxrsMetamodelChangedProcessorTestCase.java 2012-07-27 09:55:48 UTC (rev 42752)
@@ -43,6 +43,7 @@
import org.eclipse.jdt.core.IType;
import org.eclipse.jdt.core.JavaModelException;
import org.jboss.tools.ws.jaxrs.core.AbstractCommonTestCase;
+import org.jboss.tools.ws.jaxrs.core.internal.metamodel.domain.JaxrsBuiltinHttpMethod;
import org.jboss.tools.ws.jaxrs.core.internal.metamodel.domain.JaxrsEndpoint;
import org.jboss.tools.ws.jaxrs.core.internal.metamodel.domain.JaxrsHttpMethod;
import org.jboss.tools.ws.jaxrs.core.internal.metamodel.domain.JaxrsJavaApplication;
@@ -115,14 +116,14 @@
return resourceMethod;
}
- private JaxrsHttpMethod createHttpMethod(EnumJaxrsElements element) throws JavaModelException, CoreException {
- final IType type = getType(element.qualifiedName, javaProject);
+ private JaxrsHttpMethod createHttpMethod(String qualifiedName) throws JavaModelException, CoreException {
+ final IType type = getType(qualifiedName, javaProject);
final Annotation httpAnnotation = getAnnotation(type, HTTP_METHOD.qualifiedName);
final JaxrsHttpMethod httpMethod = new JaxrsHttpMethod(type, httpAnnotation, metamodel);
metamodel.add(httpMethod);
return httpMethod;
}
-
+
private JaxrsEndpoint createEndpoint(JaxrsMetamodel metamodel, JaxrsHttpMethod httpMethod, JaxrsResourceMethod... resourceMethods) {
JaxrsEndpoint endpoint = new JaxrsEndpoint(metamodel, httpMethod, new LinkedList<JaxrsResourceMethod>(
Arrays.asList(resourceMethods)));
@@ -148,7 +149,7 @@
@Test
public void shouldConstructSimpleEndpoint() throws JavaModelException, CoreException {
// pre-conditions
- final JaxrsHttpMethod httpMethod = createHttpMethod(GET);
+ final JaxrsHttpMethod httpMethod = JaxrsBuiltinHttpMethod.GET;
final JaxrsResource customerResource = createResource("org.jboss.tools.ws.jaxrs.sample.services.CustomerResource");
customerResource.addOrUpdateAnnotation(getAnnotation(customerResource.getJavaElement(), CONSUMES.qualifiedName));
customerResource.addOrUpdateAnnotation(getAnnotation(customerResource.getJavaElement(), PRODUCES.qualifiedName));
@@ -169,7 +170,7 @@
@Test
public void shouldConstructEndpointFromSubresource() throws CoreException {
// pre-conditions
- final JaxrsHttpMethod httpMethod = createHttpMethod(GET);
+ final JaxrsHttpMethod httpMethod = JaxrsBuiltinHttpMethod.GET;
final JaxrsResource producLocatorResource = createResource("org.jboss.tools.ws.jaxrs.sample.services.ProductResourceLocator");
final JaxrsResourceMethod productLocatorMethod = createResourceMethod("getProductResourceLocator",
producLocatorResource, GET);
@@ -189,7 +190,7 @@
@Test
public void shouldConstructEndpointWithQueryParams() throws CoreException {
// pre-conditions
- final JaxrsHttpMethod httpMethod = createHttpMethod(GET);
+ final JaxrsHttpMethod httpMethod = JaxrsBuiltinHttpMethod.GET;
final JaxrsResource customerResource = createResource("org.jboss.tools.ws.jaxrs.sample.services.CustomerResource");
final JaxrsResourceMethod customerResourceMethod = createResourceMethod("getCustomers", customerResource,
GET);
@@ -203,7 +204,6 @@
@Test
public void shoudCreateEndpointWhenAddingResourceMethodInRootResource() throws CoreException {
// pre-conditions
- createHttpMethod(GET);
final JaxrsResource customerResource = createResource("org.jboss.tools.ws.jaxrs.sample.services.CustomerResource");
final JaxrsResourceMethod customerResourceMethod = createResourceMethod("getCustomers", customerResource,
GET);
@@ -218,7 +218,6 @@
@Test
public void shoudCreateEndpointWhenAddingSubresourceMethodInRootResource() throws JavaModelException, CoreException {
// pre-conditions
- createHttpMethod(GET);
final JaxrsResource customerResource = createResource("org.jboss.tools.ws.jaxrs.sample.services.CustomerResource");
final JaxrsResourceMethod customerSubresourceMethod = createResourceMethod("getCustomer", customerResource,
GET);
@@ -234,7 +233,6 @@
public void shoudCreateEndpointWhenAddingSubresourceLocatorMethodInRootResource() throws JavaModelException,
CoreException {
// pre-conditions
- createHttpMethod(GET);
final JaxrsResource bookResource = createResource("org.jboss.tools.ws.jaxrs.sample.services.BookResource");
createResourceMethod("getProduct", bookResource, GET);
// createEndpoint(httpMethod, bookResourceMethod);
@@ -257,7 +255,6 @@
@Test
public void shoudCreateEndpointWhenAddingResourceMethodInSubresource() throws JavaModelException, CoreException {
// pre-conditions
- createHttpMethod(GET);
final JaxrsResource productResourceLocator = createResource("org.jboss.tools.ws.jaxrs.sample.services.ProductResourceLocator");
createResourceMethod("getProductResourceLocator", productResourceLocator, null);
final JaxrsResource bookResource = createResource("org.jboss.tools.ws.jaxrs.sample.services.BookResource");
@@ -274,7 +271,6 @@
public void shoudCreateEndpointWhenChangingSubresourceLocatorMethodIntoSubresourceMethod()
throws JavaModelException, CoreException {
// pre-conditions
- createHttpMethod(GET);
final JaxrsResource customerResource = createResource("org.jboss.tools.ws.jaxrs.sample.services.CustomerResource");
final JaxrsResourceMethod customerSubresourceMethod = createResourceMethod("getCustomer", customerResource,
null);
@@ -293,7 +289,6 @@
@Test
public void shoudCreateEndpointWhenAddingSubresourceMethodInSubresource() throws JavaModelException, CoreException {
// pre-conditions
- createHttpMethod(GET);
final JaxrsResource productResourceLocator = createResource("org.jboss.tools.ws.jaxrs.sample.services.ProductResourceLocator");
createResourceMethod("getProductResourceLocator", productResourceLocator, null);
final JaxrsResource bookResource = createResource("org.jboss.tools.ws.jaxrs.sample.services.BookResource");
@@ -315,7 +310,7 @@
public void shoudChangeUriPathTemplateWhenAddingApplication() throws JavaModelException, CoreException {
// the subresource becomes a root resource !
// pre-conditions
- final JaxrsHttpMethod httpMethod = createHttpMethod(GET);
+ final JaxrsHttpMethod httpMethod = JaxrsBuiltinHttpMethod.GET;
final JaxrsResource customerResource = createResource("org.jboss.tools.ws.jaxrs.sample.services.CustomerResource");
final JaxrsResourceMethod customerResourceMethod = createResourceMethod("getCustomer", customerResource,
GET);
@@ -336,7 +331,7 @@
public void shoudChangeUriPathTemplateWhenAddingResourcePathAnnotation() throws JavaModelException, CoreException {
// the subresource becomes a root resource !
// pre-conditions
- final JaxrsHttpMethod httpMethod = createHttpMethod(GET);
+ final JaxrsHttpMethod httpMethod = JaxrsBuiltinHttpMethod.GET;
final JaxrsResource customerResource = createResource("org.jboss.tools.ws.jaxrs.sample.services.CustomerResource");
final JaxrsResourceMethod customerResourceMethod = createResourceMethod("getCustomers", customerResource,
GET);
@@ -355,7 +350,7 @@
@Test
public void shoudChangeUriPathTemplateWhenAddingMethodPathAnnotation() throws JavaModelException, CoreException {
// pre-conditions
- final JaxrsHttpMethod httpMethod = createHttpMethod(GET);
+ final JaxrsHttpMethod httpMethod = JaxrsBuiltinHttpMethod.GET;
final JaxrsResource customerResource = createResource("org.jboss.tools.ws.jaxrs.sample.services.CustomerResource");
final JaxrsResourceMethod customerResourceMethod = createResourceMethod("getCustomer", customerResource,
GET);
@@ -381,7 +376,7 @@
public void shoudChangeUriPathTemplateWhenChangingApplicationPathAnnotation() throws JavaModelException, CoreException {
// pre-conditions
final JaxrsJavaApplication application = createApplication("org.jboss.tools.ws.jaxrs.sample.services.RestApplication");
- final JaxrsHttpMethod httpMethod = createHttpMethod(GET);
+ final JaxrsHttpMethod httpMethod = JaxrsBuiltinHttpMethod.GET;
final JaxrsResource customerResource = createResource("org.jboss.tools.ws.jaxrs.sample.services.CustomerResource");
final JaxrsResourceMethod customerResourceMethod = createResourceMethod("getCustomer", customerResource,
GET);
@@ -404,7 +399,7 @@
@Test
public void shoudChangeUriPathTemplateWhenChangingResourcePathAnnotation() throws JavaModelException, CoreException {
// pre-conditions
- final JaxrsHttpMethod httpMethod = createHttpMethod(GET);
+ final JaxrsHttpMethod httpMethod = JaxrsBuiltinHttpMethod.GET;
final JaxrsResource customerResource = createResource("org.jboss.tools.ws.jaxrs.sample.services.CustomerResource");
final JaxrsResourceMethod customerResourceMethod = createResourceMethod("getCustomer", customerResource,
GET);
@@ -427,7 +422,7 @@
@Test
public void shoudChangeUriPathTemplateWhenChangingMethodPathAnnotation() throws JavaModelException, CoreException {
// pre-conditions
- final JaxrsHttpMethod httpMethod = createHttpMethod(GET);
+ final JaxrsHttpMethod httpMethod = JaxrsBuiltinHttpMethod.GET;
final JaxrsResource customerResource = createResource("org.jboss.tools.ws.jaxrs.sample.services.CustomerResource");
final JaxrsResourceMethod customerResourceMethod = createResourceMethod("getCustomer", customerResource,
GET);
@@ -451,7 +446,7 @@
public void shoudChangeUriPathTemplateWhenRemovingResourcePathAnnotationAndMatchingSubresourceLocatorFound()
throws JavaModelException, CoreException {
// pre-conditions
- final JaxrsHttpMethod httpMethod = createHttpMethod(GET);
+ final JaxrsHttpMethod httpMethod = JaxrsBuiltinHttpMethod.GET;
// the subresource locator that will match the resourcemethod when the
// rootresource becomes a subresource
final JaxrsResource productResourceLocator = createResource("org.jboss.tools.ws.jaxrs.sample.services.ProductResourceLocator");
@@ -480,7 +475,7 @@
@Test
public void shoudChangeHttpVerbWhenChangingHttpMethodAnnotation() throws JavaModelException, CoreException {
// pre-conditions
- final JaxrsHttpMethod httpMethod = createHttpMethod(GET);
+ final JaxrsHttpMethod httpMethod = createHttpMethod("org.jboss.tools.ws.jaxrs.sample.services.FOO");
final JaxrsResource customerResource = createResource("org.jboss.tools.ws.jaxrs.sample.services.CustomerResource");
final JaxrsResourceMethod customerResourceMethod = createResourceMethod("getCustomer", customerResource,
GET);
@@ -502,7 +497,7 @@
public void shoudChangeUriPathTemplateWhenRemovingMetamodelApplication() throws JavaModelException, CoreException {
// pre-conditions
final JaxrsJavaApplication application = createApplication("org.jboss.tools.ws.jaxrs.sample.services.RestApplication");
- final JaxrsHttpMethod httpMethod = createHttpMethod(GET);
+ final JaxrsHttpMethod httpMethod = JaxrsBuiltinHttpMethod.GET;
final JaxrsResource customerResource = createResource("org.jboss.tools.ws.jaxrs.sample.services.CustomerResource");
final JaxrsResourceMethod customerResourceMethod = createResourceMethod("getCustomer", customerResource,
GET);
@@ -524,7 +519,7 @@
@Test
public void shoudChangeUriPathTemplateWhenRemovingMethodPathAnnotation() throws JavaModelException, CoreException {
// pre-conditions
- final JaxrsHttpMethod httpMethod = createHttpMethod(GET);
+ final JaxrsHttpMethod httpMethod = JaxrsBuiltinHttpMethod.GET;
final JaxrsResource customerResource = createResource("org.jboss.tools.ws.jaxrs.sample.services.CustomerResource");
final JaxrsResourceMethod customerResourceMethod = createResourceMethod("getCustomer", customerResource,
GET);
@@ -547,7 +542,7 @@
@Test
public void shoudChangeConsumedMediatypesWhenAddingResourceAnnotation() throws JavaModelException, CoreException {
// pre-conditions
- final JaxrsHttpMethod httpMethod = createHttpMethod(POST);
+ final JaxrsHttpMethod httpMethod = JaxrsBuiltinHttpMethod.POST;
final JaxrsResource customerResource = createResource("org.jboss.tools.ws.jaxrs.sample.services.CustomerResource");
final JaxrsResourceMethod customerResourceMethod = createResourceMethod("createCustomer", customerResource,
POST);
@@ -570,7 +565,7 @@
public void shoudChangeConsumedMediatypesWhenAddingResourceMethodAnnotation() throws JavaModelException,
CoreException {
// pre-conditions
- final JaxrsHttpMethod httpMethod = createHttpMethod(POST);
+ final JaxrsHttpMethod httpMethod = JaxrsBuiltinHttpMethod.POST;
final JaxrsResource customerResource = createResource("org.jboss.tools.ws.jaxrs.sample.services.CustomerResource");
final JaxrsResourceMethod customerResourceMethod = createResourceMethod("createCustomer", customerResource,
POST);
@@ -593,7 +588,7 @@
public void shoudChangeConsumedMediatypesWhenChangingResourceMethodAnnotation() throws JavaModelException,
CoreException {
// pre-conditions
- final JaxrsHttpMethod httpMethod = createHttpMethod(POST);
+ final JaxrsHttpMethod httpMethod = JaxrsBuiltinHttpMethod.POST;
final JaxrsResource customerResource = createResource("org.jboss.tools.ws.jaxrs.sample.services.CustomerResource");
final JaxrsResourceMethod customerResourceMethod = createResourceMethod("createCustomer", customerResource,
POST);
@@ -618,7 +613,7 @@
@Test
public void shoudChangeConsumedMediatypesWhenChangingResourceAnnotation() throws JavaModelException, CoreException {
// pre-conditions
- final JaxrsHttpMethod httpMethod = createHttpMethod(POST);
+ final JaxrsHttpMethod httpMethod = JaxrsBuiltinHttpMethod.POST;
final JaxrsResource customerResource = createResource("org.jboss.tools.ws.jaxrs.sample.services.CustomerResource");
final Annotation annotation = getAnnotation(customerResource.getJavaElement(), CONSUMES.qualifiedName,
"application/foo");
@@ -644,7 +639,7 @@
public void shoudChangeConsumedMediatypesWhenRemovingMethodAnnotationWithResourceDefault()
throws JavaModelException, CoreException {
// pre-conditions
- final JaxrsHttpMethod httpMethod = createHttpMethod(POST);
+ final JaxrsHttpMethod httpMethod = JaxrsBuiltinHttpMethod.POST;
final JaxrsResource customerResource = createResource("org.jboss.tools.ws.jaxrs.sample.services.CustomerResource");
customerResource.addOrUpdateAnnotation(getAnnotation(customerResource.getJavaElement(), CONSUMES.qualifiedName,
"application/xml"));
@@ -671,7 +666,7 @@
public void shoudChangeConsumedMediatypesWhenRemovingMethodAnnotationWithoutResourceDefault()
throws JavaModelException, CoreException {
// pre-conditions
- final JaxrsHttpMethod httpMethod = createHttpMethod(POST);
+ final JaxrsHttpMethod httpMethod = JaxrsBuiltinHttpMethod.POST;
final JaxrsResource customerResource = createResource("org.jboss.tools.ws.jaxrs.sample.services.CustomerResource");
final JaxrsResourceMethod customerResourceMethod = createResourceMethod("createCustomer", customerResource,
POST);
@@ -695,7 +690,7 @@
@Test
public void shoudChangeProducedMediatypesWhenAddingResourceAnnotation() throws JavaModelException, CoreException {
// pre-conditions
- final JaxrsHttpMethod httpMethod = createHttpMethod(GET);
+ final JaxrsHttpMethod httpMethod = JaxrsBuiltinHttpMethod.GET;
final JaxrsResource customerResource = createResource("org.jboss.tools.ws.jaxrs.sample.services.CustomerResource");
final JaxrsResourceMethod customerResourceMethod = createResourceMethod("getCustomerAsVCard", customerResource,
GET);
@@ -718,7 +713,7 @@
public void shoudChangeProducedMediatypesWhenAddingResourceMethodAnnotation() throws JavaModelException,
CoreException {
// pre-conditions
- final JaxrsHttpMethod httpMethod = createHttpMethod(GET);
+ final JaxrsHttpMethod httpMethod = JaxrsBuiltinHttpMethod.GET;
final JaxrsResource customerResource = createResource("org.jboss.tools.ws.jaxrs.sample.services.CustomerResource");
final JaxrsResourceMethod customerResourceMethod = createResourceMethod("getCustomerAsVCard", customerResource,
GET);
@@ -740,7 +735,7 @@
@Test
public void shoudChangeProducedMediatypesWhenChangingResourceAnnotation() throws JavaModelException, CoreException {
// pre-conditions
- final JaxrsHttpMethod httpMethod = createHttpMethod(GET);
+ final JaxrsHttpMethod httpMethod = JaxrsBuiltinHttpMethod.GET;
final JaxrsResource customerResource = createResource("org.jboss.tools.ws.jaxrs.sample.services.CustomerResource");
final Annotation annotation = getAnnotation(customerResource.getJavaElement(), PRODUCES.qualifiedName,
"application/foo");
@@ -766,7 +761,7 @@
public void shoudChangeProducedMediatypesWhenChangingResourceMethodAnnotation() throws JavaModelException,
CoreException {
// pre-conditions
- final JaxrsHttpMethod httpMethod = createHttpMethod(POST);
+ final JaxrsHttpMethod httpMethod = JaxrsBuiltinHttpMethod.POST;
final JaxrsResource customerResource = createResource("org.jboss.tools.ws.jaxrs.sample.services.CustomerResource");
final JaxrsResourceMethod customerResourceMethod = createResourceMethod("getCustomerAsVCard", customerResource,
POST);
@@ -792,7 +787,7 @@
public void shoudChangeProducedMediatypesWhenRemovingMethodAnnotationWithResourceDefault()
throws JavaModelException, CoreException {
// pre-conditions
- final JaxrsHttpMethod httpMethod = createHttpMethod(GET);
+ final JaxrsHttpMethod httpMethod = JaxrsBuiltinHttpMethod.GET;
final JaxrsResource customerResource = createResource("org.jboss.tools.ws.jaxrs.sample.services.CustomerResource");
customerResource.addOrUpdateAnnotation(getAnnotation(customerResource.getJavaElement(), PRODUCES.qualifiedName,
"application/xml"));
@@ -819,7 +814,7 @@
public void shoudChangeProducedMediatypesWhenRemovingMethodAnnotationWithoutResourceDefault()
throws JavaModelException, CoreException {
// pre-conditions
- final JaxrsHttpMethod httpMethod = createHttpMethod(POST);
+ final JaxrsHttpMethod httpMethod = JaxrsBuiltinHttpMethod.POST;
final JaxrsResource customerResource = createResource("org.jboss.tools.ws.jaxrs.sample.services.CustomerResource");
final JaxrsResourceMethod customerResourceMethod = createResourceMethod("createCustomer", customerResource,
POST);
@@ -843,7 +838,7 @@
@Test
public void shoudRemoveEndpointWhenRemovingHttpMethodAnnotation() throws JavaModelException, CoreException {
// pre-conditions
- final JaxrsHttpMethod httpMethod = createHttpMethod(GET);
+ final JaxrsHttpMethod httpMethod = createHttpMethod("org.jboss.tools.ws.jaxrs.sample.services.FOO");
final JaxrsResource customerResource = createResource("org.jboss.tools.ws.jaxrs.sample.services.CustomerResource");
final JaxrsResourceMethod customerResourceMethod = createResourceMethod("getCustomer", customerResource,
GET);
@@ -863,7 +858,7 @@
public void shoudRemoveEndpointWhenRemovingResourcePathAnnotationAndMatchingSubresourceLocatorNotFound()
throws JavaModelException, CoreException {
// pre-conditions
- final JaxrsHttpMethod httpMethod = createHttpMethod(GET);
+ final JaxrsHttpMethod httpMethod = JaxrsBuiltinHttpMethod.GET;
final JaxrsResource customerResource = createResource("org.jboss.tools.ws.jaxrs.sample.services.CustomerResource");
final JaxrsResourceMethod customerResourceMethod = createResourceMethod("getCustomer", customerResource,
GET);
@@ -885,7 +880,7 @@
@Test
public void shoudRemoveEndpointsWhenRemovingRootResource() throws JavaModelException, CoreException {
// pre-conditions
- final JaxrsHttpMethod httpMethod = createHttpMethod(GET);
+ final JaxrsHttpMethod httpMethod = JaxrsBuiltinHttpMethod.GET;
final JaxrsResource customerResource = createResource("org.jboss.tools.ws.jaxrs.sample.services.CustomerResource");
final JaxrsResourceMethod customerResourceMethod1 = createResourceMethod("getCustomer", customerResource,
GET);
@@ -907,7 +902,7 @@
@Test
public void shoudRemoveEndpointsWhenRemovingSubresource() throws JavaModelException, CoreException {
// pre-conditions
- JaxrsHttpMethod httpMethod = createHttpMethod(GET);
+ JaxrsHttpMethod httpMethod = JaxrsBuiltinHttpMethod.GET;
final JaxrsResource productResourceLocator = createResource("org.jboss.tools.ws.jaxrs.sample.services.ProductResourceLocator");
final JaxrsResourceMethod productResourceLocatorMethod = createResourceMethod("getProductResourceLocator",
productResourceLocator, null);
@@ -930,7 +925,7 @@
@Test
public void shoudRemoveEndpointsWhenRemovingHttpMethod() throws JavaModelException, CoreException {
// pre-conditions
- JaxrsHttpMethod httpMethod = createHttpMethod(GET);
+ JaxrsHttpMethod httpMethod = JaxrsBuiltinHttpMethod.GET;
final JaxrsResource productResourceLocator = createResource("org.jboss.tools.ws.jaxrs.sample.services.ProductResourceLocator");
createResourceMethod("getProductResourceLocator", productResourceLocator, null);
final JaxrsResource bookResource = createResource("org.jboss.tools.ws.jaxrs.sample.services.BookResource");
@@ -954,7 +949,7 @@
@Test
public void shoudAddEndpointsWhenChangingSubresourceLocatorReturnType() throws JavaModelException, CoreException {
// pre-conditions
- JaxrsHttpMethod httpMethod = createHttpMethod(GET);
+ JaxrsHttpMethod httpMethod = JaxrsBuiltinHttpMethod.GET;
final JaxrsResource productResourceLocator = createResource("org.jboss.tools.ws.jaxrs.sample.services.ProductResourceLocator");
final JaxrsResourceMethod productResourceLocatorMethod = createResourceMethod("getProductResourceLocator",
productResourceLocator, null);
@@ -984,7 +979,7 @@
@Test
public void shoudRemoveEndpointsWhenChangingSubresourceLocatorReturnType() throws JavaModelException, CoreException {
// pre-conditions
- JaxrsHttpMethod httpMethod = createHttpMethod(GET);
+ JaxrsHttpMethod httpMethod = JaxrsBuiltinHttpMethod.GET;
final JaxrsResource productResourceLocator = createResource("org.jboss.tools.ws.jaxrs.sample.services.ProductResourceLocator");
final JaxrsResourceMethod productResourceLocatorMethod = createResourceMethod("getProductResourceLocator",
productResourceLocator, null);
@@ -1014,7 +1009,7 @@
@Test
public void shoudRemoveEndpointsWhenRemovingSubresourceLocatorResource() throws JavaModelException, CoreException {
// pre-conditions
- JaxrsHttpMethod httpMethod = createHttpMethod(GET);
+ JaxrsHttpMethod httpMethod = JaxrsBuiltinHttpMethod.GET;
final JaxrsResource productResourceLocator = createResource("org.jboss.tools.ws.jaxrs.sample.services.ProductResourceLocator");
final JaxrsResourceMethod productResourceLocatorMethod = createResourceMethod("getProductResourceLocator",
productResourceLocator, null);
@@ -1038,7 +1033,7 @@
@Test
public void shoudRemoveEndpointWhenRemovingResourceMethodInRootResource() throws JavaModelException, CoreException {
// pre-conditions
- final JaxrsHttpMethod httpMethod = createHttpMethod(GET);
+ final JaxrsHttpMethod httpMethod = JaxrsBuiltinHttpMethod.GET;
final JaxrsResource customerResource = createResource("org.jboss.tools.ws.jaxrs.sample.services.CustomerResource");
final JaxrsResourceMethod customerResourceMethod = createResourceMethod("getCustomers", customerResource,
GET);
@@ -1057,7 +1052,7 @@
public void shoudRemoveEndpointWhenRemovingSubresourceMethodInRootResource() throws JavaModelException,
CoreException {
// pre-conditions
- final JaxrsHttpMethod httpMethod = createHttpMethod(GET);
+ final JaxrsHttpMethod httpMethod = JaxrsBuiltinHttpMethod.GET;
final JaxrsResource customerResource = createResource("org.jboss.tools.ws.jaxrs.sample.services.CustomerResource");
final JaxrsResourceMethod customerResourceMethod = createResourceMethod("getCustomer", customerResource,
GET);
@@ -1077,7 +1072,7 @@
@Test
public void shoudRemoveEndpointWhenRemovingSubresourceLocatorMethod() throws JavaModelException, CoreException {
// pre-conditions
- JaxrsHttpMethod httpMethod = createHttpMethod(GET);
+ JaxrsHttpMethod httpMethod = JaxrsBuiltinHttpMethod.GET;
final JaxrsResource productResourceLocator = createResource("org.jboss.tools.ws.jaxrs.sample.services.ProductResourceLocator");
final JaxrsResourceMethod productResourceLocatorMethod = createResourceMethod("getProductResourceLocator",
productResourceLocator, null);
@@ -1102,7 +1097,7 @@
public void shoudRemoveEndpointWhenSubresourceLocatorRootResourceBecomesSubresource() throws JavaModelException,
CoreException {
// pre-conditions
- JaxrsHttpMethod httpMethod = createHttpMethod(GET);
+ JaxrsHttpMethod httpMethod = JaxrsBuiltinHttpMethod.GET;
final JaxrsResource productResourceLocator = createResource("org.jboss.tools.ws.jaxrs.sample.services.ProductResourceLocator");
final JaxrsResourceMethod productResourceLocatorMethod = createResourceMethod("getProductResourceLocator",
productResourceLocator, null);
Modified: trunk/ws/tests/org.jboss.tools.ws.jaxrs.core.test/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/builder/ResourceChangedProcessorTestCase.java
===================================================================
--- trunk/ws/tests/org.jboss.tools.ws.jaxrs.core.test/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/builder/ResourceChangedProcessorTestCase.java 2012-07-27 08:56:30 UTC (rev 42751)
+++ trunk/ws/tests/org.jboss.tools.ws.jaxrs.core.test/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/builder/ResourceChangedProcessorTestCase.java 2012-07-27 09:55:48 UTC (rev 42752)
@@ -171,21 +171,9 @@
return affectedMetamodel.getAffectedElements();
}
- /**
- * Because sometimes, generics are painful...
- *
- * @param elements
- * @return private List<IJaxrsElement<?>> asList(IJaxrsElement<?>... elements) { final List<IJaxrsElement<?>> result
- * = new ArrayList<IJaxrsElement<?>>(); result.addAll(Arrays.asList(elements)); return result; }
- */
-
@Test
public void shouldAddHttpMethodsAndResourcesWhenAddingSourceFolderWithExistingMetamodel() throws CoreException {
// pre-conditions
- metamodel.add(createHttpMethod(GET));
- metamodel.add(createHttpMethod(POST));
- metamodel.add(createHttpMethod(PUT));
- metamodel.add(createHttpMethod(DELETE));
// operation
final IPackageFragmentRoot sourceFolder = WorkbenchUtils.getPackageFragmentRoot(javaProject, "src/main/java",
progressMonitor);
@@ -196,21 +184,17 @@
assertThat(affectedMetamodel.getDeltaKind(), equalTo(CHANGED));
assertThat(affectedMetamodel.getMetamodel(), equalTo((IJaxrsMetamodel) metamodel));
final List<JaxrsElementDelta> affectedElements = affectedMetamodel.getAffectedElements();
- // 1 application + 1 HttpMethod + 4 RootResources + 2 Subresources
+ // 1 application + 1 HttpMethod + 7 Resources
assertThat(affectedElements.size(), equalTo(9));
assertThat(affectedElements, everyItem(Matchers.<JaxrsElementDelta> hasProperty("deltaKind", equalTo(ADDED))));
- // all HttpMethods, Resources, ResourceMethods and ResourceFields
- assertThat(metamodel.getElements(javaProject).size(), equalTo(34));
+ // all HttpMethods, Resources, ResourceMethods and ResourceFields. only application is available: the java-based one found in src/main/java
+ assertThat(metamodel.getElements(javaProject).size(), equalTo(30));
}
@Test
public void shouldAddHttpMethodsAndResourcesWhenAddingSourceFolderWithExistingMetamodelWithReset()
throws CoreException {
// pre-conditions
- metamodel.add(createHttpMethod(GET));
- metamodel.add(createHttpMethod(POST));
- metamodel.add(createHttpMethod(PUT));
- metamodel.add(createHttpMethod(DELETE));
// operation
final IPackageFragmentRoot sourceFolder = WorkbenchUtils.getPackageFragmentRoot(javaProject, "src/main/java",
progressMonitor);
@@ -222,11 +206,12 @@
metamodel = (JaxrsMetamodel) affectedMetamodel.getMetamodel();
assertThat(metamodel, equalTo((IJaxrsMetamodel) metamodel));
final List<JaxrsElementDelta> affectedElements = affectedMetamodel.getAffectedElements();
- // 1 application + 1 HttpMethod + 4 RootResources + 2 Subresources
- assertThat(affectedElements.size(), equalTo(15));
+ // 1 application + 1 HttpMethod + 7 Resources
+ assertThat(affectedElements.size(), equalTo(9));
assertThat(affectedElements, everyItem(Matchers.<JaxrsElementDelta> hasProperty("deltaKind", equalTo(ADDED))));
- // all Applications, HttpMethods (including @OPTIONS and @HEAD), Resources, ResourceMethods and ResourceFields
- assertThat(metamodel.getElements(javaProject).size(), equalTo(37));
+ // all project-specific Applications, HttpMethods, Resources, ResourceMethods and ResourceFields (built-in HttpMethods are not bound to a project)
+ // 2 applications are available: the java-based and the web.xml since a full build was performed
+ assertThat(metamodel.getElements(javaProject).size(), equalTo(31));
}
/**
@@ -255,25 +240,22 @@
metamodel = (JaxrsMetamodel) affectedMetamodel.getMetamodel();
assertThat(metamodel, notNullValue());
final List<JaxrsElementDelta> affectedElements = affectedMetamodel.getAffectedElements();
- assertThat(affectedElements.size(), equalTo(15));
- // all Applications, HttpMethods (including @OPTIONS and @HEAD), project Resources, ResourceMethods and ResourceFields
- assertThat(metamodel.getElements(javaProject).size(), equalTo(37));
+ assertThat(affectedElements.size(), equalTo(9));
+ // all Applications, HttpMethods, Resources, ResourceMethods and ResourceFields specific to the project
+ assertThat(metamodel.getElements(javaProject).size(), equalTo(31));
}
@Test
- public void shouldAdd6HttpMethodsAnd0ResourceWhenAddingBinaryLib() throws CoreException {
+ public void shouldNotAddAnythingAddingBinaryLib() throws CoreException {
// pre-conditions
final IPackageFragmentRoot lib = WorkbenchUtils.getPackageFragmentRoot(javaProject,
"lib/jaxrs-api-2.0.1.GA.jar", progressMonitor);
// operation
final ResourceDelta event = createEvent(lib.getResource(), ADDED);
final List<JaxrsElementDelta> affectedElements = processResourceChanges(event, progressMonitor);
- // verifications. Damned : none in the jar...
- assertThat(affectedElements.size(), equalTo(6));
- assertThat(affectedElements, everyItem(Matchers.<JaxrsElementDelta> hasProperty("deltaKind", equalTo(ADDED))));
- verify(metamodel, times(6)).add(any(JaxrsHttpMethod.class));
- assertThat(metamodel.getElements(javaProject).size(), equalTo(6));
+ // verifications: jar should not be taken into account, even if if it contains matching elements...
+ assertThat(affectedElements.size(), equalTo(0));
}
@Test
@@ -574,7 +556,7 @@
}
@Test
- public void shouldRemoveHttpMethodWhenRemovingBinaryLib() throws CoreException {
+ public void shouldNotRemoveHttpMethodWhenRemovingBinaryLib() throws CoreException {
// pre-conditions
final IPackageFragmentRoot lib = WorkbenchUtils.getPackageFragmentRoot(javaProject,
"lib/jaxrs-api-2.0.1.GA.jar", progressMonitor);
@@ -587,10 +569,7 @@
final ResourceDelta event = createEvent(lib.getResource(), REMOVED);
final List<JaxrsElementDelta> affectedElements = processResourceChanges(event, progressMonitor);
// verifications
- assertThat(affectedElements.size(), equalTo(1));
- assertThat(affectedElements.get(0).getElement().getElementKind(), equalTo(EnumElementKind.HTTP_METHOD));
- assertThat(affectedElements, everyItem(Matchers.<JaxrsElementDelta> hasProperty("deltaKind", equalTo(REMOVED))));
- assertThat(metamodel.getElements(javaProject).size(), equalTo(0));
+ assertThat(affectedElements.size(), equalTo(0));
}
@Test
Modified: trunk/ws/tests/org.jboss.tools.ws.jaxrs.core.test/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/domain/JaxrsElementFactoryTestCase.java
===================================================================
--- trunk/ws/tests/org.jboss.tools.ws.jaxrs.core.test/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/domain/JaxrsElementFactoryTestCase.java 2012-07-27 08:56:30 UTC (rev 42751)
+++ trunk/ws/tests/org.jboss.tools.ws.jaxrs.core.test/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/domain/JaxrsElementFactoryTestCase.java 2012-07-27 09:55:48 UTC (rev 42752)
@@ -62,9 +62,8 @@
// verifications
assertNotNull(element);
final IJaxrsResource resource = (IJaxrsResource) element;
- // only @Path annotation is known by the metamodel, so pure resource
- // methods with @GET, etc. are not created here.
- assertThat(resource.getAllMethods().size(), equalTo(4));
+ // result contains a mix of resource methods and subresource methods since http methods are built-in the metamodel
+ assertThat(resource.getAllMethods().size(), equalTo(6));
}
@Test
Modified: trunk/ws/tests/org.jboss.tools.ws.jaxrs.core.test/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/domain/JaxrsMetamodelTestCase.java
===================================================================
--- trunk/ws/tests/org.jboss.tools.ws.jaxrs.core.test/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/domain/JaxrsMetamodelTestCase.java 2012-07-27 08:56:30 UTC (rev 42751)
+++ trunk/ws/tests/org.jboss.tools.ws.jaxrs.core.test/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/domain/JaxrsMetamodelTestCase.java 2012-07-27 09:55:48 UTC (rev 42752)
@@ -118,7 +118,7 @@
@Test
public void shouldAssertHTTPMethods() throws CoreException {
- // 6 HttpMethods in the jax-rs API (@GET, etc.) + 1 in the project
+ // 6 fixed HttpMethods as part of the jax-rs API (@GET, etc.) + 1 in the project
// (@FOO)
Assert.assertEquals(1 * 7, metamodel.getAllHttpMethods().size());
Set<IJaxrsHttpMethod> jaxrsHttpMethods = new HashSet<IJaxrsHttpMethod>();
@@ -224,6 +224,7 @@
Collections.sort(httpMethods);
assertThat(httpMethods.get(0).getHttpVerb(), equalTo("GET"));
assertThat(httpMethods.get(5).getHttpVerb(), equalTo("OPTIONS"));
+ assertThat(httpMethods.get(6).getHttpVerb(), equalTo("FOO"));
}
Modified: trunk/ws/tests/org.jboss.tools.ws.jaxrs.core.test/src/org/jboss/tools/ws/jaxrs/core/jdt/JaxrsAnnotationScannerTestCase.java
===================================================================
--- trunk/ws/tests/org.jboss.tools.ws.jaxrs.core.test/src/org/jboss/tools/ws/jaxrs/core/jdt/JaxrsAnnotationScannerTestCase.java 2012-07-27 08:56:30 UTC (rev 42751)
+++ trunk/ws/tests/org.jboss.tools.ws.jaxrs.core.test/src/org/jboss/tools/ws/jaxrs/core/jdt/JaxrsAnnotationScannerTestCase.java 2012-07-27 09:55:48 UTC (rev 42752)
@@ -80,10 +80,10 @@
public void shouldRetrieveAllHttpMethodsInProject() throws CoreException {
// pre-conditions
// operation
- final List<IType> resourceMethods = JaxrsAnnotationsScanner.findHttpMethodTypes(javaProject,
+ final List<IType> httpMethods = JaxrsAnnotationsScanner.findHttpMethodTypes(javaProject,
new NullProgressMonitor());
// verifications
- assertThat(resourceMethods.size(), equalTo(7));
+ assertThat(httpMethods.size(), equalTo(1));
}
@Test
13 years, 2 months
JBoss Tools SVN: r42751 - in trunk/as: plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/resolvers and 6 other directories.
by jbosstools-commits@lists.jboss.org
Author: rob.stryker(a)jboss.com
Date: 2012-07-27 04:56:30 -0400 (Fri, 27 Jul 2012)
New Revision: 42751
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.classpath.core/src/org/jboss/ide/eclipse/as/classpath/core/ejb3/EJB3ClasspathContainer.java
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/resolvers/ConfigNameResolver.java
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/UnitedServerListenerManager.java
trunk/as/tests/org.jboss.tools.as.test.core/src/org/jboss/tools/as/test/core/MySuite.java
trunk/as/tests/org.jboss.tools.as.test.core/src/org/jboss/tools/as/test/core/internal/utils/ServerCreationTestUtils.java
trunk/as/tests/org.jboss.tools.as.test.core/src/org/jboss/tools/as/test/core/parametized/server/CreateRuntimeTwiceTest.java
trunk/as/tests/org.jboss.tools.as.test.core/src/org/jboss/tools/as/test/core/parametized/server/CreateServerCheckDefaultsTest.java
trunk/as/tests/org.jboss.tools.as.test.core/src/org/jboss/tools/as/test/core/parametized/server/ParametizedSuite.java
trunk/as/tests/org.jboss.tools.as.test.core/src/org/jboss/tools/as/test/core/parametized/server/publishing/AbstractComponentPublishingTest.java
trunk/as/tests/org.jboss.tools.as.test.core/src/org/jboss/tools/as/test/core/parametized/server/publishing/DeploymentAssemblyArchivePathVarNestedWarTest.java
trunk/as/tests/org.jboss.tools.as.test.core/src/org/jboss/tools/as/test/core/parametized/server/publishing/DeploymentAssemblyArchivePathVarTest.java
trunk/as/tests/org.jboss.tools.as.test.core/src/org/jboss/tools/as/test/core/parametized/server/publishing/DeploymentAssemblyArchivePathVarWarTest.java
trunk/as/tests/org.jboss.tools.as.test.core/src/org/jboss/tools/as/test/core/parametized/server/publishing/PublishingSuite.java
trunk/as/tests/org.jboss.tools.as.test.core/src/org/jboss/tools/as/test/core/utiltests/ExpressionResolverUtilTest.java
Log:
JBIDE-12377 and JBIDE-12363 to trunk - much more to do
Modified: trunk/as/plugins/org.jboss.ide.eclipse.as.classpath.core/src/org/jboss/ide/eclipse/as/classpath/core/ejb3/EJB3ClasspathContainer.java
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.as.classpath.core/src/org/jboss/ide/eclipse/as/classpath/core/ejb3/EJB3ClasspathContainer.java 2012-07-27 05:31:58 UTC (rev 42750)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.classpath.core/src/org/jboss/ide/eclipse/as/classpath/core/ejb3/EJB3ClasspathContainer.java 2012-07-27 08:56:30 UTC (rev 42751)
@@ -58,8 +58,8 @@
this.path = path;
this.javaProject = project;
String configName = path.segment(1);
- IProject p = project.getProject();
- if( configName == null && p.exists() && p.isOpen())
+ IProject p = project == null ? null : project.getProject();
+ if( configName == null && p != null && p.exists() && p.isOpen())
configName = findLegacyConfigName(project);
IServer foundServer = findServer(configName);
jbossServer = ServerConverter.getJBossServer(foundServer);
Modified: trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/resolvers/ConfigNameResolver.java
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/resolvers/ConfigNameResolver.java 2012-07-27 05:31:58 UTC (rev 42750)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/resolvers/ConfigNameResolver.java 2012-07-27 08:56:30 UTC (rev 42751)
@@ -35,7 +35,12 @@
public static final String JBOSS_CONFIG = "jboss_config"; //$NON-NLS-1$
public static final String JBOSS_CONFIG_DIR = "jboss_config_dir"; //$NON-NLS-1$
public static final String JBOSS_AS7_CONFIG_FILE = "jboss_config_file"; //$NON-NLS-1$
+ public static final String[] ALL_VARIABLES = new String[] {
+ JBOSS_CONFIG, JBOSS_CONFIG_DIR, JBOSS_AS7_CONFIG_FILE
+ };
+
+
/*
* entry points to fill out the server name in these variable substitutions
*/
Modified: trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/UnitedServerListenerManager.java
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/UnitedServerListenerManager.java 2012-07-27 05:31:58 UTC (rev 42750)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/UnitedServerListenerManager.java 2012-07-27 08:56:30 UTC (rev 42751)
@@ -23,6 +23,7 @@
import org.eclipse.wst.server.core.IServerListener;
import org.eclipse.wst.server.core.ServerCore;
import org.eclipse.wst.server.core.ServerEvent;
+import org.jboss.ide.eclipse.as.core.util.ServerConverter;
/**
* The UnitedServerListenerManager keeps an array of
@@ -59,19 +60,9 @@
return (UnitedServerListener[]) list.toArray(new UnitedServerListener[list.size()]);
}
+ @Deprecated
public static boolean isJBossServer(IServer server) {
- if (server == null) {
- return false;
- }
- IRuntime rt = server.getRuntime();
- if (rt == null) {
- return false;
- }
- IJBossServerRuntime jbsrt = (IJBossServerRuntime)rt.loadAdapter(IJBossServerRuntime.class, new NullProgressMonitor());
- if (jbsrt == null) {
- return false;
- }
- return true;
+ return ServerConverter.getJBossServer(server) != null;
}
Modified: trunk/as/tests/org.jboss.tools.as.test.core/src/org/jboss/tools/as/test/core/MySuite.java
===================================================================
--- trunk/as/tests/org.jboss.tools.as.test.core/src/org/jboss/tools/as/test/core/MySuite.java 2012-07-27 05:31:58 UTC (rev 42750)
+++ trunk/as/tests/org.jboss.tools.as.test.core/src/org/jboss/tools/as/test/core/MySuite.java 2012-07-27 08:56:30 UTC (rev 42751)
@@ -1,13 +1,17 @@
package org.jboss.tools.as.test.core;
+import org.jboss.tools.as.test.core.classpath.ClasspathSuite;
import org.jboss.tools.as.test.core.parametized.server.ParametizedSuite;
+import org.jboss.tools.as.test.core.utiltests.UtilsSuite;
import org.junit.runner.RunWith;
import org.junit.runners.Suite;
import org.junit.runners.Suite.SuiteClasses;
@RunWith(Suite.class)
@SuiteClasses({
- ParametizedSuite.class
+ ParametizedSuite.class,
+ UtilsSuite.class,
+ ClasspathSuite.class
})
public class MySuite {
}
Modified: trunk/as/tests/org.jboss.tools.as.test.core/src/org/jboss/tools/as/test/core/internal/utils/ServerCreationTestUtils.java
===================================================================
--- trunk/as/tests/org.jboss.tools.as.test.core/src/org/jboss/tools/as/test/core/internal/utils/ServerCreationTestUtils.java 2012-07-27 05:31:58 UTC (rev 42750)
+++ trunk/as/tests/org.jboss.tools.as.test.core/src/org/jboss/tools/as/test/core/internal/utils/ServerCreationTestUtils.java 2012-07-27 08:56:30 UTC (rev 42751)
@@ -4,6 +4,8 @@
import java.io.IOException;
import java.util.HashMap;
+import junit.framework.Assert;
+
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.NullProgressMonitor;
@@ -30,7 +32,7 @@
* 2) Creating IServer objects out of either mock folders or legitimate installations
*
*/
-public class ServerCreationTestUtils {
+public class ServerCreationTestUtils extends Assert {
private static final IPath mockedServers = ASMatrixTests.getDefault().getStateLocation().append("mockedServers");
private static HashMap<String, String> asSystemJar = new HashMap<String, String>();
@@ -123,7 +125,10 @@
}
public static IServer createServerWithRuntime(String serverType, String name) throws CoreException {
+ if( serverType.equals(IJBossToolingConstants.DEPLOY_ONLY_SERVER))
+ return createDeployOnlyServer();
String loc = TestConstants.getServerHome(serverType);
+ assertNotNull("Runtime location for server type " + serverType + " not set in test suite", loc);
File locFile = new Path(loc).toFile();
return createServerWithRuntime(serverType, name, locFile);
}
Modified: trunk/as/tests/org.jboss.tools.as.test.core/src/org/jboss/tools/as/test/core/parametized/server/CreateRuntimeTwiceTest.java
===================================================================
--- trunk/as/tests/org.jboss.tools.as.test.core/src/org/jboss/tools/as/test/core/parametized/server/CreateRuntimeTwiceTest.java 2012-07-27 05:31:58 UTC (rev 42750)
+++ trunk/as/tests/org.jboss.tools.as.test.core/src/org/jboss/tools/as/test/core/parametized/server/CreateRuntimeTwiceTest.java 2012-07-27 08:56:30 UTC (rev 42751)
@@ -52,8 +52,8 @@
}
@Test
- private void createRuntimes(String serverTypeId) throws CoreException {
- IServerType type = ServerCore.findServerType(serverTypeId);
+ public void createRuntimes() throws CoreException {
+ IServerType type = ServerCore.findServerType(serverType);
IRuntimeType runtimeType = type.getRuntimeType();
IRuntimeWorkingCopy firstRuntime = runtimeType.createRuntime(null, new NullProgressMonitor());
@@ -62,7 +62,7 @@
IRuntimeWorkingCopy secondRuntime = runtimeType.createRuntime(null, new NullProgressMonitor());
IRuntime secondSavedRuntime = secondRuntime.save(true, new NullProgressMonitor());
- assertEquals(savedRuntime.getName(), secondSavedRuntime.getName());
+ assertNotSame(savedRuntime.getName(), secondSavedRuntime.getName());
assertNotSame(savedRuntime, secondSavedRuntime);
assertFalse("Why are two different runtimes " + runtimeType.getId() + " created with the same ID ?!", savedRuntime.getId().equals(secondSavedRuntime.getId()));
}
Modified: trunk/as/tests/org.jboss.tools.as.test.core/src/org/jboss/tools/as/test/core/parametized/server/CreateServerCheckDefaultsTest.java
===================================================================
--- trunk/as/tests/org.jboss.tools.as.test.core/src/org/jboss/tools/as/test/core/parametized/server/CreateServerCheckDefaultsTest.java 2012-07-27 05:31:58 UTC (rev 42750)
+++ trunk/as/tests/org.jboss.tools.as.test.core/src/org/jboss/tools/as/test/core/parametized/server/CreateServerCheckDefaultsTest.java 2012-07-27 08:56:30 UTC (rev 42751)
@@ -1,10 +1,14 @@
package org.jboss.tools.as.test.core.parametized.server;
import java.io.File;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.nio.charset.MalformedInputException;
import java.util.Collection;
import junit.framework.TestCase;
+import org.eclipse.core.runtime.Path;
import org.eclipse.wst.server.core.IRuntime;
import org.eclipse.wst.server.core.IServer;
import org.jboss.ide.eclipse.archives.webtools.filesets.Fileset;
@@ -12,9 +16,13 @@
import org.jboss.ide.eclipse.as.core.JBossServerCorePlugin;
import org.jboss.ide.eclipse.as.core.extensions.descriptors.XPathCategory;
import org.jboss.ide.eclipse.as.core.extensions.descriptors.XPathModel;
+import org.jboss.ide.eclipse.as.core.extensions.descriptors.XPathQuery;
import org.jboss.ide.eclipse.as.core.server.IJBossServerRuntime;
+import org.jboss.ide.eclipse.as.core.server.internal.ExtendedServerPropertiesAdapterFactory;
+import org.jboss.ide.eclipse.as.core.server.internal.extendedproperties.ServerExtendedProperties;
import org.jboss.ide.eclipse.as.core.server.internal.v7.LocalJBoss7ServerRuntime;
import org.jboss.ide.eclipse.as.core.util.IJBossToolingConstants;
+import org.jboss.ide.eclipse.as.core.util.RuntimeUtils;
import org.jboss.tools.as.test.core.internal.utils.ServerCreationTestUtils;
import org.jboss.tools.test.util.JobUtils;
import org.junit.After;
@@ -61,8 +69,14 @@
assertFalse("Server name should not be empty", server.getName() == null || "".equals(server.getName()));
assertFalse("Runtime name should not be empty", server.getRuntime().getName() == null || "".equals(server.getRuntime().getName()));
+ String typeId = server.getServerType().getId();
+ if( typeId.equals(IJBossToolingConstants.DEPLOY_ONLY_SERVER)) {
+ return;
+ }
+
+
IJBossServerRuntime rt = getJBossRuntime(server);
- assertNotNull("Created server does not adapt to IJBossServerRuntime", rt);
+ assertNotNull("Created server of type " + server.getServerType().getId() + " does not adapt to IJBossServerRuntime", rt);
assertNotNull(rt.getVM());
assertNotNull(rt.getExecutionEnvironment());
@@ -72,6 +86,20 @@
} else {
assertEquals("default", rt.getJBossConfiguration());
}
+
+ ServerExtendedProperties props = ExtendedServerPropertiesAdapterFactory.getServerExtendedProperties(server);
+ assertNotNull(props);
+ assertTrue(props.verifyServerStructure().isOK());
+ if( props.canVerifyRemoteModuleState())
+ assertNotNull(props.getModuleStateVerifier());
+ if( props.hasWelcomePage()) {
+ String s = props.getWelcomePageUrl();
+ try {
+ URL url = new URL(s);
+ } catch(MalformedURLException murle) {
+ fail(serverType + " has an invalid welcome page url: " + murle.getMessage());
+ }
+ }
}
@Test
@@ -79,8 +107,13 @@
JobUtils.waitForIdle();
IServer s = server;
XPathCategory[] cats = XPathModel.getDefault().getCategories(s);
+ String typeId = server.getServerType().getId();
+ if( typeId.equals(IJBossToolingConstants.DEPLOY_ONLY_SERVER)) {
+ assertTrue("Deploy-only Servers should have no default xpaths.", cats == null || cats.length == 0);
+ return;
+ }
assertFalse("Server has no xpath categories automatically added", cats == null || cats.length == 0);
- assertNotNull("Server has no 'ports' xpath category. ", XPathModel.getDefault().getCategory(s, "Ports"));
+ assertNotNull("Server has no 'ports' xpath category. ", XPathModel.getDefault().getCategory(s, XPathModel.PORTS_CATEGORY_NAME));
File xpathFile = JBossServerCorePlugin.getServerStateLocation(s).append(IJBossToolingConstants.XPATH_FILE_NAME).toFile();
try {
assertTrue("The XPath File has not been created. Xpaths will be lost on workspace restart. " + xpathFile.getAbsolutePath(), xpathFile.exists());
@@ -88,17 +121,40 @@
t.printStackTrace();
throw t;
}
+
+ // Take this chance to test some xpath model
+ // Can maybe be moved out to their own test
+ assertNull(XPathModel.getDefault().getQuery(null, null));
+ assertNull(XPathModel.getDefault().getQuery(s, null));
+ assertNull(XPathModel.getDefault().getQuery(s, new Path(XPathModel.PORTS_CATEGORY_NAME)));
+ XPathCategory cat = XPathModel.getDefault().getCategory(s, XPathModel.PORTS_CATEGORY_NAME);
+ XPathQuery[] qs = cat.getQueries();
+ assertFalse(qs == null || qs.length == 0);
+ String name = qs[0].getName();
+ assertNotNull(name);
+ XPathQuery q = XPathModel.getDefault().getQuery(s, new Path(XPathModel.PORTS_CATEGORY_NAME).append(name));
+ assertNotNull(q);
+ q = XPathModel.getDefault().getQuery(s, new Path("GaRbAgE").append(name));
+ assertNull(q);
+ assertTrue(XPathModel.getDefault().containsCategory(s, XPathModel.PORTS_CATEGORY_NAME));
+ assertFalse(XPathModel.getDefault().containsCategory(s, "GaRbAgE"));
}
@Test
public void testDefaultFilesetsAdded() {
Fileset[] fs = FilesetUtil.loadFilesets(server);
+ String typeId = server.getServerType().getId();
+ if( typeId.equals(IJBossToolingConstants.DEPLOY_ONLY_SERVER)) {
+ assertTrue("Deploy-only Servers should have no default filesets.",
+ fs == null || fs.length == 0);
+ return;
+ }
+
assertNotNull("No filesets created", fs);
assertTrue("0 filesets added for server " + server.getName(), fs.length > 0);
}
private IJBossServerRuntime getJBossRuntime(IServer s) {
- IRuntime rt = s.getRuntime();
- return (IJBossServerRuntime) rt.loadAdapter(IJBossServerRuntime.class, null);
+ return RuntimeUtils.getJBossServerRuntime(s.getRuntime());
}
}
Modified: trunk/as/tests/org.jboss.tools.as.test.core/src/org/jboss/tools/as/test/core/parametized/server/ParametizedSuite.java
===================================================================
--- trunk/as/tests/org.jboss.tools.as.test.core/src/org/jboss/tools/as/test/core/parametized/server/ParametizedSuite.java 2012-07-27 05:31:58 UTC (rev 42750)
+++ trunk/as/tests/org.jboss.tools.as.test.core/src/org/jboss/tools/as/test/core/parametized/server/ParametizedSuite.java 2012-07-27 08:56:30 UTC (rev 42751)
@@ -7,11 +7,11 @@
@RunWith(Suite.class)
@SuiteClasses({
-// ServerHomeTest.class,
-// ServerBeanLoader3Test.class,
-// CreateServerCheckDefaultsTest.class,
-// ProjectRuntimeClasspathTest.class,
-// CreateRuntimeTwiceTest.class,
+ ServerHomeTest.class,
+ ServerBeanLoader3Test.class,
+ CreateServerCheckDefaultsTest.class,
+ ProjectRuntimeClasspathTest.class,
+ CreateRuntimeTwiceTest.class,
PublishingSuite.class
})
public class ParametizedSuite {
Modified: trunk/as/tests/org.jboss.tools.as.test.core/src/org/jboss/tools/as/test/core/parametized/server/publishing/AbstractComponentPublishingTest.java
===================================================================
--- trunk/as/tests/org.jboss.tools.as.test.core/src/org/jboss/tools/as/test/core/parametized/server/publishing/AbstractComponentPublishingTest.java 2012-07-27 05:31:58 UTC (rev 42750)
+++ trunk/as/tests/org.jboss.tools.as.test.core/src/org/jboss/tools/as/test/core/parametized/server/publishing/AbstractComponentPublishingTest.java 2012-07-27 08:56:30 UTC (rev 42751)
@@ -12,10 +12,21 @@
public class AbstractComponentPublishingTest extends AbstractPublishingTest {
public static Collection<Object[]> componentJarData() {
+ return componentJarData(false);
+ }
+ public static Collection<Object[]> fullComponentJarData() {
+ return componentJarData(true);
+ }
+ public static Collection<Object[]> componentJarData(boolean complete) {
Object[] servers = ServerParameterUtils.getPublishServerTypes();
Object[] zipOption = ServerParameterUtils.getServerZipOptions();
Object[] defaultDeployLoc = ServerParameterUtils.getDefaultDeployOptions();
Object[] perModOverrides = ServerParameterUtils.getPerModuleOverrideOptions();
+ if( !complete ) {
+ // simplify these options
+ defaultDeployLoc = new Object[]{defaultDeployLoc[0]};
+ perModOverrides = new Object[]{perModOverrides[0]};
+ }
Object[] junitName = new String[] { "junit.jar", "otherOut.jar"};
Object[] outFolder = new String[] { "lib", "otherFolder", "deep/nested", ""};
Object[][] allOptions = new Object[][] {
@@ -24,6 +35,7 @@
};
return MatrixUtils.toMatrix(allOptions);
}
+
protected String jarFolder;
protected String jarName;
Modified: trunk/as/tests/org.jboss.tools.as.test.core/src/org/jboss/tools/as/test/core/parametized/server/publishing/DeploymentAssemblyArchivePathVarNestedWarTest.java
===================================================================
--- trunk/as/tests/org.jboss.tools.as.test.core/src/org/jboss/tools/as/test/core/parametized/server/publishing/DeploymentAssemblyArchivePathVarNestedWarTest.java 2012-07-27 05:31:58 UTC (rev 42750)
+++ trunk/as/tests/org.jboss.tools.as.test.core/src/org/jboss/tools/as/test/core/parametized/server/publishing/DeploymentAssemblyArchivePathVarNestedWarTest.java 2012-07-27 08:56:30 UTC (rev 42751)
@@ -11,6 +11,7 @@
package org.jboss.tools.as.test.core.parametized.server.publishing;
import java.util.ArrayList;
+import java.util.Collection;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.IPath;
@@ -27,12 +28,17 @@
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
+import org.junit.runners.Parameterized.Parameters;
@RunWith(value = Parameterized.class)
public class DeploymentAssemblyArchivePathVarNestedWarTest extends DeploymentAssemblyArchivePathVarTest {
private static String PROJECT_PREFIX = "qEar";
private static String PROJECT_NESTED_PREFIX = "qWar";
private static int PROJECT_ID = 1;
+ @Parameters
+ public static Collection<Object[]> params() {
+ return componentJarData();
+ }
public DeploymentAssemblyArchivePathVarNestedWarTest(String serverType, String zip,
String deployLoc, String perMod, String refName, String refFolder) {
super(serverType, zip, deployLoc, perMod, refName, refFolder);
Modified: trunk/as/tests/org.jboss.tools.as.test.core/src/org/jboss/tools/as/test/core/parametized/server/publishing/DeploymentAssemblyArchivePathVarTest.java
===================================================================
--- trunk/as/tests/org.jboss.tools.as.test.core/src/org/jboss/tools/as/test/core/parametized/server/publishing/DeploymentAssemblyArchivePathVarTest.java 2012-07-27 05:31:58 UTC (rev 42750)
+++ trunk/as/tests/org.jboss.tools.as.test.core/src/org/jboss/tools/as/test/core/parametized/server/publishing/DeploymentAssemblyArchivePathVarTest.java 2012-07-27 08:56:30 UTC (rev 42751)
@@ -44,7 +44,7 @@
private static int PROJECT_ID = 1;
@Parameters
public static Collection<Object[]> params() {
- return componentJarData();
+ return fullComponentJarData();
}
public DeploymentAssemblyArchivePathVarTest(String serverType, String zip,
String deployLoc, String perMod, String refName, String refFolder) {
Modified: trunk/as/tests/org.jboss.tools.as.test.core/src/org/jboss/tools/as/test/core/parametized/server/publishing/DeploymentAssemblyArchivePathVarWarTest.java
===================================================================
--- trunk/as/tests/org.jboss.tools.as.test.core/src/org/jboss/tools/as/test/core/parametized/server/publishing/DeploymentAssemblyArchivePathVarWarTest.java 2012-07-27 05:31:58 UTC (rev 42750)
+++ trunk/as/tests/org.jboss.tools.as.test.core/src/org/jboss/tools/as/test/core/parametized/server/publishing/DeploymentAssemblyArchivePathVarWarTest.java 2012-07-27 08:56:30 UTC (rev 42751)
@@ -10,6 +10,8 @@
******************************************************************************/
package org.jboss.tools.as.test.core.parametized.server.publishing;
+import java.util.Collection;
+
import org.eclipse.wst.common.componentcore.internal.operation.AddReferenceDataModelProvider;
import org.eclipse.wst.common.frameworks.datamodel.IDataModel;
import org.eclipse.wst.common.frameworks.datamodel.IDataModelProvider;
@@ -17,11 +19,17 @@
import org.jboss.tools.as.test.core.internal.utils.wtp.JavaEEFacetConstants;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
+import org.junit.runners.Parameterized.Parameters;
@RunWith(value = Parameterized.class)
public class DeploymentAssemblyArchivePathVarWarTest extends DeploymentAssemblyArchivePathVarTest {
private static String PROJECT_PREFIX = "pWar";
private static int PROJECT_ID = 1;
+ @Parameters
+ public static Collection<Object[]> params() {
+ return componentJarData();
+ }
+
public DeploymentAssemblyArchivePathVarWarTest(String serverType, String zip,
String deployLoc, String perMod, String refName, String refFolder) {
super(serverType, zip, deployLoc, perMod, refName, refFolder);
Modified: trunk/as/tests/org.jboss.tools.as.test.core/src/org/jboss/tools/as/test/core/parametized/server/publishing/PublishingSuite.java
===================================================================
--- trunk/as/tests/org.jboss.tools.as.test.core/src/org/jboss/tools/as/test/core/parametized/server/publishing/PublishingSuite.java 2012-07-27 05:31:58 UTC (rev 42750)
+++ trunk/as/tests/org.jboss.tools.as.test.core/src/org/jboss/tools/as/test/core/parametized/server/publishing/PublishingSuite.java 2012-07-27 08:56:30 UTC (rev 42751)
@@ -1,24 +1,25 @@
package org.jboss.tools.as.test.core.parametized.server.publishing;
+import org.jboss.tools.as.test.core.parametized.server.publishing.defect.RepublishDefectTest;
import org.junit.runner.RunWith;
import org.junit.runners.Suite;
import org.junit.runners.Suite.SuiteClasses;
@RunWith(Suite.class)
@SuiteClasses({
-// DeploymentAssemblyArchivePathVarTest.class,
-// DeploymentAssemblyArchivePathVarWarTest.class,
-// DeploymentAssemblyArchivePathVarNestedWarTest.class,
-// DeploymentAssemblyExternalArchiveVarTest.class,
-// DeploymentAssemblyExternalArchiveVarWarTest.class,
-// DeploymentAssemblyExternalArchiveVarNestedWarTest.class,
-// DeploymentAssemblyWorkspaceArchiveVarTest.class,
-// DeploymentAssemblyWorkspaceArchiveVarWarTest.class,
-// DeploymentAssemblyWorkspaceArchiveVarNestedWarTest.class,
+ DeploymentAssemblyArchivePathVarTest.class,
+ DeploymentAssemblyArchivePathVarWarTest.class,
+ DeploymentAssemblyArchivePathVarNestedWarTest.class,
+ DeploymentAssemblyExternalArchiveVarTest.class,
+ DeploymentAssemblyExternalArchiveVarWarTest.class,
+ DeploymentAssemblyExternalArchiveVarNestedWarTest.class,
+ DeploymentAssemblyWorkspaceArchiveVarTest.class,
+ DeploymentAssemblyWorkspaceArchiveVarWarTest.class,
+ DeploymentAssemblyWorkspaceArchiveVarNestedWarTest.class,
DeploymentAssemblyFilesetReferenceTest.class,
-// RepublishDefectTest.class,
-// SingleDeployableFileTest.class,
-// SingleDeployableFolderTest.class
+ RepublishDefectTest.class,
+ SingleDeployableFileTest.class,
+ SingleDeployableFolderTest.class
})
public class PublishingSuite {
}
Modified: trunk/as/tests/org.jboss.tools.as.test.core/src/org/jboss/tools/as/test/core/utiltests/ExpressionResolverUtilTest.java
===================================================================
--- trunk/as/tests/org.jboss.tools.as.test.core/src/org/jboss/tools/as/test/core/utiltests/ExpressionResolverUtilTest.java 2012-07-27 05:31:58 UTC (rev 42750)
+++ trunk/as/tests/org.jboss.tools.as.test.core/src/org/jboss/tools/as/test/core/utiltests/ExpressionResolverUtilTest.java 2012-07-27 08:56:30 UTC (rev 42751)
@@ -1,20 +1,30 @@
package org.jboss.tools.as.test.core.utiltests;
+import junit.framework.TestCase;
+
import org.jboss.ide.eclipse.as.core.util.ExpressionResolverUtil;
+import org.junit.Test;
-import junit.framework.TestCase;
-
public class ExpressionResolverUtilTest extends TestCase {
+ @Test
public void testExpressionResolver() {
- assertEquals("aaa", ExpressionResolverUtil.safeReplaceProperties("aaa"));
- assertEquals("t9", ExpressionResolverUtil.safeReplaceProperties("t${something:9}"));
- assertEquals("t9a", ExpressionResolverUtil.safeReplaceProperties("t${something:9}a"));
+ assertEquals("aaa", re("aaa"));
+ assertEquals("t9", re("t${something:9}"));
+ assertEquals("t9a", re("t${something:9}a"));
// NO recursive checking
- assertEquals("5:notfound}", ExpressionResolverUtil.safeReplaceProperties("${twoPoint${someNumber:5}:notfound}"));
+ assertEquals("5:notfound}", re("${twoPoint${someNumber:5}:notfound}"));
// unresolvable, so no change
- assertEquals("t${something}", ExpressionResolverUtil.safeReplaceProperties("t${something}"));
- assertEquals("t${something}a", ExpressionResolverUtil.safeReplaceProperties("t${something}a"));
+ assertEquals("t${something}", re("t${something}"));
+ assertEquals("t${something}a", re("t${something}a"));
+ assertEquals("t$ablah", re("t$ablah"));
+
+ // custom handling
+ assertEquals("t$stuff", re("t$$stuff"));
}
+
+ private String re(String s) {
+ return ExpressionResolverUtil.safeReplaceProperties(s);
+ }
}
13 years, 2 months
JBoss Tools SVN: r42750 - trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/extensions/descriptors.
by jbosstools-commits@lists.jboss.org
Author: rob.stryker(a)jboss.com
Date: 2012-07-27 01:31:58 -0400 (Fri, 27 Jul 2012)
New Revision: 42750
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/extensions/descriptors/XPathModel.java
Log:
JBIDE-12377 add null check for unit tests
Modified: trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/extensions/descriptors/XPathModel.java
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/extensions/descriptors/XPathModel.java 2012-07-27 05:30:39 UTC (rev 42749)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/extensions/descriptors/XPathModel.java 2012-07-27 05:31:58 UTC (rev 42750)
@@ -101,6 +101,8 @@
public XPathQuery getQuery(IServer server, IPath path) {
+ if( server == null || path == null || path.segmentCount() != 2)
+ return null;
XPathCategory cat = getCategory(server, path.segment(0));
if( cat != null )
return cat.getQuery(path.segment(1));
13 years, 2 months
JBoss Tools SVN: r42749 - trunk/as/plugins/org.jboss.ide.eclipse.as.classpath.core/src/org/jboss/ide/eclipse/as/classpath/core/ejb3.
by jbosstools-commits@lists.jboss.org
Author: rob.stryker(a)jboss.com
Date: 2012-07-27 01:30:39 -0400 (Fri, 27 Jul 2012)
New Revision: 42749
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.classpath.core/src/org/jboss/ide/eclipse/as/classpath/core/ejb3/EJB30SupportVerifier.java
trunk/as/plugins/org.jboss.ide.eclipse.as.classpath.core/src/org/jboss/ide/eclipse/as/classpath/core/ejb3/EJB3ClasspathContainer.java
Log:
JBIDE-12377 code cleanup
Modified: trunk/as/plugins/org.jboss.ide.eclipse.as.classpath.core/src/org/jboss/ide/eclipse/as/classpath/core/ejb3/EJB30SupportVerifier.java
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.as.classpath.core/src/org/jboss/ide/eclipse/as/classpath/core/ejb3/EJB30SupportVerifier.java 2012-07-27 04:45:58 UTC (rev 42748)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.classpath.core/src/org/jboss/ide/eclipse/as/classpath/core/ejb3/EJB30SupportVerifier.java 2012-07-27 05:30:39 UTC (rev 42749)
@@ -33,6 +33,8 @@
}
public static boolean verify(IRuntime rt) {
+ if( rt == null ) // deploy only server protection
+ return false;
IJBossServerRuntime jbRuntime = (IJBossServerRuntime)rt.loadAdapter(IJBossServerRuntime.class, null);
if( jbRuntime == null )
return false;
Modified: trunk/as/plugins/org.jboss.ide.eclipse.as.classpath.core/src/org/jboss/ide/eclipse/as/classpath/core/ejb3/EJB3ClasspathContainer.java
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.as.classpath.core/src/org/jboss/ide/eclipse/as/classpath/core/ejb3/EJB3ClasspathContainer.java 2012-07-27 04:45:58 UTC (rev 42748)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.classpath.core/src/org/jboss/ide/eclipse/as/classpath/core/ejb3/EJB3ClasspathContainer.java 2012-07-27 05:30:39 UTC (rev 42749)
@@ -32,6 +32,7 @@
import org.jboss.ide.eclipse.as.classpath.core.Messages;
import org.jboss.ide.eclipse.as.core.server.IJBossServerConstants;
import org.jboss.ide.eclipse.as.core.server.internal.JBossServer;
+import org.jboss.ide.eclipse.as.core.util.ServerConverter;
/**
* @author Marshall
@@ -57,39 +58,50 @@
this.path = path;
this.javaProject = project;
String configName = path.segment(1);
- IServer servers[] = ServerCore.getServers();
IProject p = project.getProject();
- if( p.exists() && p.isOpen() /* && Deprecated : p.isLocal(IResource.DEPTH_INFINITE)*/) {
- try {
- if (configName == null) {
- // old classpath container, try finding the persisten property
- configName = project.getProject().getPersistentProperty(JBOSS_EJB3_CONFIGURATION);
- if (configName != null) {
- // go ahead and remove the persistent property
- project.getProject().setPersistentProperty(JBOSS_EJB3_CONFIGURATION, null);
- }
- }
- } catch( CoreException ce ) {
- // This should never occur. If it does, it regards legacy situations.
- // The project is opened and accessible. There are no reasons for this
- // to ever occur.
+ if( configName == null && p.exists() && p.isOpen())
+ configName = findLegacyConfigName(project);
+ IServer foundServer = findServer(configName);
+ jbossServer = ServerConverter.getJBossServer(foundServer);
+ if( jbossServer != null ) {
+ try {
+ homePath = jbossServer.getServer().getRuntime().getLocation();
+ configPath = new Path(jbossServer.getConfigDirectory());
+ } catch( Exception e ) {
+ IStatus status = new Status(IStatus.ERROR, ClasspathCorePlugin.PLUGIN_ID,Messages.EJB3ClasspathContainer_could_not_determine_home, e);
+ ClasspathCorePlugin.getDefault().getLog().log(status);
+ }
+ }
+ }
+
+ private String findLegacyConfigName(IJavaProject project) {
+ if( project == null )
+ return null;
+ String configName = null;
+ try {
+ // old classpath container, try finding the persisten property
+ configName = project.getProject().getPersistentProperty(JBOSS_EJB3_CONFIGURATION);
+ if (configName != null) {
+ // go ahead and remove the persistent property
+ project.getProject().setPersistentProperty(JBOSS_EJB3_CONFIGURATION, null);
+ }
+ } catch( CoreException ce ) {
+ // This should never occur. If it does, it regards legacy situations.
+ // The project is opened and accessible. There are no reasons for this
+ // to ever occur.
+ }
+ return configName;
+ }
+ private IServer findServer(String serverName) {
+ IServer[] servers = ServerCore.getServers();
+ for (int i = 0; i < servers.length; i++) {
+ if (servers[i].getName().equals(serverName)) {
+ return servers[i];
}
- }
- for (int i = 0; i < servers.length; i++) {
- if (servers[i].getName().equals(configName)) {
- jbossServer = (JBossServer) servers[i].loadAdapter(JBossServer.class, new NullProgressMonitor());
- try {
- homePath = jbossServer.getServer().getRuntime().getLocation();
- configPath = new Path(jbossServer.getConfigDirectory());
- } catch( Exception e ) {
- IStatus status = new Status(IStatus.ERROR, ClasspathCorePlugin.PLUGIN_ID,Messages.EJB3ClasspathContainer_could_not_determine_home, e);
- ClasspathCorePlugin.getDefault().getLog().log(status);
- }
- break;
- }
- }
+ }
+ return null;
}
-
+
public String getDescription() {
return Messages.EJB3ClasspathContainer_ejb30_description;
}
@@ -111,14 +123,16 @@
}
public IClasspathEntry[] getClasspathEntries() {
- try {
- String id = jbossServer.getServer().getServerType().getRuntimeType().getId();
- if( id.equals(AS_40)) return get40Jars(homePath, configPath);
- if( id.equals(AS_42)) return get42Jars(homePath, configPath);
- if( id.equals(AS_50)) return get50Jars(homePath, configPath);
- if( id.equals(AS_51)) return get51Jars(homePath, configPath);
- if( id.equals(AS_60)) return get60Jars(homePath, configPath);
- } catch( FileNotFoundException fnfe ) {}
+ if( jbossServer != null ) {
+ try {
+ String id = jbossServer.getServer().getServerType().getRuntimeType().getId();
+ if( id.equals(AS_40)) return get40Jars(homePath, configPath);
+ if( id.equals(AS_42)) return get42Jars(homePath, configPath);
+ if( id.equals(AS_50)) return get50Jars(homePath, configPath);
+ if( id.equals(AS_51)) return get51Jars(homePath, configPath);
+ if( id.equals(AS_60)) return get60Jars(homePath, configPath);
+ } catch( FileNotFoundException fnfe ) {}
+ }
return new IClasspathEntry[]{};
}
13 years, 2 months
JBoss Tools SVN: r42748 - trunk/as/plugins/org.jboss.ide.eclipse.as.classpath.core/src/org/jboss/ide/eclipse/as/classpath/core/runtime.
by jbosstools-commits@lists.jboss.org
Author: rob.stryker(a)jboss.com
Date: 2012-07-27 00:45:58 -0400 (Fri, 27 Jul 2012)
New Revision: 42748
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.classpath.core/src/org/jboss/ide/eclipse/as/classpath/core/runtime/RuntimeKey.java
Log:
JBIDE-12377 unused internal code removed. A usage scan on all of jbt reveals these methods (getter/setter) are unused. The RuntimeKey is used only for .equals and hashcode methods to ensure a unique RuntimeKey
Modified: trunk/as/plugins/org.jboss.ide.eclipse.as.classpath.core/src/org/jboss/ide/eclipse/as/classpath/core/runtime/RuntimeKey.java
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.as.classpath.core/src/org/jboss/ide/eclipse/as/classpath/core/runtime/RuntimeKey.java 2012-07-27 04:41:22 UTC (rev 42747)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.classpath.core/src/org/jboss/ide/eclipse/as/classpath/core/runtime/RuntimeKey.java 2012-07-27 04:45:58 UTC (rev 42748)
@@ -23,30 +23,6 @@
this.id = id;
}
- public IPath getLocation() {
- return location;
- }
-
- public void setLocation(IPath location) {
- this.location = location;
- }
-
- public IPath getConfigPath() {
- return configPath;
- }
-
- public void setConfigPath(IPath configPath) {
- this.configPath = configPath;
- }
-
- public String getId() {
- return id;
- }
-
- public void setId(String id) {
- this.id = id;
- }
-
@Override
public int hashCode() {
final int prime = 31;
13 years, 2 months
JBoss Tools SVN: r42747 - trunk/as/plugins/org.jboss.ide.eclipse.as.classpath.core/src/org/jboss/ide/eclipse/as/classpath/core/runtime.
by jbosstools-commits@lists.jboss.org
Author: rob.stryker(a)jboss.com
Date: 2012-07-27 00:41:22 -0400 (Fri, 27 Jul 2012)
New Revision: 42747
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.classpath.core/src/org/jboss/ide/eclipse/as/classpath/core/runtime/ClientAllRuntimeClasspathProvider.java
Log:
JBIDE-12377 unused internal code removed
Modified: trunk/as/plugins/org.jboss.ide.eclipse.as.classpath.core/src/org/jboss/ide/eclipse/as/classpath/core/runtime/ClientAllRuntimeClasspathProvider.java
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.as.classpath.core/src/org/jboss/ide/eclipse/as/classpath/core/runtime/ClientAllRuntimeClasspathProvider.java 2012-07-26 23:56:51 UTC (rev 42746)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.classpath.core/src/org/jboss/ide/eclipse/as/classpath/core/runtime/ClientAllRuntimeClasspathProvider.java 2012-07-27 04:41:22 UTC (rev 42747)
@@ -139,52 +139,7 @@
protected IClasspathEntry getEntry(Entry entry) {
return JavaRuntime.newArchiveRuntimeClasspathEntry(entry.getPath()).getClasspathEntry();
}
-
- protected void addPaths(IPath folder, Set<Entry> list) {
- addPaths(folder, list, false);
- }
- protected class SimpleFileFilter implements FileFilter {
- private List<String> ignore;
- public SimpleFileFilter(String[] ignore) {
- this.ignore = Arrays.asList(ignore);
- }
- public boolean accept(File pathname) {
- if( !pathname.getName().endsWith(EXT_JAR)) return false;
- boolean contains = ignore.contains(pathname.getName());
- return !contains;
- }
- }
-
- protected void addPaths(IPath folder, Set<Entry> list, boolean recurse) {
- addPaths(folder, list, recurse, new SimpleFileFilter(new String[]{"jaxb-xjc.jar"})); //$NON-NLS-1$
- }
-
- protected void addPaths(IPath folder, Set<Entry> list, boolean recurse, FileFilter filter) {
- if( folder.toFile().exists()) {
- File f = folder.toFile();
- if(f.isDirectory()) {
- File[] asFiles = f.listFiles();
- for( int i = 0; i < asFiles.length; i++ ) {
- if( filter == null || filter.accept(folder.append(asFiles[i].getName()).toFile())) {
- addSinglePath(folder.append(asFiles[i].getName()), list);
- } else if( recurse && asFiles[i].isDirectory()) {
- addPaths(folder.append(asFiles[i].getName()), list, true, filter);
- }
- }
- } else { // item is a file, not a folder
- if( filter == null || filter.accept(folder.toFile()))
- addSinglePath(folder, list);
- }
- }
- }
-
- protected void addSinglePath(IPath p, Set<Entry> list) {
- if (!p.toFile().exists()) {
- return;
- }
- list.add(new Entry(p, p.lastSegment(), p.toFile().length()));
- }
protected void addSinglePath(IPath p, ArrayList<Entry> list) {
if (!p.toFile().exists()) {
return;
13 years, 2 months
JBoss Tools SVN: r42746 - trunk/jst/plugins/org.jboss.tools.jst.web.ui/src/org/jboss/tools/jst/web/ui/action.
by jbosstools-commits@lists.jboss.org
Author: dazarov
Date: 2012-07-26 19:56:51 -0400 (Thu, 26 Jul 2012)
New Revision: 42746
Modified:
trunk/jst/plugins/org.jboss.tools.jst.web.ui/src/org/jboss/tools/jst/web/ui/action/JSPProblemMarkerResolutionGenerator.java
Log:
Make Quick Fix "Add tag library definition" work with KB Model instead of using plain tag library list https://issues.jboss.org/browse/JBIDE-12304
Modified: trunk/jst/plugins/org.jboss.tools.jst.web.ui/src/org/jboss/tools/jst/web/ui/action/JSPProblemMarkerResolutionGenerator.java
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.web.ui/src/org/jboss/tools/jst/web/ui/action/JSPProblemMarkerResolutionGenerator.java 2012-07-26 23:17:26 UTC (rev 42745)
+++ trunk/jst/plugins/org.jboss.tools.jst.web.ui/src/org/jboss/tools/jst/web/ui/action/JSPProblemMarkerResolutionGenerator.java 2012-07-26 23:56:51 UTC (rev 42746)
@@ -99,6 +99,10 @@
if(prefix == null)
return new IJavaCompletionProposal[]{};
+ String tagName = getTagName(message);
+ if(tagName == null)
+ return new IJavaCompletionProposal[]{};
+
IFile file = MarkerResolutionUtils.getFile();
if(file == null)
return new IJavaCompletionProposal[]{};
@@ -126,22 +130,24 @@
ITagLibrary[] libraries = kbProject.getTagLibraries();
ArrayList<String> names = new ArrayList<String>();
+ boolean worked = false;
for(ITagLibrary l : libraries){
if(l instanceof TLDLibrary){
((TLDLibrary) l).createDefaultNameSpace();
}
INameSpace ns = l.getDefaultNameSpace();
if(ns != null && ns.getPrefix() != null && ns.getPrefix().equals(prefix)){
+ worked = true;
String uri = ns.getURI();
String resolutionName = getResolutionName(xmlDocument != null && xmlDocument.isXMLType(), true, prefix, uri);
- if(resolutionName != null && !names.contains(resolutionName)){
+ if(resolutionName != null && !names.contains(resolutionName) && l.getComponent(tagName) != null){
proposals.add(new AddTLDMarkerResolution(resolutionName, start, end, uri, prefix));
names.add(resolutionName);
}
}
}
- if(proposals.size() == 0 && libs.containsKey(prefix)){
+ if(proposals.size() == 0 && libs.containsKey(prefix) && !worked){
String uri = libs.get(prefix);
String resolutionName = getResolutionName(xmlDocument != null && xmlDocument.isXMLType(), true, prefix, uri);
if(resolutionName != null){
@@ -183,6 +189,10 @@
if(prefix == null)
return new IMarkerResolution[]{};
+ String tagName = getTagName(message);
+ if(tagName == null)
+ return new IMarkerResolution[]{};
+
IFile file = (IFile)marker.getResource();
ELContext context = PageContextFactory.createPageContext(file);
@@ -203,22 +213,24 @@
ITagLibrary[] libraries = kbProject.getTagLibraries();
ArrayList<String> names = new ArrayList<String>();
+ boolean worked = false;
for(ITagLibrary l : libraries){
if(l instanceof TLDLibrary){
((TLDLibrary) l).createDefaultNameSpace();
}
INameSpace ns = l.getDefaultNameSpace();
if(ns != null && ns.getPrefix() != null && ns.getPrefix().equals(prefix)){
+ worked = true;
String uri = ns.getURI();
String resolutionName = getResolutionName(marker.getType().equals(HTML_VALIDATOR_MARKER) || marker.isSubtypeOf(HTML_VALIDATOR_MARKER), marker.getType().equals(JSP_VALIDATOR_MARKER) || marker.isSubtypeOf(JSP_VALIDATOR_MARKER), prefix, uri);
- if(resolutionName != null && !names.contains(resolutionName)){
+ if(resolutionName != null && !names.contains(resolutionName) && l.getComponent(tagName) != null){
resolutions.add(new AddTLDMarkerResolution(file, resolutionName, start, end, uri, prefix));
names.add(resolutionName);
}
}
}
- if(resolutions.size() == 0 && libs.containsKey(prefix)){
+ if(resolutions.size() == 0 && libs.containsKey(prefix) && !worked){
String uri = libs.get(prefix);
String resolutionName = getResolutionName(marker.getType().equals(HTML_VALIDATOR_MARKER) || marker.isSubtypeOf(HTML_VALIDATOR_MARKER), marker.getType().equals(JSP_VALIDATOR_MARKER) || marker.isSubtypeOf(JSP_VALIDATOR_MARKER), prefix, uri);
if(resolutionName != null){
@@ -244,6 +256,22 @@
return prefix;
}
+ public static String getTagName(String message){
+ String tagName=""; //$NON-NLS-1$
+
+ int start = message.indexOf(":"); //$NON-NLS-1$
+ if(start < 0)
+ return null;
+
+ int end = message.indexOf(")", start); //$NON-NLS-1$
+ if(end < 0)
+ return null;
+
+ tagName = message.substring(start+1, end);
+
+ return tagName;
+ }
+
@Override
public boolean hasResolutions(IMarker marker) {
try{
13 years, 2 months
JBoss Tools SVN: r42745 - trunk/jst/plugins/org.jboss.tools.jst.web.ui/src/org/jboss/tools/jst/web/ui/action.
by jbosstools-commits@lists.jboss.org
Author: dazarov
Date: 2012-07-26 19:17:26 -0400 (Thu, 26 Jul 2012)
New Revision: 42745
Modified:
trunk/jst/plugins/org.jboss.tools.jst.web.ui/src/org/jboss/tools/jst/web/ui/action/JSPProblemMarkerResolutionGenerator.java
Log:
Make Quick Fix "Add tag library definition" work with KB Model instead of using plain tag library list https://issues.jboss.org/browse/JBIDE-12304
Modified: trunk/jst/plugins/org.jboss.tools.jst.web.ui/src/org/jboss/tools/jst/web/ui/action/JSPProblemMarkerResolutionGenerator.java
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.web.ui/src/org/jboss/tools/jst/web/ui/action/JSPProblemMarkerResolutionGenerator.java 2012-07-26 22:27:16 UTC (rev 42744)
+++ trunk/jst/plugins/org.jboss.tools.jst.web.ui/src/org/jboss/tools/jst/web/ui/action/JSPProblemMarkerResolutionGenerator.java 2012-07-26 23:17:26 UTC (rev 42745)
@@ -12,6 +12,9 @@
import java.util.ArrayList;
import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IMarker;
@@ -27,10 +30,13 @@
import org.eclipse.wst.sse.ui.internal.reconcile.TemporaryAnnotation;
import org.eclipse.wst.xml.core.internal.provisional.document.IDOMDocument;
import org.eclipse.wst.xml.core.internal.provisional.document.IDOMModel;
+import org.jboss.tools.common.el.core.resolver.ELContext;
import org.jboss.tools.common.quickfix.IQuickFixGenerator;
import org.jboss.tools.common.refactoring.MarkerResolutionUtils;
import org.jboss.tools.jst.web.kb.IKbProject;
import org.jboss.tools.jst.web.kb.KbProjectFactory;
+import org.jboss.tools.jst.web.kb.PageContextFactory;
+import org.jboss.tools.jst.web.kb.internal.XmlContextImpl;
import org.jboss.tools.jst.web.kb.internal.taglib.TLDLibrary;
import org.jboss.tools.jst.web.kb.taglib.INameSpace;
import org.jboss.tools.jst.web.kb.taglib.ITagLibrary;
@@ -93,15 +99,29 @@
if(prefix == null)
return new IJavaCompletionProposal[]{};
+ IFile file = MarkerResolutionUtils.getFile();
+ if(file == null)
+ return new IJavaCompletionProposal[]{};
+
+ ELContext context = PageContextFactory.createPageContext(file);
+ if(context instanceof XmlContextImpl){
+ Map<String, List<INameSpace>> nameSpaces = ((XmlContextImpl) context).getNameSpaces(start);
+ Iterator<List<INameSpace>> iterator = nameSpaces.values().iterator();
+ while(iterator.hasNext()){
+ List<INameSpace> list = iterator.next();
+ for(INameSpace ns : list){
+ if(prefix.equals(ns.getPrefix())){
+ return new IJavaCompletionProposal[]{};
+ }
+ }
+ }
+ }
+
Object additionalInfo = ta.getAdditionalFixInfo();
if(additionalInfo instanceof IDocument){
IStructuredModel model = StructuredModelManager.getModelManager().getModelForRead((IStructuredDocument)additionalInfo);
IDOMDocument xmlDocument = (model instanceof IDOMModel) ? ((IDOMModel) model).getDocument() : null;
- IFile file = MarkerResolutionUtils.getFile();
- if(file == null)
- return new IJavaCompletionProposal[]{};
-
IKbProject kbProject = KbProjectFactory.getKbProject(file.getProject(), true);
ITagLibrary[] libraries = kbProject.getTagLibraries();
@@ -163,9 +183,22 @@
if(prefix == null)
return new IMarkerResolution[]{};
-
IFile file = (IFile)marker.getResource();
+ ELContext context = PageContextFactory.createPageContext(file);
+ if(context instanceof XmlContextImpl){
+ Map<String, List<INameSpace>> nameSpaces = ((XmlContextImpl) context).getNameSpaces(start);
+ Iterator<List<INameSpace>> iterator = nameSpaces.values().iterator();
+ while(iterator.hasNext()){
+ List<INameSpace> list = iterator.next();
+ for(INameSpace ns : list){
+ if(prefix.equals(ns.getPrefix())){
+ return new IMarkerResolution[]{};
+ }
+ }
+ }
+ }
+
IKbProject kbProject = KbProjectFactory.getKbProject(file.getProject(), true);
ITagLibrary[] libraries = kbProject.getTagLibraries();
13 years, 2 months
JBoss Tools SVN: r42744 - trunk/jst/plugins/org.jboss.tools.jst.web.ui/src/org/jboss/tools/jst/web/ui/action.
by jbosstools-commits@lists.jboss.org
Author: dazarov
Date: 2012-07-26 18:27:16 -0400 (Thu, 26 Jul 2012)
New Revision: 42744
Modified:
trunk/jst/plugins/org.jboss.tools.jst.web.ui/src/org/jboss/tools/jst/web/ui/action/AddTLDMarkerResolution.java
Log:
Make Quick Fix "Add tag library definition" work with KB Model instead of using plain tag library list https://issues.jboss.org/browse/JBIDE-12304
Modified: trunk/jst/plugins/org.jboss.tools.jst.web.ui/src/org/jboss/tools/jst/web/ui/action/AddTLDMarkerResolution.java
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.web.ui/src/org/jboss/tools/jst/web/ui/action/AddTLDMarkerResolution.java 2012-07-26 22:11:05 UTC (rev 42743)
+++ trunk/jst/plugins/org.jboss.tools.jst.web.ui/src/org/jboss/tools/jst/web/ui/action/AddTLDMarkerResolution.java 2012-07-26 22:27:16 UTC (rev 42744)
@@ -32,6 +32,7 @@
import org.jboss.tools.common.model.ui.ModelUIImages;
import org.jboss.tools.common.model.ui.views.palette.PaletteInsertHelper;
import org.jboss.tools.common.quickfix.IBaseMarkerResolution;
+import org.jboss.tools.common.ui.CommonUIPlugin;
import org.jboss.tools.jst.jsp.jspeditor.dnd.JSPPaletteInsertHelper;
import org.jboss.tools.jst.jsp.jspeditor.dnd.PaletteTaglibInserter;
import org.jboss.tools.jst.web.ui.Messages;
@@ -134,7 +135,7 @@
@Override
public Image getImage() {
- return ModelUIImages.getImageDescriptor(ModelUIImages.TAGLIB_FILE).createImage();
+ return CommonUIPlugin.getImageDescriptorRegistry().get(ModelUIImages.getImageDescriptor(ModelUIImages.TAGLIB_FILE));
}
@Override
13 years, 2 months
JBoss Tools SVN: r42743 - trunk/jst/plugins/org.jboss.tools.jst.web.ui/src/org/jboss/tools/jst/web/ui/action.
by jbosstools-commits@lists.jboss.org
Author: dazarov
Date: 2012-07-26 18:11:05 -0400 (Thu, 26 Jul 2012)
New Revision: 42743
Modified:
trunk/jst/plugins/org.jboss.tools.jst.web.ui/src/org/jboss/tools/jst/web/ui/action/JSPProblemMarkerResolutionGenerator.java
Log:
Make Quick Fix "Add tag library definition" work with KB Model instead of using plain tag library list https://issues.jboss.org/browse/JBIDE-12304
Modified: trunk/jst/plugins/org.jboss.tools.jst.web.ui/src/org/jboss/tools/jst/web/ui/action/JSPProblemMarkerResolutionGenerator.java
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.web.ui/src/org/jboss/tools/jst/web/ui/action/JSPProblemMarkerResolutionGenerator.java 2012-07-26 21:44:16 UTC (rev 42742)
+++ trunk/jst/plugins/org.jboss.tools.jst.web.ui/src/org/jboss/tools/jst/web/ui/action/JSPProblemMarkerResolutionGenerator.java 2012-07-26 22:11:05 UTC (rev 42743)
@@ -105,6 +105,7 @@
IKbProject kbProject = KbProjectFactory.getKbProject(file.getProject(), true);
ITagLibrary[] libraries = kbProject.getTagLibraries();
+ ArrayList<String> names = new ArrayList<String>();
for(ITagLibrary l : libraries){
if(l instanceof TLDLibrary){
((TLDLibrary) l).createDefaultNameSpace();
@@ -113,8 +114,9 @@
if(ns != null && ns.getPrefix() != null && ns.getPrefix().equals(prefix)){
String uri = ns.getURI();
String resolutionName = getResolutionName(xmlDocument != null && xmlDocument.isXMLType(), true, prefix, uri);
- if(resolutionName != null){
+ if(resolutionName != null && !names.contains(resolutionName)){
proposals.add(new AddTLDMarkerResolution(resolutionName, start, end, uri, prefix));
+ names.add(resolutionName);
}
}
}
@@ -167,6 +169,7 @@
IKbProject kbProject = KbProjectFactory.getKbProject(file.getProject(), true);
ITagLibrary[] libraries = kbProject.getTagLibraries();
+ ArrayList<String> names = new ArrayList<String>();
for(ITagLibrary l : libraries){
if(l instanceof TLDLibrary){
((TLDLibrary) l).createDefaultNameSpace();
@@ -175,8 +178,9 @@
if(ns != null && ns.getPrefix() != null && ns.getPrefix().equals(prefix)){
String uri = ns.getURI();
String resolutionName = getResolutionName(marker.getType().equals(HTML_VALIDATOR_MARKER) || marker.isSubtypeOf(HTML_VALIDATOR_MARKER), marker.getType().equals(JSP_VALIDATOR_MARKER) || marker.isSubtypeOf(JSP_VALIDATOR_MARKER), prefix, uri);
- if(resolutionName != null){
+ if(resolutionName != null && !names.contains(resolutionName)){
resolutions.add(new AddTLDMarkerResolution(file, resolutionName, start, end, uri, prefix));
+ names.add(resolutionName);
}
}
}
13 years, 2 months