Skip to content

Commit

Permalink
enhance the js script meta data support
Browse files Browse the repository at this point in the history
  • Loading branch information
zhiqiangqian committed Jul 9, 2014
1 parent 398e214 commit 518f722
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 25 deletions.
Expand Up @@ -136,8 +136,7 @@ public ICompletionProposal[] computeCompletionProposals(

protected JSExpression createJSExpression( )
{
return new JSExpression( context,
currentExpressionStr );
return new JSExpression( context, currentExpressionStr );
}

/**
Expand Down Expand Up @@ -241,14 +240,14 @@ protected CompletionProposal[] getCompletionProposals(
null,
metas[i].getName( ),
null,
null ) );
metas[i].getDescription( ) ) );
}
}
return proposals.toArray( new CompletionProposal[proposals.size( )] );
}

protected CompletionProposal[] getCompletionProposals( JSObjectMetaData meta,
int offset )
protected CompletionProposal[] getCompletionProposals(
JSObjectMetaData meta, int offset )
{
List<CompletionProposal> proposals = new ArrayList<CompletionProposal>( );
int wordLength = currentWord == null ? 0 : currentWord.length( );
Expand All @@ -270,7 +269,7 @@ protected CompletionProposal[] getCompletionProposals( JSObjectMetaData meta,
getMemberImage( members[i].getVisibility( ) ),
members[i].getDisplayText( ),
null,
null ) );
members[i].getDescription( ) ) );
}
}
}
Expand Down Expand Up @@ -298,7 +297,7 @@ protected CompletionProposal[] getCompletionProposals( JSObjectMetaData meta,
getMethodImage( methods[i].getVisibility( ) ),
methods[i].getDisplayText( ),
null,
null ) );
methods[i].getDescription( ) ) );
}
}
}
Expand Down Expand Up @@ -344,8 +343,8 @@ protected Image getMethodImage( int visibility )
/*
* (non-Javadoc)
*
* @see org.eclipse.jface.text.contentassist.IContentAssistProcessor#computeContextInformation(org.eclipse.jface.text.ITextViewer,
* int)
* @see org.eclipse.jface.text.contentassist.IContentAssistProcessor#
* computeContextInformation(org.eclipse.jface.text.ITextViewer, int)
*/
public IContextInformation[] computeContextInformation( ITextViewer viewer,
int offset )
Expand All @@ -356,7 +355,8 @@ public IContextInformation[] computeContextInformation( ITextViewer viewer,
/*
* (non-Javadoc)
*
* @see org.eclipse.jface.text.contentassist.IContentAssistProcessor#getCompletionProposalAutoActivationCharacters()
* @see org.eclipse.jface.text.contentassist.IContentAssistProcessor#
* getCompletionProposalAutoActivationCharacters()
*/
public char[] getCompletionProposalAutoActivationCharacters( )
{
Expand All @@ -368,7 +368,8 @@ public char[] getCompletionProposalAutoActivationCharacters( )
/*
* (non-Javadoc)
*
* @see org.eclipse.jface.text.contentassist.IContentAssistProcessor#getContextInformationAutoActivationCharacters()
* @see org.eclipse.jface.text.contentassist.IContentAssistProcessor#
* getContextInformationAutoActivationCharacters()
*/
public char[] getContextInformationAutoActivationCharacters( )
{
Expand All @@ -378,7 +379,9 @@ public char[] getContextInformationAutoActivationCharacters( )
/*
* (non-Javadoc)
*
* @see org.eclipse.jface.text.contentassist.IContentAssistProcessor#getErrorMessage()
* @see
* org.eclipse.jface.text.contentassist.IContentAssistProcessor#getErrorMessage
* ()
*/
public String getErrorMessage( )
{
Expand All @@ -388,7 +391,8 @@ public String getErrorMessage( )
/*
* (non-Javadoc)
*
* @see org.eclipse.jface.text.contentassist.IContentAssistProcessor#getContextInformationValidator()
* @see org.eclipse.jface.text.contentassist.IContentAssistProcessor#
* getContextInformationValidator()
*/
public IContextInformationValidator getContextInformationValidator( )
{
Expand Down
Expand Up @@ -146,6 +146,11 @@ public void setVariable( String name, IClassInfo classInfo )
else
objectMetaMap.put( name, new ExtensionClassJSObject( classInfo ) );
}

public void setVariable( String name, JSObjectMetaData meta )
{
objectMetaMap.put( name, meta );
}

public void removeVariable( String name )
{
Expand Down
Expand Up @@ -23,7 +23,7 @@
* implementation should better done by Engine because Engine knows what the
* properties and methods can be used in javascript better.
*/
class JavaClassJSObject implements JSObjectMetaData
public class JavaClassJSObject implements JSObjectMetaData
{

private Class<?> clazz;
Expand Down Expand Up @@ -58,6 +58,11 @@ public JSMethod[] getMethods( )
return jsMehods.toArray( new JSMethod[jsMehods.size( )] );
}

protected JavaClassMethod createJavaClassMethod( Method mtd )
{
return new JavaClassMethod( mtd );
}

private List<JavaClassMethod> getMethods( Method[] methods )
{
List<JavaClassMethod> jsMehods = new ArrayList<JavaClassMethod>( );
Expand All @@ -80,7 +85,7 @@ private List<JavaClassMethod> getMethods( Method[] methods )
getMethodList.add( methods[i].getName( ).substring( 3 ) );
continue;
}
jsMehods.add( new JavaClassMethod( methods[i] ) );
jsMehods.add( createJavaClassMethod( methods[i] ) );
}

for ( int i = 0; i < methods.length; i++ )
Expand All @@ -92,7 +97,7 @@ private List<JavaClassMethod> getMethods( Method[] methods )
if ( !getMethodList.contains( methods[i].getName( )
.substring( 3 ) ) )
{
jsMehods.add( new JavaClassMethod( methods[i] ) );
jsMehods.add( createJavaClassMethod( methods[i] ) );
}
continue;
}
Expand All @@ -104,7 +109,7 @@ private List<JavaClassMethod> getMethods( Method[] methods )
if ( !setMethodList.contains( methods[i].getName( )
.substring( 3 ) ) )
{
jsMehods.add( new JavaClassMethod( methods[i] ) );
jsMehods.add( createJavaClassMethod( methods[i] ) );
}
continue;
}
Expand Down Expand Up @@ -173,7 +178,7 @@ private List<JavaClassField> getFields( Class<?> clazz )
return jsFields;
}

private String getFieldName( String methodName )
private static String getFieldName( String methodName )
{
if ( methodName.length( ) == 3 )
{
Expand Down Expand Up @@ -205,7 +210,7 @@ public int getVisibility( )
/**
* JavaClassMethod
*/
private class JavaClassMethod implements JSMethod, Comparable
public static class JavaClassMethod implements JSMethod, Comparable<Object>
{

private Method method;
Expand Down Expand Up @@ -236,8 +241,8 @@ public JSObjectMetaData getReturn( )

public JSObjectMetaData[] getArguments( )
{
//TODO impl real argument info, currently simply use argument type
// TODO impl real argument info, currently simply use argument type

Class<?>[] types = method.getParameterTypes( );

if ( types.length > 0 )
Expand Down Expand Up @@ -333,7 +338,7 @@ public int compareTo( Object obj )
/**
* JavaClassField
*/
private class JavaClassField implements JSField, Comparable
public static class JavaClassField implements JSField, Comparable<Object>
{

private String name;
Expand Down Expand Up @@ -490,7 +495,7 @@ public int compareTo( Object obj )

}

private String getSimpleName( Class<?> clazz )
private static String getSimpleName( Class<?> clazz )
{
String simpleName = null;
if ( clazz.isArray( ) )
Expand All @@ -513,7 +518,7 @@ private String getSimpleName( Class<?> clazz )
return simpleName;
}

private String getSimpleName( String name )
private static String getSimpleName( String name )
{
return name.substring( name.lastIndexOf( "." ) + 1 ); //$NON-NLS-1$
}
Expand All @@ -533,7 +538,7 @@ public JSObjectMetaData getComponentType( )
* the specified <code>Class</code> object.
* @return the name of the specified <code>Class</code> object.
*/
private String getClazzName( Class<?> clazz )
private static String getClazzName( Class<?> clazz )
{
String name;

Expand Down

0 comments on commit 518f722

Please sign in to comment.