You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@felix.apache.org by cz...@apache.org on 2011/03/04 15:21:00 UTC

svn commit: r1077961 - in /felix/trunk/scrplugin/generator/src/main/java/org/apache/felix/scrplugin: SCRDescriptorGenerator.java helper/IssueLog.java

Author: cziegeler
Date: Fri Mar  4 14:21:00 2011
New Revision: 1077961

URL: http://svn.apache.org/viewvc?rev=1077961&view=rev
Log:
FELIX-2853 : Deprecate javadoc tags

Modified:
    felix/trunk/scrplugin/generator/src/main/java/org/apache/felix/scrplugin/SCRDescriptorGenerator.java
    felix/trunk/scrplugin/generator/src/main/java/org/apache/felix/scrplugin/helper/IssueLog.java

Modified: felix/trunk/scrplugin/generator/src/main/java/org/apache/felix/scrplugin/SCRDescriptorGenerator.java
URL: http://svn.apache.org/viewvc/felix/trunk/scrplugin/generator/src/main/java/org/apache/felix/scrplugin/SCRDescriptorGenerator.java?rev=1077961&r1=1077960&r2=1077961&view=diff
==============================================================================
--- felix/trunk/scrplugin/generator/src/main/java/org/apache/felix/scrplugin/SCRDescriptorGenerator.java (original)
+++ felix/trunk/scrplugin/generator/src/main/java/org/apache/felix/scrplugin/SCRDescriptorGenerator.java Fri Mar  4 14:21:00 2011
@@ -26,6 +26,7 @@ import org.apache.felix.scrplugin.helper
 import org.apache.felix.scrplugin.om.*;
 import org.apache.felix.scrplugin.om.metatype.*;
 import org.apache.felix.scrplugin.tags.*;
+import org.apache.felix.scrplugin.tags.annotation.AnnotationJavaClassDescription;
 import org.apache.felix.scrplugin.tags.qdox.QDoxJavaClassDescription;
 import org.apache.felix.scrplugin.xml.ComponentDescriptorIO;
 import org.apache.felix.scrplugin.xml.MetaTypeIO;
@@ -240,6 +241,13 @@ public class SCRDescriptorGenerator
             final JavaTag tag = javaSources[i].getTagByName( Constants.COMPONENT );
             if ( tag != null )
             {
+                // FELIX-2853 : Deprecate javadoc tags.
+                // This is not the most clever way of doing this, but it is the least intrusive...
+                if ( javaSources[i] instanceof QDoxJavaClassDescription
+                     && !(javaSources[i] instanceof AnnotationJavaClassDescription)) {
+                    iLog.addDeprecationWarning("Class " + javaSources[i].getName() + " is using deprecated javadoc tags ",
+                            tag.getSourceLocation(), tag.getLineNumber());
+                }
                 this.logger.debug( "Processing service class " + javaSources[i].getName() );
                 // check if there is more than one component tag!
                 if ( javaSources[i].getTagsByName( Constants.COMPONENT, false ).length > 1 )

Modified: felix/trunk/scrplugin/generator/src/main/java/org/apache/felix/scrplugin/helper/IssueLog.java
URL: http://svn.apache.org/viewvc/felix/trunk/scrplugin/generator/src/main/java/org/apache/felix/scrplugin/helper/IssueLog.java?rev=1077961&r1=1077960&r2=1077961&view=diff
==============================================================================
--- felix/trunk/scrplugin/generator/src/main/java/org/apache/felix/scrplugin/helper/IssueLog.java (original)
+++ felix/trunk/scrplugin/generator/src/main/java/org/apache/felix/scrplugin/helper/IssueLog.java Fri Mar  4 14:21:00 2011
@@ -18,9 +18,7 @@
  */
 package org.apache.felix.scrplugin.helper;
 
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
+import java.util.*;
 
 import org.apache.felix.scrplugin.Log;
 
@@ -35,6 +33,8 @@ public class IssueLog {
 
     private final List<Entry> warnings = new ArrayList<Entry>();
 
+    private final List<Entry> deprecationWarnings = new ArrayList<Entry>();
+
     public IssueLog(final boolean strictMode) {
         this.strictMode = strictMode;
     }
@@ -44,7 +44,8 @@ public class IssueLog {
     }
 
     public boolean hasErrors() {
-        return errors.size() > 0 || (this.strictMode && warnings.size() > 0 );
+        return errors.size() > 0 ||
+               (this.strictMode && (warnings.size() > 0 || this.deprecationWarnings.size() > 0));
     }
 
     public void addError(final String message, final String location, final int lineNumber) {
@@ -55,10 +56,40 @@ public class IssueLog {
         warnings.add( new Entry( message, location, lineNumber ) );
     }
 
+    public void addDeprecationWarning(final String message, final String location, final int lineNumber) {
+        deprecationWarnings.add( new Entry( message, location, lineNumber ) );
+    }
+
     public void logMessages( final Log log )
     {
         // now log warnings and errors (warnings first)
         // in strict mode everything is an error!
+        final Iterator<Entry> depWarnings = this.deprecationWarnings.iterator();
+        while ( depWarnings.hasNext() )
+        {
+            final Entry entry = depWarnings.next();
+            if ( strictMode )
+            {
+                log.error( entry.message, entry.location, entry.lineNumber);
+            }
+            else
+            {
+                log.warn( entry.message, entry.location, entry.lineNumber);
+            }
+        }
+        if ( this.deprecationWarnings.size() > 0 ) {
+            final String msg = "It is highly recommended to fix these problems, as future versions might not " +
+             "support these features anymore.";
+            if ( strictMode )
+            {
+                log.error( msg );
+            }
+            else
+            {
+                log.warn( msg );
+            }
+        }
+
         final Iterator<Entry> warnings = this.warnings.iterator();
         while ( warnings.hasNext() )
         {
@@ -81,14 +112,6 @@ public class IssueLog {
         }
     }
 
-    public Iterator<String> getWarnings() {
-        return null; // warnings.iterator();
-    }
-
-    public Iterator<String> getErrors() {
-        return null; // errors.iterator();
-    }
-
     private static class Entry
     {
         final String message;