JBoss Tools SVN: r37200 - trunk/common/plugins/org.jboss.tools.common.validation/src/org/jboss/tools/common/validation.
by jbosstools-commits@lists.jboss.org
Author: akazakov
Date: 2011-12-09 20:20:39 -0500 (Fri, 09 Dec 2011)
New Revision: 37200
Modified:
trunk/common/plugins/org.jboss.tools.common.validation/src/org/jboss/tools/common/validation/ValidationErrorManager.java
Log:
https://issues.jboss.org/browse/JBIDE-10187 Add support for a @SuppressWarnings
Modified: trunk/common/plugins/org.jboss.tools.common.validation/src/org/jboss/tools/common/validation/ValidationErrorManager.java
===================================================================
--- trunk/common/plugins/org.jboss.tools.common.validation/src/org/jboss/tools/common/validation/ValidationErrorManager.java 2011-12-10 01:03:53 UTC (rev 37199)
+++ trunk/common/plugins/org.jboss.tools.common.validation/src/org/jboss/tools/common/validation/ValidationErrorManager.java 2011-12-10 01:20:39 UTC (rev 37200)
@@ -163,7 +163,7 @@
}
IMarker marker = addError(message, preferenceKey, messageArguments, 0, location
.getLength(), location.getStartPosition(), newTarget);
-
+
if(marker != null){
try {
marker.setAttribute(SUPPRESS_WARNINGS_ENABLED_ATTRIBUTE, true);
@@ -186,19 +186,19 @@
IMemberValuePair[] pairs = annotation.getMemberValuePairs();
if(pairs.length==1) {
Object v = pairs[0].getValue();
- String[] warnings = null;
- if(v instanceof String[]) {
- warnings = (String[])v;
- } else if(v instanceof String) {
+ Object[] warnings = null;
+ if(v instanceof Object[]) {
+ warnings = (Object[])v;
+ } else if(v instanceof String) {
warnings = new String[]{v.toString()};
- for (String warning : warnings) {
- String trimed = warning.trim();
- if(trimed.equals(preferenceKey) || trimed.equals(ALL_WARNINGS)) {
- // Ok, we seem to have such a suppress. Let's make sure the full name of annotation is java.lang.SuppressWarnings
- if(EclipseJavaUtil.checkAnnotationByFulltName(annotation, SUPPRESS_WARNINGS_ANNOTATION_FULL)) {
- result = annotation;
- break;
- }
+ }
+ for (Object warning : warnings) {
+ String trimed = warning.toString().trim();
+ if(trimed.equals(preferenceKey) || trimed.equals(ALL_WARNINGS)) {
+ // Ok, we seem to have such a suppress. Let's make sure the full name of annotation is java.lang.SuppressWarnings
+ if(EclipseJavaUtil.checkAnnotationByFulltName(annotation, SUPPRESS_WARNINGS_ANNOTATION_FULL)) {
+ result = annotation;
+ break;
}
}
}
14 years, 4 months
JBoss Tools SVN: r37199 - in trunk: vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor and 1 other directory.
by jbosstools-commits@lists.jboss.org
Author: dgolovin
Date: 2011-12-09 20:03:53 -0500 (Fri, 09 Dec 2011)
New Revision: 37199
Modified:
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/src/org/jboss/tools/jsf/vpe/jsf/test/jbide/JsfJbide2362Test.java
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeController.java
Log:
https://issues.jboss.org/browse/JBIDE-10351 test failure in org.jboss.tools.jsf.vpe.jsf.test
resolved
Modified: trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/src/org/jboss/tools/jsf/vpe/jsf/test/jbide/JsfJbide2362Test.java
===================================================================
--- trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/src/org/jboss/tools/jsf/vpe/jsf/test/jbide/JsfJbide2362Test.java 2011-12-10 00:40:07 UTC (rev 37198)
+++ trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/src/org/jboss/tools/jsf/vpe/jsf/test/jbide/JsfJbide2362Test.java 2011-12-10 01:03:53 UTC (rev 37199)
@@ -181,11 +181,10 @@
for (int j = 0; j < insertedString.length(); j++) {
styledText.setCaretOffset(offset + j);
styledText.insert(String.valueOf(insertedString.charAt(j)));
- TestUtil.delay();
}
TestUtil.delay(VpeController.DEFAULT_UPDATE_DELAY_TIME * 2); // ensure that vpe is started to update
- TestUtil.waitForJobs();
+ TestUtil.waitForIdle();
assertNotNull(xulRunnerEditor.getSelectedElement());
}
Modified: trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeController.java
===================================================================
--- trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeController.java 2011-12-10 00:40:07 UTC (rev 37198)
+++ trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeController.java 2011-12-10 01:03:53 UTC (rev 37199)
@@ -2118,7 +2118,8 @@
// node is created, see JBIDE-5105
visualEditor.reinitDesignMode();
visualBuilder.clearSelectionRectangle();
- //selectionManager = null;
+ // this is required because fullRefresh cannot be interrupded by messages from OS queue
+ selectionManager = null;
IDOMModel sourceModel = (IDOMModel) getModel();
if (sourceModel != null) {
IDOMDocument sourceDocument = sourceModel.getDocument();
@@ -2134,6 +2135,8 @@
selectionManager = new SelectionManager(pageContext, sourceEditor,
visualSelectionController);
+ // selection should be restored after full refresh
+ selectionManager.refreshVisualSelection();
keyEventHandler = new KeyEventManager(sourceEditor, domMapping,
pageContext);
14 years, 4 months
JBoss Tools SVN: r37198 - in trunk/common/plugins: org.jboss.tools.common.ui/src/org/jboss/tools/common/ui/marker and 1 other directories.
by jbosstools-commits@lists.jboss.org
Author: dazarov
Date: 2011-12-09 19:40:07 -0500 (Fri, 09 Dec 2011)
New Revision: 37198
Modified:
trunk/common/plugins/org.jboss.tools.common.ui/src/org/jboss/tools/common/ui/marker/AddSuppressWarningsMarkerResolution.java
trunk/common/plugins/org.jboss.tools.common.ui/src/org/jboss/tools/common/ui/marker/ConfigureProblemSeverityResolutionGenerator.java
trunk/common/plugins/org.jboss.tools.common.validation/src/org/jboss/tools/common/validation/ValidationErrorManager.java
trunk/common/plugins/org.jboss.tools.common/src/org/jboss/tools/common/EclipseUtil.java
Log:
Add @SuppressWarnings quick fix https://issues.jboss.org/browse/JBIDE-10187
Modified: trunk/common/plugins/org.jboss.tools.common/src/org/jboss/tools/common/EclipseUtil.java
===================================================================
--- trunk/common/plugins/org.jboss.tools.common/src/org/jboss/tools/common/EclipseUtil.java 2011-12-09 23:10:25 UTC (rev 37197)
+++ trunk/common/plugins/org.jboss.tools.common/src/org/jboss/tools/common/EclipseUtil.java 2011-12-10 00:40:07 UTC (rev 37198)
@@ -25,7 +25,6 @@
import org.eclipse.jdt.core.ICompilationUnit;
import org.eclipse.jdt.core.IJavaElement;
import org.eclipse.jdt.core.IJavaProject;
-import org.eclipse.jdt.core.IPackageFragment;
import org.eclipse.jdt.core.JavaCore;
/**
@@ -78,25 +77,9 @@
}
public static ICompilationUnit getCompilationUnit(IFile f) throws CoreException {
- IProject project = f.getProject();
- IJavaProject javaProject = (IJavaProject)project.getNature(JavaCore.NATURE_ID);
- IResource[] rs = getJavaSourceRoots(project);
- for (int i = 0; i < rs.length; i++) {
- if(rs[i].getFullPath().isPrefixOf(f.getFullPath())) {
- IPath path = f.getFullPath().removeFirstSegments(rs[i].getFullPath().segmentCount());
- IJavaElement e = javaProject.findElement(path);
- if(e == null && path.lastSegment().equals("package-info.java")) {
- //strange but sometimes only this works
- IJavaElement ep = javaProject.findElement(path.removeLastSegments(1));
- if(ep instanceof IPackageFragment) {
- e = ((IPackageFragment)ep).getCompilationUnit("package-info.java");
- }
- }
- if(e instanceof ICompilationUnit) {
- return (ICompilationUnit)e;
- }
- }
- }
+ IJavaElement element= JavaCore.create(f);
+ if (element instanceof ICompilationUnit)
+ return (ICompilationUnit) element;
return null;
}
Modified: trunk/common/plugins/org.jboss.tools.common.ui/src/org/jboss/tools/common/ui/marker/AddSuppressWarningsMarkerResolution.java
===================================================================
--- trunk/common/plugins/org.jboss.tools.common.ui/src/org/jboss/tools/common/ui/marker/AddSuppressWarningsMarkerResolution.java 2011-12-09 23:10:25 UTC (rev 37197)
+++ trunk/common/plugins/org.jboss.tools.common.ui/src/org/jboss/tools/common/ui/marker/AddSuppressWarningsMarkerResolution.java 2011-12-10 00:40:07 UTC (rev 37198)
@@ -10,41 +10,153 @@
******************************************************************************/
package org.jboss.tools.common.ui.marker;
+import java.util.Collection;
+import java.util.List;
+
+import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IMarker;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IConfigurationElement;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.jdt.core.IAnnotatable;
+import org.eclipse.jdt.core.IAnnotation;
+import org.eclipse.jdt.core.IBuffer;
+import org.eclipse.jdt.core.ICompilationUnit;
import org.eclipse.jdt.core.IJavaElement;
+import org.eclipse.jdt.core.ILocalVariable;
+import org.eclipse.jdt.core.IMember;
+import org.eclipse.jdt.core.IMethod;
+import org.eclipse.jdt.core.ISourceReference;
+import org.eclipse.jdt.core.IType;
+import org.eclipse.jdt.core.JavaCore;
+import org.eclipse.jdt.core.JavaModelException;
import org.eclipse.jdt.internal.ui.JavaPlugin;
import org.eclipse.jdt.internal.ui.JavaPluginImages;
+import org.eclipse.jdt.internal.ui.preferences.ProblemSeveritiesConfigurationBlock;
+import org.eclipse.jdt.ui.PreferenceConstants;
+import org.eclipse.jface.preference.IPreferenceNode;
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.jface.preference.PreferenceManager;
import org.eclipse.osgi.util.NLS;
import org.eclipse.swt.graphics.Image;
import org.eclipse.ui.IMarkerResolution2;
+import org.eclipse.ui.dialogs.PreferencesUtil;
+import org.eclipse.ui.internal.dialogs.PropertyPageContributorManager;
+import org.eclipse.ui.internal.dialogs.PropertyPageManager;
+import org.eclipse.ui.internal.dialogs.PropertyPageNode;
+import org.jboss.tools.common.EclipseUtil;
import org.jboss.tools.common.ui.CommonUIMessages;
+import org.jboss.tools.common.ui.CommonUIPlugin;
/**
* @author Daniel Azarov
*/
public class AddSuppressWarningsMarkerResolution implements
IMarkerResolution2 {
+ public static final String SPACE = " "; //$NON-NLS-1$
+ public static final String AT = "@"; //$NON-NLS-1$
+ private static final String JAVA_COMPILER_ID="org.eclipse.jdt.ui.propertyPages.CompliancePreferencePage"; //$NON-NLS-1$
+ private static final String PROBLEM_SEVERITIES_ID="org.eclipse.jdt.ui.propertyPages.ProblemSeveritiesPreferencePage"; //$NON-NLS-1$
+
+
+ private IFile file;
private IJavaElement element;
private String preferenceKey;
+ private String label;
- public AddSuppressWarningsMarkerResolution(IJavaElement element, String preferenceKey){
+ public AddSuppressWarningsMarkerResolution(IFile file, IJavaElement element, String preferenceKey){
+ this.file = file;
this.element = element;
this.preferenceKey = preferenceKey;
+ label = NLS.bind(CommonUIMessages.ADD_SUPPRESS_WARNINGS, element.getElementName());
}
public String getLabel() {
- return CommonUIMessages.CONFIGURE_PROBLEM_SEVERITY;
+ return label;
}
public void run(IMarker marker) {
+ try {
+ ICompilationUnit original = EclipseUtil.getCompilationUnit(file);
+ ICompilationUnit compilationUnit;
+ compilationUnit = original.getWorkingCopy(new NullProgressMonitor());
+
+ addAnnotation("SuppressWarnings(\""+preferenceKey+"\")", compilationUnit, element);
+
+ compilationUnit.commitWorkingCopy(true, new NullProgressMonitor());
+ compilationUnit.discardWorkingCopy();
+ } catch (JavaModelException e) {
+ CommonUIPlugin.getDefault().logError(e);
+ } catch (CoreException e) {
+ CommonUIPlugin.getDefault().logError(e);
+ }
+
+ JavaCore.getPlugin().getPluginPreferences().setValue(JavaCore.COMPILER_PB_UNHANDLED_WARNING_TOKEN, JavaCore.IGNORE);
+ JavaCore.getPlugin().savePluginPreferences();
}
-
+
public String getDescription() {
- return NLS.bind(CommonUIMessages.CONFIGURE_PROBLEM_SEVERITY, element.getElementName());
+ return label;
}
public Image getImage() {
return JavaPlugin.getImageDescriptorRegistry().get(JavaPluginImages.DESC_OBJS_ANNOTATION);
}
-
-}
+
+ public static void addAnnotation(String name, ICompilationUnit compilationUnit, IJavaElement element) throws JavaModelException{
+ IJavaElement workingCopyElement = findWorkingCopy(compilationUnit, element);
+ if(workingCopyElement == null){
+ return;
+ }
+
+ if(!(workingCopyElement instanceof ISourceReference))
+ return;
+
+ ISourceReference workingCopySourceReference = (ISourceReference) workingCopyElement;
+
+ //IAnnotation annotation = findAnnotation(workingCopyMember, name);
+ //if(annotation != null && annotation.exists())
+ // return;
+
+ IBuffer buffer = compilationUnit.getBuffer();
+
+ String str = AT+name;
+
+ if(workingCopySourceReference instanceof IType){
+ str += compilationUnit.findRecommendedLineSeparator();
+ }else{
+ str += SPACE;
+ }
+
+ buffer.replace(workingCopySourceReference.getSourceRange().getOffset(), 0, str);
+ }
+
+ @SuppressWarnings("unchecked")
+ public static <T extends IJavaElement> T findWorkingCopy(ICompilationUnit compilationUnit, T element) throws JavaModelException{
+ if(element instanceof IAnnotation){
+ IJavaElement parent = findWorkingCopy(compilationUnit, element.getParent());
+ if(parent instanceof IAnnotatable){
+ for(IAnnotation a : ((IAnnotatable)parent).getAnnotations()){
+ if(a.getElementName().equals(element.getElementName()))
+ return (T)a;
+ }
+ }
+ }else if(element instanceof ILocalVariable && ((ILocalVariable) element).isParameter()){
+ IJavaElement parent = findWorkingCopy(compilationUnit, element.getParent());
+ if(parent instanceof IMethod){
+ for(ILocalVariable parameter : ((IMethod)parent).getParameters()){
+ if(parameter.getElementName().equals(element.getElementName()) && parameter.getTypeSignature().equals(((ILocalVariable)element).getTypeSignature()))
+ return (T)parameter;
+ }
+ }
+ }else{
+ IJavaElement[] elements = compilationUnit.findElements(element);
+ if(elements != null){
+ for(IJavaElement e : elements){
+ if(e.getClass().equals(element.getClass()))
+ return (T)e;
+ }
+ }
+ }
+ return null;
+ }}
Modified: trunk/common/plugins/org.jboss.tools.common.ui/src/org/jboss/tools/common/ui/marker/ConfigureProblemSeverityResolutionGenerator.java
===================================================================
--- trunk/common/plugins/org.jboss.tools.common.ui/src/org/jboss/tools/common/ui/marker/ConfigureProblemSeverityResolutionGenerator.java 2011-12-09 23:10:25 UTC (rev 37197)
+++ trunk/common/plugins/org.jboss.tools.common.ui/src/org/jboss/tools/common/ui/marker/ConfigureProblemSeverityResolutionGenerator.java 2011-12-10 00:40:07 UTC (rev 37198)
@@ -12,11 +12,17 @@
import java.util.ArrayList;
+import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IMarker;
import org.eclipse.core.runtime.CoreException;
+import org.eclipse.jdt.core.ICompilationUnit;
import org.eclipse.jdt.core.IJavaElement;
+import org.eclipse.jdt.core.ILocalVariable;
+import org.eclipse.jdt.core.IMethod;
+import org.eclipse.jdt.core.JavaModelException;
import org.eclipse.ui.IMarkerResolution;
import org.eclipse.ui.IMarkerResolutionGenerator2;
+import org.jboss.tools.common.EclipseUtil;
import org.jboss.tools.common.ui.CommonUIPlugin;
import org.jboss.tools.common.validation.ValidationErrorManager;
@@ -28,14 +34,23 @@
public IMarkerResolution[] getResolutions(IMarker marker) {
ArrayList<IMarkerResolution> resolutions = new ArrayList<IMarkerResolution>();
+ int position = marker.getAttribute(IMarker.CHAR_START, 0);
try {
- String preferenceKey = getPreferenceKey(marker);
- String preferencePageId = getPreferencePageId(marker);
- if(preferenceKey != null && preferencePageId != null){
- resolutions.add(new ConfigureProblemSeverityMarkerResolution(preferencePageId, preferenceKey));
- IJavaElement element = findJavaElement(marker);
- if(element != null){
- resolutions.add(new AddSuppressWarningsMarkerResolution(element, preferenceKey));
+ if(marker.getResource() instanceof IFile){
+ IFile file = (IFile)marker.getResource();
+ if(file != null){
+ String preferenceKey = getPreferenceKey(marker);
+ String preferencePageId = getPreferencePageId(marker);
+ if(preferenceKey != null && preferencePageId != null){
+ resolutions.add(new ConfigureProblemSeverityMarkerResolution(preferencePageId, preferenceKey));
+ boolean enabled = marker.getAttribute(ValidationErrorManager.SUPPRESS_WARNINGS_ENABLED_ATTRIBUTE, false);
+ if(enabled){
+ IJavaElement element = findJavaElement(file, position);
+ if(element != null){
+ resolutions.add(new AddSuppressWarningsMarkerResolution(file, element, preferenceKey));
+ }
+ }
+ }
}
}
} catch (CoreException e) {
@@ -44,9 +59,31 @@
return resolutions.toArray(new IMarkerResolution[] {});
}
- private IJavaElement findJavaElement(IMarker marker){
+ private IJavaElement findJavaElement(IFile file, int position){
+ ICompilationUnit compilationUnit = null;
+ try {
+ compilationUnit = EclipseUtil.getCompilationUnit(file);
+ IJavaElement element = compilationUnit.getElementAt(position);
+ if(element != null && element instanceof IMethod){
+ IJavaElement parameter = findParameter((IMethod)element, position);
+ if(parameter != null){
+ return parameter;
+ }
+ }
+ return element;
+ } catch (CoreException e) {
+ CommonUIPlugin.getDefault().logError(e);
+ }
return null;
}
+
+ private ILocalVariable findParameter(IMethod method, int position) throws JavaModelException{
+ for(ILocalVariable parameter : method.getParameters()){
+ if(parameter.getSourceRange().getOffset() <= position && parameter.getSourceRange().getOffset()+parameter.getSourceRange().getLength() > position)
+ return parameter;
+ }
+ return null;
+ }
public boolean hasResolutions(IMarker marker) {
try {
Modified: trunk/common/plugins/org.jboss.tools.common.validation/src/org/jboss/tools/common/validation/ValidationErrorManager.java
===================================================================
--- trunk/common/plugins/org.jboss.tools.common.validation/src/org/jboss/tools/common/validation/ValidationErrorManager.java 2011-12-09 23:10:25 UTC (rev 37197)
+++ trunk/common/plugins/org.jboss.tools.common.validation/src/org/jboss/tools/common/validation/ValidationErrorManager.java 2011-12-10 00:40:07 UTC (rev 37198)
@@ -49,6 +49,7 @@
static String VALIDATION_MARKER_GROUP = "groupName"; //$NON-NLS-1$
public static final String PREFERENCE_KEY_ATTRIBUTE_NAME = "preference_key"; //$NON-NLS-1$
public static final String PREFERENCE_PAGE_ID_NAME = "preference_page_id"; //$NON-NLS-1$
+ public static final String SUPPRESS_WARNINGS_ENABLED_ATTRIBUTE = "sup_warn_ena"; //$NON-NLS-1$
protected IStatus OK_STATUS = new Status(IStatus.OK,
"org.eclipse.wst.validation", 0, "OK", null); //$NON-NLS-1$ //$NON-NLS-2$
@@ -160,8 +161,17 @@
} catch (JavaModelException e) {
CommonPlugin.getDefault().logError(e);
}
- return addError(message, preferenceKey, messageArguments, 0, location
+ IMarker marker = addError(message, preferenceKey, messageArguments, 0, location
.getLength(), location.getStartPosition(), newTarget);
+
+ if(marker != null){
+ try {
+ marker.setAttribute(SUPPRESS_WARNINGS_ENABLED_ATTRIBUTE, true);
+ } catch (CoreException e) {
+ CommonPlugin.getDefault().logError(e);
+ }
+ }
+ return marker;
}
private static final String SUPPRESS_WARNINGS_ANNOTATION_SHORT = "SuppressWarnings";
14 years, 4 months
JBoss Tools SVN: r37197 - in trunk/common/plugins/org.jboss.tools.common/src/org/jboss/tools/common/java: impl and 1 other directory.
by jbosstools-commits@lists.jboss.org
Author: akazakov
Date: 2011-12-09 18:10:25 -0500 (Fri, 09 Dec 2011)
New Revision: 37197
Modified:
trunk/common/plugins/org.jboss.tools.common/src/org/jboss/tools/common/java/IAnnotationDeclaration.java
trunk/common/plugins/org.jboss.tools.common/src/org/jboss/tools/common/java/impl/AnnotationDeclaration.java
trunk/common/plugins/org.jboss.tools.common/src/org/jboss/tools/common/java/impl/AnnotationLiteral.java
Log:
https://issues.jboss.org/browse/JBIDE-10187 Add support for a @SuppressWarnings
Modified: trunk/common/plugins/org.jboss.tools.common/src/org/jboss/tools/common/java/IAnnotationDeclaration.java
===================================================================
--- trunk/common/plugins/org.jboss.tools.common/src/org/jboss/tools/common/java/IAnnotationDeclaration.java 2011-12-09 23:07:58 UTC (rev 37196)
+++ trunk/common/plugins/org.jboss.tools.common/src/org/jboss/tools/common/java/IAnnotationDeclaration.java 2011-12-09 23:10:25 UTC (rev 37197)
@@ -15,7 +15,6 @@
import org.eclipse.jdt.core.IMember;
import org.eclipse.jdt.core.IMemberValuePair;
import org.eclipse.jdt.core.IType;
-import org.jboss.tools.common.text.ITextSourceReference;
/**
* Represents an annotation declaration. For example, in CDI, a qualifier or a scope
@@ -23,7 +22,7 @@
*
* @author Alexey Kazakov
*/
-public interface IAnnotationDeclaration extends ITextSourceReference {
+public interface IAnnotationDeclaration extends IJavaSourceReference {
/**
* Returns the member value pairs.
Modified: trunk/common/plugins/org.jboss.tools.common/src/org/jboss/tools/common/java/impl/AnnotationDeclaration.java
===================================================================
--- trunk/common/plugins/org.jboss.tools.common/src/org/jboss/tools/common/java/impl/AnnotationDeclaration.java 2011-12-09 23:07:58 UTC (rev 37196)
+++ trunk/common/plugins/org.jboss.tools.common/src/org/jboss/tools/common/java/impl/AnnotationDeclaration.java 2011-12-09 23:10:25 UTC (rev 37197)
@@ -25,7 +25,6 @@
import org.jboss.tools.common.java.IAnnotationDeclaration;
import org.jboss.tools.common.java.IAnnotationType;
import org.jboss.tools.common.java.IJavaAnnotation;
-import org.jboss.tools.common.java.impl.JavaAnnotation;
import org.jboss.tools.common.util.EclipseJavaUtil;
/**
@@ -172,4 +171,9 @@
}
return null;
}
+
+ @Override
+ public IMember getSourceMember() {
+ return getParentMember();
+ }
}
\ No newline at end of file
Modified: trunk/common/plugins/org.jboss.tools.common/src/org/jboss/tools/common/java/impl/AnnotationLiteral.java
===================================================================
--- trunk/common/plugins/org.jboss.tools.common/src/org/jboss/tools/common/java/impl/AnnotationLiteral.java 2011-12-09 23:07:58 UTC (rev 37196)
+++ trunk/common/plugins/org.jboss.tools.common/src/org/jboss/tools/common/java/impl/AnnotationLiteral.java 2011-12-09 23:10:25 UTC (rev 37197)
@@ -86,5 +86,4 @@
public IMemberValuePair[] getMemberValuePairs() {
return memberValues;
}
-
-}
+}
\ No newline at end of file
14 years, 4 months
JBoss Tools SVN: r37196 - trunk/common/plugins/org.jboss.tools.common.validation/src/org/jboss/tools/common/validation.
by jbosstools-commits@lists.jboss.org
Author: akazakov
Date: 2011-12-09 18:07:58 -0500 (Fri, 09 Dec 2011)
New Revision: 37196
Modified:
trunk/common/plugins/org.jboss.tools.common.validation/src/org/jboss/tools/common/validation/ValidationErrorManager.java
Log:
https://issues.jboss.org/browse/JBIDE-10187 Add support for a @SuppressWarnings
Modified: trunk/common/plugins/org.jboss.tools.common.validation/src/org/jboss/tools/common/validation/ValidationErrorManager.java
===================================================================
--- trunk/common/plugins/org.jboss.tools.common.validation/src/org/jboss/tools/common/validation/ValidationErrorManager.java 2011-12-09 22:58:17 UTC (rev 37195)
+++ trunk/common/plugins/org.jboss.tools.common.validation/src/org/jboss/tools/common/validation/ValidationErrorManager.java 2011-12-09 23:07:58 UTC (rev 37196)
@@ -153,13 +153,13 @@
if(location.getResource() != null && location.getResource().exists() && !location.getResource().equals(target)) {
newTarget = location.getResource();
}
-// try {
-// if(hasSuppressWarningsAnnotation(preferenceKey, location)) {
-// return null;
-// }
-// } catch (JavaModelException e) {
-// CommonPlugin.getDefault().logError(e);
-// }
+ try {
+ if(hasSuppressWarningsAnnotation(preferenceKey, location)) {
+ return null;
+ }
+ } catch (JavaModelException e) {
+ CommonPlugin.getDefault().logError(e);
+ }
return addError(message, preferenceKey, messageArguments, 0, location
.getLength(), location.getStartPosition(), newTarget);
}
14 years, 4 months
JBoss Tools SVN: r37195 - in trunk/common/plugins: org.jboss.tools.common.validation/META-INF and 1 other directories.
by jbosstools-commits@lists.jboss.org
Author: akazakov
Date: 2011-12-09 17:58:17 -0500 (Fri, 09 Dec 2011)
New Revision: 37195
Modified:
trunk/common/plugins/org.jboss.tools.common.validation/META-INF/MANIFEST.MF
trunk/common/plugins/org.jboss.tools.common.validation/src/org/jboss/tools/common/validation/ValidationErrorManager.java
trunk/common/plugins/org.jboss.tools.common/src/org/jboss/tools/common/util/EclipseJavaUtil.java
Log:
https://issues.jboss.org/browse/JBIDE-10187 Add support for a @SuppressWarnings
Modified: trunk/common/plugins/org.jboss.tools.common/src/org/jboss/tools/common/util/EclipseJavaUtil.java
===================================================================
--- trunk/common/plugins/org.jboss.tools.common/src/org/jboss/tools/common/util/EclipseJavaUtil.java 2011-12-09 22:20:45 UTC (rev 37194)
+++ trunk/common/plugins/org.jboss.tools.common/src/org/jboss/tools/common/util/EclipseJavaUtil.java 2011-12-09 22:58:17 UTC (rev 37195)
@@ -22,6 +22,7 @@
import org.eclipse.jdt.core.IAnnotation;
import org.eclipse.jdt.core.ICompilationUnit;
import org.eclipse.jdt.core.IField;
+import org.eclipse.jdt.core.IJavaElement;
import org.eclipse.jdt.core.IJavaProject;
import org.eclipse.jdt.core.IMember;
import org.eclipse.jdt.core.IMethod;
@@ -171,4 +172,83 @@
return null;
}
+ /**
+ * Returns annotation by the full name declared for the given java member or its parents.
+ * @param member
+ * @param name
+ * @param checkParents
+ * @return
+ * @throws JavaModelException
+ */
+ public static IAnnotation findAnnotationByFullName(IMember member, String name, boolean checkParents) throws JavaModelException {
+ String shortName = name;
+ int i = name.lastIndexOf('.');
+ if(i>-1) {
+ shortName = name.substring(i+1);
+ }
+ IAnnotation annotation = findAnnotationByShortName(member, shortName, checkParents);
+ return annotation!=null && checkAnnotationByFulltName(annotation, name) ? annotation:null;
+ }
+
+ /**
+ * Returns true if the given annotation has the given full name
+ * @param annotation
+ * @param fullName
+ * @return
+ * @throws JavaModelException
+ */
+ public static boolean checkAnnotationByFulltName(IAnnotation annotation, String fullName) throws JavaModelException {
+ if(annotation.getElementName().equals(fullName)) {
+ return true;
+ }
+ boolean result = true;
+ IType sourceType = null;
+ IJavaElement parent = annotation.getParent();
+ if(parent instanceof IMember) {
+ if(parent instanceof IType) {
+ sourceType = (IType)parent;
+ } else {
+ sourceType = ((IMember)parent).getDeclaringType();
+ }
+ String fullAnnotationName = EclipseJavaUtil.resolveType(sourceType, annotation.getElementName());
+ if(fullAnnotationName!=null) {
+ IType annotationType = sourceType.getJavaProject().findType(fullAnnotationName);
+ result = annotationType!=null && annotationType.getFullyQualifiedName().equals(fullName);
+ } else {
+ result = false;
+ }
+ }
+ return result;
+ }
+
+ /**
+ * Returns annotation by the short name declared for the given java member or its parents.
+ * @param member
+ * @param name
+ * @param checkParents
+ * @return
+ * @throws JavaModelException
+ */
+ public static IAnnotation findAnnotationByShortName(IMember member, String name, boolean checkParents) throws JavaModelException {
+ if(member instanceof IAnnotatable) {
+ IAnnotation[] annotations = ((IAnnotatable)member).getAnnotations();
+ for (IAnnotation annotation : annotations) {
+ String aName = annotation.getElementName();
+ int i = aName.lastIndexOf('.');
+ if(i>-1) {
+ aName = aName.substring(i+1);
+ }
+ if(aName.equals(name)) {
+ return annotation;
+ }
+ }
+ }
+ if(checkParents) {
+ IJavaElement parent = member.getParent();
+ if(parent!=null && parent instanceof IMember) {
+ return findAnnotationByShortName((IMember)parent, name, true);
+ }
+ }
+ return null;
+ }
}
\ No newline at end of file
Modified: trunk/common/plugins/org.jboss.tools.common.validation/META-INF/MANIFEST.MF
===================================================================
--- trunk/common/plugins/org.jboss.tools.common.validation/META-INF/MANIFEST.MF 2011-12-09 22:20:45 UTC (rev 37194)
+++ trunk/common/plugins/org.jboss.tools.common.validation/META-INF/MANIFEST.MF 2011-12-09 22:58:17 UTC (rev 37195)
@@ -16,7 +16,8 @@
org.eclipse.ui.ide;bundle-version="3.7.0",
org.eclipse.jface;bundle-version="3.7.0",
org.eclipse.ui;bundle-version="3.7.0",
- org.eclipse.wst.validation.ui;bundle-version="1.2.204"
+ org.eclipse.wst.validation.ui;bundle-version="1.2.204",
+ org.eclipse.jdt.core;bundle-version="3.7.0"
Bundle-ActivationPolicy: lazy
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Bundle-Vendor: %providerName
Modified: trunk/common/plugins/org.jboss.tools.common.validation/src/org/jboss/tools/common/validation/ValidationErrorManager.java
===================================================================
--- trunk/common/plugins/org.jboss.tools.common.validation/src/org/jboss/tools/common/validation/ValidationErrorManager.java 2011-12-09 22:20:45 UTC (rev 37194)
+++ trunk/common/plugins/org.jboss.tools.common.validation/src/org/jboss/tools/common/validation/ValidationErrorManager.java 2011-12-09 22:58:17 UTC (rev 37195)
@@ -20,6 +20,10 @@
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
+import org.eclipse.jdt.core.IAnnotation;
+import org.eclipse.jdt.core.IMember;
+import org.eclipse.jdt.core.IMemberValuePair;
+import org.eclipse.jdt.core.JavaModelException;
import org.eclipse.jface.text.BadLocationException;
import org.eclipse.jface.text.IDocument;
import org.eclipse.osgi.util.NLS;
@@ -30,8 +34,10 @@
import org.eclipse.wst.validation.internal.provisional.core.IReporter;
import org.eclipse.wst.validation.internal.provisional.core.IValidator;
import org.jboss.tools.common.CommonPlugin;
+import org.jboss.tools.common.java.IJavaSourceReference;
import org.jboss.tools.common.preferences.SeverityPreferences;
import org.jboss.tools.common.text.ITextSourceReference;
+import org.jboss.tools.common.util.EclipseJavaUtil;
/**
* @author Alexey Kazakov
@@ -145,12 +151,63 @@
IResource target) {
IResource newTarget = target;
if(location.getResource() != null && location.getResource().exists() && !location.getResource().equals(target)) {
- newTarget = location.getResource();
+ newTarget = location.getResource();
}
+// try {
+// if(hasSuppressWarningsAnnotation(preferenceKey, location)) {
+// return null;
+// }
+// } catch (JavaModelException e) {
+// CommonPlugin.getDefault().logError(e);
+// }
return addError(message, preferenceKey, messageArguments, 0, location
.getLength(), location.getStartPosition(), newTarget);
}
+ private static final String SUPPRESS_WARNINGS_ANNOTATION_SHORT = "SuppressWarnings";
+ private static final String SUPPRESS_WARNINGS_ANNOTATION_FULL = "java.lang.SuppressWarnings";
+ private static final String ALL_WARNINGS = "all";
+
+ private static IAnnotation getSuppressWarningsAnnotation(String preferenceKey, IMember member) throws JavaModelException {
+ // Does the element have @SuppressWarnings? Check it by the short name only.
+ IAnnotation annotation = EclipseJavaUtil.findAnnotationByShortName(member, SUPPRESS_WARNINGS_ANNOTATION_SHORT, true);
+ IAnnotation result = null;
+ if(annotation!=null) {
+ IMemberValuePair[] pairs = annotation.getMemberValuePairs();
+ if(pairs.length==1) {
+ Object v = pairs[0].getValue();
+ String[] warnings = null;
+ if(v instanceof String[]) {
+ warnings = (String[])v;
+ } else if(v instanceof String) {
+ warnings = new String[]{v.toString()};
+ for (String warning : warnings) {
+ String trimed = warning.trim();
+ if(trimed.equals(preferenceKey) || trimed.equals(ALL_WARNINGS)) {
+ // Ok, we seem to have such a suppress. Let's make sure the full name of annotation is java.lang.SuppressWarnings
+ if(EclipseJavaUtil.checkAnnotationByFulltName(annotation, SUPPRESS_WARNINGS_ANNOTATION_FULL)) {
+ result = annotation;
+ break;
+ }
+ }
+ }
+ }
+ }
+ }
+
+ return result;
+ }
+
+ private static boolean hasSuppressWarningsAnnotation(String preferenceKey, ITextSourceReference location) throws JavaModelException {
+ boolean result = false;
+ if(location instanceof IJavaSourceReference) {
+ IMember member = ((IJavaSourceReference) location).getSourceMember();
+ result = getSuppressWarningsAnnotation(preferenceKey, member)!=null;
+ }
+
+ return result;
+ }
+
/*
* (non-Javadoc)
*
14 years, 4 months
JBoss Tools SVN: r37194 - in trunk/jsf: tests/org.jboss.tools.jsf.test/src/org/jboss/tools/jsf/test/validation and 1 other directory.
by jbosstools-commits@lists.jboss.org
Author: scabanovich
Date: 2011-12-09 17:20:45 -0500 (Fri, 09 Dec 2011)
New Revision: 37194
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/web/validation/FacesConfigValidator.java
trunk/jsf/tests/org.jboss.tools.jsf.test/src/org/jboss/tools/jsf/test/validation/FacesConfigValidatorTest.java
Log:
JBIDE-10190
https://issues.jboss.org/browse/JBIDE-10190
Supported incremental faces-config.xml validation.
Modified: trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/web/validation/FacesConfigValidator.java
===================================================================
--- trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/web/validation/FacesConfigValidator.java 2011-12-09 22:13:03 UTC (rev 37193)
+++ trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/web/validation/FacesConfigValidator.java 2011-12-09 22:20:45 UTC (rev 37194)
@@ -140,34 +140,34 @@
addCheck(new CheckClass(this, JSFSeverityPreferences.INVALID_COMPONENT_CLASS, "component-class", false, null, "javax.faces.component.UIComponent"), ENT_COMPONENT, ENT_COMPONENT_11);
String ENT_CONVERTER = "JSFConverter";
- addCheck(new CheckClass(this, JSFSeverityPreferences.INVALID_CONVERTER_CLASS, "converter-class", false, "javax.faces.convert.Converter", null), ENT_CONVERTER);
- addCheck(new CheckClass(this, JSFSeverityPreferences.INVALID_CONVERTER_FOR_CLASS, "converter-for-class", true, null, null), ENT_CONVERTER);
+ addCheck(new JSFCheckClass(this, JSFSeverityPreferences.INVALID_CONVERTER_CLASS, "converter-class", false, "javax.faces.convert.Converter", null), ENT_CONVERTER);
+ addCheck(new JSFCheckClass(this, JSFSeverityPreferences.INVALID_CONVERTER_FOR_CLASS, "converter-for-class", true, null, null), ENT_CONVERTER);
String ENT_FACTORY = "JSFFactory", ENT_FACTORY_20 = ENT_FACTORY + SUFF_20;
- addCheck(new CheckClass(this, JSFSeverityPreferences.INVALID_APPLICATION_FACTORY, "application-factory", false, null, "javax.faces.application.ApplicationFactory"), ENT_FACTORY, ENT_FACTORY_20);
- addCheck(new CheckClass(this, JSFSeverityPreferences.INVALID_FACES_CONTEXT_FACTORY, "faces-context-factory", false, null, "javax.faces.context.FacesContextFactory"), ENT_FACTORY, ENT_FACTORY_20);
- addCheck(new CheckClass(this, JSFSeverityPreferences.INVALID_LIFECYCLE_FACTORY, "lifecycle-factory", false, null, "javax.faces.lifecycle.LifecycleFactory"), ENT_FACTORY, ENT_FACTORY_20);
- addCheck(new CheckClass(this, JSFSeverityPreferences.INVALID_RENDER_KIT_FACTORY, "render-kit-factory", false, null, "javax.faces.render.RenderKitFactory"), ENT_FACTORY, ENT_FACTORY_20);
+ addCheck(new JSFCheckClass(this, JSFSeverityPreferences.INVALID_APPLICATION_FACTORY, "application-factory", false, null, "javax.faces.application.ApplicationFactory"), ENT_FACTORY, ENT_FACTORY_20);
+ addCheck(new JSFCheckClass(this, JSFSeverityPreferences.INVALID_FACES_CONTEXT_FACTORY, "faces-context-factory", false, null, "javax.faces.context.FacesContextFactory"), ENT_FACTORY, ENT_FACTORY_20);
+ addCheck(new JSFCheckClass(this, JSFSeverityPreferences.INVALID_LIFECYCLE_FACTORY, "lifecycle-factory", false, null, "javax.faces.lifecycle.LifecycleFactory"), ENT_FACTORY, ENT_FACTORY_20);
+ addCheck(new JSFCheckClass(this, JSFSeverityPreferences.INVALID_RENDER_KIT_FACTORY, "render-kit-factory", false, null, "javax.faces.render.RenderKitFactory"), ENT_FACTORY, ENT_FACTORY_20);
String ENT_LIST_ENTRIES = "JSFListEntries", ENT_MAP_ENTRIES = "JSFMapEntries";
- addCheck(new CheckClass(this, JSFSeverityPreferences.INVALID_KEY_CLASS, "key-class", true, null, null), ENT_MAP_ENTRIES);
- addCheck(new CheckClass(this, JSFSeverityPreferences.INVALID_KEY_CLASS, "value-class", true, null, null), ENT_LIST_ENTRIES, ENT_MAP_ENTRIES);
+ addCheck(new JSFCheckClass(this, JSFSeverityPreferences.INVALID_KEY_CLASS, "key-class", true, null, null), ENT_MAP_ENTRIES);
+ addCheck(new JSFCheckClass(this, JSFSeverityPreferences.INVALID_KEY_CLASS, "value-class", true, null, null), ENT_LIST_ENTRIES, ENT_MAP_ENTRIES);
String ENT_MANAGED_BEAN = "JSFManagedBean", ENT_MANAGED_BEAN_20 = ENT_MANAGED_BEAN + SUFF_20;
- addCheck(new CheckClass(this, JSFSeverityPreferences.INVALID_BEAN_CLASS, "managed-bean-class", false, null, null), ENT_MANAGED_BEAN, ENT_MANAGED_BEAN_20);
+ addCheck(new JSFCheckClass(this, JSFSeverityPreferences.INVALID_BEAN_CLASS, "managed-bean-class", false, null, null), ENT_MANAGED_BEAN, ENT_MANAGED_BEAN_20);
String ENT_MANAGED_PROPERTY = "JSFManagedProperty";
- addCheck(new CheckClass(this, JSFSeverityPreferences.INVALID_PROPERTY_CLASS, "property-class", false, null, null), ENT_MANAGED_PROPERTY);
+ addCheck(new JSFCheckClass(this, JSFSeverityPreferences.INVALID_PROPERTY_CLASS, "property-class", false, null, null), ENT_MANAGED_PROPERTY);
String ENT_REFERENCED_BEAN = "JSFReferencedBean";
addCheck(new CheckClass(this, JSFSeverityPreferences.INVALID_BEAN_CLASS, "referenced-bean-class", false, null, null), ENT_REFERENCED_BEAN);
String ENT_PHASE_LISTENER = "JSFPhaseListener";
- addCheck(new CheckClass(this, JSFSeverityPreferences.INVALID_PHASE_LISTENER, "phase-listener", false, null, "javax.faces.event.PhaseListener"), ENT_PHASE_LISTENER);
+ addCheck(new JSFCheckClass(this, JSFSeverityPreferences.INVALID_PHASE_LISTENER, "phase-listener", false, null, "javax.faces.event.PhaseListener"), ENT_PHASE_LISTENER);
String ENT_RENDER_KIT = "JSFRenderKit", ENT_RENDER_KIT_11 = ENT_RENDER_KIT + SUFF_11, ENT_RENDER_KIT_12 = ENT_RENDER_KIT + SUFF_12, ENT_RENDER_KIT_20 = ENT_RENDER_KIT + SUFF_20;
- addCheck(new CheckClass(this, JSFSeverityPreferences.INVALID_RENDER_KIT_CLASS, "render-kit-class", false, null, "javax.faces.render.RenderKit"), ENT_RENDER_KIT, ENT_RENDER_KIT_11, ENT_RENDER_KIT_12, ENT_RENDER_KIT_20);
+ addCheck(new JSFCheckClass(this, JSFSeverityPreferences.INVALID_RENDER_KIT_CLASS, "render-kit-class", false, null, "javax.faces.render.RenderKit"), ENT_RENDER_KIT, ENT_RENDER_KIT_11, ENT_RENDER_KIT_12, ENT_RENDER_KIT_20);
String ENT_RENDERER = "JSFRenderer", ENT_RENDERER_11 = ENT_RENDERER + SUFF_11;
- addCheck(new CheckClass(this, JSFSeverityPreferences.INVALID_RENDERER_CLASS, "renderer-class", false, null, "javax.faces.render.Renderer"), ENT_RENDERER, ENT_RENDERER_11);
+ addCheck(new JSFCheckClass(this, JSFSeverityPreferences.INVALID_RENDERER_CLASS, "renderer-class", false, null, "javax.faces.render.Renderer"), ENT_RENDERER, ENT_RENDERER_11);
String ENT_VALIDATOR = "JSFValidator", ENT_VALIDATOR_12 = ENT_VALIDATOR + SUFF_12;
- addCheck(new CheckClass(this, JSFSeverityPreferences.INVALID_VALIDATOR_CLASS, "validator-class", false, null, "javax.faces.validator.Validator"), ENT_VALIDATOR, ENT_VALIDATOR_12);
+ addCheck(new JSFCheckClass(this, JSFSeverityPreferences.INVALID_VALIDATOR_CLASS, "validator-class", false, null, "javax.faces.validator.Validator"), ENT_VALIDATOR, ENT_VALIDATOR_12);
addCheck(new JSFCheckFromViewId(this), new String[]{ENT_NAVIGATION_CASE, ENT_NAVIGATION_CASE_20, ENT_NAVIGATION_RULE, ENT_NAVIGATION_RULE_20});
addCheck(new JSFCheckToViewId(this), new String[]{ENT_NAVIGATION_CASE, ENT_NAVIGATION_CASE_20, ENT_NAVIGATION_RULE, ENT_NAVIGATION_RULE_20});
Modified: trunk/jsf/tests/org.jboss.tools.jsf.test/src/org/jboss/tools/jsf/test/validation/FacesConfigValidatorTest.java
===================================================================
--- trunk/jsf/tests/org.jboss.tools.jsf.test/src/org/jboss/tools/jsf/test/validation/FacesConfigValidatorTest.java 2011-12-09 22:13:03 UTC (rev 37193)
+++ trunk/jsf/tests/org.jboss.tools.jsf.test/src/org/jboss/tools/jsf/test/validation/FacesConfigValidatorTest.java 2011-12-09 22:20:45 UTC (rev 37194)
@@ -16,17 +16,12 @@
import junit.framework.TestCase;
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IMarker;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.NullProgressMonitor;
-import org.eclipse.core.runtime.Path;
import org.eclipse.osgi.util.NLS;
import org.eclipse.wst.validation.ValidationFramework;
-import org.jboss.tools.jsf.jsf2.util.JSF2ResourceUtil;
import org.jboss.tools.jsf.model.JSFConstants;
import org.jboss.tools.jsf.web.validation.JSFValidationMessage;
import org.jboss.tools.tests.AbstractResourceMarkerTest;
14 years, 4 months
JBoss Tools SVN: r37193 - trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/web/validation.
by jbosstools-commits@lists.jboss.org
Author: scabanovich
Date: 2011-12-09 17:13:03 -0500 (Fri, 09 Dec 2011)
New Revision: 37193
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/web/validation/FacesConfigValidator.java
Log:
JBIDE-10190
https://issues.jboss.org/browse/JBIDE-10190
Supported incremental faces-config.xml validation.
Modified: trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/web/validation/FacesConfigValidator.java
===================================================================
--- trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/web/validation/FacesConfigValidator.java 2011-12-09 22:02:14 UTC (rev 37192)
+++ trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/web/validation/FacesConfigValidator.java 2011-12-09 22:13:03 UTC (rev 37193)
@@ -25,12 +25,15 @@
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
+import org.eclipse.jdt.core.ICompilationUnit;
+import org.eclipse.jdt.core.IType;
import org.eclipse.osgi.util.NLS;
import org.eclipse.wst.common.project.facet.core.IFacetedProject;
import org.eclipse.wst.common.project.facet.core.IProjectFacet;
import org.eclipse.wst.common.project.facet.core.ProjectFacetsManager;
import org.eclipse.wst.validation.internal.core.ValidationException;
import org.eclipse.wst.validation.internal.provisional.core.IReporter;
+import org.jboss.tools.common.EclipseUtil;
import org.jboss.tools.common.model.XModel;
import org.jboss.tools.common.model.XModelObject;
import org.jboss.tools.common.model.impl.XModelImpl;
@@ -46,6 +49,7 @@
import org.jboss.tools.common.validation.internal.SimpleValidatingProjectTree;
import org.jboss.tools.common.validation.internal.ValidatingProjectSet;
import org.jboss.tools.common.web.WebUtils;
+import org.jboss.tools.jsf.JSFModelPlugin;
import org.jboss.tools.jsf.model.JSFConstants;
import org.jboss.tools.jsf.model.pv.JSFProjectsTree;
import org.jboss.tools.jsf.web.JSFWebHelper;
@@ -53,6 +57,8 @@
import org.jboss.tools.jsf.web.pattern.JSFUrlPattern;
import org.jboss.tools.jsf.web.validation.composite.CompositeComponentValidator;
import org.jboss.tools.jst.web.WebModelPlugin;
+import org.jboss.tools.jst.web.kb.IKbProject;
+import org.jboss.tools.jst.web.kb.KbProjectFactory;
import org.jboss.tools.jst.web.model.helpers.WebAppHelper;
import org.jboss.tools.jst.web.model.pv.WebProjectNode;
import org.jboss.tools.jst.web.validation.Check;
@@ -66,7 +72,7 @@
public static final String PROBLEM_TYPE = "org.jboss.tools.jsf.facesconfigproblem"; //$NON-NLS-1$
public static final String PREFERENCE_PAGE_ID = CompositeComponentValidator.PREFERENCE_PAGE_ID;
- public static String SHORT_ID = "verification"; //$NON-NLS-1$
+ public static String SHORT_ID = "jsf-verification"; //$NON-NLS-1$
static String XML_EXT = ".xml"; //$NON-NLS-1$
@@ -108,15 +114,27 @@
}
}
+ static class JSFCheckClass extends CheckClass {
+
+ public JSFCheckClass(ValidationErrorManager manager, String preference, String attr, boolean allowsPrimitive, String implementsType, String extendsType) {
+ super(manager, preference, attr, allowsPrimitive, implementsType, extendsType);
+ }
+
+ protected String getShortId() {
+ return SHORT_ID;
+ }
+
+ }
+
void createChecks() {
String ENT_APP = "JSFApplication", ENT_APP_12 = ENT_APP + SUFF_12, ENT_APP_20 = ENT_APP + SUFF_20;
- addCheck(new CheckClass(this, JSFSeverityPreferences.INVALID_ACTION_LISTENER, "action-listener", false, "javax.faces.event.ActionListener", null), ENT_APP, ENT_APP_12, ENT_APP_20);
- addCheck(new CheckClass(this, JSFSeverityPreferences.INVALID_NAVIGATION_HANDLER, "navigation-handler", false, "javax.faces.application.NavigationHandler", null), ENT_APP, ENT_APP_12, ENT_APP_20);
- addCheck(new CheckClass(this, JSFSeverityPreferences.INVALID_PROPERTY_RESOLVER, "class name", false, "javax.faces.el.PropertyResolver", null).setVisualAttribute("property-resolver"), "JSFPropertyResolver");
- addCheck(new CheckClass(this, JSFSeverityPreferences.INVALID_STATE_MANAGER, "state-manager", false, "javax.faces.application.StateManager", null), ENT_APP, ENT_APP_12, ENT_APP_20);
- addCheck(new CheckClass(this, JSFSeverityPreferences.INVALID_VARIABLE_RESOLVER, "class name", false, "javax.el.ELResolver", null).setVisualAttribute("el-resolver"), "JSFELResolver");
- addCheck(new CheckClass(this, JSFSeverityPreferences.INVALID_VARIABLE_RESOLVER, "class name", false, "javax.faces.el.VariableResolver", null).setVisualAttribute("variable-resolver"), "JSFVariableResolver");
- addCheck(new CheckClass(this, JSFSeverityPreferences.INVALID_VIEW_HANDLER, "view-handler", false, "javax.faces.application.ViewHandler", null), ENT_APP, ENT_APP_12, ENT_APP_20);
+ addCheck(new JSFCheckClass(this, JSFSeverityPreferences.INVALID_ACTION_LISTENER, "action-listener", false, "javax.faces.event.ActionListener", null), ENT_APP, ENT_APP_12, ENT_APP_20);
+ addCheck(new JSFCheckClass(this, JSFSeverityPreferences.INVALID_NAVIGATION_HANDLER, "navigation-handler", false, "javax.faces.application.NavigationHandler", null), ENT_APP, ENT_APP_12, ENT_APP_20);
+ addCheck(new JSFCheckClass(this, JSFSeverityPreferences.INVALID_PROPERTY_RESOLVER, "class name", false, "javax.faces.el.PropertyResolver", null).setVisualAttribute("property-resolver"), "JSFPropertyResolver");
+ addCheck(new JSFCheckClass(this, JSFSeverityPreferences.INVALID_STATE_MANAGER, "state-manager", false, "javax.faces.application.StateManager", null), ENT_APP, ENT_APP_12, ENT_APP_20);
+ addCheck(new JSFCheckClass(this, JSFSeverityPreferences.INVALID_VARIABLE_RESOLVER, "class name", false, null, "javax.el.ELResolver").setVisualAttribute("el-resolver"), "JSFELResolver");
+ addCheck(new JSFCheckClass(this, JSFSeverityPreferences.INVALID_VARIABLE_RESOLVER, "class name", false, "javax.faces.el.VariableResolver", null).setVisualAttribute("variable-resolver"), "JSFVariableResolver");
+ addCheck(new JSFCheckClass(this, JSFSeverityPreferences.INVALID_VIEW_HANDLER, "view-handler", false, "javax.faces.application.ViewHandler", null), ENT_APP, ENT_APP_12, ENT_APP_20);
String ENT_COMPONENT = "JSFComponent", ENT_COMPONENT_11 = ENT_COMPONENT + SUFF_11;
addCheck(new CheckClass(this, JSFSeverityPreferences.INVALID_COMPONENT_CLASS, "component-class", false, null, "javax.faces.component.UIComponent"), ENT_COMPONENT, ENT_COMPONENT_11);
@@ -175,7 +193,12 @@
public IValidatingProjectTree getValidatingProjects(IProject project) {
IProjectValidationContext rootContext = contexts.get(project);
if(rootContext == null) {
- rootContext = new ProjectValidationContext();
+ IKbProject kb = KbProjectFactory.getKbProject(project, true);
+ if(kb != null) {
+ rootContext = kb.getValidationContext();
+ } else {
+ rootContext = new ProjectValidationContext();
+ }
contexts.put(project, rootContext);
}
@@ -222,7 +245,21 @@
IReporter reporter) throws ValidationException {
init(project, validationHelper, context, manager, reporter);
+ Set<IPath> resourcesToClean = new HashSet<IPath>(); // Resource which we should remove from validation context
for (IFile file: changedFiles) {
+ resourcesToClean.add(file.getFullPath());
+ }
+
+ changedFiles = collectFiles(project, changedFiles, context);
+
+ for(IFile file: changedFiles) {
+ removeAllMessagesFromResource(file);
+ resourcesToClean.add(file.getFullPath());
+ }
+
+ getValidationContext().removeLinkedCoreResources(SHORT_ID, resourcesToClean);
+
+ for (IFile file: changedFiles) {
if(file.getName().endsWith(XML_EXT)) {
XModelObject o = EclipseResourceUtil.createObjectForResource(file);
if(o != null) {
@@ -314,6 +351,81 @@
return PREFERENCE_PAGE_ID;
}
+ private Set<IFile> collectFiles(IProject project, Set<IFile> changedFiles, IProjectValidationContext context) {
+ Set<IFile> files = new HashSet<IFile>();
+ if(context == null) {
+ files.addAll(changedFiles);
+ return files;
+ }
+ Set<IFile> direct = new HashSet<IFile>();
+ Set<IFile> dependent = new HashSet<IFile>();
+ for (IFile f: changedFiles) {
+ if(f != null && f.getProject() == project) {
+ Set<IPath> paths = context.getCoreResourcesByVariableName(SHORT_ID, f.getFullPath().toOSString(), true);
+ String name = f.getName();
+
+ if(name.endsWith(".java")) {
+ try {
+ ICompilationUnit unit = EclipseUtil.getCompilationUnit(f);
+ if(unit != null) {
+ IType[] ts = unit.getTypes();
+ for (IType t: ts) {
+ String type = t.getFullyQualifiedName();
+ Set<IPath> paths1 = context.getCoreResourcesByVariableName(SHORT_ID, type, true);
+ if(paths1 != null) {
+ if(paths != null) {
+ paths.addAll(paths1);
+ } else {
+ paths = paths1;
+ }
+ }
+ }
+ }
+ } catch (CoreException e) {
+ JSFModelPlugin.getDefault().logError(e);
+ }
+ } else {
+ IPath[] ps = WebUtils.getWebContentPaths(project);
+ for (IPath rootPath: ps) {
+ if(rootPath.isPrefixOf(f.getFullPath())) {
+ String s = f.getFullPath().removeFirstSegments(rootPath.segmentCount()).toString();
+ if(!s.startsWith("/")) s = "/" + s;
+ Set<IPath> paths1 = context.getCoreResourcesByVariableName(SHORT_ID, s, true);
+ if(paths1 != null) {
+ if(paths != null) {
+ paths.addAll(paths1);
+ } else {
+ paths = paths1;
+ }
+ }
+ }
+ }
+ }
+
+ if(name.endsWith(".xml") && f.exists()) { //$NON-NLS-1$
+ if(!direct.contains(f) && !dependent.contains(f)) {
+ files.add(f);
+ }
+ direct.add(f);
+ dependent.remove(f);
+ }
+
+ if(paths != null) {
+ for (IPath path: paths) {
+ IFile f1 = project.getParent().getFile(path);
+ if(f1.exists()) {
+ if(direct.contains(f1) || dependent.contains(f1)) continue;
+ dependent.add(f1);
+ files.add(f1);
+ }
+ }
+ }
+ }
+ }
+
+ return files;
+ }
+
}
class JSFCheckFromViewId extends Check {
@@ -368,11 +480,26 @@
o = model.getByPath(value);
}
}
+
+ IFile f = (IFile)object.getAdapter(IFile.class);
+ if(f != null) {
+ IProjectValidationContext context = manager.getValidationContext();
+ if(context != null) {
+ context.addLinkedCoreResource(FacesConfigValidator.SHORT_ID, value, f.getFullPath(), true);
+ }
+ }
+
if(o != null) {
- IFile f = (IFile)o.getAdapter(IFile.class);
- if(f != null) {
- String path = f.getLocation().toOSString().replace('\\', '/');
- if(path.endsWith(value)) return;
+ IFile f2 = (IFile)o.getAdapter(IFile.class);
+ if(f2 != null) {
+ String path = f2.getLocation().toOSString().replace('\\', '/');
+ IProjectValidationContext context = manager.getValidationContext();
+ if(context != null) {
+ context.addLinkedCoreResource(FacesConfigValidator.SHORT_ID, f2.getFullPath().toOSString(), f.getFullPath(), true);
+ }
+ if(path.endsWith(value)) {
+ return;
+ }
}
} else if(checkTiles(model, value)) {
return;
14 years, 4 months
JBoss Tools SVN: r37192 - trunk/jst/plugins/org.jboss.tools.jst.web/src/org/jboss/tools/jst/web/validation.
by jbosstools-commits@lists.jboss.org
Author: scabanovich
Date: 2011-12-09 17:02:14 -0500 (Fri, 09 Dec 2011)
New Revision: 37192
Modified:
trunk/jst/plugins/org.jboss.tools.jst.web/src/org/jboss/tools/jst/web/validation/Check.java
trunk/jst/plugins/org.jboss.tools.jst.web/src/org/jboss/tools/jst/web/validation/CheckClass.java
Log:
JBIDE-10190
https://issues.jboss.org/browse/JBIDE-10190
Supported incremental faces-config.xml validation.
Modified: trunk/jst/plugins/org.jboss.tools.jst.web/src/org/jboss/tools/jst/web/validation/Check.java
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.web/src/org/jboss/tools/jst/web/validation/Check.java 2011-12-09 20:01:02 UTC (rev 37191)
+++ trunk/jst/plugins/org.jboss.tools.jst.web/src/org/jboss/tools/jst/web/validation/Check.java 2011-12-09 22:02:14 UTC (rev 37192)
@@ -26,7 +26,7 @@
static String ATTR_ATTRIBUTE = "attribute"; //$NON-NLS-1$
protected String preference;
protected String attr;
- ValidationErrorManager manager;
+ protected ValidationErrorManager manager;
public Check(ValidationErrorManager manager, String preference, String attr) {
this.manager = manager;
Modified: trunk/jst/plugins/org.jboss.tools.jst.web/src/org/jboss/tools/jst/web/validation/CheckClass.java
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.web/src/org/jboss/tools/jst/web/validation/CheckClass.java 2011-12-09 20:01:02 UTC (rev 37191)
+++ trunk/jst/plugins/org.jboss.tools.jst.web/src/org/jboss/tools/jst/web/validation/CheckClass.java 2011-12-09 22:02:14 UTC (rev 37192)
@@ -40,6 +40,10 @@
visualAttr = attr;
}
+ protected String getShortId() {
+ return WebXMLCoreValidator.SHORT_ID;
+ }
+
public CheckClass(ValidationErrorManager manager, String preference, String attr, boolean allowsPrimitive, String implementsType, String extendsType) {
this(manager, preference, attr);
this.allowsPrimitive = allowsPrimitive;
@@ -75,9 +79,9 @@
if(f != null) {
IProjectValidationContext context = manager.getValidationContext();
if(context != null) {
- context.addLinkedCoreResource(WebXMLCoreValidator.SHORT_ID, value, f.getFullPath(), true);
+ context.addLinkedCoreResource(getShortId(), value, f.getFullPath(), true);
if(type != null && type.getResource() != null && type.exists()) {
- context.addLinkedCoreResource(WebXMLCoreValidator.SHORT_ID, type.getResource().getFullPath().toOSString(), f.getFullPath(), true);
+ context.addLinkedCoreResource(getShortId(), type.getResource().getFullPath().toOSString(), f.getFullPath(), true);
}
}
}
14 years, 4 months
JBoss Tools SVN: r37191 - in trunk/documentation/whatsnew/vpe: images/3.3.0.M5 and 1 other directory.
by jbosstools-commits@lists.jboss.org
Author: yradtsevich
Date: 2011-12-09 15:01:02 -0500 (Fri, 09 Dec 2011)
New Revision: 37191
Added:
trunk/documentation/whatsnew/vpe/images/3.3.0.M5/9539.png
Modified:
trunk/documentation/whatsnew/vpe/vpe-news-3.3.0.M5.html
Log:
https://issues.jboss.org/browse/JBIDE-10380 : CLONE - CLONE - CLONE - CLONE - Visual Editor Component N&N
Added: trunk/documentation/whatsnew/vpe/images/3.3.0.M5/9539.png
===================================================================
(Binary files differ)
Property changes on: trunk/documentation/whatsnew/vpe/images/3.3.0.M5/9539.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Modified: trunk/documentation/whatsnew/vpe/vpe-news-3.3.0.M5.html
===================================================================
--- trunk/documentation/whatsnew/vpe/vpe-news-3.3.0.M5.html 2011-12-09 19:59:26 UTC (rev 37190)
+++ trunk/documentation/whatsnew/vpe/vpe-news-3.3.0.M5.html 2011-12-09 20:01:02 UTC (rev 37191)
@@ -32,40 +32,43 @@
<tr>
<td colspan="2">
<hr />
- <h3>Editor</h3>
+ <h3>BrowserSim</h3>
<hr />
</td>
</tr>
<tr>
<td valign="top" align="left">
<b><p>
- Hot keys for VPE Refresh.
+ New BrowserSim Application
<p></b>
</td>
<td valign="top">
- <p>Now there are "F5" and "CTRL+R" shortcuts to perform vusial refresh in Visual Page Editor.</p>
- <p><img src="images/3.3.0.M5/10020.png" alt="Hot keys for VPE Refresh" /></p>
+ <p>BrowserSim is a mobile browser simulator which is integrated into Eclipse as an external web browser. It allows to browse
+ web pages as if they are opened on a mobile device.</p>
+ <p><img src="images/3.3.0.M5/9539.png" alt="Google Image search for 'RedHat'" title="Google Image search for 'RedHat'"/></p>
<p><small>
- <a href="https://jira.jboss.org/jira/browse/JBIDE-10020">Related Jira</a>
+ <a href="https://jira.jboss.org/jira/browse/JBIDE-9539">Related Jira</a>
</small></p>
</td>
</tr>
- <tr>
+ <tr>
<td colspan="2">
<hr />
+ <h3>Editor</h3>
+ <hr />
</td>
</tr>
<tr>
<td valign="top" align="left">
<b><p>
- Browser Simulator application.
+ Hot keys for VPE Refresh.
<p></b>
</td>
<td valign="top">
- <p>Browsersim application for testing mobile/desktop web application was added.</p>
- <p><img src="images/3.3.0.M5/.png" alt="" /></p>
+ <p>Now there are "F5" and "CTRL+R" shortcuts to perform vusial refresh in Visual Page Editor.</p>
+ <p><img src="images/3.3.0.M5/10020.png" alt="Hot keys for VPE Refresh" /></p>
<p><small>
- <a href="https://jira.jboss.org/jira/browse/JBIDE-9539">Related Jira</a>
+ <a href="https://jira.jboss.org/jira/browse/JBIDE-10020">Related Jira</a>
</small></p>
</td>
</tr>
14 years, 4 months