idx
int64
0
165k
question
stringlengths
73
4.15k
target
stringlengths
5
918
len_question
int64
21
890
len_target
int64
3
255
33,700
protected static String quoteRegex ( String regex ) { if ( regex == null ) { return "" ; //$NON-NLS-1$ } return regex . replaceAll ( REGEX_SPECIAL_CHARS , REGEX_SPECIAL_CHARS_PROTECT ) ; }
Protect the given regular expression .
62
6
33,701
protected static String orRegex ( Iterable < String > elements ) { final StringBuilder regex = new StringBuilder ( ) ; for ( final String element : elements ) { if ( regex . length ( ) > 0 ) { regex . append ( "|" ) ; //$NON-NLS-1$ } regex . append ( "(?:" ) ; //$NON-NLS-1$ regex . append ( quoteRegex ( element ) ) ; regex . append ( ")" ) ; //$NON-NLS-1$ } return regex . toString ( ) ; }
Build a regular expression that is matching one of the given elements .
125
13
33,702
@ SafeVarargs protected static Set < String > sortedConcat ( Iterable < String > ... iterables ) { final Set < String > set = new TreeSet <> ( ) ; for ( final Iterable < String > iterable : iterables ) { for ( final String obj : iterable ) { set . add ( obj ) ; } } return set ; }
Concat the given iterables .
77
7
33,703
public void addMimeType ( String mimeType ) { if ( ! Strings . isEmpty ( mimeType ) ) { for ( final String mtype : mimeType . split ( "[:;,]" ) ) { //$NON-NLS-1$ this . mimeTypes . add ( mtype ) ; } } }
Add a mime type for the SARL source code .
74
12
33,704
@ Pure public List < String > getMimeTypes ( ) { if ( this . mimeTypes . isEmpty ( ) ) { return Arrays . asList ( "text/x-" + getLanguageSimpleName ( ) . toLowerCase ( ) ) ; //$NON-NLS-1$ } return this . mimeTypes ; }
Replies the mime types for the SARL source code .
74
13
33,705
@ Pure public String getBasename ( String defaultName ) { if ( Strings . isEmpty ( this . basename ) ) { return defaultName ; } return this . basename ; }
Replies the basename of the XML file to generate .
40
12
33,706
@ SuppressWarnings ( "checkstyle:nestedifdepth" ) private static void exploreGrammar ( Grammar grammar , Set < String > expressionKeywords , Set < String > modifiers , Set < String > primitiveTypes , Set < String > punctuation , Set < String > literals , Set < String > excludedKeywords , Set < String > ignored ) { for ( final AbstractRule rule : grammar . getRules ( ) ) { final boolean isModifierRule = MODIFIER_RULE_PATTERN . matcher ( rule . getName ( ) ) . matches ( ) ; final TreeIterator < EObject > iterator = rule . eAllContents ( ) ; while ( iterator . hasNext ( ) ) { final EObject object = iterator . next ( ) ; if ( object instanceof Keyword ) { final Keyword xkeyword = ( Keyword ) object ; final String value = xkeyword . getValue ( ) ; if ( ! Strings . isEmpty ( value ) ) { if ( KEYWORD_PATTERN . matcher ( value ) . matches ( ) ) { if ( ! literals . contains ( value ) && ! primitiveTypes . contains ( value ) ) { if ( excludedKeywords . contains ( value ) ) { ignored . add ( value ) ; } else { if ( isModifierRule ) { modifiers . add ( value ) ; } else { expressionKeywords . add ( value ) ; } } } } else if ( PUNCTUATION_PATTERN . matcher ( value ) . matches ( ) ) { punctuation . add ( value ) ; } } } } } }
Explore the grammar for extracting the key elements .
346
9
33,707
protected final void generate ( Set < String > literals , Set < String > expressionKeywords , Set < String > modifiers , Set < String > primitiveTypes , Set < String > punctuation , Set < String > ignored , Set < String > specialKeywords , Set < String > typeDeclarationKeywords ) { final T appendable = newStyleAppendable ( ) ; generate ( appendable , literals , expressionKeywords , modifiers , primitiveTypes , punctuation , ignored , specialKeywords , typeDeclarationKeywords ) ; final String language = getLanguageSimpleName ( ) . toLowerCase ( ) ; final String basename = getBasename ( MessageFormat . format ( getBasenameTemplate ( ) , language ) ) ; writeFile ( basename , appendable ) ; generateAdditionalFiles ( basename , appendable ) ; generateReadme ( basename ) ; }
Generate the external specification .
183
6
33,708
public static CharSequence concat ( CharSequence ... lines ) { return new CharSequence ( ) { private final StringBuilder content = new StringBuilder ( ) ; private int next ; private int length = - 1 ; @ Override public String toString ( ) { ensure ( length ( ) ) ; return this . content . toString ( ) ; } private void ensure ( int index ) { while ( this . next < lines . length && index >= this . content . length ( ) ) { if ( lines [ this . next ] != null ) { this . content . append ( lines [ this . next ] ) . append ( "\n" ) ; //$NON-NLS-1$ } ++ this . next ; } } @ Override public CharSequence subSequence ( int start , int end ) { ensure ( end - 1 ) ; return this . content . subSequence ( start , end ) ; } @ Override public int length ( ) { if ( this . length < 0 ) { int len = 0 ; for ( final CharSequence seq : lines ) { len += seq . length ( ) + 1 ; } len = Math . max ( 0 , len - 1 ) ; this . length = len ; } return this . length ; } @ Override public char charAt ( int index ) { ensure ( index ) ; return this . content . charAt ( index ) ; } } ; }
Contact the given strings of characters .
297
7
33,709
protected void generateReadme ( String basename ) { final Object content = getReadmeFileContent ( basename ) ; if ( content != null ) { final String textualContent = content . toString ( ) ; if ( ! Strings . isEmpty ( textualContent ) ) { final byte [ ] bytes = textualContent . getBytes ( ) ; for ( final String output : getOutputs ( ) ) { final File directory = new File ( output ) . getAbsoluteFile ( ) ; try { directory . mkdirs ( ) ; final File outputFile = new File ( directory , README_BASENAME ) ; Files . write ( Paths . get ( outputFile . getAbsolutePath ( ) ) , bytes ) ; } catch ( IOException e ) { throw new RuntimeException ( e ) ; } } } } }
Generate the README file .
175
7
33,710
protected String getLanguageSimpleName ( ) { final String name = getGrammar ( ) . getName ( ) ; final int index = name . lastIndexOf ( ' ' ) ; if ( index > 0 ) { return name . substring ( index + 1 ) ; } return name ; }
Replies the simple name of the language .
62
9
33,711
@ Pure protected String lines ( String prefix , String ... lines ) { final String delimiter = getCodeConfig ( ) . getLineDelimiter ( ) ; final StringBuilder buffer = new StringBuilder ( ) ; for ( final String line : lines ) { buffer . append ( prefix ) ; buffer . append ( line ) ; buffer . append ( delimiter ) ; } return buffer . toString ( ) ; }
Merge the given lines with prefix .
85
8
33,712
@ SuppressWarnings ( "static-method" ) protected OutputConfiguration createStandardOutputConfiguration ( ) { final OutputConfiguration defaultOutput = new OutputConfiguration ( IFileSystemAccess . DEFAULT_OUTPUT ) ; defaultOutput . setDescription ( Messages . SarlOutputConfigurationProvider_0 ) ; defaultOutput . setOutputDirectory ( SARLConfig . FOLDER_SOURCE_GENERATED ) ; defaultOutput . setOverrideExistingResources ( true ) ; defaultOutput . setCreateOutputDirectory ( true ) ; defaultOutput . setCanClearOutputDirectory ( false ) ; defaultOutput . setCleanUpDerivedResources ( true ) ; defaultOutput . setSetDerivedProperty ( true ) ; defaultOutput . setKeepLocalHistory ( false ) ; return defaultOutput ; }
Create the standard output configuration .
161
6
33,713
@ Provides @ io . janusproject . kernel . annotations . Kernel @ Singleton public static AgentContext getKernel ( ContextSpaceService contextService , @ Named ( JanusConfig . DEFAULT_CONTEXT_ID_NAME ) UUID janusContextID , @ Named ( JanusConfig . DEFAULT_SPACE_ID_NAME ) UUID defaultJanusSpaceId ) { return contextService . createContext ( janusContextID , defaultJanusSpaceId ) ; }
Construct the root agent context within the Janus platform .
101
11
33,714
@ Provides public static AgentInternalEventsDispatcher createAgentInternalEventsDispatcher ( Injector injector ) { final AgentInternalEventsDispatcher aeb = new AgentInternalEventsDispatcher ( injector . getInstance ( ExecutorService . class ) ) ; // to be able to inject the ExecutorService and SubscriberFindingStrategy injector . injectMembers ( aeb ) ; return aeb ; }
Create an instance of the event dispatcher for an agent .
89
11
33,715
protected LightweightTypeReference getSarlCapacityFieldType ( IResolvedTypes resolvedTypes , JvmField field ) { // For capacity call redirection LightweightTypeReference fieldType = resolvedTypes . getActualType ( field ) ; final JvmAnnotationReference capacityAnnotation = this . annotationLookup . findAnnotation ( field , ImportedCapacityFeature . class ) ; if ( capacityAnnotation != null ) { final JvmTypeReference ref = ( ( JvmTypeAnnotationValue ) capacityAnnotation . getValues ( ) . get ( 0 ) ) . getValues ( ) . get ( 0 ) ; fieldType = resolvedTypes . getActualType ( ref . getType ( ) ) ; } return fieldType ; }
Replies the type of the field that represents a SARL capacity buffer .
156
15
33,716
protected XAbstractFeatureCall createSarlCapacityExtensionProvider ( JvmIdentifiableElement thisFeature , JvmField field ) { // For capacity call redirection if ( thisFeature instanceof JvmDeclaredType ) { final JvmAnnotationReference capacityAnnotation = this . annotationLookup . findAnnotation ( field , ImportedCapacityFeature . class ) ; if ( capacityAnnotation != null ) { final String methodName = Utils . createNameForHiddenCapacityImplementationCallingMethodFromFieldName ( field . getSimpleName ( ) ) ; final JvmOperation callerOperation = findOperation ( ( JvmDeclaredType ) thisFeature , methodName ) ; if ( callerOperation != null ) { final XbaseFactory baseFactory = getXbaseFactory ( ) ; final XMemberFeatureCall extensionProvider = baseFactory . createXMemberFeatureCall ( ) ; extensionProvider . setFeature ( callerOperation ) ; final XFeatureCall thisAccess = baseFactory . createXFeatureCall ( ) ; thisAccess . setFeature ( thisFeature ) ; extensionProvider . setMemberCallTarget ( thisAccess ) ; return extensionProvider ; } } } return null ; }
Create the extension provider dedicated to the access to the used capacity functions .
243
14
33,717
protected static boolean runRejectedTask ( Runnable runnable , ThreadPoolExecutor executor ) { // Runs the task directly in the calling thread of the {@code execute} method, // unless the executor has been shut down, in which case the task // is discarded. if ( ! executor . isShutdown ( ) ) { runnable . run ( ) ; return true ; } return false ; }
Run the given task within the current thread if the executor is not shut down . The task is not run by the given executor . The executor is used for checking if the executor service is shut down .
89
44
33,718
@ Pure public static < C extends Capacity > C createSkillDelegator ( Skill originalSkill , Class < C > capacity , AgentTrait capacityCaller ) throws Exception { final String name = capacity . getName ( ) + CAPACITY_WRAPPER_NAME ; final Class < ? > type = Class . forName ( name , true , capacity . getClassLoader ( ) ) ; final Constructor < ? > cons = type . getDeclaredConstructor ( capacity , AgentTrait . class ) ; return capacity . cast ( cons . newInstance ( originalSkill , capacityCaller ) ) ; }
Create a delegator for the given skill .
127
9
33,719
@ Pure public static < C extends Capacity > C createSkillDelegatorIfPossible ( Skill originalSkill , Class < C > capacity , AgentTrait capacityCaller ) throws ClassCastException { try { return Capacities . createSkillDelegator ( originalSkill , capacity , capacityCaller ) ; } catch ( Exception e ) { return capacity . cast ( originalSkill ) ; } }
Create a delegator for the given skill when it is possible .
82
13
33,720
protected void build ( EObject object , ISourceAppender appender ) throws IOException { final IJvmTypeProvider provider = getTypeResolutionContext ( ) ; if ( provider != null ) { final Map < Key < ? > , Binding < ? > > bindings = this . originalInjector . getBindings ( ) ; Injector localInjector = CodeBuilderFactory . createOverridingInjector ( this . originalInjector , ( binder ) - > binder . bind ( AbstractTypeScopeProvider . class ) . toInstance ( AbstractSourceAppender . this . scopeProvider ) ) ; final IScopeProvider oldDelegate = this . typeScopes . getDelegate ( ) ; localInjector . injectMembers ( this . typeScopes ) ; try { final AppenderSerializer serializer = localInjector . getProvider ( AppenderSerializer . class ) . get ( ) ; serializer . serialize ( object , appender , isFormatting ( ) ) ; } finally { try { final Field f = DelegatingScopes . class . getDeclaredField ( "delegate" ) ; if ( ! f . isAccessible ( ) ) { f . setAccessible ( true ) ; } f . set ( this . typeScopes , oldDelegate ) ; } catch ( Exception exception ) { throw new Error ( exception ) ; } } } else { final AppenderSerializer serializer = this . originalInjector . getProvider ( AppenderSerializer . class ) . get ( ) ; serializer . serialize ( object , appender , isFormatting ( ) ) ; } }
Build the source code and put it into the given appender .
349
13
33,721
protected boolean isEarlyExitSARLStatement ( XExpression expression ) { if ( expression instanceof XAbstractFeatureCall ) { // Do not call expression.getFeature() since the feature may be unresolved. // The type resolution at this point causes exceptions in the reentrant type resolver. // The second parameter (false) forces to ignore feature resolution. final Object element = expression . eGet ( XbasePackage . Literals . XABSTRACT_FEATURE_CALL__FEATURE , false ) ; return this . originalComputer . isEarlyExitAnnotatedElement ( element ) ; } return false ; }
Replies if the given expression is a early - exit SARL statement .
129
15
33,722
public void addUpperConstraint ( String type ) { final JvmUpperBound constraint = this . jvmTypesFactory . createJvmUpperBound ( ) ; constraint . setTypeReference ( newTypeRef ( this . context , type ) ) ; getJvmTypeParameter ( ) . getConstraints ( ) . add ( constraint ) ; }
Add upper type bounds .
76
5
33,723
public void addLowerConstraint ( String type ) { final JvmLowerBound constraint = this . jvmTypesFactory . createJvmLowerBound ( ) ; constraint . setTypeReference ( newTypeRef ( this . context , type ) ) ; getJvmTypeParameter ( ) . getConstraints ( ) . add ( constraint ) ; }
Add lower type bounds .
73
5
33,724
public ImageDescriptor getImageDescriptor ( String imagePath ) { ImageDescriptor descriptor = getImageRegistry ( ) . getDescriptor ( imagePath ) ; if ( descriptor == null ) { descriptor = AbstractUIPlugin . imageDescriptorFromPlugin ( SARLEclipsePlugin . PLUGIN_ID , imagePath ) ; if ( descriptor != null ) { getImageRegistry ( ) . put ( imagePath , descriptor ) ; } } return descriptor ; }
Replies the image descriptor for the given image path .
101
11
33,725
@ SuppressWarnings ( "static-method" ) public IStatus createMultiStatus ( Iterable < ? extends IStatus > status ) { final IStatus max = findMax ( status ) ; final MultiStatus multiStatus ; if ( max == null ) { multiStatus = new MultiStatus ( PLUGIN_ID , 0 , null , null ) ; } else { multiStatus = new MultiStatus ( PLUGIN_ID , 0 , max . getMessage ( ) , max . getException ( ) ) ; } for ( final IStatus s : status ) { multiStatus . add ( s ) ; } return multiStatus ; }
Create a multistatus .
133
6
33,726
public void logErrorMessage ( String message ) { getILog ( ) . log ( new Status ( IStatus . ERROR , PLUGIN_ID , message , null ) ) ; }
Logs an internal error with the specified message .
39
10
33,727
@ SuppressWarnings ( { "static-method" , "checkstyle:regexp" } ) public void logDebugMessage ( String message , Throwable cause ) { Debug . println ( message ) ; if ( cause != null ) { Debug . printStackTrace ( cause ) ; } }
Logs an internal debug message with the specified message .
64
11
33,728
public void savePreferences ( ) { final IEclipsePreferences prefs = getPreferences ( ) ; try { prefs . flush ( ) ; } catch ( BackingStoreException e ) { getILog ( ) . log ( createStatus ( IStatus . ERROR , e ) ) ; } }
Saves the preferences for the plug - in .
63
10
33,729
public void openError ( Shell shell , String title , String message , Throwable exception ) { final Throwable ex = ( exception != null ) ? Throwables . getRootCause ( exception ) : null ; if ( ex != null ) { log ( ex ) ; final IStatus status = createStatus ( IStatus . ERROR , message , ex ) ; ErrorDialog . openError ( shell , title , message , status ) ; } else { MessageDialog . openError ( shell , title , message ) ; } }
Display an error dialog and log the error .
105
9
33,730
public static IJavaSearchScope createSearchScope ( IJavaProject project , Class < ? > type , boolean onlySubTypes ) { try { final IType superType = project . findType ( type . getName ( ) ) ; return SearchEngine . createStrictHierarchyScope ( project , superType , // only sub types onlySubTypes , // include the type true , null ) ; } catch ( JavaModelException e ) { SARLEclipsePlugin . getDefault ( ) . log ( e ) ; } return SearchEngine . createJavaSearchScope ( new IJavaElement [ ] { project } ) ; }
Creates a searching scope including only one project .
128
10
33,731
private void fillWizardPageWithSelectedTypes ( ) { final StructuredSelection selection = getSelectedItems ( ) ; if ( selection == null ) { return ; } for ( final Iterator < ? > iter = selection . iterator ( ) ; iter . hasNext ( ) ; ) { final Object obj = iter . next ( ) ; if ( obj instanceof TypeNameMatch ) { accessedHistoryItem ( obj ) ; final TypeNameMatch type = ( TypeNameMatch ) obj ; final String qualifiedName = Utilities . getNameWithTypeParameters ( type . getType ( ) ) ; final String message ; if ( addTypeToWizardPage ( this . typeWizardPage , qualifiedName ) ) { message = MessageFormat . format ( Messages . AbstractSuperTypeSelectionDialog_2 , TextProcessor . process ( qualifiedName , JAVA_ELEMENT_DELIMITERS ) ) ; } else { message = MessageFormat . format ( Messages . AbstractSuperTypeSelectionDialog_3 , TextProcessor . process ( qualifiedName , JAVA_ELEMENT_DELIMITERS ) ) ; } updateStatus ( new StatusInfo ( IStatus . INFO , message ) ) ; } } }
Adds selected interfaces to the list .
257
7
33,732
protected IScope createCastOperatorScope ( EObject context , EReference reference , IResolvedTypes resolvedTypes ) { if ( ! ( context instanceof SarlCastedExpression ) ) { return IScope . NULLSCOPE ; } final SarlCastedExpression call = ( SarlCastedExpression ) context ; final XExpression receiver = call . getTarget ( ) ; if ( receiver == null ) { return IScope . NULLSCOPE ; } return getFeatureScopes ( ) . createFeatureCallScopeForReceiver ( call , receiver , getParent ( ) , resolvedTypes ) ; }
create a scope for cast operator .
131
7
33,733
public void eInit ( IJvmTypeProvider context ) { setTypeResolutionContext ( context ) ; if ( this . block == null ) { this . block = XbaseFactory . eINSTANCE . createXBlockExpression ( ) ; } }
Create the XBlockExpression .
53
7
33,734
@ Pure public String getAutoGeneratedActionString ( Resource resource ) { TaskTags tags = getTaskTagProvider ( ) . getTaskTags ( resource ) ; String taskTag ; if ( tags != null && tags . getTaskTags ( ) != null && ! tags . getTaskTags ( ) . isEmpty ( ) ) { taskTag = tags . getTaskTags ( ) . get ( 0 ) . getName ( ) ; } else { taskTag = "TODO" ; } return taskTag + " Auto-generated code." ; }
Replies the string for auto - generated comments .
114
10
33,735
public IExpressionBuilder addExpression ( ) { final IExpressionBuilder builder = this . expressionProvider . get ( ) ; builder . eInit ( getXBlockExpression ( ) , new Procedures . Procedure1 < XExpression > ( ) { private int index = - 1 ; public void apply ( XExpression it ) { if ( this . index >= 0 ) { getXBlockExpression ( ) . getExpressions ( ) . set ( index , it ) ; } else { getXBlockExpression ( ) . getExpressions ( ) . add ( it ) ; this . index = getXBlockExpression ( ) . getExpressions ( ) . size ( ) - 1 ; } } } , getTypeResolutionContext ( ) ) ; return builder ; }
Add an expression inside the block .
163
7
33,736
private void handleAntScriptBrowseButtonPressed ( ) { FileDialog dialog = new FileDialog ( getContainer ( ) . getShell ( ) , SWT . SAVE ) ; dialog . setFilterExtensions ( new String [ ] { "*." + ANTSCRIPT_EXTENSION } ) ; //$NON-NLS-1$ String currentSourceString = getAntScriptValue ( ) ; int lastSeparatorIndex = currentSourceString . lastIndexOf ( File . separator ) ; if ( lastSeparatorIndex != - 1 ) { dialog . setFilterPath ( currentSourceString . substring ( 0 , lastSeparatorIndex ) ) ; dialog . setFileName ( currentSourceString . substring ( lastSeparatorIndex + 1 , currentSourceString . length ( ) ) ) ; } String selectedFileName = dialog . open ( ) ; if ( selectedFileName != null ) fAntScriptNamesCombo . setText ( selectedFileName ) ; }
Open an appropriate ant script browser so that the user can specify a source to import from
210
17
33,737
private String getAntScriptValue ( ) { String antScriptText = fAntScriptNamesCombo . getText ( ) . trim ( ) ; if ( antScriptText . indexOf ( ' ' ) < 0 ) antScriptText += "." + ANTSCRIPT_EXTENSION ; //$NON-NLS-1$ return antScriptText ; }
Answer the contents of the ant script specification widget . If this value does not have the required suffix then add it first .
77
24
33,738
protected Label createLabel ( Composite parent , String text , boolean bold ) { Label label = new Label ( parent , SWT . NONE ) ; if ( bold ) label . setFont ( JFaceResources . getBannerFont ( ) ) ; label . setText ( text ) ; GridData gridData = new GridData ( SWT . BEGINNING , SWT . CENTER , false , false ) ; label . setLayoutData ( gridData ) ; return label ; }
Creates a new label with an optional bold font .
100
11
33,739
protected void createLibraryHandlingGroup ( Composite parent ) { fLibraryHandlingGroup = new Composite ( parent , SWT . NONE ) ; GridLayout layout = new GridLayout ( ) ; fLibraryHandlingGroup . setLayout ( layout ) ; fLibraryHandlingGroup . setLayoutData ( new GridData ( GridData . HORIZONTAL_ALIGN_FILL | GridData . VERTICAL_ALIGN_FILL | GridData . GRAB_HORIZONTAL ) ) ; createLabel ( fLibraryHandlingGroup , FatJarPackagerMessages . FatJarPackageWizardPage_libraryHandlingGroupTitle , false ) ; fExtractJarsRadioButton = new Button ( fLibraryHandlingGroup , SWT . RADIO | SWT . LEFT ) ; fExtractJarsRadioButton . setText ( FatJarPackagerMessages . FatJarPackageWizardPage_extractJars_text ) ; fExtractJarsRadioButton . setLayoutData ( new GridData ( GridData . FILL_HORIZONTAL ) ) ; fExtractJarsRadioButton . addListener ( SWT . Selection , new Listener ( ) { @ Override public void handleEvent ( Event event ) { if ( ( ( Button ) event . widget ) . getSelection ( ) ) fLibraryHandler = new ExtractLibraryHandler ( ) ; } } ) ; fPackageJarsRadioButton = new Button ( fLibraryHandlingGroup , SWT . RADIO | SWT . LEFT ) ; fPackageJarsRadioButton . setText ( FatJarPackagerMessages . FatJarPackageWizardPage_packageJars_text ) ; fPackageJarsRadioButton . setLayoutData ( new GridData ( GridData . FILL_HORIZONTAL ) ) ; fPackageJarsRadioButton . addListener ( SWT . Selection , new Listener ( ) { @ Override public void handleEvent ( Event event ) { if ( ( ( Button ) event . widget ) . getSelection ( ) ) fLibraryHandler = new PackageLibraryHandler ( ) ; } } ) ; fCopyJarFilesRadioButton = new Button ( fLibraryHandlingGroup , SWT . RADIO | SWT . LEFT ) ; fCopyJarFilesRadioButton . setText ( FatJarPackagerMessages . FatJarPackageWizardPage_copyJarFiles_text ) ; fCopyJarFilesRadioButton . setLayoutData ( new GridData ( GridData . FILL_HORIZONTAL ) ) ; fCopyJarFilesRadioButton . addListener ( SWT . Selection , new Listener ( ) { @ Override public void handleEvent ( Event event ) { if ( ( ( Button ) event . widget ) . getSelection ( ) ) fLibraryHandler = new CopyLibraryHandler ( ) ; } } ) ; // set default for first selection (no previous widget settings to restore) setLibraryHandler ( new ExtractLibraryHandler ( ) ) ; }
Create the export options specification widgets .
634
7
33,740
@ Override protected void updateModel ( ) { super . updateModel ( ) ; String comboText = fAntScriptNamesCombo . getText ( ) ; IPath path = Path . fromOSString ( comboText ) ; if ( path . segmentCount ( ) > 0 && ensureAntScriptFileIsValid ( path . toFile ( ) ) && path . getFileExtension ( ) == null ) path = path . addFileExtension ( ANTSCRIPT_EXTENSION ) ; fAntScriptLocation = getAbsoluteLocation ( path ) ; }
Stores the widget values in the JAR package .
117
11
33,741
private IPath getAbsoluteLocation ( IPath location ) { if ( location . isAbsolute ( ) ) return location ; IWorkspaceRoot root = ResourcesPlugin . getWorkspace ( ) . getRoot ( ) ; if ( location . segmentCount ( ) >= 2 && ! ".." . equals ( location . segment ( 0 ) ) ) { //$NON-NLS-1$ IFile file = root . getFile ( location ) ; IPath absolutePath = file . getLocation ( ) ; if ( absolutePath != null ) { return absolutePath ; } } // The path does not exist in the workspace (e.g. because there's no such project). // Fallback is to just append the path to the workspace root. return root . getLocation ( ) . append ( location ) ; }
Gets the absolute location relative to the workspace .
170
10
33,742
private boolean ensureAntScriptFileIsValid ( File antScriptFile ) { if ( antScriptFile . exists ( ) && antScriptFile . isDirectory ( ) && fAntScriptNamesCombo . getText ( ) . length ( ) > 0 ) { setErrorMessage ( FatJarPackagerMessages . FatJarPackageWizardPage_error_antScriptLocationIsDir ) ; fAntScriptNamesCombo . setFocus ( ) ; return false ; } if ( antScriptFile . exists ( ) ) { if ( ! antScriptFile . canWrite ( ) ) { setErrorMessage ( FatJarPackagerMessages . FatJarPackageWizardPage_error_antScriptLocationUnwritable ) ; fAntScriptNamesCombo . setFocus ( ) ; return false ; } } return true ; }
Returns a boolean indicating whether the passed File handle is is valid and available for use .
169
17
33,743
protected static String getPathLabel ( IPath path , boolean isOSPath ) { String label ; if ( isOSPath ) { label = path . toOSString ( ) ; } else { label = path . makeRelative ( ) . toString ( ) ; } return label ; }
Returns the label of a path .
60
7
33,744
@ SuppressWarnings ( "static-method" ) protected void safeRefresh ( IProject project , IProgressMonitor monitor ) { try { project . refreshLocal ( IResource . DEPTH_INFINITE , monitor ) ; } catch ( CoreException exception ) { SARLEclipsePlugin . getDefault ( ) . log ( exception ) ; } }
Refresh the project file hierarchy .
75
7
33,745
public static String [ ] getSARLProjectSourceFolders ( ) { return new String [ ] { SARLConfig . FOLDER_SOURCE_SARL , SARLConfig . FOLDER_SOURCE_JAVA , SARLConfig . FOLDER_RESOURCES , SARLConfig . FOLDER_TEST_SOURCE_SARL , SARLConfig . FOLDER_SOURCE_GENERATED , SARLConfig . FOLDER_TEST_SOURCE_GENERATED , } ; }
Replies the list of the standard source folders for a SARL project .
115
15
33,746
public static void configureSARLProject ( IProject project , boolean addNatures , boolean configureJavaNature , boolean createFolders , IProgressMonitor monitor ) { try { final SubMonitor subMonitor = SubMonitor . convert ( monitor , 11 ) ; // Add Natures final IStatus status = Status . OK_STATUS ; if ( addNatures ) { addSarlNatures ( project , subMonitor . newChild ( 1 ) ) ; if ( status != null && ! status . isOK ( ) ) { SARLEclipsePlugin . getDefault ( ) . getLog ( ) . log ( status ) ; } } // Ensure SARL specific folders. final OutParameter < IFolder [ ] > sourceFolders = new OutParameter <> ( ) ; final OutParameter < IFolder [ ] > testSourceFolders = new OutParameter <> ( ) ; final OutParameter < IFolder [ ] > generationFolders = new OutParameter <> ( ) ; final OutParameter < IFolder [ ] > testGenerationFolders = new OutParameter <> ( ) ; final OutParameter < IFolder > generationFolder = new OutParameter <> ( ) ; final OutParameter < IFolder > outputFolder = new OutParameter <> ( ) ; final OutParameter < IFolder > testOutputFolder = new OutParameter <> ( ) ; ensureSourceFolders ( project , createFolders , subMonitor , sourceFolders , testSourceFolders , generationFolders , testGenerationFolders , generationFolder , outputFolder , testOutputFolder ) ; // SARL specific configuration SARLPreferences . setSpecificSARLConfigurationFor ( project , generationFolder . get ( ) . getProjectRelativePath ( ) ) ; subMonitor . worked ( 1 ) ; // Create the Java project if ( configureJavaNature ) { if ( ! addNatures ) { addNatures ( project , subMonitor . newChild ( 1 ) , JavaCore . NATURE_ID ) ; } final IJavaProject javaProject = JavaCore . create ( project ) ; subMonitor . worked ( 1 ) ; // Build path BuildPathsBlock . flush ( buildClassPathEntries ( javaProject , sourceFolders . get ( ) , testSourceFolders . get ( ) , generationFolders . get ( ) , testGenerationFolders . get ( ) , testOutputFolder . get ( ) . getFullPath ( ) , false , true ) , outputFolder . get ( ) . getFullPath ( ) , javaProject , null , subMonitor . newChild ( 1 ) ) ; } subMonitor . done ( ) ; } catch ( CoreException exception ) { SARLEclipsePlugin . getDefault ( ) . log ( exception ) ; } }
Configure the SARL project .
584
7
33,747
public static void configureSARLSourceFolders ( IProject project , boolean createFolders , IProgressMonitor monitor ) { try { final SubMonitor subMonitor = SubMonitor . convert ( monitor , 8 ) ; final OutParameter < IFolder [ ] > sourceFolders = new OutParameter <> ( ) ; final OutParameter < IFolder [ ] > testSourceFolders = new OutParameter <> ( ) ; final OutParameter < IFolder [ ] > generationFolders = new OutParameter <> ( ) ; final OutParameter < IFolder [ ] > testGenerationFolders = new OutParameter <> ( ) ; final OutParameter < IFolder > testOutputFolder = new OutParameter <> ( ) ; ensureSourceFolders ( project , createFolders , subMonitor , sourceFolders , testSourceFolders , generationFolders , testGenerationFolders , null , null , testOutputFolder ) ; final IJavaProject javaProject = JavaCore . create ( project ) ; subMonitor . worked ( 1 ) ; // Build path BuildPathsBlock . flush ( buildClassPathEntries ( javaProject , sourceFolders . get ( ) , testSourceFolders . get ( ) , generationFolders . get ( ) , testGenerationFolders . get ( ) , testOutputFolder . get ( ) . getFullPath ( ) , true , false ) , javaProject . getOutputLocation ( ) , javaProject , null , subMonitor . newChild ( 1 ) ) ; subMonitor . done ( ) ; } catch ( CoreException exception ) { SARLEclipsePlugin . getDefault ( ) . log ( exception ) ; } }
Configure the source folders for a SARL project .
360
11
33,748
public static List < IClasspathEntry > getDefaultSourceClassPathEntries ( IPath projectFolder ) { final IPath srcJava = projectFolder . append ( Path . fromPortableString ( SARLConfig . FOLDER_SOURCE_JAVA ) ) ; final IClasspathEntry srcJavaEntry = JavaCore . newSourceEntry ( srcJava . makeAbsolute ( ) ) ; final IPath srcSarl = projectFolder . append ( Path . fromPortableString ( SARLConfig . FOLDER_SOURCE_SARL ) ) ; final IClasspathEntry srcSarlEntry = JavaCore . newSourceEntry ( srcSarl . makeAbsolute ( ) ) ; final IPath srcGeneratedSources = projectFolder . append ( Path . fromPortableString ( SARLConfig . FOLDER_SOURCE_GENERATED ) ) ; final IClasspathAttribute attr = JavaCore . newClasspathAttribute ( IClasspathAttribute . IGNORE_OPTIONAL_PROBLEMS , Boolean . TRUE . toString ( ) ) ; final IClasspathEntry srcGeneratedSourcesEntry = JavaCore . newSourceEntry ( srcGeneratedSources . makeAbsolute ( ) , ClasspathEntry . INCLUDE_ALL , ClasspathEntry . EXCLUDE_NONE , null /*output location*/ , new IClasspathAttribute [ ] { attr } ) ; final IPath srcResources = projectFolder . append ( Path . fromPortableString ( SARLConfig . FOLDER_RESOURCES ) ) ; final IClasspathEntry srcResourcesEntry = JavaCore . newSourceEntry ( srcResources . makeAbsolute ( ) ) ; return Arrays . asList ( srcSarlEntry , srcJavaEntry , srcResourcesEntry , srcGeneratedSourcesEntry ) ; }
Replies the default source entries for a SARL project .
383
12
33,749
@ SuppressWarnings ( "checkstyle:npathcomplexity" ) protected void collectProjectFoldersFromDirectory ( Collection < File > folders , File directory , Set < String > directoriesVisited , boolean nestedProjects , IProgressMonitor monitor ) { if ( monitor . isCanceled ( ) ) { return ; } monitor . subTask ( NLS . bind ( Messages . SARLProjectConfigurator_0 , directory . getPath ( ) ) ) ; final File [ ] contents = directory . listFiles ( ) ; if ( contents == null ) { return ; } Set < String > visited = directoriesVisited ; if ( visited == null ) { visited = new HashSet <> ( ) ; try { visited . add ( directory . getCanonicalPath ( ) ) ; } catch ( IOException exception ) { StatusManager . getManager ( ) . handle ( StatusUtil . newStatus ( IStatus . ERROR , exception . getLocalizedMessage ( ) , exception ) ) ; } } final Set < File > subdirectories = new LinkedHashSet <> ( ) ; for ( final File file : contents ) { if ( file . isDirectory ( ) ) { subdirectories . add ( file ) ; } else if ( file . getName ( ) . endsWith ( this . fileExtension ) ) { // Found a SARL file. final File rootFile = getProjectFolderForSourceFolder ( file . getParentFile ( ) ) ; if ( rootFile != null ) { folders . add ( rootFile ) ; return ; } } } for ( final File subdir : subdirectories ) { try { final String canonicalPath = subdir . getCanonicalPath ( ) ; if ( ! visited . add ( canonicalPath ) ) { // already been here --> do not recurse continue ; } } catch ( IOException exception ) { StatusManager . getManager ( ) . handle ( StatusUtil . newStatus ( IStatus . ERROR , exception . getLocalizedMessage ( ) , exception ) ) ; } collectProjectFoldersFromDirectory ( folders , subdir , visited , nestedProjects , monitor ) ; } }
Collect the list of SARL project folders that are under directory into files .
452
15
33,750
public static IStatus addNatures ( IProject project , IProgressMonitor monitor , String ... natureIdentifiers ) { if ( project != null && natureIdentifiers != null && natureIdentifiers . length > 0 ) { try { final SubMonitor subMonitor = SubMonitor . convert ( monitor , natureIdentifiers . length + 2 ) ; final IProjectDescription description = project . getDescription ( ) ; final List < String > natures = new LinkedList <> ( Arrays . asList ( description . getNatureIds ( ) ) ) ; for ( final String natureIdentifier : natureIdentifiers ) { if ( ! Strings . isNullOrEmpty ( natureIdentifier ) && ! natures . contains ( natureIdentifier ) ) { natures . add ( 0 , natureIdentifier ) ; } subMonitor . worked ( 1 ) ; } final String [ ] newNatures = natures . toArray ( new String [ natures . size ( ) ] ) ; final IStatus status = ResourcesPlugin . getWorkspace ( ) . validateNatureSet ( newNatures ) ; subMonitor . worked ( 1 ) ; // check the status and decide what to do if ( status . getCode ( ) == IStatus . OK ) { description . setNatureIds ( newNatures ) ; project . setDescription ( description , subMonitor . newChild ( 1 ) ) ; } subMonitor . done ( ) ; return status ; } catch ( CoreException exception ) { return SARLEclipsePlugin . getDefault ( ) . createStatus ( IStatus . ERROR , exception ) ; } } return SARLEclipsePlugin . getDefault ( ) . createOkStatus ( ) ; }
Add the natures to the given project .
348
9
33,751
public static IStatus addSarlNatures ( IProject project , IProgressMonitor monitor ) { return addNatures ( project , monitor , getSarlNatures ( ) ) ; }
Add the SARL natures to the given project .
39
11
33,752
public IAnnotation getAnnotation ( IAnnotatable element , String qualifiedName ) { if ( element != null ) { try { final int separator = qualifiedName . lastIndexOf ( ' ' ) ; final String simpleName ; if ( separator >= 0 && separator < ( qualifiedName . length ( ) - 1 ) ) { simpleName = qualifiedName . substring ( separator + 1 , qualifiedName . length ( ) ) ; } else { simpleName = qualifiedName ; } for ( final IAnnotation annotation : element . getAnnotations ( ) ) { final String name = annotation . getElementName ( ) ; if ( name . equals ( simpleName ) || name . equals ( qualifiedName ) ) { return annotation ; } } } catch ( JavaModelException e ) { // } } return null ; }
Replies the annotation with the given qualified name .
172
10
33,753
public JvmConstructor getJvmConstructor ( IMethod constructor , XtendTypeDeclaration context ) throws JavaModelException { if ( constructor . isConstructor ( ) ) { final JvmType type = this . typeReferences . findDeclaredType ( constructor . getDeclaringType ( ) . getFullyQualifiedName ( ) , context ) ; if ( type instanceof JvmDeclaredType ) { final JvmDeclaredType declaredType = ( JvmDeclaredType ) type ; final ActionParameterTypes jdtSignature = this . actionPrototypeProvider . createParameterTypes ( Flags . isVarargs ( constructor . getFlags ( ) ) , getFormalParameterProvider ( constructor ) ) ; for ( final JvmConstructor jvmConstructor : declaredType . getDeclaredConstructors ( ) ) { final ActionParameterTypes jvmSignature = this . actionPrototypeProvider . createParameterTypesFromJvmModel ( jvmConstructor . isVarArgs ( ) , jvmConstructor . getParameters ( ) ) ; if ( jvmSignature . equals ( jdtSignature ) ) { return jvmConstructor ; } } } } return null ; }
Create the JvmConstructor for the given JDT constructor .
251
13
33,754
protected IFormalParameterBuilder [ ] createFormalParametersWith ( ParameterBuilder parameterBuilder , IMethod operation ) throws JavaModelException , IllegalArgumentException { final boolean isVarargs = Flags . isVarargs ( operation . getFlags ( ) ) ; final ILocalVariable [ ] rawParameters = operation . getParameters ( ) ; final FormalParameterProvider parameters = getFormalParameterProvider ( operation ) ; final int len = parameters . getFormalParameterCount ( ) ; final IFormalParameterBuilder [ ] paramBuilders = new IFormalParameterBuilder [ len ] ; for ( int i = 0 ; i < len ; ++ i ) { final ILocalVariable rawParameter = rawParameters [ i ] ; final IAnnotation annotation = getAnnotation ( rawParameter , DefaultValue . class . getName ( ) ) ; final String defaultValue = ( annotation != null ) ? extractDefaultValue ( operation , annotation ) : null ; final boolean isV = isVarargs && i == len - 1 ; String type = parameters . getFormalParameterType ( i , isV ) ; if ( isV && type . endsWith ( "[]" ) ) { //$NON-NLS-1$ type = type . substring ( 0 , type . length ( ) - 2 ) ; } final IFormalParameterBuilder sarlParameter = parameterBuilder . addParameter ( parameters . getFormalParameterName ( i ) ) ; sarlParameter . setParameterType ( type ) ; if ( defaultValue != null ) { sarlParameter . getDefaultValue ( ) . setExpression ( defaultValue ) ; } if ( isV ) { sarlParameter . setVarArg ( true ) ; } paramBuilders [ i ] = sarlParameter ; } return paramBuilders ; }
Create the formal parameters for the given operation .
371
9
33,755
public void createStandardConstructorsWith ( ConstructorBuilder codeBuilder , Collection < IMethod > superClassConstructors , XtendTypeDeclaration context ) throws JavaModelException { if ( superClassConstructors != null ) { for ( final IMethod constructor : superClassConstructors ) { if ( ! isGeneratedOperation ( constructor ) ) { final ISarlConstructorBuilder cons = codeBuilder . addConstructor ( ) ; // Create parameters final IFormalParameterBuilder [ ] sarlParams = createFormalParametersWith ( name -> cons . addParameter ( name ) , constructor ) ; // Create the block final IBlockExpressionBuilder block = cons . getExpression ( ) ; // Create thre super-call expression final IExpressionBuilder superCall = block . addExpression ( ) ; final XFeatureCall call = XbaseFactory . eINSTANCE . createXFeatureCall ( ) ; superCall . setXExpression ( call ) ; // Set the todo comment. superCall . setDocumentation ( block . getAutoGeneratedActionString ( ) ) ; // Create the super-call XExpression call . setFeature ( getJvmConstructor ( constructor , context ) ) ; call . setExplicitOperationCall ( true ) ; final List < XExpression > arguments = call . getFeatureCallArguments ( ) ; for ( final IFormalParameterBuilder currentParam : sarlParams ) { final XFeatureCall argumentSource = XbaseFactory . eINSTANCE . createXFeatureCall ( ) ; arguments . add ( argumentSource ) ; currentParam . setReferenceInto ( argumentSource ) ; } } } } }
Add the given constructors to the Ecore container .
346
11
33,756
public void createActionsWith ( ActionBuilder codeBuilder , Collection < IMethod > methods , XtendTypeDeclaration context ) throws JavaModelException , IllegalArgumentException { if ( methods != null ) { for ( final IMethod operation : methods ) { if ( ! isGeneratedOperation ( operation ) ) { final ISarlActionBuilder action = codeBuilder . addAction ( operation . getElementName ( ) ) ; action . setReturnType ( Signature . toString ( operation . getReturnType ( ) ) ) ; final IFormalParameterBuilder [ ] sarlParams = createFormalParametersWith ( name -> action . addParameter ( name ) , operation ) ; if ( context != null ) { final JvmType type = this . typeReferences . findDeclaredType ( operation . getDeclaringType ( ) . getFullyQualifiedName ( ) , context ) ; final JvmOperation superOperation = getJvmOperation ( operation , type ) ; // Create the block final IBlockExpressionBuilder block = action . getExpression ( ) ; if ( ( type . eClass ( ) != TypesPackage . Literals . JVM_GENERIC_TYPE || ! ( ( JvmGenericType ) type ) . isInterface ( ) ) && superOperation != null && ! superOperation . isAbstract ( ) ) { // Create the super-call expression final IExpressionBuilder superCall = block . addExpression ( ) ; final XMemberFeatureCall call = XbaseFactory . eINSTANCE . createXMemberFeatureCall ( ) ; superCall . setXExpression ( call ) ; superCall . setDocumentation ( block . getAutoGeneratedActionString ( ) ) ; call . setFeature ( superOperation ) ; call . setMemberCallTarget ( superCall . createReferenceToSuper ( ) ) ; final List < XExpression > arguments = call . getMemberCallArguments ( ) ; for ( final IFormalParameterBuilder currentParam : sarlParams ) { final XFeatureCall argumentSource = XbaseFactory . eINSTANCE . createXFeatureCall ( ) ; arguments . add ( argumentSource ) ; currentParam . setReferenceInto ( argumentSource ) ; } } else { final JvmTypeReference ret = superOperation != null ? superOperation . getReturnType ( ) : null ; block . setDefaultAutoGeneratedContent ( ret == null ? null : ret . getIdentifier ( ) ) ; } } } } } }
Create the operations into the SARL feature container .
517
10
33,757
public boolean isSubClassOf ( TypeFinder typeFinder , String subClass , String superClass ) throws JavaModelException { final SuperTypeIterator typeIterator = new SuperTypeIterator ( typeFinder , false , subClass ) ; while ( typeIterator . hasNext ( ) ) { final IType type = typeIterator . next ( ) ; if ( Objects . equals ( type . getFullyQualifiedName ( ) , superClass ) ) { return true ; } } return false ; }
Replies if the given type is a subclass of the second type .
103
14
33,758
public static int compare ( XExpression e1 , XExpression e2 ) { if ( e1 == e2 ) { return 0 ; } if ( e1 == null ) { return Integer . MIN_VALUE ; } if ( e2 == null ) { return Integer . MAX_VALUE ; } return e1 . toString ( ) . compareTo ( e2 . toString ( ) ) ; }
Compare two Xtext expressions .
85
6
33,759
protected static void setMainJavaClass ( ILaunchConfigurationWorkingCopy wc , String name ) { wc . setAttribute ( IJavaLaunchConfigurationConstants . ATTR_MAIN_TYPE_NAME , name ) ; }
Change the main java class within the given configuration .
47
10
33,760
protected ILaunchConfigurationWorkingCopy initLaunchConfiguration ( String configurationType , String projectName , String id , boolean resetJavaMainClass ) throws CoreException { final ILaunchManager launchManager = DebugPlugin . getDefault ( ) . getLaunchManager ( ) ; final ILaunchConfigurationType configType = launchManager . getLaunchConfigurationType ( configurationType ) ; final ILaunchConfigurationWorkingCopy wc = configType . newInstance ( null , launchManager . generateLaunchConfigurationName ( id ) ) ; setProjectName ( wc , projectName ) ; setDefaultContextIdentifier ( wc , null ) ; setLaunchingFlags ( wc , DEFAULT_SHOW_LOGO , DEFAULT_SHOW_LOG_INFO , DEFAULT_OFFLINE ) ; setRuntimeConfiguration ( wc , SARLRuntime . getDefaultSREInstall ( ) , DEFAULT_USE_SYSTEM_SRE , DEFAULT_USE_PROJECT_SRE , resetJavaMainClass ) ; JavaMigrationDelegate . updateResourceMapping ( wc ) ; return wc ; }
initialize the launch configuration .
226
6
33,761
protected static String trimFileExtension ( String fileName ) { if ( fileName . lastIndexOf ( ' ' ) == - 1 ) { return fileName ; } return fileName . substring ( 0 , fileName . lastIndexOf ( ' ' ) ) ; }
Remove the file extension .
57
5
33,762
protected void generateMetadata ( IXmlStyleAppendable it ) { it . appendTagWithValue ( "property" , //$NON-NLS-1$ Strings . concat ( ";" , getMimeTypes ( ) ) , //$NON-NLS-1$ "name" , "mimetypes" ) ; //$NON-NLS-1$ //$NON-NLS-2$ final StringBuilder buffer = new StringBuilder ( ) ; for ( final String fileExtension : getLanguage ( ) . getFileExtensions ( ) ) { if ( buffer . length ( ) > 0 ) { buffer . append ( ";" ) ; //$NON-NLS-1$ } buffer . append ( "*." ) . append ( fileExtension ) ; //$NON-NLS-1$ } it . appendTagWithValue ( "property" , //$NON-NLS-1$ buffer . toString ( ) , "name" , "globs" ) ; //$NON-NLS-1$ //$NON-NLS-2$ it . appendTagWithValue ( "property" , //$NON-NLS-1$ "//" , //$NON-NLS-1$ "name" , "line-comment-start" ) ; //$NON-NLS-1$ //$NON-NLS-2$ it . appendTagWithValue ( "property" , //$NON-NLS-1$ "/*" , //$NON-NLS-1$ "name" , "block-comment-start" ) ; //$NON-NLS-1$ //$NON-NLS-2$ it . appendTagWithValue ( "property" , //$NON-NLS-1$ "*/" , //$NON-NLS-1$ "name" , "block-comment-end" ) ; //$NON-NLS-1$ //$NON-NLS-2$ }
Generate the metadata section .
447
6
33,763
protected void selectSRE ( ) { final File file ; if ( StandardSREPage . this . workingCopy . getJarFile ( ) != null ) { file = StandardSREPage . this . workingCopy . getJarFile ( ) . toFile ( ) ; } else { file = null ; } final FileDialog dialog = new FileDialog ( getShell ( ) , SWT . OPEN ) ; dialog . setText ( Messages . StandardSREPage_4 ) ; dialog . setFilterExtensions ( new String [ ] { "*.jar" } ) ; //$NON-NLS-1$ if ( file != null && file . exists ( ) ) { dialog . setFileName ( file . getAbsolutePath ( ) ) ; } final String selectedFile = dialog . open ( ) ; if ( selectedFile != null ) { final IPath path = Path . fromOSString ( selectedFile ) ; // IWorkspace workspace = ResourcesPlugin.getWorkspace(); // IPath workspaceLocation = workspace.getRoot().getLocation(); // SARLEclipsePlugin.logDebugMessage("Workspace (Path): " + workspaceLocation); //$NON-NLS-1$ // if (workspaceLocation.isPrefixOf(path)) { // SARLEclipsePlugin.logDebugMessage("Make relative path"); //$NON-NLS-1$ // path = workspaceLocation.makeRelativeTo(workspaceLocation); // } // SARLEclipsePlugin.logDebugMessage("Resolved Path (Path): " + path); //$NON-NLS-1$ // createWorkingCopy ( ) ; this . workingCopy . setJarFile ( path ) ; final IStatus status = validate ( ) ; // initializeFields ( ) ; setPageStatus ( status ) ; updatePageStatus ( ) ; } }
Ask to the user to selected the SRE .
385
10
33,764
private void initializeFields ( ) { final IPath path = this . workingCopy . getJarFile ( ) ; String tooltip = null ; String basename = null ; if ( path != null ) { tooltip = path . toOSString ( ) ; final IPath tmpPath = path . removeTrailingSeparator ( ) ; if ( tmpPath != null ) { basename = tmpPath . lastSegment ( ) ; } } this . sreLibraryTextField . setText ( Strings . nullToEmpty ( basename ) ) ; this . sreLibraryTextField . setToolTipText ( Strings . nullToEmpty ( tooltip ) ) ; // final String name = this . workingCopy . getNameNoDefault ( ) ; this . sreNameTextField . setText ( Strings . nullToEmpty ( name ) ) ; // final String mainClass = this . workingCopy . getMainClass ( ) ; this . sreMainClassTextField . setText ( Strings . nullToEmpty ( mainClass ) ) ; // this . sreIdTextField . setText ( this . workingCopy . getId ( ) ) ; }
Initialize the dialogs fields .
242
7
33,765
public static IPath getSourceBundlePath ( Bundle bundle , IPath bundleLocation ) { IPath sourcesPath = null ; // Not an essential functionality, make it robust try { final IPath srcFolderPath = getSourceRootProjectFolderPath ( bundle ) ; if ( srcFolderPath == null ) { //common case, jar file. final IPath bundlesParentFolder = bundleLocation . removeLastSegments ( 1 ) ; final String binaryJarName = bundleLocation . lastSegment ( ) ; final String symbolicName = bundle . getSymbolicName ( ) ; final String sourceJarName = binaryJarName . replace ( symbolicName , symbolicName . concat ( SOURCE_SUFIX ) ) ; final IPath potentialSourceJar = bundlesParentFolder . append ( sourceJarName ) ; if ( potentialSourceJar . toFile ( ) . exists ( ) ) { sourcesPath = potentialSourceJar ; } } else { sourcesPath = srcFolderPath ; } } catch ( Throwable t ) { throw new RuntimeException ( t ) ; } return sourcesPath ; }
Replies the source location for the given bundle .
222
10
33,766
public static IPath getBundlePath ( Bundle bundle ) { IPath path = getBinFolderPath ( bundle ) ; if ( path == null ) { // common jar file case, no bin folder try { path = new Path ( FileLocator . getBundleFile ( bundle ) . getAbsolutePath ( ) ) ; } catch ( IOException e ) { throw new RuntimeException ( e ) ; } } return path ; }
Replies the path of the binary files of the given bundle .
91
13
33,767
public void setReferenceInto ( XFeatureCall container ) { JvmVoid jvmVoid = this . jvmTypesFactory . createJvmVoid ( ) ; if ( jvmVoid instanceof InternalEObject ) { final InternalEObject jvmVoidProxy = ( InternalEObject ) jvmVoid ; final EObject param = getSarlFormalParameter ( ) ; final Resource resource = param . eResource ( ) ; // Get the derived object final SarlFormalParameter jvmParam = getAssociatedElement ( SarlFormalParameter . class , param , resource ) ; // Set the proxy URI final URI uri = EcoreUtil2 . getNormalizedURI ( jvmParam ) ; jvmVoidProxy . eSetProxyURI ( uri ) ; } container . setFeature ( jvmVoid ) ; }
Replies the JvmIdentifiable that corresponds to the formal parameter .
184
14
33,768
public void setParameterType ( String type ) { String typeName ; if ( Strings . isEmpty ( type ) ) { typeName = Object . class . getName ( ) ; } else { typeName = type ; } this . parameter . setParameterType ( newTypeRef ( this . context , typeName ) ) ; }
Change the type .
69
4
33,769
@ Pure public IExpressionBuilder getDefaultValue ( ) { if ( this . defaultValue == null ) { this . defaultValue = this . expressionProvider . get ( ) ; this . defaultValue . eInit ( this . parameter , new Procedures . Procedure1 < XExpression > ( ) { public void apply ( XExpression it ) { getSarlFormalParameter ( ) . setDefaultValue ( it ) ; } } , getTypeResolutionContext ( ) ) ; } return this . defaultValue ; }
Replies the default value of the parameter .
108
9
33,770
@ SuppressWarnings ( "static-method" ) public JvmAnnotationReference findAnnotation ( JvmAnnotationTarget annotationTarget , String lookupType ) { // avoid creating an empty list for all given targets but check for #eIsSet first if ( annotationTarget . eIsSet ( TypesPackage . Literals . JVM_ANNOTATION_TARGET__ANNOTATIONS ) ) { for ( final JvmAnnotationReference annotation : annotationTarget . getAnnotations ( ) ) { final JvmAnnotationType annotationType = annotation . getAnnotation ( ) ; if ( annotationType != null && Objects . equals ( lookupType , annotationType . getQualifiedName ( ) ) ) { return annotation ; } } } return null ; }
Find an annotation .
158
4
33,771
public List < String > getTempResourceRoots ( ) { final List < String > tmp = this . tmpResources == null ? Collections . emptyList ( ) : this . tmpResources ; this . tmpResources = null ; return tmp ; }
Replies the temprary root folders for resources .
50
11
33,772
protected List < StringConcatenationClient > generateTopElements ( boolean forInterface , boolean forAppender ) { final List < StringConcatenationClient > topElements = new ArrayList <> ( ) ; for ( final CodeElementExtractor . ElementDescription description : getCodeElementExtractor ( ) . getTopElements ( getGrammar ( ) , getCodeBuilderConfig ( ) ) ) { topElements . add ( generateTopElement ( description , forInterface , forAppender ) ) ; } return topElements ; }
Extract top elements from the grammar .
116
8
33,773
protected void generateIScriptBuilder ( ) { final List < StringConcatenationClient > topElements = generateTopElements ( true , false ) ; final TypeReference builder = getScriptBuilderInterface ( ) ; final StringConcatenationClient content = new StringConcatenationClient ( ) { @ Override protected void appendTo ( TargetStringConcatenation it ) { it . append ( "/** Builder of " + getLanguageName ( ) + " scripts." ) ; //$NON-NLS-1$ //$NON-NLS-2$ it . newLine ( ) ; it . append ( " *" ) ; //$NON-NLS-1$ it . newLine ( ) ; it . append ( " * <p>This builder is provided for helping to create " //$NON-NLS-1$ + getLanguageName ( ) + " Ecore elements." ) ; //$NON-NLS-1$ it . newLine ( ) ; it . append ( " *" ) ; //$NON-NLS-1$ it . newLine ( ) ; it . append ( " * <p>Do not forget to invoke {@link #finalizeScript()} for creating imports, etc." ) ; //$NON-NLS-1$ it . newLine ( ) ; it . append ( " */" ) ; //$NON-NLS-1$ it . newLine ( ) ; it . append ( "@SuppressWarnings(\"all\")" ) ; //$NON-NLS-1$ it . newLine ( ) ; it . append ( "public interface " ) ; //$NON-NLS-1$ it . append ( builder . getSimpleName ( ) ) ; it . append ( " {" ) ; //$NON-NLS-1$ it . newLineIfNotEmpty ( ) ; it . newLine ( ) ; it . append ( generateFieldsAndMethods ( true , false ) ) ; for ( final StringConcatenationClient element : topElements ) { it . append ( element ) ; } it . append ( "}" ) ; //$NON-NLS-1$ it . newLineIfNotEmpty ( ) ; it . newLine ( ) ; } } ; final JavaFileAccess javaFile = getFileAccessFactory ( ) . createJavaFile ( builder , content ) ; javaFile . writeTo ( getSrcGen ( ) ) ; }
Generate the script builder interface .
533
7
33,774
protected void generateScriptSourceAppender ( ) { final List < StringConcatenationClient > topElements = generateTopElements ( false , true ) ; final TypeReference appender = getCodeElementExtractor ( ) . getElementAppenderImpl ( "Script" ) ; //$NON-NLS-1$ final StringConcatenationClient content = new StringConcatenationClient ( ) { @ Override protected void appendTo ( TargetStringConcatenation it ) { it . append ( "/** Appender of " + getLanguageName ( ) + " scripts." ) ; //$NON-NLS-1$ //$NON-NLS-2$ it . newLine ( ) ; it . append ( " *" ) ; //$NON-NLS-1$ it . newLine ( ) ; it . append ( " */" ) ; //$NON-NLS-1$ it . newLine ( ) ; it . append ( "@SuppressWarnings(\"all\")" ) ; //$NON-NLS-1$ it . newLine ( ) ; it . append ( "public class " ) ; //$NON-NLS-1$ it . append ( getScriptAppender ( ) . getSimpleName ( ) ) ; it . append ( " extends " ) ; //$NON-NLS-1$ it . append ( getCodeElementExtractor ( ) . getAbstractAppenderImpl ( ) ) ; it . append ( " implements " ) ; //$NON-NLS-1$ it . append ( getScriptBuilderInterface ( ) ) ; it . append ( " {" ) ; //$NON-NLS-1$ it . newLineIfNotEmpty ( ) ; it . newLine ( ) ; it . append ( generateFieldsAndMethods ( false , true ) ) ; for ( final StringConcatenationClient element : topElements ) { it . append ( element ) ; } it . append ( "}" ) ; //$NON-NLS-1$ it . newLineIfNotEmpty ( ) ; it . newLine ( ) ; } } ; final JavaFileAccess javaFile = getFileAccessFactory ( ) . createJavaFile ( appender , content ) ; javaFile . writeTo ( getSrcGen ( ) ) ; }
Generate the script appender .
502
7
33,775
protected void generateScriptBuilderImpl ( ) { final List < StringConcatenationClient > topElements = generateTopElements ( false , false ) ; final TypeReference script = getScriptBuilderImpl ( ) ; final TypeReference scriptInterface = getScriptBuilderInterface ( ) ; final StringConcatenationClient content = new StringConcatenationClient ( ) { @ Override protected void appendTo ( TargetStringConcatenation it ) { it . append ( "@SuppressWarnings(\"all\")" ) ; //$NON-NLS-1$ it . newLine ( ) ; it . append ( "public class " ) ; //$NON-NLS-1$ it . append ( script . getSimpleName ( ) ) ; it . append ( " extends " ) ; //$NON-NLS-1$ it . append ( getAbstractBuilderImpl ( ) ) ; it . append ( " implements " ) ; //$NON-NLS-1$ it . append ( scriptInterface ) ; it . append ( " {" ) ; //$NON-NLS-1$ it . newLineIfNotEmpty ( ) ; it . newLine ( ) ; it . append ( generateFieldsAndMethods ( false , false ) ) ; for ( final StringConcatenationClient element : topElements ) { it . append ( element ) ; } it . append ( "}" ) ; //$NON-NLS-1$ it . newLineIfNotEmpty ( ) ; } } ; final JavaFileAccess javaFile = getFileAccessFactory ( ) . createJavaFile ( script , content ) ; javaFile . writeTo ( getSrcGen ( ) ) ; }
Generate the script builder default implementation .
364
8
33,776
public static Class < ? > findClass ( String classname ) { Class < ? > type = null ; final ClassLoader loader = ClassLoaderFinder . findClassLoader ( ) ; if ( loader != null ) { try { type = loader . loadClass ( classname ) ; } catch ( ClassNotFoundException e ) { // } } if ( type == null ) { try { type = ClassFinder . class . getClassLoader ( ) . loadClass ( classname ) ; } catch ( ClassNotFoundException e ) { // } } if ( type == null ) { try { type = Class . forName ( classname ) ; } catch ( ClassNotFoundException e ) { // } } if ( type != null && ! LogService . class . isAssignableFrom ( type ) ) { return type ; } return null ; }
Find the class with a search policy .
177
8
33,777
protected void generatePreamble ( IStyleAppendable it ) { clearHilights ( ) ; final String nm = getLanguageSimpleName ( ) . toLowerCase ( ) ; final String cmd = Strings . toFirstUpper ( getLanguageSimpleName ( ) . toLowerCase ( ) ) + "HiLink" ; //$NON-NLS-1$ appendComment ( it , "Quit when a syntax file was already loaded" ) ; //$NON-NLS-1$ appendCmd ( it , false , "if !exists(\"main_syntax\")" ) . increaseIndentation ( ) . newLine ( ) ; //$NON-NLS-1$ appendCmd ( it , false , "if exists(\"b:current_syntax\")" ) . increaseIndentation ( ) . newLine ( ) ; //$NON-NLS-1$ appendCmd ( it , false , "finish" ) . decreaseIndentation ( ) . newLine ( ) ; //$NON-NLS-1$ appendCmd ( it , "endif" ) ; //$NON-NLS-1$ appendComment ( it , "we define it here so that included files can test for it" ) ; //$NON-NLS-1$ appendCmd ( it , "let main_syntax='" + nm + "'" ) ; //$NON-NLS-1$ //$NON-NLS-2$ appendCmd ( it , false , "syn region " + nm + "Fold start=\"{\" end=\"}\" transparent fold" ) ; //$NON-NLS-1$ //$NON-NLS-2$ it . decreaseIndentation ( ) . newLine ( ) ; appendCmd ( it , "endif" ) ; //$NON-NLS-1$ it . newLine ( ) ; appendCmd ( it , "let s:cpo_save = &cpo" ) ; //$NON-NLS-1$ appendCmd ( it , "set cpo&vim" ) ; //$NON-NLS-1$ it . newLine ( ) ; appendComment ( it , "don't use standard HiLink, it will not work with included syntax files" ) ; //$NON-NLS-1$ appendCmd ( it , false , "if version < 508" ) . increaseIndentation ( ) . newLine ( ) ; //$NON-NLS-1$ appendCmd ( it , false , "command! -nargs=+ " + cmd + " hi link <args>" ) . decreaseIndentation ( ) . newLine ( ) ; //$NON-NLS-1$ //$NON-NLS-2$ appendCmd ( it , false , "else" ) . increaseIndentation ( ) . newLine ( ) ; //$NON-NLS-1$ appendCmd ( it , false , "command! -nargs=+ " + cmd + " hi def link <args>" ) . decreaseIndentation ( ) . newLine ( ) ; //$NON-NLS-1$ //$NON-NLS-2$ appendCmd ( it , "endif" ) ; //$NON-NLS-1$ it . newLine ( ) ; appendComment ( it , "some characters that cannot be in a SARL program (outside a string)" ) ; //$NON-NLS-1$ appendMatch ( it , nm + "Error" , "[\\\\`]" ) ; //$NON-NLS-1$ //$NON-NLS-2$ it . newLine ( ) ; }
Generate the preamble of the Vim style .
807
11
33,778
protected void generatePrimitiveTypes ( IStyleAppendable it , Iterable < String > types ) { final Iterator < String > iterator = types . iterator ( ) ; if ( iterator . hasNext ( ) ) { appendComment ( it , "primitive types." ) ; //$NON-NLS-1$ appendMatch ( it , "sarlArrayDeclaration" , "\\(\\s*\\[\\s*\\]\\)*" , true ) ; //$NON-NLS-1$//$NON-NLS-2$ it . append ( "syn keyword sarlPrimitiveType" ) ; //$NON-NLS-1$ do { it . append ( " " ) ; //$NON-NLS-1$ it . append ( iterator . next ( ) ) ; } while ( iterator . hasNext ( ) ) ; it . append ( " nextgroup=sarlArrayDeclaration" ) . newLine ( ) ; //$NON-NLS-1$ appendCluster ( it , "sarlPrimitiveType" ) ; //$NON-NLS-1$ hilight ( "sarlPrimitiveType" , VimSyntaxGroup . SPECIAL ) ; //$NON-NLS-1$ hilight ( "sarlArrayDeclaration" , VimSyntaxGroup . SPECIAL ) ; //$NON-NLS-1$ it . newLine ( ) ; } }
Generate the keywords for the primitive types .
312
9
33,779
protected void generateComments ( IStyleAppendable it ) { appendComment ( it , "comments" ) ; //$NON-NLS-1$ appendRegion ( it , "sarlComment" , "/\\*" , "\\*/" , "@Spell" ) ; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ appendCmd ( it , "syn match sarlCommentStar contained \"^\\s*\\*[^/]\"me=e-1" ) ; //$NON-NLS-1$ appendMatch ( it , "sarlCommentStar" , "^\\s*\\*$" , true ) ; //$NON-NLS-1$ //$NON-NLS-2$ appendMatch ( it , "sarlLineComment" , "//.*" , "@Spell" ) ; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ appendCluster ( it , "sarlComment" , "sarlLineComment" ) ; //$NON-NLS-1$ //$NON-NLS-2$ hilight ( "sarlComment" , VimSyntaxGroup . COMMENT ) ; //$NON-NLS-1$ hilight ( "sarlLineComment" , VimSyntaxGroup . COMMENT ) ; //$NON-NLS-1$ appendComment ( it , "match the special comment /**/" ) ; //$NON-NLS-1$ appendMatch ( it , "sarlComment" , "/\\*\\*/" ) ; //$NON-NLS-1$ //$NON-NLS-2$ it . newLine ( ) ; }
Generate the Vim comments .
408
6
33,780
protected void generateStrings ( IStyleAppendable it ) { appendComment ( it , "Strings constants" ) ; //$NON-NLS-1$ appendMatch ( it , "sarlSpecialError" , "\\\\." , true ) ; //$NON-NLS-1$ //$NON-NLS-2$ appendMatch ( it , "sarlSpecialCharError" , "[^']" , true ) ; //$NON-NLS-1$ //$NON-NLS-2$ appendMatch ( it , "sarlSpecialChar" , "\\\\\\([4-9]\\d\\|[0-3]\\d\\d\\|[\"\\\\'ntbrf]\\|u\\x\\{4\\}\\)" , true ) ; //$NON-NLS-1$ //$NON-NLS-2$ appendRegion ( it , true , "sarlString" , "\"" , "\"" , //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ "sarlSpecialChar" , "sarlSpecialError" , "@Spell" ) ; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ appendRegion ( it , true , "sarlString" , "'" , "'" , //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ "sarlSpecialChar" , "sarlSpecialError" , "@Spell" ) ; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ appendCluster ( it , "sarlString" ) ; //$NON-NLS-1$ hilight ( "sarlString" , VimSyntaxGroup . CONSTANT ) ; //$NON-NLS-1$ it . newLine ( ) ; }
Generate the Vim strings of characters .
454
8
33,781
protected void generateNumericConstants ( IStyleAppendable it ) { appendComment ( it , "numerical constants" ) ; //$NON-NLS-1$ appendMatch ( it , "sarlNumber" , "[0-9][0-9]*\\.[0-9]\\+([eE][0-9]\\+)\\?[fFdD]\\?" ) ; //$NON-NLS-1$ //$NON-NLS-2$ appendMatch ( it , "sarlNumber" , "0[xX][0-9a-fA-F]\\+" ) ; //$NON-NLS-1$ //$NON-NLS-2$ appendMatch ( it , "sarlNumber" , "[0-9]\\+[lL]\\?" ) ; //$NON-NLS-1$ //$NON-NLS-2$ appendCluster ( it , "sarlNumber" ) ; //$NON-NLS-1$ hilight ( "sarlNumber" , VimSyntaxGroup . CONSTANT ) ; //$NON-NLS-1$ it . newLine ( ) ; }
Generate the Vim numeric constants .
269
7
33,782
protected void generateAnnotations ( IStyleAppendable it ) { appendComment ( it , "annnotation" ) ; //$NON-NLS-1$ appendMatch ( it , "sarlAnnotation" , "@[_a-zA-Z][_0-9a-zA-Z]*\\([.$][_a-zA-Z][_0-9a-zA-Z]*\\)*" ) ; //$NON-NLS-1$ //$NON-NLS-2$ appendCluster ( it , "sarlAnnotation" ) ; //$NON-NLS-1$ hilight ( "sarlAnnotation" , VimSyntaxGroup . PRE_PROCESSOR ) ; //$NON-NLS-1$ it . newLine ( ) ; }
Generate the annotations .
183
5
33,783
protected void generateKeywords ( IStyleAppendable it , String family , VimSyntaxGroup color , Iterable < String > keywords ) { appendComment ( it , "keywords for the '" + family + "' family." ) ; //$NON-NLS-1$ //$NON-NLS-2$ final Iterator < String > iterator = keywords . iterator ( ) ; if ( iterator . hasNext ( ) ) { it . append ( "syn keyword " ) ; //$NON-NLS-1$ it . append ( family ) ; do { it . append ( " " ) ; //$NON-NLS-1$ it . append ( iterator . next ( ) ) ; } while ( iterator . hasNext ( ) ) ; } it . newLine ( ) ; appendCluster ( it , family ) ; hilight ( family , color ) ; it . newLine ( ) ; }
Generate the Vim keywords .
197
6
33,784
protected IStyleAppendable appendCmd ( IStyleAppendable it , String text ) { return appendCmd ( it , true , text ) ; }
Append a Vim command .
34
6
33,785
protected void generateFileTypeDetectionScript ( String basename ) { final CharSequence scriptContent = getFileTypeDetectionScript ( ) ; if ( scriptContent != null ) { final String textualContent = scriptContent . toString ( ) ; if ( ! Strings . isEmpty ( textualContent ) ) { final byte [ ] bytes = textualContent . getBytes ( ) ; for ( final String output : getOutputs ( ) ) { final File directory = new File ( output , FTDETECT_FOLDER ) . getAbsoluteFile ( ) ; try { final File outputFile = new File ( directory , basename ) ; outputFile . getParentFile ( ) . mkdirs ( ) ; Files . write ( Paths . get ( outputFile . getAbsolutePath ( ) ) , bytes ) ; } catch ( IOException e ) { throw new RuntimeException ( e ) ; } } } } }
Generate the script for detecting the SARL files .
193
11
33,786
protected CharSequence getFileTypeDetectionScript ( ) { return concat ( "\" Vim filetype-detection file" , //$NON-NLS-1$ "\" Language: " + getLanguageSimpleName ( ) , //$NON-NLS-1$ "\" Version: " + getLanguageVersion ( ) , //$NON-NLS-1$ "" , //$NON-NLS-1$ "au BufRead,BufNewFile *." + getLanguage ( ) . getFileExtensions ( ) . get ( 0 ) //$NON-NLS-1$ + " set filetype=" + getLanguageSimpleName ( ) . toLowerCase ( ) ) ; //$NON-NLS-1$ }
Replies the script for detecting the SARL files .
166
11
33,787
@ Override protected Set < OutputConfiguration > getOutputConfigurations ( IProject project ) { final Set < OutputConfiguration > original = this . configurationProvider . getOutputConfigurations ( getProject ( ) ) ; return Sets . filter ( original , it -> ! ExtraLanguageOutputConfigurations . isExtraLanguageOutputConfiguration ( it . getName ( ) ) ) ; }
Replies the output configurations for the given project .
75
10
33,788
public static IntegerRange parseRange ( String stringRange , int minValue ) { final String sepPattern = "[,;\\-:]" ; //$NON-NLS-1$ try { final Matcher matcher = Pattern . compile ( "^\\s*" //$NON-NLS-1$ + "(?:(?<left>[0-9]+)\\s*(?:(?<sep1>" + sepPattern + ")\\s*(?<right1>[0-9]+)?)?)" //$NON-NLS-1$ //$NON-NLS-2$ + "|(?:(?<sep2>" + sepPattern + ")\\s*(?<right2>[0-9]+))" //$NON-NLS-1$ //$NON-NLS-2$ + "\\s*$" ) //$NON-NLS-1$ . matcher ( stringRange ) ; if ( matcher . matches ( ) ) { final String left = matcher . group ( "left" ) ; //$NON-NLS-1$ final String sep = select ( matcher . group ( "sep1" ) , matcher . group ( "sep2" ) ) ; //$NON-NLS-1$ //$NON-NLS-2$ final String right = select ( matcher . group ( "right1" ) , matcher . group ( "right2" ) ) ; //$NON-NLS-1$ //$NON-NLS-2$ if ( Strings . isEmpty ( left ) ) { if ( ! Strings . isEmpty ( sep ) && ! Strings . isEmpty ( right ) ) { return new IntegerRange ( minValue , Math . max ( minValue , Integer . valueOf ( right ) ) ) ; } } else { final int leftValue = Math . max ( minValue , Integer . valueOf ( left ) ) ; if ( Strings . isEmpty ( sep ) ) { return new IntegerRange ( leftValue , leftValue ) ; } if ( Strings . isEmpty ( right ) ) { return new IntegerRange ( leftValue , Integer . MAX_VALUE ) ; } final int rightValue = Math . max ( minValue , Integer . valueOf ( right ) ) ; if ( rightValue < leftValue ) { return new IntegerRange ( rightValue , leftValue ) ; } return new IntegerRange ( leftValue , rightValue ) ; } } } catch ( Throwable exception ) { throw new IllegalArgumentException ( MessageFormat . format ( Messages . GenerateMojo_4 , stringRange ) , exception ) ; } throw new IllegalArgumentException ( MessageFormat . format ( Messages . GenerateMojo_4 , stringRange ) ) ; }
Parse a range of integers .
607
7
33,789
public static boolean isHtmlFileExtension ( String extension ) { for ( final String ext : HTML_FILE_EXTENSIONS ) { if ( Strings . equal ( ext , extension ) ) { return true ; } } return false ; }
Replies if the given extension is for HTML file .
51
11
33,790
@ Inject public void setDocumentParser ( SarlDocumentationParser parser ) { assert parser != null ; this . parser = parser ; this . parser . reset ( ) ; }
Change the document parser .
37
5
33,791
public Iterable < ValidationComponent > getStandardValidationComponents ( File inputFile ) { final ValidationHandler handler = new ValidationHandler ( ) ; getDocumentParser ( ) . extractValidationComponents ( inputFile , handler ) ; return handler . getComponents ( ) ; }
Extract the validation components from the given file .
61
10
33,792
public final List < DynamicValidationComponent > getMarkerSpecificValidationComponents ( File inputFile , File rootFolder , DynamicValidationContext context ) { return getSpecificValidationComponents ( transform ( inputFile , false ) , inputFile , rootFolder , context ) ; }
Extract the validation components that are specific to the marker language .
59
13
33,793
public static IBundleDependencies getJanusPlatformClasspath ( ) { final Bundle bundle = Platform . getBundle ( JanusEclipsePlugin . JANUS_KERNEL_PLUGIN_ID ) ; return BundleUtil . resolveBundleDependencies ( bundle , new JanusBundleJavadocURLMappings ( ) , JANUS_ROOT_BUNDLE_NAMES ) ; }
Replies the standard classpath for running the Janus platform .
93
13
33,794
public static int compare ( XtendParameter p1 , XtendParameter p2 ) { if ( p1 != p2 ) { if ( p1 == null ) { return Integer . MIN_VALUE ; } if ( p2 == null ) { return Integer . MAX_VALUE ; } final JvmTypeReference t1 = p1 . getParameterType ( ) ; final JvmTypeReference t2 = p2 . getParameterType ( ) ; if ( t1 != t2 ) { final int cmp ; if ( t1 == null ) { cmp = Integer . MIN_VALUE ; } else if ( t2 == null ) { cmp = Integer . MAX_VALUE ; } else { cmp = t1 . getIdentifier ( ) . compareTo ( t2 . getIdentifier ( ) ) ; } if ( cmp != 0 ) { return cmp ; } } } return 0 ; }
Compare the two formal parameters .
193
6
33,795
public ISarlBehaviorUnitBuilder addSarlBehaviorUnit ( String name ) { ISarlBehaviorUnitBuilder builder = this . iSarlBehaviorUnitBuilderProvider . get ( ) ; builder . eInit ( getSarlBehavior ( ) , name , getTypeResolutionContext ( ) ) ; return builder ; }
Create a SarlBehaviorUnit .
69
8
33,796
public ISarlFieldBuilder addVarSarlField ( String name ) { ISarlFieldBuilder builder = this . iSarlFieldBuilderProvider . get ( ) ; builder . eInit ( getSarlBehavior ( ) , name , "var" , getTypeResolutionContext ( ) ) ; return builder ; }
Create a SarlField .
66
6
33,797
public ISarlActionBuilder addDefSarlAction ( String name ) { ISarlActionBuilder builder = this . iSarlActionBuilderProvider . get ( ) ; builder . eInit ( getSarlBehavior ( ) , name , "def" , getTypeResolutionContext ( ) ) ; return builder ; }
Create a SarlAction .
66
6
33,798
public ISarlClassBuilder addSarlClass ( String name ) { ISarlClassBuilder builder = this . iSarlClassBuilderProvider . get ( ) ; builder . eInit ( getSarlBehavior ( ) , name , getTypeResolutionContext ( ) ) ; return builder ; }
Create a SarlClass .
61
6
33,799
public void addSarlCapacityUses ( String ... name ) { if ( name != null && name . length > 0 ) { SarlCapacityUses member = SarlFactory . eINSTANCE . createSarlCapacityUses ( ) ; this . sarlBehavior . getMembers ( ) . add ( member ) ; member . setAnnotationInfo ( XtendFactory . eINSTANCE . createXtendMember ( ) ) ; Collection < JvmParameterizedTypeReference > thecollection = member . getCapacities ( ) ; for ( final String aname : name ) { if ( ! Strings . isEmpty ( aname ) ) { thecollection . add ( newTypeRef ( this . sarlBehavior , aname ) ) ; } } } }
Create a SarlCapacityUses .
166
9