Skip to content

Commit

Permalink
- Summary: Refactoring JS assistant code for extra work.(#49523)
Browse files Browse the repository at this point in the history
- Bugzilla Bug(s) Resolved: 

- Description:
Refactored JS assistant code for extra work.(#49523)
  • Loading branch information
heli committed May 3, 2012
1 parent 2bcdf42 commit 5fdd95a
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 12 deletions.
Expand Up @@ -39,10 +39,10 @@ public class JSCompletionProcessor implements IContentAssistProcessor
* presentation wrapper class for expression script objects.
*/
// private static IExpressionProvider provider = new ExpressionProvider( );
private JSSyntaxContext context;
protected JSSyntaxContext context;

private String currentWord = ""; //$NON-NLS-1$
private String currentExpressionStr = ""; //$NON-NLS-1$
protected String currentWord = ""; //$NON-NLS-1$
protected String currentExpressionStr = ""; //$NON-NLS-1$
private JSExpression currentExpression;

public JSCompletionProcessor( JSSyntaxContext context )
Expand Down Expand Up @@ -122,8 +122,7 @@ public ICompletionProposal[] computeCompletionProposals(
// can not cache last expression, because context may be
// changed.
this.currentExpressionStr = expression;
this.currentExpression = new JSExpression( context,
currentExpressionStr );
this.currentExpression = createJSExpression( );
// }
return getCompletionProposals( currentExpression.getReturnType( ),
offset );
Expand All @@ -135,6 +134,12 @@ public ICompletionProposal[] computeCompletionProposals(
return null;
}

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

/**
* Get the JS expression in current position, split the last not complete
* code fragment.
Expand Down Expand Up @@ -217,7 +222,7 @@ else if ( meta instanceof JSObjectMetaData[] )
return null;
}

private CompletionProposal[] getCompletionProposals(
protected CompletionProposal[] getCompletionProposals(
JSObjectMetaData[] metas, int offset )
{
List<CompletionProposal> proposals = new ArrayList<CompletionProposal>( );
Expand All @@ -242,7 +247,7 @@ private CompletionProposal[] getCompletionProposals(
return proposals.toArray( new CompletionProposal[proposals.size( )] );
}

private CompletionProposal[] getCompletionProposals( JSObjectMetaData meta,
protected CompletionProposal[] getCompletionProposals( JSObjectMetaData meta,
int offset )
{
List<CompletionProposal> proposals = new ArrayList<CompletionProposal>( );
Expand Down Expand Up @@ -300,7 +305,7 @@ private CompletionProposal[] getCompletionProposals( JSObjectMetaData meta,
return proposals.toArray( new CompletionProposal[proposals.size( )] );
}

private Image getMemberImage( int visibility )
protected Image getMemberImage( int visibility )
{
switch ( visibility )
{
Expand All @@ -318,7 +323,7 @@ private Image getMemberImage( int visibility )
return null;
}

private Image getMethodImage( int visibility )
protected Image getMethodImage( int visibility )
{
switch ( visibility )
{
Expand Down
Expand Up @@ -92,8 +92,7 @@ else if ( isField( currentCode ) )// is a field or package declare
{
try
{
objectMeta = JSSyntaxContext.getJavaClassMeta( preCode
+ currentCode );
objectMeta = getFieldObjectMeta( currentCode, preCode );
}
catch ( ClassNotFoundException e )
{
Expand Down Expand Up @@ -134,6 +133,13 @@ else if ( objectMeta == null && !".".equals( currentCode ) ) //$NON-NLS-1$
return objectMeta;
}

protected JSObjectMetaData getFieldObjectMeta( String currentCode,
String preCode ) throws ClassNotFoundException
{
return JSSyntaxContext.getJavaClassMeta( preCode
+ currentCode );
}

private boolean isArray( String currentCode )
{
return currentCode.startsWith( "[" ) //$NON-NLS-1$
Expand Down
Expand Up @@ -41,7 +41,7 @@ public class JSSourceViewerConfiguration extends SourceViewerConfiguration
{

private RuleBasedScanner scanner;
private JSSyntaxContext context;
protected JSSyntaxContext context;
private IPreferenceStore preferenceStore;
private Color foregroundColor;

Expand Down

0 comments on commit 5fdd95a

Please sign in to comment.