@@ -90,29 +90,16 @@ FormatterFunc createFormat() throws Exception {
9090 } else {
9191 File file = configSignature .getOnlyFile ();
9292
93- Class <?> optionCls = classLoader .loadClass ("scala.Option" );
94- Class <?> configCls = classLoader .loadClass ("org.scalafmt.config.Config" );
93+ Class <?> configCls = classLoader .loadClass ("org.scalafmt.Scalafmt" );
9594
9695 Object either ;
9796
98- try {
99- // scalafmt >= v0.7.0-RC1
100- Method fromHocon = configCls .getMethod ("fromHoconString" , String .class , optionCls );
101- Object fromHoconEmptyPath = configCls .getMethod ("fromHoconString$default$2" ).invoke (null );
97+ Method fromHocon = configCls .getMethod ("fromHoconString" , String .class );
10298
103- String configStr = new String (Files .readAllBytes (file .toPath ()), StandardCharsets .UTF_8 );
99+ String configStr = new String (Files .readAllBytes (file .toPath ()), StandardCharsets .UTF_8 );
104100
105- Object configured = fromHocon .invoke (null , configStr , fromHoconEmptyPath );
106- either = invokeNoArg (configured , "toEither" );
107- } catch (NoSuchMethodException e ) {
108- // In case of a NoSuchMethodException try old configuration API
109- // scalafmt <= v0.6.8
110- Method fromHocon = configCls .getMethod ("fromHocon" , String .class , optionCls );
111- Object fromHoconEmptyPath = configCls .getMethod ("fromHocon$default$2" ).invoke (null );
112-
113- String configStr = new String (Files .readAllBytes (file .toPath ()), StandardCharsets .UTF_8 );
114- either = fromHocon .invoke (null , configStr , fromHoconEmptyPath );
115- }
101+ Object configured = fromHocon .invoke (null , configStr );
102+ either = invokeNoArg (configured , "toEither" );
116103
117104 config = invokeNoArg (invokeNoArg (either , "right" ), "get" );
118105 }
0 commit comments