idx int64 0 41.2k | question stringlengths 74 4.04k | target stringlengths 7 750 |
|---|---|---|
33,800 | @ 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 . |
33,801 | 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 . |
33,802 | public static void configureSARLProject ( IProject project , boolean addNatures , boolean configureJavaNature , boolean createFolders , IProgressMonitor monitor ) { try { final SubMonitor subMonitor = SubMonitor . convert ( monitor , 11 ) ; final IStatus status = Status . OK_STATUS ; if ( addNatures ) { addSarlNatures ( project , subMonitor . newChild ( 1 ) ) ; if ( status != null && ! status . isOK ( ) ) { SARLEclipsePlugin . getDefault ( ) . getLog ( ) . log ( status ) ; } } 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 ) ; SARLPreferences . setSpecificSARLConfigurationFor ( project , generationFolder . get ( ) . getProjectRelativePath ( ) ) ; subMonitor . worked ( 1 ) ; if ( configureJavaNature ) { if ( ! addNatures ) { addNatures ( project , subMonitor . newChild ( 1 ) , JavaCore . NATURE_ID ) ; } final IJavaProject javaProject = JavaCore . create ( project ) ; subMonitor . worked ( 1 ) ; 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 . |
33,803 | 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 ) ; 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 . |
33,804 | 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 , 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 . |
33,805 | @ 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 ) ) { 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 ) ) { 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 . |
33,806 | 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 ) ; 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 . |
33,807 | public static IStatus addSarlNatures ( IProject project , IProgressMonitor monitor ) { return addNatures ( project , monitor , getSarlNatures ( ) ) ; } | Add the SARL natures to the given project . |
33,808 | 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 . |
33,809 | 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 . |
33,810 | 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 ( "[]" ) ) { 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 . |
33,811 | 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 ( ) ; final IFormalParameterBuilder [ ] sarlParams = createFormalParametersWith ( name -> cons . addParameter ( name ) , constructor ) ; final IBlockExpressionBuilder block = cons . getExpression ( ) ; final IExpressionBuilder superCall = block . addExpression ( ) ; final XFeatureCall call = XbaseFactory . eINSTANCE . createXFeatureCall ( ) ; superCall . setXExpression ( call ) ; superCall . setDocumentation ( block . getAutoGeneratedActionString ( ) ) ; 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 . |
33,812 | 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 ) ; final IBlockExpressionBuilder block = action . getExpression ( ) ; if ( ( type . eClass ( ) != TypesPackage . Literals . JVM_GENERIC_TYPE || ! ( ( JvmGenericType ) type ) . isInterface ( ) ) && superOperation != null && ! superOperation . isAbstract ( ) ) { 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 . |
33,813 | 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 . |
33,814 | 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 . |
33,815 | 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 . |
33,816 | 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 . |
33,817 | protected static String trimFileExtension ( String fileName ) { if ( fileName . lastIndexOf ( '.' ) == - 1 ) { return fileName ; } return fileName . substring ( 0 , fileName . lastIndexOf ( '.' ) ) ; } | Remove the file extension . |
33,818 | protected void generateMetadata ( IXmlStyleAppendable it ) { it . appendTagWithValue ( "property" , Strings . concat ( ";" , getMimeTypes ( ) ) , "name" , "mimetypes" ) ; final StringBuilder buffer = new StringBuilder ( ) ; for ( final String fileExtension : getLanguage ( ) . getFileExtensions ( ) ) { if ( buffer . length ( ) > 0 ) { buffer . append ( ";" ) ; } buffer . append ( "*." ) . append ( fileExtension ) ; } it . appendTagWithValue ( "property" , buffer . toString ( ) , "name" , "globs" ) ; it . appendTagWithValue ( "property" , "//" , "name" , "line-comment-start" ) ; it . appendTagWithValue ( "property" , "/*" , "name" , "block-comment-start" ) ; it . appendTagWithValue ( "property" , "*/" , "name" , "block-comment-end" ) ; } | Generate the metadata section . |
33,819 | @ SuppressWarnings ( "static-method" ) protected void generateStyles ( IXmlStyleAppendable it ) { it . appendTag ( "style" , "id" , "comment" , "_name" , "Comment" , "map-to" , "def:comment" ) ; it . appendTag ( "style" , "id" , "error" , "_name" , "Error" , "map-to" , "def:error" ) ; it . appendTag ( "style" , "id" , "escaped-character" , "_name" , "Escaped Character" , "map-to" , "def:special-char" ) ; it . appendTag ( "style" , "id" , "string" , "_name" , "String" , "map-to" , "def:string" ) ; it . appendTag ( "style" , "id" , "keyword" , "_name" , "Keyword" , "map-to" , "def:keyword" ) ; it . appendTag ( "style" , "id" , "literal" , "_name" , "Literal" , "map-to" , "def:special-constant" ) ; it . appendTag ( "style" , "id" , "number" , "_name" , "Number" , "map-to" , "def:number" ) ; it . appendTag ( "style" , "id" , "operator" , "_name" , "Operator" , "map-to" , "def:operator" ) ; it . appendTag ( "style" , "id" , "identifier" , "_name" , "Identifier" , "map-to" , "def:text" ) ; it . appendTag ( "style" , "id" , "annotation" , "_name" , "Annotation" , "map-to" , "def:preprocessor" ) ; } | Generate the style section . |
33,820 | 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" } ) ; if ( file != null && file . exists ( ) ) { dialog . setFileName ( file . getAbsolutePath ( ) ) ; } final String selectedFile = dialog . open ( ) ; if ( selectedFile != null ) { final IPath path = Path . fromOSString ( selectedFile ) ; createWorkingCopy ( ) ; this . workingCopy . setJarFile ( path ) ; final IStatus status = validate ( ) ; initializeFields ( ) ; setPageStatus ( status ) ; updatePageStatus ( ) ; } } | Ask to the user to selected the SRE . |
33,821 | 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 . |
33,822 | public static IPath getSourceBundlePath ( Bundle bundle , IPath bundleLocation ) { IPath sourcesPath = null ; try { final IPath srcFolderPath = getSourceRootProjectFolderPath ( bundle ) ; if ( srcFolderPath == null ) { 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 . |
33,823 | public static IPath getBundlePath ( Bundle bundle ) { IPath path = getBinFolderPath ( bundle ) ; if ( path == null ) { 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 . |
33,824 | 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 ( ) ; final SarlFormalParameter jvmParam = getAssociatedElement ( SarlFormalParameter . class , param , resource ) ; final URI uri = EcoreUtil2 . getNormalizedURI ( jvmParam ) ; jvmVoidProxy . eSetProxyURI ( uri ) ; } container . setFeature ( jvmVoid ) ; } | Replies the JvmIdentifiable that corresponds to the formal parameter . |
33,825 | 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 . |
33,826 | 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 . |
33,827 | @ SuppressWarnings ( "static-method" ) public JvmAnnotationReference findAnnotation ( JvmAnnotationTarget annotationTarget , String lookupType ) { 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 . |
33,828 | 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 . |
33,829 | @ SuppressWarnings ( "checkstyle:all" ) protected StringConcatenationClient generateTopElement ( CodeElementExtractor . ElementDescription description , boolean forInterface , boolean forAppender ) { final String topElementName = Strings . toFirstUpper ( description . getName ( ) ) ; final TypeReference builderType = getCodeElementExtractor ( ) . getElementBuilderInterface ( topElementName ) ; return new StringConcatenationClient ( ) { protected void appendTo ( TargetStringConcatenation it ) { if ( ! forInterface && ! forAppender ) { it . append ( "\t@" ) ; it . append ( Inject . class ) ; it . newLine ( ) ; it . append ( "\tprivate " ) ; it . append ( Provider . class ) ; it . append ( "<" ) ; it . append ( builderType ) ; it . append ( "> " ) ; it . append ( Strings . toFirstLower ( topElementName ) ) ; it . append ( "Provider;" ) ; it . newLineIfNotEmpty ( ) ; it . newLine ( ) ; } it . append ( "\t/** Create " + getAorAnArticle ( topElementName ) + " " + topElementName + " builder." ) ; it . newLine ( ) ; it . append ( "\t * @param name the name of the " + topElementName + "." ) ; it . newLine ( ) ; it . append ( "\t * @return the builder." ) ; it . newLine ( ) ; it . append ( "\t */" ) ; it . newLine ( ) ; it . append ( "\t" ) ; if ( ! forInterface ) { it . append ( "public " ) ; } it . append ( builderType ) ; it . append ( " add" ) ; it . append ( topElementName ) ; it . append ( "(String name)" ) ; if ( forInterface ) { it . append ( ";" ) ; it . newLineIfNotEmpty ( ) ; } else { it . append ( " {" ) ; it . newLine ( ) ; if ( forAppender ) { it . append ( "\t\t return this.builder.add" ) ; it . append ( topElementName ) ; it . append ( "(name);" ) ; } else { it . append ( "\t\t" ) ; it . append ( builderType ) ; it . append ( " builder = this." ) ; it . append ( Strings . toFirstLower ( topElementName ) ) ; it . append ( "Provider.get();" ) ; it . newLine ( ) ; it . append ( "\t\tbuilder.eInit(getScript(), name, getTypeResolutionContext());" ) ; it . newLine ( ) ; it . append ( "\t\treturn builder;" ) ; } it . newLine ( ) ; it . append ( "\t}" ) ; it . newLineIfNotEmpty ( ) ; } it . newLine ( ) ; } } ; } | Extract a top element from the grammar . |
33,830 | 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 . |
33,831 | protected void generateIScriptBuilder ( ) { final List < StringConcatenationClient > topElements = generateTopElements ( true , false ) ; final TypeReference builder = getScriptBuilderInterface ( ) ; final StringConcatenationClient content = new StringConcatenationClient ( ) { protected void appendTo ( TargetStringConcatenation it ) { it . append ( "/** Builder of " + getLanguageName ( ) + " scripts." ) ; it . newLine ( ) ; it . append ( " *" ) ; it . newLine ( ) ; it . append ( " * <p>This builder is provided for helping to create " + getLanguageName ( ) + " Ecore elements." ) ; it . newLine ( ) ; it . append ( " *" ) ; it . newLine ( ) ; it . append ( " * <p>Do not forget to invoke {@link #finalizeScript()} for creating imports, etc." ) ; it . newLine ( ) ; it . append ( " */" ) ; it . newLine ( ) ; it . append ( "@SuppressWarnings(\"all\")" ) ; it . newLine ( ) ; it . append ( "public interface " ) ; it . append ( builder . getSimpleName ( ) ) ; it . append ( " {" ) ; it . newLineIfNotEmpty ( ) ; it . newLine ( ) ; it . append ( generateFieldsAndMethods ( true , false ) ) ; for ( final StringConcatenationClient element : topElements ) { it . append ( element ) ; } it . append ( "}" ) ; it . newLineIfNotEmpty ( ) ; it . newLine ( ) ; } } ; final JavaFileAccess javaFile = getFileAccessFactory ( ) . createJavaFile ( builder , content ) ; javaFile . writeTo ( getSrcGen ( ) ) ; } | Generate the script builder interface . |
33,832 | protected void generateScriptSourceAppender ( ) { final List < StringConcatenationClient > topElements = generateTopElements ( false , true ) ; final TypeReference appender = getCodeElementExtractor ( ) . getElementAppenderImpl ( "Script" ) ; final StringConcatenationClient content = new StringConcatenationClient ( ) { protected void appendTo ( TargetStringConcatenation it ) { it . append ( "/** Appender of " + getLanguageName ( ) + " scripts." ) ; it . newLine ( ) ; it . append ( " *" ) ; it . newLine ( ) ; it . append ( " */" ) ; it . newLine ( ) ; it . append ( "@SuppressWarnings(\"all\")" ) ; it . newLine ( ) ; it . append ( "public class " ) ; it . append ( getScriptAppender ( ) . getSimpleName ( ) ) ; it . append ( " extends " ) ; it . append ( getCodeElementExtractor ( ) . getAbstractAppenderImpl ( ) ) ; it . append ( " implements " ) ; it . append ( getScriptBuilderInterface ( ) ) ; it . append ( " {" ) ; it . newLineIfNotEmpty ( ) ; it . newLine ( ) ; it . append ( generateFieldsAndMethods ( false , true ) ) ; for ( final StringConcatenationClient element : topElements ) { it . append ( element ) ; } it . append ( "}" ) ; it . newLineIfNotEmpty ( ) ; it . newLine ( ) ; } } ; final JavaFileAccess javaFile = getFileAccessFactory ( ) . createJavaFile ( appender , content ) ; javaFile . writeTo ( getSrcGen ( ) ) ; } | Generate the script appender . |
33,833 | protected void generateScriptBuilderImpl ( ) { final List < StringConcatenationClient > topElements = generateTopElements ( false , false ) ; final TypeReference script = getScriptBuilderImpl ( ) ; final TypeReference scriptInterface = getScriptBuilderInterface ( ) ; final StringConcatenationClient content = new StringConcatenationClient ( ) { protected void appendTo ( TargetStringConcatenation it ) { it . append ( "@SuppressWarnings(\"all\")" ) ; it . newLine ( ) ; it . append ( "public class " ) ; it . append ( script . getSimpleName ( ) ) ; it . append ( " extends " ) ; it . append ( getAbstractBuilderImpl ( ) ) ; it . append ( " implements " ) ; it . append ( scriptInterface ) ; it . append ( " {" ) ; it . newLineIfNotEmpty ( ) ; it . newLine ( ) ; it . append ( generateFieldsAndMethods ( false , false ) ) ; for ( final StringConcatenationClient element : topElements ) { it . append ( element ) ; } it . append ( "}" ) ; it . newLineIfNotEmpty ( ) ; } } ; final JavaFileAccess javaFile = getFileAccessFactory ( ) . createJavaFile ( script , content ) ; javaFile . writeTo ( getSrcGen ( ) ) ; } | Generate the script builder default implementation . |
33,834 | 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 . |
33,835 | protected void generatePreamble ( IStyleAppendable it ) { clearHilights ( ) ; final String nm = getLanguageSimpleName ( ) . toLowerCase ( ) ; final String cmd = Strings . toFirstUpper ( getLanguageSimpleName ( ) . toLowerCase ( ) ) + "HiLink" ; appendComment ( it , "Quit when a syntax file was already loaded" ) ; appendCmd ( it , false , "if !exists(\"main_syntax\")" ) . increaseIndentation ( ) . newLine ( ) ; appendCmd ( it , false , "if exists(\"b:current_syntax\")" ) . increaseIndentation ( ) . newLine ( ) ; appendCmd ( it , false , "finish" ) . decreaseIndentation ( ) . newLine ( ) ; appendCmd ( it , "endif" ) ; appendComment ( it , "we define it here so that included files can test for it" ) ; appendCmd ( it , "let main_syntax='" + nm + "'" ) ; appendCmd ( it , false , "syn region " + nm + "Fold start=\"{\" end=\"}\" transparent fold" ) ; it . decreaseIndentation ( ) . newLine ( ) ; appendCmd ( it , "endif" ) ; it . newLine ( ) ; appendCmd ( it , "let s:cpo_save = &cpo" ) ; appendCmd ( it , "set cpo&vim" ) ; it . newLine ( ) ; appendComment ( it , "don't use standard HiLink, it will not work with included syntax files" ) ; appendCmd ( it , false , "if version < 508" ) . increaseIndentation ( ) . newLine ( ) ; appendCmd ( it , false , "command! -nargs=+ " + cmd + " hi link <args>" ) . decreaseIndentation ( ) . newLine ( ) ; appendCmd ( it , false , "else" ) . increaseIndentation ( ) . newLine ( ) ; appendCmd ( it , false , "command! -nargs=+ " + cmd + " hi def link <args>" ) . decreaseIndentation ( ) . newLine ( ) ; appendCmd ( it , "endif" ) ; it . newLine ( ) ; appendComment ( it , "some characters that cannot be in a SARL program (outside a string)" ) ; appendMatch ( it , nm + "Error" , "[\\\\`]" ) ; it . newLine ( ) ; } | Generate the preamble of the Vim style . |
33,836 | protected void generatePostamble ( IStyleAppendable it ) { appendComment ( it , "catch errors caused by wrong parenthesis" ) ; appendCmd ( it , "syn region sarlParenT transparent matchgroup=sarlParen start=\"(\" end=\")\" contains=@sarlTop,sarlParenT1" ) ; appendCmd ( it , "syn region sarlParenT1 transparent matchgroup=sarlParen1 start=\"(\" end=\")\"" + " contains=@sarlTop,sarlParenT2 contained" ) ; appendCmd ( it , "syn region sarlParenT2 transparent matchgroup=sarlParen2 start=\"(\" end=\")\"" + " contains=@sarlTop,sarlParenT contained" ) ; appendCmd ( it , "syn match sarlParenError \")\"" ) ; appendComment ( it , "catch errors caused by wrong square parenthesis" ) ; appendCmd ( it , "syn region sarlParenT transparent matchgroup=sarlParen start=\"\\[\" end=\"\\]\"" + " contains=@sarlTop,sarlParenT1" ) ; appendCmd ( it , "syn region sarlParenT1 transparent matchgroup=sarlParen1 start=\"\\[\" end=\"\\]\"" + " contains=@sarlTop,sarlParenT2 contained" ) ; appendCmd ( it , "syn region sarlParenT2 transparent matchgroup=sarlParen2 start=\"\\[\" end=\"\\]\"" + " contains=@sarlTop,sarlParenT contained" ) ; appendCmd ( it , "syn match sarlParenError \"\\]\"" ) ; it . newLine ( ) ; appendCmd ( it , "SarlHiLink sarlParenError sarlError" ) ; it . newLine ( ) ; appendCmd ( it , false , "if !exists(\"sarl_minlines\")" ) . increaseIndentation ( ) . newLine ( ) ; appendCmd ( it , false , "let sarl_minlines = 10" ) . decreaseIndentation ( ) . newLine ( ) ; appendCmd ( it , "endif" ) ; appendCmd ( it , "exec \"syn sync ccomment sarlComment minlines=\" . sarl_minlines" ) ; it . newLine ( ) ; appendComment ( it , "The default highlighting." ) ; for ( final Entry < String , VimSyntaxGroup > hilight : this . hilights . entrySet ( ) ) { appendCmd ( it , "SarlHiLink " + hilight . getKey ( ) + " " + hilight . getValue ( ) . getVimConstant ( ) ) ; } clearHilights ( ) ; it . newLine ( ) ; appendCmd ( it , "delcommand SarlHiLink" ) ; it . newLine ( ) ; appendCmd ( it , "let b:current_syntax = \"" + getLanguageSimpleName ( ) . toLowerCase ( ) + "\"" ) ; it . newLine ( ) ; appendCmd ( it , false , "if main_syntax == '" + getLanguageSimpleName ( ) . toLowerCase ( ) + "'" ) ; it . increaseIndentation ( ) . newLine ( ) ; appendCmd ( it , false , "unlet main_syntax" ) . decreaseIndentation ( ) . newLine ( ) ; appendCmd ( it , "endif" ) ; it . newLine ( ) ; appendCmd ( it , "let b:spell_options=\"contained\"" ) ; appendCmd ( it , "let &cpo = s:cpo_save" ) ; appendCmd ( it , "unlet s:cpo_save" ) ; } | Generate the postamble of the Vim style . |
33,837 | protected void generatePrimitiveTypes ( IStyleAppendable it , Iterable < String > types ) { final Iterator < String > iterator = types . iterator ( ) ; if ( iterator . hasNext ( ) ) { appendComment ( it , "primitive types." ) ; appendMatch ( it , "sarlArrayDeclaration" , "\\(\\s*\\[\\s*\\]\\)*" , true ) ; it . append ( "syn keyword sarlPrimitiveType" ) ; do { it . append ( " " ) ; it . append ( iterator . next ( ) ) ; } while ( iterator . hasNext ( ) ) ; it . append ( " nextgroup=sarlArrayDeclaration" ) . newLine ( ) ; appendCluster ( it , "sarlPrimitiveType" ) ; hilight ( "sarlPrimitiveType" , VimSyntaxGroup . SPECIAL ) ; hilight ( "sarlArrayDeclaration" , VimSyntaxGroup . SPECIAL ) ; it . newLine ( ) ; } } | Generate the keywords for the primitive types . |
33,838 | protected void generateComments ( IStyleAppendable it ) { appendComment ( it , "comments" ) ; appendRegion ( it , "sarlComment" , "/\\*" , "\\*/" , "@Spell" ) ; appendCmd ( it , "syn match sarlCommentStar contained \"^\\s*\\*[^/]\"me=e-1" ) ; appendMatch ( it , "sarlCommentStar" , "^\\s*\\*$" , true ) ; appendMatch ( it , "sarlLineComment" , "//.*" , "@Spell" ) ; appendCluster ( it , "sarlComment" , "sarlLineComment" ) ; hilight ( "sarlComment" , VimSyntaxGroup . COMMENT ) ; hilight ( "sarlLineComment" , VimSyntaxGroup . COMMENT ) ; appendComment ( it , "match the special comment /**/" ) ; appendMatch ( it , "sarlComment" , "/\\*\\*/" ) ; it . newLine ( ) ; } | Generate the Vim comments . |
33,839 | protected void generateStrings ( IStyleAppendable it ) { appendComment ( it , "Strings constants" ) ; appendMatch ( it , "sarlSpecialError" , "\\\\." , true ) ; appendMatch ( it , "sarlSpecialCharError" , "[^']" , true ) ; appendMatch ( it , "sarlSpecialChar" , "\\\\\\([4-9]\\d\\|[0-3]\\d\\d\\|[\"\\\\'ntbrf]\\|u\\x\\{4\\}\\)" , true ) ; appendRegion ( it , true , "sarlString" , "\"" , "\"" , "sarlSpecialChar" , "sarlSpecialError" , "@Spell" ) ; appendRegion ( it , true , "sarlString" , "'" , "'" , "sarlSpecialChar" , "sarlSpecialError" , "@Spell" ) ; appendCluster ( it , "sarlString" ) ; hilight ( "sarlString" , VimSyntaxGroup . CONSTANT ) ; it . newLine ( ) ; } | Generate the Vim strings of characters . |
33,840 | protected void generateNumericConstants ( IStyleAppendable it ) { appendComment ( it , "numerical constants" ) ; appendMatch ( it , "sarlNumber" , "[0-9][0-9]*\\.[0-9]\\+([eE][0-9]\\+)\\?[fFdD]\\?" ) ; appendMatch ( it , "sarlNumber" , "0[xX][0-9a-fA-F]\\+" ) ; appendMatch ( it , "sarlNumber" , "[0-9]\\+[lL]\\?" ) ; appendCluster ( it , "sarlNumber" ) ; hilight ( "sarlNumber" , VimSyntaxGroup . CONSTANT ) ; it . newLine ( ) ; } | Generate the Vim numeric constants . |
33,841 | protected void generateAnnotations ( IStyleAppendable it ) { appendComment ( it , "annnotation" ) ; appendMatch ( it , "sarlAnnotation" , "@[_a-zA-Z][_0-9a-zA-Z]*\\([.$][_a-zA-Z][_0-9a-zA-Z]*\\)*" ) ; appendCluster ( it , "sarlAnnotation" ) ; hilight ( "sarlAnnotation" , VimSyntaxGroup . PRE_PROCESSOR ) ; it . newLine ( ) ; } | Generate the annotations . |
33,842 | protected void generateKeywords ( IStyleAppendable it , String family , VimSyntaxGroup color , Iterable < String > keywords ) { appendComment ( it , "keywords for the '" + family + "' family." ) ; final Iterator < String > iterator = keywords . iterator ( ) ; if ( iterator . hasNext ( ) ) { it . append ( "syn keyword " ) ; it . append ( family ) ; do { it . append ( " " ) ; it . append ( iterator . next ( ) ) ; } while ( iterator . hasNext ( ) ) ; } it . newLine ( ) ; appendCluster ( it , family ) ; hilight ( family , color ) ; it . newLine ( ) ; } | Generate the Vim keywords . |
33,843 | protected IStyleAppendable appendCmd ( IStyleAppendable it , String text ) { return appendCmd ( it , true , text ) ; } | Append a Vim command . |
33,844 | 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 . |
33,845 | protected CharSequence getFileTypeDetectionScript ( ) { return concat ( "\" Vim filetype-detection file" , "\" Language: " + getLanguageSimpleName ( ) , "\" Version: " + getLanguageVersion ( ) , "" , "au BufRead,BufNewFile *." + getLanguage ( ) . getFileExtensions ( ) . get ( 0 ) + " set filetype=" + getLanguageSimpleName ( ) . toLowerCase ( ) ) ; } | Replies the script for detecting the SARL files . |
33,846 | 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 . |
33,847 | public static IntegerRange parseRange ( String stringRange , int minValue ) { final String sepPattern = "[,;\\-:]" ; try { final Matcher matcher = Pattern . compile ( "^\\s*" + "(?:(?<left>[0-9]+)\\s*(?:(?<sep1>" + sepPattern + ")\\s*(?<right1>[0-9]+)?)?)" + "|(?:(?<sep2>" + sepPattern + ")\\s*(?<right2>[0-9]+))" + "\\s*$" ) . matcher ( stringRange ) ; if ( matcher . matches ( ) ) { final String left = matcher . group ( "left" ) ; final String sep = select ( matcher . group ( "sep1" ) , matcher . group ( "sep2" ) ) ; final String right = select ( matcher . group ( "right1" ) , matcher . group ( "right2" ) ) ; 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 . |
33,848 | 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 . |
33,849 | public void setDocumentParser ( SarlDocumentationParser parser ) { assert parser != null ; this . parser = parser ; this . parser . reset ( ) ; } | Change the document parser . |
33,850 | 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 . |
33,851 | 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 . |
33,852 | 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 . |
33,853 | 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 . |
33,854 | public ISarlBehaviorUnitBuilder addSarlBehaviorUnit ( String name ) { ISarlBehaviorUnitBuilder builder = this . iSarlBehaviorUnitBuilderProvider . get ( ) ; builder . eInit ( getSarlBehavior ( ) , name , getTypeResolutionContext ( ) ) ; return builder ; } | Create a SarlBehaviorUnit . |
33,855 | public ISarlFieldBuilder addVarSarlField ( String name ) { ISarlFieldBuilder builder = this . iSarlFieldBuilderProvider . get ( ) ; builder . eInit ( getSarlBehavior ( ) , name , "var" , getTypeResolutionContext ( ) ) ; return builder ; } | Create a SarlField . |
33,856 | public ISarlActionBuilder addDefSarlAction ( String name ) { ISarlActionBuilder builder = this . iSarlActionBuilderProvider . get ( ) ; builder . eInit ( getSarlBehavior ( ) , name , "def" , getTypeResolutionContext ( ) ) ; return builder ; } | Create a SarlAction . |
33,857 | public ISarlClassBuilder addSarlClass ( String name ) { ISarlClassBuilder builder = this . iSarlClassBuilderProvider . get ( ) ; builder . eInit ( getSarlBehavior ( ) , name , getTypeResolutionContext ( ) ) ; return builder ; } | Create a SarlClass . |
33,858 | 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 . |
33,859 | public void addSarlRequiredCapacity ( String ... name ) { if ( name != null && name . length > 0 ) { SarlRequiredCapacity member = SarlFactory . eINSTANCE . createSarlRequiredCapacity ( ) ; 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 SarlRequiredCapacity . |
33,860 | @ SuppressWarnings ( "static-method" ) public SarlConfig getSarlcConfig ( ConfigurationFactory configFactory , Injector injector ) { final SarlConfig config = SarlConfig . getConfiguration ( configFactory ) ; injector . injectMembers ( config ) ; return config ; } | Replies the instance of the sarl configuration . |
33,861 | public static RefactoringStatus validatePackageName ( String newName ) { if ( ! PACKAGE_NAME_PATTERN . matcher ( newName ) . find ( ) ) { RefactoringStatus . createErrorStatus ( MessageFormat . format ( Messages . SARLJdtPackageRenameParticipant_0 , newName ) ) ; } return new RefactoringStatus ( ) ; } | Validate the package name . |
33,862 | protected void setPackageName ( String newName , ResourceSet resourceSet ) { final EObject object = resourceSet . getEObject ( this . uriProvider . apply ( resourceSet ) , true ) ; if ( object instanceof SarlScript ) { ( ( SarlScript ) object ) . setPackage ( newName ) ; } else { throw new RefactoringException ( "SARL script not loaded." ) ; } } | Change the package name . |
33,863 | protected TextEdit getDeclarationTextEdit ( String newName , ResourceSet resourceSet ) { final EObject object = resourceSet . getEObject ( this . uriProvider . apply ( resourceSet ) , true ) ; if ( object instanceof SarlScript ) { final ITextRegion region = getOriginalPackageRegion ( ( SarlScript ) object ) ; if ( region != null ) { return new ReplaceEdit ( region . getOffset ( ) , region . getLength ( ) , newName ) ; } } throw new RefactoringException ( "SARL script not loaded." ) ; } | Replies the text update for the rename . |
33,864 | protected ITextRegion getOriginalPackageRegion ( final SarlScript script ) { return this . locationInFileProvider . getFullTextRegion ( script , XtendPackage . Literals . XTEND_FILE__PACKAGE , 0 ) ; } | Replies the text region that is corresponding to the package name . |
33,865 | public void setOutputLanguage ( @ Named ( Constants . LANGUAGE_NAME ) String outputLanguage ) { if ( ! Strings . isNullOrEmpty ( outputLanguage ) ) { final String [ ] parts = outputLanguage . split ( "\\.+" ) ; if ( parts . length > 0 ) { final String simpleName = parts [ parts . length - 1 ] ; if ( ! Strings . isNullOrEmpty ( simpleName ) ) { this . languageName = simpleName ; return ; } } } this . languageName = null ; } | Change the name of the language . |
33,866 | public static Function2 < String , String , String > getFencedCodeBlockFormatter ( ) { return ( languageName , content ) -> { return "```" + Strings . nullToEmpty ( languageName ) . toLowerCase ( ) + "\n" + content + "```\n" ; } ; } | Replies the fenced code block formatter . |
33,867 | public static Function2 < String , String , String > getBasicCodeBlockFormatter ( ) { return ( languageName , content ) -> { return Pattern . compile ( "^" , Pattern . MULTILINE ) . matcher ( content ) . replaceAll ( "\t" ) ; } ; } | Replies the basic code block formatter . |
33,868 | public void reset ( ) { this . rawPatterns . clear ( ) ; this . compiledPatterns . clear ( ) ; this . inlineFormat = DEFAULT_INLINE_FORMAT ; this . blockFormat = null ; this . outlineOutputTag = DEFAULT_OUTLINE_OUTPUT_TAG ; this . dynamicNameExtractionPattern = DEFAULT_TAG_NAME_PATTERN ; this . lineContinuation = DEFAULT_LINE_CONTINUATION ; } | Reset to the default settings . |
33,869 | public void setPattern ( Tag tag , String regex ) { if ( Strings . isNullOrEmpty ( regex ) ) { this . rawPatterns . remove ( tag ) ; this . compiledPatterns . remove ( tag ) ; } else { this . rawPatterns . put ( tag , regex ) ; this . compiledPatterns . put ( tag , Pattern . compile ( "^\\s*" + regex , PATTERN_COMPILE_OPTIONS ) ) ; } } | Change the pattern of the tag . |
33,870 | public String getPattern ( Tag tag ) { final String pattern = this . rawPatterns . get ( tag ) ; if ( pattern == null ) { return tag . getDefaultPattern ( ) ; } return pattern ; } | Replies the pattern of the tag . |
33,871 | public Tag getTagForPattern ( CharSequence text ) { for ( final Tag tag : Tag . values ( ) ) { Pattern pattern = this . compiledPatterns . get ( tag ) ; if ( pattern == null ) { pattern = Pattern . compile ( "^\\s*" + getPattern ( tag ) , Pattern . DOTALL ) ; this . compiledPatterns . put ( tag , pattern ) ; } final Matcher matcher = pattern . matcher ( text ) ; if ( matcher . find ( ) ) { return tag ; } } return null ; } | Replies the tag that is matching the given text . |
33,872 | public String getLineSeparator ( ) { if ( Strings . isNullOrEmpty ( this . lineSeparator ) ) { final String nl = System . getProperty ( "line.separator" ) ; if ( Strings . isNullOrEmpty ( nl ) ) { return "\n" ; } return nl ; } return this . lineSeparator ; } | Replies the OS - dependent line separator . |
33,873 | protected void extractDynamicName ( Tag tag , CharSequence name , OutParameter < String > dynamicName ) { if ( tag . hasDynamicName ( ) ) { final Pattern pattern = Pattern . compile ( getDynamicNameExtractionPattern ( ) ) ; final Matcher matcher = pattern . matcher ( name ) ; if ( matcher . matches ( ) ) { dynamicName . set ( Strings . nullToEmpty ( matcher . group ( 1 ) ) ) ; return ; } } dynamicName . set ( name . toString ( ) ) ; } | Extract the dynamic name of that from the raw text . |
33,874 | public String transform ( File inputFile ) { final String content ; try ( FileReader reader = new FileReader ( inputFile ) ) { content = read ( reader ) ; } catch ( IOException exception ) { reportError ( Messages . SarlDocumentationParser_0 , exception ) ; return null ; } return transform ( content , inputFile ) ; } | Read the given file and transform its content in order to have a raw text . |
33,875 | protected String postProcessing ( CharSequence text ) { final String lineContinuation = getLineContinuation ( ) ; if ( lineContinuation != null ) { final Pattern pattern = Pattern . compile ( "\\s*\\\\[\\n\\r]+\\s*" , Pattern . DOTALL ) ; final Matcher matcher = pattern . matcher ( text . toString ( ) . trim ( ) ) ; return matcher . replaceAll ( lineContinuation ) ; } return text . toString ( ) . trim ( ) ; } | Do a post processing of the text . |
33,876 | protected static String formatBlockText ( String content , String languageName , Function2 < String , String , String > blockFormat ) { String replacement = Strings . nullToEmpty ( content ) ; final String [ ] lines = replacement . trim ( ) . split ( "[\n\r]+" ) ; int minIndent = Integer . MAX_VALUE ; final Pattern wpPattern = Pattern . compile ( "^(\\s*)[^\\s]" ) ; for ( int i = lines . length > 1 ? 1 : 0 ; i < lines . length ; ++ i ) { final String line = lines [ i ] ; final Matcher matcher = wpPattern . matcher ( line ) ; if ( matcher . find ( ) ) { final int n = matcher . group ( 1 ) . length ( ) ; if ( n < minIndent ) { minIndent = n ; if ( minIndent <= 0 ) { break ; } } } } final StringBuilder buffer = new StringBuilder ( ) ; buffer . append ( lines [ 0 ] ) ; buffer . append ( "\n" ) ; for ( int i = 1 ; i < lines . length ; ++ i ) { final String line = lines [ i ] ; buffer . append ( line . replaceFirst ( "^\\s{0," + minIndent + "}" , "" ) ) ; buffer . append ( "\n" ) ; } replacement = buffer . toString ( ) . replaceFirst ( "[\n\r]+$" , "\n" ) ; if ( ! Strings . isNullOrEmpty ( replacement ) && ! "\n" . equals ( replacement ) ) { if ( blockFormat != null ) { return blockFormat . apply ( languageName , replacement ) ; } return replacement ; } return "" ; } | Format the given text in order to be suitable for being output as a block . |
33,877 | protected void generateInnerDocumentationAdapter ( ) { final TypeReference adapter = getCodeElementExtractor ( ) . getInnerBlockDocumentationAdapter ( ) ; final StringConcatenationClient content = new StringConcatenationClient ( ) { protected void appendTo ( TargetStringConcatenation it ) { it . append ( "public class " ) ; it . append ( adapter . getSimpleName ( ) ) ; it . append ( " extends " ) ; it . append ( AdapterImpl . class ) ; it . append ( " {" ) ; it . newLineIfNotEmpty ( ) ; it . newLine ( ) ; it . append ( "\tprivate String documentation;" ) ; it . newLine ( ) ; it . append ( "\t@" ) ; it . append ( Pure . class ) ; it . newLine ( ) ; it . append ( "\tpublic String getDocumentation() {" ) ; it . newLineIfNotEmpty ( ) ; it . newLine ( ) ; it . append ( "\t\treturn this.documentation;" ) ; it . newLine ( ) ; it . append ( "\t}" ) ; it . newLineIfNotEmpty ( ) ; it . newLine ( ) ; it . append ( "\tpublic void setDocumentation(String documentation) {" ) ; it . newLine ( ) ; it . append ( "\t\tthis.documentation = documentation;" ) ; it . newLine ( ) ; it . append ( "\t}" ) ; it . newLineIfNotEmpty ( ) ; it . newLine ( ) ; it . append ( "\t@" ) ; it . append ( Pure . class ) ; it . newLine ( ) ; it . append ( "\tpublic boolean isAdapterForType(Object type) {" ) ; it . newLine ( ) ; it . append ( "\t\treturn type == " ) ; it . append ( adapter . getSimpleName ( ) ) ; it . append ( ".class;" ) ; it . newLine ( ) ; it . append ( "\t}" ) ; it . newLineIfNotEmpty ( ) ; it . newLine ( ) ; it . append ( "}" ) ; it . newLineIfNotEmpty ( ) ; } } ; final JavaFileAccess createJavaFile = getFileAccessFactory ( ) . createJavaFile ( adapter , content ) ; createJavaFile . writeTo ( getSrcGen ( ) ) ; } | Generate the adapter that supports the inner documentation . |
33,878 | public void setAutoFormattingEnabled ( Boolean enable ) { final IPreferenceStore store = getWritablePreferenceStore ( null ) ; if ( enable == null ) { store . setToDefault ( AUTOFORMATTING_PROPERTY ) ; } else { store . setValue ( AUTOFORMATTING_PROPERTY , enable . booleanValue ( ) ) ; } } | Enable or disable the auto - formatting feature into the SARL editor . |
33,879 | public void setReturnType ( String type ) { if ( ! Strings . isEmpty ( type ) && ! Objects . equals ( "void" , type ) && ! Objects . equals ( Void . class . getName ( ) , type ) ) { this . sarlAction . setReturnType ( newTypeRef ( container , type ) ) ; } else { this . sarlAction . setReturnType ( null ) ; } } | Change the return type . |
33,880 | public void addAnnotation ( String type ) { if ( ! Strings . isEmpty ( type ) ) { XAnnotation annotation = XAnnotationsFactory . eINSTANCE . createXAnnotation ( ) ; annotation . setAnnotationType ( newTypeRef ( getSarlAction ( ) , type ) . getType ( ) ) ; getSarlAction ( ) . getAnnotations ( ) . add ( annotation ) ; } } | Add an annotation . |
33,881 | public static void useJanusMessageFormat ( ) { final String format = System . getProperty ( FORMAT_PROPERTY_KEY , null ) ; if ( format == null || format . isEmpty ( ) ) { System . setProperty ( FORMAT_PROPERTY_KEY , JANUS_FORMAT ) ; } } | Change the configuration of the root logger for using the Janus format for the messages . |
33,882 | public static Logger createPlatformLogger ( ) { final Logger logger = Logger . getAnonymousLogger ( ) ; for ( final Handler handler : logger . getHandlers ( ) ) { logger . removeHandler ( handler ) ; } final Handler stderr = new StandardErrorOutputConsoleHandler ( ) ; stderr . setLevel ( Level . ALL ) ; final Handler stdout = new StandardOutputConsoleHandler ( ) ; stdout . setLevel ( Level . ALL ) ; logger . addHandler ( stderr ) ; logger . addHandler ( stdout ) ; logger . setUseParentHandlers ( false ) ; logger . setLevel ( Level . ALL ) ; return logger ; } | Create a logger with the given name for the platform . |
33,883 | public static Level getLoggingLevelFromProperties ( ) { if ( levelFromProperties == null ) { final String verboseLevel = JanusConfig . getSystemProperty ( JanusConfig . VERBOSE_LEVEL_NAME , JanusConfig . VERBOSE_LEVEL_VALUE ) ; levelFromProperties = parseLoggingLevel ( verboseLevel ) ; } return levelFromProperties ; } | Extract the logging level from the system properties . |
33,884 | @ SuppressWarnings ( { "checkstyle:returncount" , "checkstyle:cyclomaticcomplexity" } ) public static Level parseLoggingLevel ( String level ) { if ( level == null ) { return Level . INFO ; } switch ( level . toLowerCase ( ) ) { case "none" : case "false" : case "0" : return Level . OFF ; case "severe" : case "error" : case "1" : return Level . SEVERE ; case "warn" : case "warning" : case "2" : return Level . WARNING ; case "info" : case "true" : case "3" : return Level . INFO ; case "fine" : case "config" : case "4" : return Level . FINE ; case "finer" : case "5" : return Level . FINER ; case "finest" : case "debug" : case "6" : return Level . FINEST ; case "all" : case "7" : return Level . ALL ; default : try { return fromInt ( Integer . parseInt ( level ) ) ; } catch ( Throwable exception ) { } return Level . INFO ; } } | Extract the logging level from the given string . |
33,885 | @ SuppressWarnings ( { "checkstyle:magicnumber" , "checkstyle:returncount" } ) public static Level fromInt ( int num ) { switch ( num ) { case 0 : return Level . OFF ; case 1 : return Level . SEVERE ; case 2 : return Level . WARNING ; case 3 : return Level . INFO ; case 4 : return Level . FINE ; case 5 : return Level . FINER ; case 6 : return Level . FINEST ; case 7 : return Level . ALL ; default : if ( num < 0 ) { return Level . OFF ; } return Level . ALL ; } } | Convert a numerical representation of logging level to the logging level . |
33,886 | @ SuppressWarnings ( { "checkstyle:magicnumber" , "checkstyle:returncount" , "checkstyle:npathcomplexity" } ) public static int toInt ( Level level ) { if ( level == Level . OFF ) { return 0 ; } if ( level == Level . SEVERE ) { return 1 ; } if ( level == Level . WARNING ) { return 2 ; } if ( level == Level . INFO ) { return 3 ; } if ( level == Level . CONFIG ) { return 4 ; } if ( level == Level . FINE ) { return 4 ; } if ( level == Level . FINER ) { return 5 ; } if ( level == Level . FINEST ) { return 6 ; } if ( level == Level . ALL ) { return 7 ; } return 3 ; } | Convert a logging level to its numerical equivalent . |
33,887 | public static void startServices ( IServiceManager manager ) { final List < Service > otherServices = new ArrayList < > ( ) ; final List < Service > infraServices = new ArrayList < > ( ) ; final LinkedList < DependencyNode > serviceQueue = new LinkedList < > ( ) ; final Accessors accessors = new StartingPhaseAccessors ( ) ; buildDependencyGraph ( manager , serviceQueue , infraServices , otherServices , accessors ) ; runDependencyGraph ( serviceQueue , infraServices , otherServices , accessors ) ; manager . awaitHealthy ( ) ; } | Start the services associated to the given service manager . |
33,888 | public static void stopServices ( IServiceManager manager ) { final List < Service > otherServices = new ArrayList < > ( ) ; final List < Service > infraServices = new ArrayList < > ( ) ; final LinkedList < DependencyNode > serviceQueue = new LinkedList < > ( ) ; final Accessors accessors = new StoppingPhaseAccessors ( ) ; buildInvertedDependencyGraph ( manager , serviceQueue , infraServices , otherServices , accessors ) ; runDependencyGraph ( serviceQueue , infraServices , otherServices , accessors ) ; manager . awaitStopped ( ) ; } | Stop the services associated to the given service manager . |
33,889 | @ SuppressWarnings ( "checkstyle:npathcomplexity" ) private static void runDependencyGraph ( Queue < DependencyNode > roots , List < Service > infraServices , List < Service > freeServices , Accessors accessors ) { final boolean async = accessors . isAsyncStateWaitingEnabled ( ) ; final Set < Class < ? extends Service > > executed = new TreeSet < > ( Comparators . CLASS_COMPARATOR ) ; accessors . runInfrastructureServicesBefore ( infraServices ) ; accessors . runFreeServicesBefore ( freeServices ) ; while ( ! roots . isEmpty ( ) ) { final DependencyNode node = roots . remove ( ) ; assert node != null && node . getType ( ) != null ; if ( ! executed . contains ( node . getType ( ) ) ) { executed . add ( node . getType ( ) ) ; roots . addAll ( node . getNextServices ( ) ) ; roots . addAll ( node . getNextWeakServices ( ) ) ; assert node . getService ( ) != null ; if ( async ) { for ( final WeakReference < DependencyNode > asyncService : node . getAsyncStateServices ( ) ) { final AsyncStateService as = ( AsyncStateService ) ( asyncService . get ( ) . getService ( ) ) ; assert as != null ; while ( ! as . isReadyForOtherServices ( ) ) { Thread . yield ( ) ; } } } accessors . run ( node . getService ( ) ) ; } } accessors . runFreeServicesAfter ( freeServices ) ; accessors . runInfrastructureServicesAfter ( infraServices ) ; } | Run the dependency graph for the services . |
33,890 | public static SynchronizedIterable < AgentContext > getContextsOf ( Agent agent ) throws Exception { final ExternalContextAccess skill = SREutils . getInternalSkill ( agent , ExternalContextAccess . class ) ; assert skill != null ; return skill . getAllContexts ( ) ; } | Replies the contexts in which the agent is located . |
33,891 | public static AgentContext getContextIn ( Agent agent ) throws Exception { final InnerContextAccess skill = SREutils . getInternalSkill ( agent , InnerContextAccess . class ) ; if ( skill instanceof InnerContextSkill ) { final InnerContextSkill janusSkill = ( InnerContextSkill ) skill ; if ( janusSkill . hasInnerContext ( ) ) { return janusSkill . getInnerContext ( ) ; } return null ; } if ( skill == null ) { return null ; } return skill . getInnerContext ( ) ; } | Replies the inner context of the agent if it was created . |
33,892 | @ SuppressWarnings ( "static-method" ) protected void _toJavaStatement ( SarlBreakExpression breakExpression , ITreeAppendable appendable , boolean isReferenced ) { appendable . newLine ( ) . append ( "break;" ) ; } | Generate the Java code related to the preparation statements for the break keyword . |
33,893 | @ SuppressWarnings ( "static-method" ) protected Map < XVariableDeclaration , XFeatureCall > getReferencedLocalVariable ( XExpression expression , boolean onlyWritable ) { final Map < XVariableDeclaration , XFeatureCall > localVariables = new TreeMap < > ( ( k1 , k2 ) -> { return k1 . getIdentifier ( ) . compareTo ( k2 . getIdentifier ( ) ) ; } ) ; for ( final XFeatureCall featureCall : EcoreUtil2 . getAllContentsOfType ( expression , XFeatureCall . class ) ) { if ( featureCall . getFeature ( ) instanceof XVariableDeclaration ) { final XVariableDeclaration localVariable = ( XVariableDeclaration ) featureCall . getFeature ( ) ; if ( ( ! onlyWritable || localVariable . isWriteable ( ) ) && ! localVariables . containsKey ( localVariable ) ) { localVariables . put ( localVariable , featureCall ) ; } } } return localVariables ; } | Replies all the variables that are referenced into the given expression . |
33,894 | protected boolean isAtLeastJava8 ( EObject context ) { return this . generatorConfigProvider . get ( EcoreUtil . getRootContainer ( context ) ) . getJavaSourceVersion ( ) . isAtLeast ( JavaVersion . JAVA8 ) ; } | Replies if the generation is for Java version 8 at least . |
33,895 | protected void _toJavaExpression ( SarlAssertExpression assertExpression , ITreeAppendable appendable ) { if ( ! assertExpression . isIsStatic ( ) && isAtLeastJava8 ( assertExpression ) ) { appendable . append ( "/* error - couldn't compile nested assert */" ) ; } } | Generate the Java code related to the expression for the assert keyword . |
33,896 | protected void jvmOperationCallToJavaExpression ( final XExpression sourceObject , final JvmOperation operation , XExpression receiver , List < XExpression > arguments , ITreeAppendable appendable ) { String name = null ; assert operation != null ; if ( appendable . hasName ( operation ) ) { name = appendable . getName ( operation ) ; } else { name = this . featureNameProvider . getSimpleName ( operation ) ; } if ( name == null ) { name = "/* name is null */" ; } if ( operation . isStatic ( ) ) { final JvmDeclaredType operationContainer = operation . getDeclaringType ( ) ; final JvmIdentifiableElement container = getLogicalContainerProvider ( ) . getNearestLogicalContainer ( sourceObject ) ; final JvmType containerType = EcoreUtil2 . getContainerOfType ( container , JvmType . class ) ; final LightweightTypeReference reference = newTypeReferenceOwner ( sourceObject ) . toLightweightTypeReference ( operationContainer ) ; if ( ! reference . isAssignableFrom ( containerType ) ) { appendable . append ( operationContainer ) ; appendable . append ( "." ) ; } } else if ( receiver != null ) { internalToJavaExpression ( receiver , appendable ) ; appendable . append ( "." ) ; } else { appendable . append ( "this." ) ; } appendable . trace ( sourceObject , XbasePackage . Literals . XABSTRACT_FEATURE_CALL__FEATURE , 0 ) . append ( name ) ; appendable . append ( "(" ) ; if ( arguments != null && ! arguments . isEmpty ( ) ) { appendArguments ( arguments , appendable , true ) ; } appendable . append ( ")" ) ; } | Generate the Java expression for the given JVM operation . |
33,897 | @ SuppressWarnings ( "static-method" ) protected boolean canBeNotStaticAnonymousClass ( XClosure closure , LightweightTypeReference typeRef , JvmOperation operation ) { return ! typeRef . isSubtypeOf ( Serializable . class ) ; } | Replies if the given closure could be represented by an not static anonymous class . |
33,898 | Collection < V > wrapValues ( K key , Collection < V > values ) { final Object backEnd = DataViewDelegate . undelegate ( values ) ; if ( backEnd instanceof List < ? > ) { return new SingleKeyValueListView ( key , ( List < V > ) values ) ; } if ( backEnd instanceof Set < ? > ) { return new SingleKeyValueSetView ( key , ( Set < V > ) values ) ; } throw new IllegalStateException ( "Unsupported type of the backend multimap: " + values . getClass ( ) ) ; } | Wrap the given values into a dedicated view . |
33,899 | @ SuppressWarnings ( { "unchecked" , "checkstyle:illegaltype" } ) Collection < V > copyValues ( Collection < V > values ) { final Object backEnd = DataViewDelegate . undelegate ( values ) ; if ( backEnd instanceof List < ? > ) { return Lists . newArrayList ( values ) ; } if ( backEnd instanceof TreeSet < ? > ) { TreeSet < V > c = ( TreeSet < V > ) backEnd ; c = Sets . newTreeSet ( c . comparator ( ) ) ; c . addAll ( values ) ; return c ; } if ( backEnd instanceof LinkedHashSet < ? > ) { return Sets . newLinkedHashSet ( values ) ; } if ( backEnd instanceof Set < ? > ) { return Sets . newHashSet ( values ) ; } throw new IllegalStateException ( "Unsupported type of the backend multimap: " + values . getClass ( ) ) ; } | Copy the given values . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.