FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Handling links to PGraphics, etc correctly again. · processing/processing-docs@3b280e6 · GitHub

Repository navigation

Commit 3b280e6

Browse files
committed
Handling links to PGraphics, etc correctly again.
Issue 137 is still fixed, but this is a less-blunt instrument for solving that issue. We are separately tracking fields and methods now for linking.
1 parent def074d commit 3b280e6

2 files changed

Lines changed: 21 additions & 45 deletions

File tree

396 Bytes
Binary file not shown.

‎java_generate/ReferenceGenerator/src/writers/BaseWriter.java‎

Lines changed: 21 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -712,37 +712,24 @@ protected static String getRelated( ProgramElementDoc doc ) throws IOException
712712
TemplateWriter templateWriter = new TemplateWriter();
713713
ArrayList<HashMap<String, String>> vars = new ArrayList<HashMap<String,String>>();
714714

715-
// it is no longer clear to me what purpose this classMembers mapping serves
716-
// It's left in source for now in case it proves important. However, building the
717-
// entire reference only turned up cases where it overwrites method @see tags
718-
// with field @see tags, which is not something we want.
719-
// Eliminating this fixes github issue 137
720-
/*
721-
HashMap<String, ProgramElementDoc> classMembers = new HashMap<String, ProgramElementDoc>();
715+
// keep track of class members so that links to methods in e.g. PGraphics
716+
// that are copied into PApplet are correctly linked.
717+
HashMap<String, ProgramElementDoc> classMethods = new HashMap<String, ProgramElementDoc>();
718+
HashMap<String, ProgramElementDoc> classFields = new HashMap<String, ProgramElementDoc>();
722719
if( doc.isMethod() || doc.isField() )
723-
{
720+
{ // fill our maps
724721
ClassDoc containingClass = doc.containingClass();
725-
// consider only doing this if we aren't in the core
726-
// doing this in the core protects against errant references to PGraphics
727-
// if( !containingClass.name().equalsIgnoreCase("PApplet") )
728-
{
729-
for( MethodDoc m : containingClass.methods() )
730-
{
731-
if( needsWriting( m ) )
732-
{
733-
classMembers.put( m.name(), m );
734-
}
722+
for( MethodDoc m : containingClass.methods() ) {
723+
if( needsWriting( m ) ) {
724+
classMethods.put( m.name(), m );
735725
}
736-
for( FieldDoc f : containingClass.fields() )
737-
{
738-
if( needsWriting( f ) )
739-
{
740-
classMembers.put( f.name(), f );
741-
}
726+
}
727+
for( FieldDoc f : containingClass.fields() ) {
728+
if( needsWriting( f ) ) {
729+
classFields.put( f.name(), f );
742730
}
743731
}
744732
}
745-
//*/
746733

747734
// add link to each @see item
748735
for( SeeTag tag : getAllSeeTags( doc ) )
@@ -752,28 +739,19 @@ protected static String getRelated( ProgramElementDoc doc ) throws IOException
752739
if( tag.referencedMember() != null )
753740
{
754741
ref = tag.referencedMember();
755-
/*
756-
if( classMembers.containsKey( ref.name() ) )
757-
{
758-
ProgramElementDoc prior = classMembers.get( ref.name() );
759-
String refType = (ref.isMethod() ? " Method()" : " Field");
760-
String priorType = (prior.isMethod() ? " Method()" : " Field");
761-
if( !priorType.equals( refType ) )
762-
{
763-
System.out.println( "\n++++++++++++++++++++++++++++++++++++++++++" );
764-
System.out.println( "Would collapse " + ref.name() + refType );
765-
System.out.println( "into " + prior.name() + priorType );
766-
System.out.println( "++++++++++++++++++++++++++++++++++++++++++\n" );
767-
}
768-
// previously, we replaced references this way
769-
// doesn't seem to be helpful
742+
if( ref.isMethod() && classMethods.containsKey( ref.name() ) ) {
743+
// link to the member as it is in this class, instead of
744+
// as it is in another class
745+
ProgramElementDoc prior = classMethods.get( ref.name() );
746+
ref = prior;
747+
}
748+
else if ( ref.isField() && classFields.containsKey( ref.name() ) ) {
749+
ProgramElementDoc prior = classFields.get( ref.name() );
770750
ref = prior;
771751
}
772-
*/
773752
}
774753
if( needsWriting( ref ) )
775-
{
776-
// add links to things that are actually written
754+
{ // add links to things that are actually written
777755
map.put("name", getName( ref ));
778756
map.put("anchor", getAnchor( ref ));
779757
vars.add(map);
@@ -825,9 +803,7 @@ protected static String getRelated( ProgramElementDoc doc ) throws IOException
825803
{
826804
e.printStackTrace();
827805
}
828-
829806
}
830-
831807
}
832808

833809
return templateWriter.writeLoop("related.partial.html", vars);

0 commit comments

Comments
 (0)

Back | FazBrowse Home | New Git URL